@@ -4,6 +4,14 @@ set -ueo pipefail
44# Top-level test runner. Usage is "run.sh" to run tests in compile-only mode,
55# or "run.sh <runwasi>" where <runwasi> is a WASI-capable runtime to run the
66# tests in full compile and execute mode.
7+ #
8+ # By default this script will look for `clang` and `clang++` in $PATH and
9+ # assume that they are correctly configured with the sysroot in the default
10+ # location. Alternatively, exporting $CC and $CXX allow more flexibility. e.g:
11+ #
12+ # export CXX="<wasi-sdk>/bin/clang++ --sysroot <wasi-sdk>/share/wasi-sysroot"
13+ # export CCC="<wasi-sdk>/bin/clang --sysroot <wasi-sdk>/share/wasi-sysroot"
14+ #
715
816# Determine the wasm runtime to use, if one is provided.
917if [ $# -gt 0 ]; then
1220 runwasi=" "
1321fi
1422
15- cd compile-only
23+ testdir=$( dirname $0 )
24+ CC=${CC:= clang}
25+ CXX=${CXX:= clang++}
26+
27+ echo $CC
28+ echo $CXX
29+
30+ cd $testdir /compile-only
1631for options in -O0 -O2 " -O2 -flto" ; do
1732 echo " ===== Testing compile-only with $options ====="
1833 for file in * .c; do
1934 echo " Testing compile-only $file ..."
20- ../testcase.sh " " clang " $options " " $file "
35+ ../testcase.sh " " " $CC " " $options " " $file "
2136 done
2237 for file in * .cc; do
2338 echo " Testing compile-only $file ..."
24- ../testcase.sh " " clang++ " $options " " $file "
39+ ../testcase.sh " " " $CXX " " $options " " $file "
2540 done
2641done
2742cd - > /dev/null
2843
29- cd general
44+ cd $testdir / general
3045for options in -O0 -O2 " -O2 -flto" ; do
3146 echo " ===== Testing with $options ====="
3247 for file in * .c; do
3348 echo " Testing $file ..."
34- ../testcase.sh " $runwasi " clang " $options " " $file "
49+ ../testcase.sh " $runwasi " " $CC " " $options " " $file "
3550 done
3651 for file in * .cc; do
3752 echo " Testing $file ..."
38- ../testcase.sh " $runwasi " clang++ " $options " " $file "
53+ ../testcase.sh " $runwasi " " $CXX " " $options " " $file "
3954 done
4055done
4156cd - > /dev/null
0 commit comments