Honor $CC and $CXX in test runner (#132)

pull/136/head
Sam Clegg 5 years ago committed by GitHub
parent 5531968c18
commit 800231ee93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,14 @@ set -ueo pipefail
# Top-level test runner. Usage is "run.sh" to run tests in compile-only mode, # Top-level test runner. Usage is "run.sh" to run tests in compile-only mode,
# or "run.sh <runwasi>" where <runwasi> is a WASI-capable runtime to run the # or "run.sh <runwasi>" where <runwasi> is a WASI-capable runtime to run the
# tests in full compile and execute mode. # tests in full compile and execute mode.
#
# By default this script will look for `clang` and `clang++` in $PATH and
# 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 CCC="<wasi-sdk>/bin/clang --sysroot <wasi-sdk>/share/wasi-sysroot"
#
# Determine the wasm runtime to use, if one is provided. # Determine the wasm runtime to use, if one is provided.
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
@ -12,30 +20,37 @@ else
runwasi="" runwasi=""
fi fi
cd compile-only testdir=$(dirname $0)
CC=${CC:=clang}
CXX=${CXX:=clang++}
echo $CC
echo $CXX
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 "" clang "$options" "$file" ../testcase.sh "" "$CC" "$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 "" clang++ "$options" "$file" ../testcase.sh "" "$CXX" "$options" "$file"
done done
done done
cd - >/dev/null cd - >/dev/null
cd 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 "$runwasi" clang "$options" "$file" ../testcase.sh "$runwasi" "$CC" "$options" "$file"
done done
for file in *.cc; do for file in *.cc; do
echo "Testing $file..." echo "Testing $file..."
../testcase.sh "$runwasi" clang++ "$options" "$file" ../testcase.sh "$runwasi" "$CXX" "$options" "$file"
done done
done done
cd - >/dev/null cd - >/dev/null

@ -7,7 +7,7 @@ set -ueo pipefail
# Command-line parsing; this script is meant to be run from a higher-level # Command-line parsing; this script is meant to be run from a higher-level
# script, so don't do anything fancy. # script, so don't do anything fancy.
runwasi="$1" runwasi="$1"
clang="$2" compiler="$2"
options="$3" options="$3"
input="$4" input="$4"
@ -27,7 +27,7 @@ fi
echo "Testing $input..." echo "Testing $input..."
# Compile the testcase. # Compile the testcase.
"$clang" $options $file_options "$input" -o "$wasm" $compiler $options $file_options "$input" -o "$wasm"
# If we don't have a runwasi command, we're just doing compile-only testing. # If we don't have a runwasi command, we're just doing compile-only testing.
if [ "$runwasi" == "" ]; then if [ "$runwasi" == "" ]; then

Loading…
Cancel
Save