diff options
| author | Antonio Terceiro <[email protected]> | 2025-02-23 09:48:23 -0300 |
|---|---|---|
| committer | Quentin Carbonneaux <[email protected]> | 2025-03-15 14:43:33 +0100 |
| commit | 903610de4fb27ad020e30b0e77eb0a278a949524 (patch) | |
| tree | c0256ef0fd95c98c1fa55a49d9d9b8388050b5d9 /tools | |
| parent | f7ab20680b84ff16936bff17def5f9a849ff57cb (diff) | |
tools/test.sh: test the native architecture without QEMU
While at it, extract most duplicated code across targets into a
function.
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/test.sh | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/tools/test.sh b/tools/test.sh index f8025c4..7af62a5 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -16,26 +16,50 @@ asmref=$tmp.ref.s exe=$tmp.exe out=$tmp.out +qemu_not_needed() { + "$@" +} + +cc= +find_cc_and_qemu() { + if [ -n "$cc" ]; then + return + fi + target="$1" + candidate_cc="$2" + if $candidate_cc -v >/dev/null 2>&1; then + cc=$candidate_cc + echo "cc: $cc" + + if [ "$target" = "$(uname -m)" ]; then + qemu=qemu_not_needed + echo "qemu: not needed, testing native architecture" + else + qemu="$3" + if $qemu -version >/dev/null 2>&1; then + sysroot=$($candidate_cc -print-sysroot) + if [ -n "$sysroot" ]; then + qemu="$qemu -L $sysroot" + fi + echo "qemu: $qemu" + else + qemu= + echo "qemu: not found" + fi + fi + echo + + fi +} + init() { case "$TARGET" in arm64) for p in aarch64-linux-musl aarch64-linux-gnu do - cc="$p-gcc -no-pie -static" - qemu="qemu-aarch64" - if - $cc -v >/dev/null 2>&1 && - $qemu -version >/dev/null 2>&1 - then - if sysroot=$($cc -print-sysroot) && test -n "$sysroot" - then - qemu="$qemu -L $sysroot" - fi - break - fi - cc= + find_cc_and_qemu aarch64 "$p-gcc -no-pie -static" "qemu-aarch64" done - if test -z "$cc" + if test -z "$cc" -o -z "$qemu" then echo "Cannot find arm64 compiler or qemu." exit 77 @@ -45,21 +69,9 @@ init() { rv64) for p in riscv64-linux-musl riscv64-linux-gnu do - cc="$p-gcc -no-pie -static" - qemu="qemu-riscv64" - if - $cc -v >/dev/null 2>&1 && - $qemu -version >/dev/null 2>&1 - then - if sysroot=$($cc -print-sysroot) && test -n "$sysroot" - then - qemu="$qemu -L $sysroot" - fi - break - fi - cc= + find_cc_and_qemu riscv64 "$p-gcc -no-pie -static" "qemu-riscv64" done - if test -z "$cc" + if test -z "$cc" -o -z "$qemu" then echo "Cannot find riscv64 compiler or qemu." exit 77 @@ -69,21 +81,9 @@ init() { x86_64) for p in x86_64-linux-musl x86_64-linux-gnu do - cc="$p-gcc -no-pie -static" - qemu="qemu-x86_64" - if - $cc -v >/dev/null 2>&1 && - $qemu -version >/dev/null 2>&1 - then - if sysroot=$($cc -print-sysroot) && test -n "$sysroot" - then - qemu="$qemu -L $sysroot" - fi - break - fi - cc= + find_cc_and_qemu x86_64 "$p-gcc -no-pie -static" "qemu-x86_64" done - if test -z "$cc" + if test -z "$cc" -o -z "$qemu" then echo "Cannot find x86_64 compiler or qemu." exit 77 |
