add test and fix em tests

This commit is contained in:
Mark McCaskey
2019-04-05 11:24:27 -07:00
parent 44fba93266
commit 7f6e4785f0
52 changed files with 145 additions and 42 deletions

0
lib/emscripten/a.txt Normal file
View File

View File

@ -46,26 +46,42 @@ pub fn compile(file: &str, ignores: &Vec<String>) -> Option<String> {
output_path.set_extension("js"); output_path.set_extension("js");
let output_str = output_path.to_str().unwrap(); let output_str = output_path.to_str().unwrap();
// Compile to wasm let wasm_file_metadata = {
let _wasm_compilation = Command::new("emcc") let mut wasm_file_path = PathBuf::from(file);
.arg(file) wasm_file_path.set_extension("wasm");
.arg("-s") if let Ok(wasm_file) = File::open(wasm_file_path) {
.arg("WASM=1") Some(wasm_file.metadata().unwrap())
.arg("-o") } else {
.arg(output_str) None
.output() }
.expect("failed to execute process"); };
// panic!("{:?}", wasm_compilation); let real_file = File::open(file).unwrap();
// if output.stderr { let file_metadata = real_file.metadata().unwrap();
// panic!("{}", output.stderr); if wasm_file_metadata.is_none()
// } || file_metadata.modified().unwrap() >= wasm_file_metadata.unwrap().modified().unwrap()
// Remove js file {
// Compile to wasm
let _wasm_compilation = Command::new("emcc")
.arg(file)
.arg("-s")
.arg("WASM=1")
.arg("-o")
.arg(output_str)
.output()
.expect("failed to execute process");
if Path::new(output_str).is_file() { // panic!("{:?}", wasm_compilation);
fs::remove_file(output_str).unwrap(); // if output.stderr {
} else { // panic!("{}", output.stderr);
println!("Output JS not found: {}", output_str); // }
// Remove js file
if Path::new(output_str).is_file() {
fs::remove_file(output_str).unwrap();
} else {
println!("Output JS not found: {}", output_str);
}
} }
let mut output_path = PathBuf::from(file); let mut output_path = PathBuf::from(file);

4
lib/emscripten/emtests/hello.cpp vendored Normal file
View File

@ -0,0 +1,4 @@
#include <iostream>
int main() {
std::cout << "hello world\n";
}

2
lib/emscripten/emtests/hello.out vendored Normal file
View File

@ -0,0 +1,2 @@
hello world

BIN
lib/emscripten/emtests/hello.wasm vendored Normal file

Binary file not shown.

View File

@ -72,3 +72,46 @@ test_std_cout_new
test_strptime_reentrant test_strptime_reentrant
test_gmtime test_gmtime
test_time_c test_time_c
test_execvp
test_nl_types
test_phiundef
test_pipe
test_printf_2
test_printf_more
test_regex
test_relocatable_void_function
test_rounding
test_set_align
test_sintvars
test_sizeof
test_sscanf
test_sscanf_3
test_sscanf_4
test_sscanf_5
test_sscanf_6
test_sscanf_caps
test_sscanf_float
test_sscanf_n
test_strcasecmp
test_strcmp_uni
test_strndup
test_strstr
test_strtod
test_strtok
test_strtol_bin
test_strtol_dec
test_strtol_hex
test_strtol_oct
test_strtoll_bin
test_strtoll_dec
test_strtoll_hex
test_strtoll_oct
test_struct_varargs
test_transtrcase
test_trickystring
test_unary_literal
test_vfs
test_vprintf
test_vsnprintf
test_write_stdout_fileno
test_zerodiv

0
lib/emscripten/foo.txt Normal file
View File

View File

@ -176,6 +176,7 @@ mod test_unary_literal;
mod test_utf; mod test_utf;
mod test_varargs; mod test_varargs;
mod test_varargs_multi; mod test_varargs_multi;
mod test_vfs;
mod test_vprintf; mod test_vprintf;
mod test_vsnprintf; mod test_vsnprintf;
mod test_wprintf; mod test_wprintf;

View File

@ -1,17 +1,10 @@
#[test] #[test]
fn test_execvp() { #[ignore]
#[cfg(not(target_os = "windows"))] fn test_test_execvp() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_execvp.wasm", "../../emtests/test_execvp.wasm",
"test_execvp", "test_execvp",
vec![], vec![],
"../../emtests/test_execvp.out" "../../emtests/test_execvp.out"
); );
#[cfg(target_os = "windows")]
assert_emscripten_output!(
"../../emtests/test_execvp_windows.wasm",
"test_execvp",
vec![],
"../../emtests/test_execvp.out"
);
} }

View File

