Skip to content

Commit

Permalink
Added emscripten env test
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Dec 12, 2018
1 parent 2c2d210 commit 332840a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build/emtests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use std::process::Command;
static BANNER: &str = "// Rust test file autogenerated with cargo build (build/emtests.rs).
// Please do NOT modify it by hand, as it will be reseted on next build.\n";

const TESTS: [&str; 2] = [
const TESTS: [&str; 3] = [
"emtests/env.c",
"emtests/puts.c",
"emtests/printf.c"
];
Expand Down
13 changes: 13 additions & 0 deletions emtests/env.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("INIT\n");
const char* UNEXISTENT_ENVVAR = getenv("UNEXISTENT_ENVVAR");
printf("get UNEXISTENT_ENVVAR: %s\n",(UNEXISTENT_ENVVAR!=NULL)? UNEXISTENT_ENVVAR : "[NULL]");
printf("set UNEXISTENT_ENVVAR = SET\n");
putenv("UNEXISTENT_ENVVAR=SET");
UNEXISTENT_ENVVAR = getenv("UNEXISTENT_ENVVAR");
printf("get UNEXISTENT_ENVVAR: %s\n",(UNEXISTENT_ENVVAR!=NULL)? UNEXISTENT_ENVVAR : "[NULL]");
printf("END\n");
}
5 changes: 5 additions & 0 deletions emtests/env.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INIT
get UNEXISTENT_ENVVAR: [NULL]
set UNEXISTENT_ENVVAR = SET
get UNEXISTENT_ENVVAR: SET
END
Binary file added emtests/env.wasm
Binary file not shown.
4 changes: 4 additions & 0 deletions src/emtests/env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[test]
fn test_env() {
assert_emscripten_output!("../../emtests/env.wasm", "env", vec![], "../../emtests/env.output");
}
1 change: 1 addition & 0 deletions src/emtests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
// The _common module is not autogenerated, as it provides common macros for the emtests
#[macro_use]
mod _common;
mod env;
mod puts;
mod printf;

0 comments on commit 332840a

Please sign in to comment.