Added emscripten env test

This commit is contained in:
Syrus 2018-12-11 21:32:53 -08:00
parent 2c2d21044f
commit 332840afe3
6 changed files with 25 additions and 1 deletions

View File

@ -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"
];

13
emtests/env.c Normal file
View File

@ -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
emtests/env.output Normal file
View File

@ -0,0 +1,5 @@
INIT
get UNEXISTENT_ENVVAR: [NULL]
set UNEXISTENT_ENVVAR = SET
get UNEXISTENT_ENVVAR: SET
END

BIN
emtests/env.wasm Normal file

Binary file not shown.

4
src/emtests/env.rs Normal file
View File

@ -0,0 +1,4 @@
#[test]
fn test_env() {
assert_emscripten_output!("../../emtests/env.wasm", "env", vec![], "../../emtests/env.output");
}

View File

@ -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;