@ -1,8 +1,8 @@
#[test] #[test]
fn test_getcwd() { fn test_test_getcwd() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_getcwd.wasm", "../../emtests/test_getcwd.wasm",
"getcwd", "test_getcwd",
vec![], vec![],
"../../emtests/test_getcwd.out" "../../emtests/test_getcwd.out"
); );

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_nl_types() { fn test_test_nl_types() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_nl_types.wasm", "../../emtests/test_nl_types.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_phiundef() { fn test_test_phiundef() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_phiundef.wasm", "../../emtests/test_phiundef.wasm",

View File

@ -1,8 +1,10 @@
use crate::emtests::_common::assert_emscripten_output;
#[test] #[test]
fn test_pipe() { #[ignore]
let wasm_bytes = include_bytes!("../../emtests/test_pipe.wasm"); fn test_test_pipe() {
let expected_str = include_str!("../../emtests/test_pipe.out"); assert_emscripten_output!(
assert_emscripten_output(wasm_bytes, expected_str); "../../emtests/test_pipe.wasm",
"test_pipe",
vec![],
"../../emtests/test_pipe.out"
);
} }

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_printf_2() { fn test_test_printf_2() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_printf_2.wasm", "../../emtests/test_printf_2.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_printf_more() { fn test_test_printf_more() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_printf_more.wasm", "../../emtests/test_printf_more.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_regex() { fn test_test_regex() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_regex.wasm", "../../emtests/test_regex.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_relocatable_void_function() { fn test_test_relocatable_void_function() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_relocatable_void_function.wasm", "../../emtests/test_relocatable_void_function.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_rounding() { fn test_test_rounding() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_rounding.wasm", "../../emtests/test_rounding.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_set_align() { fn test_test_set_align() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_set_align.wasm", "../../emtests/test_set_align.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_sintvars() { fn test_test_sintvars() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_sintvars.wasm", "../../emtests/test_sintvars.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_sizeof() { fn test_test_sizeof() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_sizeof.wasm", "../../emtests/test_sizeof.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_sscanf() { fn test_test_sscanf() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_sscanf.wasm", "../../emtests/test_sscanf.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_sscanf_3() { fn test_test_sscanf_3() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_sscanf_3.wasm", "../../emtests/test_sscanf_3.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_sscanf_4() { fn test_test_sscanf_4() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_sscanf_4.wasm", "../../emtests/test_sscanf_4.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_sscanf_5() { fn test_test_sscanf_5() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_sscanf_5.wasm", "../../emtests/test_sscanf_5.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_sscanf_6() { fn test_test_sscanf_6() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_sscanf_6.wasm", "../../emtests/test_sscanf_6.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_sscanf_caps() { fn test_test_sscanf_caps() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_sscanf_caps.wasm", "../../emtests/test_sscanf_caps.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_sscanf_float() { fn test_test_sscanf_float() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_sscanf_float.wasm", "../../emtests/test_sscanf_float.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_sscanf_n() { fn test_test_sscanf_n() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_sscanf_n.wasm", "../../emtests/test_sscanf_n.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strcasecmp() { fn test_test_strcasecmp() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strcasecmp.wasm", "../../emtests/test_strcasecmp.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strcmp_uni() { fn test_test_strcmp_uni() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strcmp_uni.wasm", "../../emtests/test_strcmp_uni.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strndup() { fn test_test_strndup() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strndup.wasm", "../../emtests/test_strndup.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strstr() { fn test_test_strstr() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strstr.wasm", "../../emtests/test_strstr.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strtod() { fn test_test_strtod() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strtod.wasm", "../../emtests/test_strtod.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strtok() { fn test_test_strtok() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strtok.wasm", "../../emtests/test_strtok.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strtol_bin() { fn test_test_strtol_bin() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strtol_bin.wasm", "../../emtests/test_strtol_bin.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strtol_dec() { fn test_test_strtol_dec() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strtol_dec.wasm", "../../emtests/test_strtol_dec.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strtol_hex() { fn test_test_strtol_hex() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strtol_hex.wasm", "../../emtests/test_strtol_hex.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strtol_oct() { fn test_test_strtol_oct() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strtol_oct.wasm", "../../emtests/test_strtol_oct.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strtoll_bin() { fn test_test_strtoll_bin() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strtoll_bin.wasm", "../../emtests/test_strtoll_bin.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strtoll_dec() { fn test_test_strtoll_dec() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strtoll_dec.wasm", "../../emtests/test_strtoll_dec.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strtoll_hex() { fn test_test_strtoll_hex() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strtoll_hex.wasm", "../../emtests/test_strtoll_hex.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_strtoll_oct() { fn test_test_strtoll_oct() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_strtoll_oct.wasm", "../../emtests/test_strtoll_oct.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_struct_varargs() { fn test_test_struct_varargs() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_struct_varargs.wasm", "../../emtests/test_struct_varargs.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_transtrcase() { fn test_test_transtrcase() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_transtrcase.wasm", "../../emtests/test_transtrcase.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_trickystring() { fn test_test_trickystring() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_trickystring.wasm", "../../emtests/test_trickystring.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_unary_literal() { fn test_test_unary_literal() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_unary_literal.wasm", "../../emtests/test_unary_literal.wasm",

View File

@ -1,8 +1,10 @@
use crate::emtests::_common::assert_emscripten_output;
#[test] #[test]
fn test_vfs() { #[ignore]
let wasm_bytes = include_bytes!("../../emtests/test_vfs_bundle.wasm"); fn test_test_vfs() {
let expected_str = include_str!("../../emtests/test_vfs.out"); assert_emscripten_output!(
assert_emscripten_output(wasm_bytes, expected_str); "../../emtests/test_vfs.wasm",
"test_vfs",
vec![],
"../../emtests/test_vfs.out"
);
} }

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_vprintf() { fn test_test_vprintf() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_vprintf.wasm", "../../emtests/test_vprintf.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_vsnprintf() { fn test_test_vsnprintf() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_vsnprintf.wasm", "../../emtests/test_vsnprintf.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_write_stdout_fileno() { fn test_test_write_stdout_fileno() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_write_stdout_fileno.wasm", "../../emtests/test_write_stdout_fileno.wasm",

View File

@ -1,4 +1,5 @@
#[test] #[test]
#[ignore]
fn test_test_zerodiv() { fn test_test_zerodiv() {
assert_emscripten_output!( assert_emscripten_output!(
"../../emtests/test_zerodiv.wasm", "../../emtests/test_zerodiv.wasm",