diff --git a/tests/golden/target-select.sh b/tests/golden/target-select.sh index 2264fb95..723346a9 100644 --- a/tests/golden/target-select.sh +++ b/tests/golden/target-select.sh @@ -27,6 +27,10 @@ set -u echo "TEST-MARKER target-select" . "$(dirname "$0")/../lib.sh" +# The compilers built here choose their own default; the suite's +# x86_64-elf (tests/run.sh, tests/lib.sh) is one a TARGETS=arm compiler +# lacks, and it refused even --version. As default-target.sh does. +unset EMBCC_DEFAULT_TARGET EMBCC=${EMBCC:-$EMBCC_ROOT/embcc} out=$EMBCC_ROOT/tests/golden/out/target-select diff --git a/tests/lib.sh b/tests/lib.sh index 45ee5814..aa775f29 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -21,6 +21,13 @@ fi . "$EMBCC_ROOT/tools/hostpaths.sh" NEWLIB_INC=$X86_NEWLIB/include +# The target nothing names, as tests/run.sh sets it: the tests were written +# against x86_64-elf and name every other target. Since embcc compiles for +# the host by default (#198), a test run by hand on a Mac built Mach-O +# objects without this, and embld-doctor failed for a contributor although +# the suite passed (#201). default-target.sh unsets it to test the default. +export EMBCC_DEFAULT_TARGET=x86_64-elf + # READELF / OBJDUMP / OBJCOPY come from tools/hostpaths.sh too. # An x86-64 program is run natively only where the host IS x86-64 Linux; any diff --git a/tests/run.sh b/tests/run.sh index 7eae42c7..b422a858 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -128,6 +128,20 @@ if ! why=$("$EMBCC" --target="$TARGET" --print-target 2>&1 >/dev/null) && exit 0 fi +# The families this compiler lacks ("Not built:" in --version; none for a +# full build). A test that stops on one of them is a skip. A test that +# names a family this compiler HAS was refused by a compiler the test +# built itself -- target-select's TARGETS=arm one says exactly these words +# on purpose -- and its failure is a failure: counted as a skip, it hid +# target-select failing in CI from #198 on. +NOT_BUILT=$("$EMBCC" --version 2>/dev/null | sed -n 's/^Not built://p') +unbuilt_skip() { # unbuilt_skip OUTPUT: stopped on a family it lacks? + for fam in $(printf '%s\n' "$1" | grep -o "$UNBUILT" | awk '{print $7}'); do + case " $NOT_BUILT " in *" $fam "*) return 0 ;; esac + done + return 1 +} + pass=0 fail=0 skip=0 @@ -243,7 +257,7 @@ while [ $i -lt $n_sh ]; do ok "$t" elif [ "$status" -eq 0 ]; then bad "$t" "exit 0 but marker 'TEST-MARKER $name' missing — did it run?" "$out" - elif printf '%s\n' "$out" | grep -q "$UNBUILT"; then + elif unbuilt_skip "$out"; then # stopped on a target this compiler was built without (make # TARGETS=): not run, so neither a pass nor a failure echo "SKIP $t ($(printf '%s\n' "$out" | grep -m1 "$UNBUILT" |