Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/golden/target-select.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" |
Expand Down
Loading