wasmer/lib/runtime-c-api/tests/runtime_c_api_tests.rs

50 lines
1.3 KiB
Rust
Raw Normal View History

2019-02-02 20:16:53 -06:00
use std::process::Command;
2019-02-01 22:10:36 -06:00
#[test]
fn test_c_api() {
2019-02-02 20:16:53 -06:00
let project_tests_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/tests");
2019-02-02 20:16:53 -06:00
run_command("cmake", project_tests_dir, Some("."));
run_command("make", project_tests_dir, Some("-Wdev -Werror=dev"));
Tryin gto make c_api_tests verbose mitigates the flaky error Each time `make capi` is run, there is a flaky error: ``` Running target/release/deps/runtime_c_api_tests-3df0f74fcea1252d running 1 test test test_c_api ... FAILED failures: ---- test_c_api stdout ---- Running command: `cmake` arg: Some(".") output: status: 0 stdout: -- Configuring done -- Generating done -- Build files have been written to: /Users/syrusakbary/Development/wasmer/lib/runtime-c-api/tests stderr: Running command: `make` arg: Some("-Wdev -Werror=dev") output: status: 0 stdout: [ 7%] Built target test-tables [ 15%] Built target test-module-exports [ 23%] Built target test-module-imports [ 30%] Built target test-globals [ 38%] Built target test-imports [ 46%] Built target test-module [ 53%] Built target test-module-serialize [ 61%] Built target test-memory [ 69%] Built target test-validate [ 76%] Built target test-import-function [ 84%] Built target test-instantiate [ 92%] Built target test-exports [100%] Built target test-exported-memory stderr: Running command: `make` arg: Some("test") output: status: 2 stdout: Running tests... Test project /Users/syrusakbary/Development/wasmer/lib/runtime-c-api/tests Start 1: test-exported-memory 1/13 Test #1: test-exported-memory .............Child aborted***Exception: 0.00 sec Start 2: test-exports 2/13 Test #2: test-exports ..................... Passed 0.01 sec Start 3: test-globals 3/13 Test #3: test-globals ..................... Passed 0.00 sec Start 4: test-import-function 4/13 Test #4: test-import-function ............. Passed 0.01 sec Start 5: test-imports 5/13 Test #5: test-imports ..................... Passed 0.01 sec Start 6: test-instantiate 6/13 Test #6: test-instantiate ................. Passed 0.01 sec Start 7: test-memory 7/13 Test #7: test-memory ...................... Passed 0.00 sec Start 8: test-module 8/13 Test #8: test-module ...................... Passed 0.01 sec Start 9: test-module-exports 9/13 Test #9: test-module-exports .............. Passed 0.01 sec Start 10: test-module-imports 10/13 Test #10: test-module-imports .............. Passed 0.01 sec Start 11: test-module-serialize 11/13 Test #11: test-module-serialize ............ Passed 0.01 sec Start 12: test-tables 12/13 Test #12: test-tables ...................... Passed 0.00 sec Start 13: test-validate 13/13 Test #13: test-validate .................... Passed 0.00 sec 92% tests passed, 1 tests failed out of 13 Total Test time (real) = 0.08 sec The following tests FAILED: 1 - test-exported-memory (Child aborted) stderr: Errors while running CTest make[1]: *** [test] Error 8 thread 'test_c_api' panicked at 'Command failed with exit status: ExitStatus(ExitStatus(512))', lib/runtime-c-api/tests/runtime_c_api_tests.rs:43:17 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. ```
2019-08-01 00:22:52 -07:00
run_command("make", project_tests_dir, Some("test VERBOSE=1"));
2019-02-02 20:16:53 -06:00
}
fn run_command(command_str: &str, dir: &str, arg: Option<&str>) {
println!("Running command: `{}` arg: {:?}", command_str, arg);
2019-02-02 20:16:53 -06:00
let mut command = Command::new(command_str);
2019-02-02 20:16:53 -06:00
if let Some(a) = arg {
command.arg(a);
}
2019-02-02 20:16:53 -06:00
command.current_dir(dir);
2019-02-02 20:16:53 -06:00
let result = command.output();
2019-02-02 20:16:53 -06:00
match result {
Ok(r) => {
println!("output:");
2019-02-02 20:16:53 -06:00
if let Some(code) = r.status.code() {
println!("status: {}", code);
} else {
println!("status: None");
}
2019-02-02 20:16:53 -06:00
println!("stdout:");
println!("{}", String::from_utf8_lossy(&r.stdout[..]));
println!("stderr:");
println!("{}", String::from_utf8_lossy(&r.stderr[..]));
2019-02-02 20:16:53 -06:00
if r.status.success() {
assert!(true)
} else {
panic!("Command failed with exit status: {:?}", r.status);
}
}
2019-02-02 20:16:53 -06:00
Err(e) => panic!("Command failed: {}", e),
}
2019-02-01 22:10:36 -06:00
}