Add a test for environment variables.

This adds basic support for environment variables to the test harness,
and adds a simple test.

This tests the bug found in https://github.com/CraneStation/wasi-libc/pull/159.
pull/97/head
Dan Gohman 5 years ago
parent 677ffc715c
commit 51abbf27ae

@ -0,0 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
int main(void) {
printf("HELLO = %s\n", getenv("HELLO"));
return 0;
}

@ -0,0 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
int main(void) {
printf("HELLO = %s\n", getenv("HELLO"));
return 0;
}

@ -41,9 +41,16 @@ else
stdin="/dev/null"
fi
# Determine any environment variables to set.
if [ -e "$input.env" ]; then
env=$(sed -e 's/^/--env /' < "$input.env")
else
env=""
fi
# Run the test, capturing stdout, stderr, and the exit status.
exit_status=0
"$runwasi" "$wasm" \
"$runwasi" $env "$wasm" \
< "$stdin" \
> "$stdout_observed" \
2> "$stderr_observed" \

Loading…
Cancel
Save