@ -6,13 +6,7 @@ set -ueo pipefail
# <runwasi> is a WASI-capable runtime to run the tests in full compile and
# <runwasi> is a WASI-capable runtime to run the tests in full compile and
# execute mode.
# execute mode.
#
#
# By default this script will look for `clang` and `clang++` in $PATH and
# The compiler used during testing is loaded from `<path to wasi-sdk>`.
# assume that they are correctly configured with the sysroot in the default
# location. Alternatively, exporting $CC and $CXX allow more flexibility. e.g:
#
# export CXX="<wasi-sdk>/bin/clang++ --sysroot <wasi-sdk>/share/wasi-sysroot"
# export CC="<wasi-sdk>/bin/clang --sysroot <wasi-sdk>/share/wasi-sysroot"
#
if [ $# -lt 1 ] ; then
if [ $# -lt 1 ] ; then
echo "Path to WASI SDK is required"
echo "Path to WASI SDK is required"
exit 1
exit 1
@ -37,44 +31,48 @@ else
fi
fi
testdir = $( dirname $0 )
testdir = $( dirname $0 )
CC = ${ CC : =clang }
CXX = ${ CXX : =clang++ }
echo $CC
echo $CXX
echo " SDK: $wasi_sdk "
echo " SDK: $wasi_sdk "
for target in wasm32-wasi wasm32-wasip1 wasm32-wasi-threads wasm32-wasip1-threads wasm32-wasip2; do
# NB: all tests are run with the default `clang` and `clang++` executables
# but they're also executed with the target-prefixed `clang` executables to
# ensure that those work as well when the `--target` option is omitted.
for target in $TARGETS ; do
echo " ===== Testing target $target ===== "
echo " ===== Testing target $target ===== "
cd $testdir /compile-only
cd $testdir /compile-only
for options in -O0 -O2 "-O2 -flto" ; do
for options in -O0 -O2 "-O2 -flto" ; do
echo " ===== Testing compile-only with $options ===== "
echo " ===== Testing compile-only with $options ===== "
for file in *.c; do
for file in *.c; do
echo " Testing compile-only $file ... "
echo " Testing compile-only $file ... "
../testcase.sh " $target " "" "" "" " $CC " " $options " " $file "
../testcase.sh " $target " "" "" "" " $wasi_sdk /bin/clang " " $options --target= $target " " $file "
../testcase.sh " $target " "" "" "" " $wasi_sdk /bin/ $target -clang " " $options " " $file "
done
done
for file in *.cc; do
for file in *.cc; do
echo " Testing compile-only $file ... "
echo " Testing compile-only $file ... "
../testcase.sh " $target " "" "" "" " $CXX " " $options " " $file "
../testcase.sh " $target " "" "" "" " $wasi_sdk /bin/clang++ " " $options --target= $target -fno-exceptions " " $file "
../testcase.sh " $target " "" "" "" " $wasi_sdk /bin/ $target -clang++ " " $options -fno-exceptions " " $file "
done
done
done
done
cd - >/dev/null
cd - >/dev/null
cd $testdir /general
cd $testdir /general
for options in -O0 -O2 "-O2 -flto" ; do
for options in -O0 -O2 "-O2 -flto" ; do
echo " ===== Testing with $options ===== "
echo " ===== Testing with $options ===== "
for file in *.c; do
for file in *.c; do
echo " Testing $file ... "
echo " Testing $file ... "
../testcase.sh " $target " " $runwasi " " $adapter " " $wasm_tools " " $CC " " $options " " $file "
../testcase.sh " $target " " $runwasi " " $adapter " " $wasm_tools " " $wasi_sdk /bin/clang " " $options --target= $target " " $file "
../testcase.sh " $target " " $runwasi " " $adapter " " $wasm_tools " " $wasi_sdk /bin/ $target -clang " " $options " " $file "
done
done
for file in *.cc; do
for file in *.cc; do
echo " Testing $file ... "
echo " Testing $file ... "
../testcase.sh " $target " " $runwasi " " $adapter " " $wasm_tools " " $CXX " " $options " " $file "
../testcase.sh " $target " " $runwasi " " $adapter " " $wasm_tools " " $wasi_sdk /bin/clang++ " " $options --target= $target -fno-exceptions " " $file "
../testcase.sh " $target " " $runwasi " " $adapter " " $wasm_tools " " $wasi_sdk /bin/ $target -clang++ " " $options -fno-exceptions " " $file "
done
done
done
done
cd - >/dev/null
cd - >/dev/null
done
done
# Test cmake build system for wasi-sdk
# Test cmake build system for wasi-sdk
test_cmake( ) {
test_cmake( ) {
local option
local option