diff --git a/tests/general/env-absent.c b/tests/general/env-absent.c new file mode 100644 index 0000000..b5f6284 --- /dev/null +++ b/tests/general/env-absent.c @@ -0,0 +1,7 @@ +#include +#include + +int main(void) { + printf("HELLO = %s\n", getenv("HELLO")); + return 0; +} diff --git a/tests/general/env-absent.c.stdout.expected b/tests/general/env-absent.c.stdout.expected new file mode 100644 index 0000000..f5614c3 --- /dev/null +++ b/tests/general/env-absent.c.stdout.expected @@ -0,0 +1 @@ +HELLO = (null) diff --git a/tests/general/env.c b/tests/general/env.c new file mode 100644 index 0000000..b5f6284 --- /dev/null +++ b/tests/general/env.c @@ -0,0 +1,7 @@ +#include +#include + +int main(void) { + printf("HELLO = %s\n", getenv("HELLO")); + return 0; +} diff --git a/tests/general/env.c.env b/tests/general/env.c.env new file mode 100644 index 0000000..9be21df --- /dev/null +++ b/tests/general/env.c.env @@ -0,0 +1 @@ +HELLO=hello diff --git a/tests/general/env.c.stdout.expected b/tests/general/env.c.stdout.expected new file mode 100644 index 0000000..b9a2a66 --- /dev/null +++ b/tests/general/env.c.stdout.expected @@ -0,0 +1 @@ +HELLO = hello diff --git a/tests/testcase.sh b/tests/testcase.sh index 61deefb..d2da956 100755 --- a/tests/testcase.sh +++ b/tests/testcase.sh @@ -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" \