summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Werkmeister2020-11-17 21:54:42 +0100
committerLucas Werkmeister2020-11-17 21:54:42 +0100
commit4900009ab7455050557f35b379a7541a5e800356 (patch)
tree6ddda9c38df4a6921a8fd17a871bafdaa718813d
parente8b20aff1ea89ebabcf7db134675a6f0929dcb89 (diff)
downloadaur-4900009ab7455050557f35b379a7541a5e800356.tar.gz
Add GraalWasm to test.sh script
Needs Emscripten to compile the C file, which apparently puts the emcc binary in an unusual location, so add that to the PATH as well. I also considered adding the .wasm file to the Git repository directly, but it seems the format changes occasionally – a file I used to test earlier GraalWasm releases didn’t work with 20.3.0 anymore – so let’s instead have the test script compile the source code from scratch, and require the testing user to have emscripten installed.
-rwxr-xr-xtest.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/test.sh b/test.sh
index 165308404931..83e1e33d24f5 100755
--- a/test.sh
+++ b/test.sh
@@ -49,4 +49,24 @@ if [[ $helloWorld != 'Hello, world!' ]]; then
exit 1
fi
+printf '%s\n' 'Testing GraalWASM...'
+
+PATH=$PATH:/usr/lib/emscripten
+
+cat > hello.c << 'EOF'
+#include <stdio.h>
+
+int main() {
+ printf("Hello, WASM!\n");
+ return 0;
+}
+EOF
+emcc -o hello.wasm hello.c || exit
+
+helloWorld=$(wasm --Builtins=wasi_snapshot_preview1 hello.wasm) || exit
+if [[ $helloWorld != 'Hello, WASM!' ]]; then
+ printf 'expected "Hello, WASM!", got %q\n' "$helloWorld"
+ exit 1
+fi
+
printf '%s\n' 'Done.'