libsodium/test/default/wasi-test-wrapper.sh

29 lines
808 B
Bash
Raw Normal View History

2019-05-30 10:04:55 -04:00
#! /bin/sh
MAX_MEMORY_TESTS="67108864"
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "wasmtime" ]; then
if command -v wasmtime >/dev/null; then
wasmtime -o --dir=. "$1" && exit 0
fi
fi
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "wasmer" ]; then
if command -v wasmer >/dev/null; then
wasmer run "$1" --backend "${WASMER_BACKEND:-cranelift}" --dir=. && exit 0
fi
fi
2019-05-30 10:04:55 -04:00
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "lucet" ]; then
if command -v lucetc-wasi >/dev/null && command -v lucet-wasi >/dev/null; then
lucetc-wasi \
--reserved-size "${MAX_MEMORY_TESTS}" \
-o "${1}.so" --opt-level 2 "$1" &&
lucet-wasi --dir=.:. --max-heap-size "${MAX_MEMORY_TESTS}" "${1}.so" &&
2019-05-30 10:04:55 -04:00
rm -f "${1}.so" && exit 0
fi
fi
echo "WebAssembly runtime failed" >&2
exit 1