-
Notifications
You must be signed in to change notification settings - Fork 824
/
wasm-test.sh
executable file
·67 lines (52 loc) · 1.26 KB
/
wasm-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
set -e
input=$1
input_dir=$(dirname $input)
cd $input_dir
input_base=$(basename $input .wasm)
if [ -e "$input_base.stdin" ]; then
stdin="$input_base.stdin"
else
stdin="/dev/null"
fi
out_dir="$(mktemp -d)"
stdout_actual="$out_dir/stdout"
stderr_actual="$out_dir/stderr"
status_actual="$out_dir/status"
if [ -e "$input_base.arg" ]; then
arg=$(cat "$input_base.arg")
else
arg=""
fi
if [ -e "$input_base.dir" ]; then
dir="--dir $input_base.dir"
else
dir=""
fi
if [ -e "$input_base.env" ]; then
env=$(sed -e 's/^/--env /' < "$input_base.env")
else
env=""
fi
status=0
"../../target/release/wasmer" --mapdir /hamlet:./test_fs/hamlet --mapdir /fyi:./test_fs/fyi "$input_base.wasm" $dir $env -- $arg \
< "$stdin" \
> "$stdout_actual" \
2> "$stderr_actual" \
|| status=$?
echo $status > "$status_actual"
stdout_expected="$input_base.stdout"
if [ -e "$stdout_expected" ]; then
diff -u "$stdout_expected" "$stdout_actual"
fi
stderr_expected="$input_base.stderr"
if [ -e "$stderr_expected" ]; then
diff -u "$stderr_expected" "$stderr_actual"
fi
status_expected="$input_base.status"
if [ -e "$input_base.status" ]; then
diff -u "$status_expected" "$status_actual"
elif [ ! "$status" -eq "0" ]; then
cat $stderr_actual
exit 1
fi