Skip to content

Commit 60a48b7

Browse files
committed
Add --interpreter flag and HOST_PLATFORM to test infrastructure
Distinguish host OS from target platform in test_wamr.sh so that cross-compilation targets can skip the native build_iwasm step and pass a pre-built iwasm binary path to the spec test runner.
1 parent ebc4f8e commit 60a48b7

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

tests/wamr-test-suites/spec-test-script/all.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def get_iwasm_cmd(platform: str) -> str:
5858
"AARCH64_VFP",
5959
"ARMV7",
6060
"ARMV7_VFP",
61+
"HEXAGON",
6162
"RISCV32",
6263
"RISCV32_ILP32F",
6364
"RISCV32_ILP32D",
@@ -598,9 +599,20 @@ def main():
598599
)
599600
parser.add_argument('--no-pty', action='store_true',
600601
help="Use direct pipes instead of pseudo-tty")
602+
parser.add_argument(
603+
"--interpreter",
604+
default="",
605+
dest="interpreter",
606+
help="Specify the iwasm interpreter path (overrides the default)",
607+
)
601608

602609
options = parser.parse_args()
603610

611+
# Override global IWASM_CMD if --interpreter is specified
612+
global IWASM_CMD
613+
if options.interpreter:
614+
IWASM_CMD = options.interpreter
615+
604616
# Convert target to lower case for internal use, e.g. X86_64 -> x86_64
605617
# target is always exist, so no need to check it
606618
options.target = options.target.lower()

tests/wamr-test-suites/spec-test-script/runtest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"riscv64_lp64f": ["--target=riscv64", "--target-abi=lp64f", "--cpu=generic-rv64", "--cpu-features=+m,+a,+c,+f", "--size-level=1"],
6363
"riscv64_lp64d": ["--target=riscv64", "--target-abi=lp64d", "--cpu=generic-rv64", "--cpu-features=+m,+a,+c,+f,+d", "--size-level=1"],
6464
"xtensa": ["--target=xtensa"],
65+
"hexagon": ["--target=hexagon"],
6566
}
6667

6768
# AOT compilation options mapping for XIP mode

tests/wamr-test-suites/test_wamr.sh

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function help()
2020
echo " unit|wamr_compiler)"
2121
echo "-m set compile target of iwasm(x86_64|x86_32|armv7|armv7_vfp|thumbv7|thumbv7_vfp|"
2222
echo " riscv32|riscv32_ilp32f|riscv32_ilp32d|riscv64|"
23-
echo " riscv64_lp64f|riscv64_lp64d|aarch64|aarch64_vfp)"
23+
echo " riscv64_lp64f|riscv64_lp64d|aarch64|aarch64_vfp|hexagon)"
2424
echo "-t set compile type of iwasm(classic-interp|fast-interp|jit|aot|fast-jit|multi-tier-jit)"
2525
echo "-M enable multi module feature"
2626
echo "-p enable multi thread feature"
@@ -83,14 +83,16 @@ else
8383
PLATFORM=$(uname -s | tr A-Z a-z)
8484
PYTHON_EXE=python3
8585
fi
86+
HOST_PLATFORM=${PLATFORM}
8687
PARALLELISM=0
8788
ENABLE_QEMU=0
8889
QEMU_FIRMWARE=""
8990
WAMRC_CMD=""
9091
# prod/testsuite-all branch
9192
WASI_TESTSUITE_COMMIT="ee807fc551978490bf1c277059aabfa1e589a6c2"
9293
TARGET_LIST=("AARCH64" "AARCH64_VFP" "ARMV7" "ARMV7_VFP" "THUMBV7" "THUMBV7_VFP" \
93-
"RISCV32" "RISCV32_ILP32F" "RISCV32_ILP32D" "RISCV64" "RISCV64_LP64F" "RISCV64_LP64D" "XTENSA")
94+
"RISCV32" "RISCV32_ILP32F" "RISCV32_ILP32D" "RISCV64" "RISCV64_LP64F" "RISCV64_LP64D" \
95+
"HEXAGON" "XTENSA")
9496
REQUIREMENT_NAME=""
9597
# Initialize an empty array for subrequirement IDs
9698
SUBREQUIREMENT_IDS=()
@@ -380,7 +382,7 @@ function sightglass_test()
380382
function setup_wabt()
381383
{
382384
# please sync with .github/actions/install-wasi-sdk-wabt/action.yml
383-
case ${PLATFORM} in
385+
case ${HOST_PLATFORM} in
384386
cosmopolitan)
385387
;;
386388
linux)
@@ -396,7 +398,7 @@ function setup_wabt()
396398
WABT_VERSION=1.0.37
397399
;;
398400
*)
399-
echo "wabt platform for ${PLATFORM} in unknown"
401+
echo "wabt platform for ${HOST_PLATFORM} in unknown"
400402
exit 1
401403
;;
402404
esac
@@ -603,6 +605,11 @@ function spec_test()
603605
# set the current running target
604606
ARGS_FOR_SPEC_TEST+="-m ${TARGET} "
605607

608+
# For cross-compilation targets, pass the iwasm path explicitly
609+
if [[ "${TARGET_LIST[*]}" =~ "${TARGET}" ]]; then
610+
ARGS_FOR_SPEC_TEST+="--interpreter ${IWASM_CMD} "
611+
fi
612+
606613
# require warmc only in aot mode
607614
if [[ $1 == 'aot' ]]; then
608615
ARGS_FOR_SPEC_TEST+="-t "
@@ -637,7 +644,7 @@ function spec_test()
637644
ARGS_FOR_SPEC_TEST+="--qemu-firmware ${QEMU_FIRMWARE} "
638645
fi
639646

640-
if [[ ${PLATFORM} == "windows" ]]; then
647+
if [[ ${HOST_PLATFORM} == "windows" ]]; then
641648
ARGS_FOR_SPEC_TEST+="--no-pty "
642649
fi
643650

@@ -831,7 +838,7 @@ function build_iwasm_with_cfg()
831838
exit 1
832839
fi
833840

834-
if [[ ${PLATFORM} == "cosmopolitan" ]]; then
841+
if [[ ${HOST_PLATFORM} == "cosmopolitan" ]]; then
835842
# convert from APE to ELF so it can be ran easier
836843
# HACK: link to linux so tests work when platform is detected by uname
837844
cp iwasm.com iwasm \
@@ -1124,7 +1131,7 @@ function trigger()
11241131
"classic-interp")
11251132
# classic-interp
11261133
BUILD_FLAGS="$CLASSIC_INTERP_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
1127-
if [[ ${ENABLE_QEMU} == 0 ]]; then
1134+
if [[ ${ENABLE_QEMU} == 0 ]] && ! [[ "${TARGET_LIST[*]}" =~ "${TARGET}" ]]; then
11281135
build_iwasm_with_cfg $BUILD_FLAGS
11291136
fi
11301137
for suite in "${TEST_CASE_ARR[@]}"; do
@@ -1136,7 +1143,7 @@ function trigger()
11361143
"fast-interp")
11371144
# fast-interp
11381145
BUILD_FLAGS="$FAST_INTERP_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
1139-
if [[ ${ENABLE_QEMU} == 0 ]]; then
1146+
if [[ ${ENABLE_QEMU} == 0 ]] && ! [[ "${TARGET_LIST[*]}" =~ "${TARGET}" ]]; then
11401147
build_iwasm_with_cfg $BUILD_FLAGS
11411148
fi
11421149
for suite in "${TEST_CASE_ARR[@]}"; do
@@ -1167,7 +1174,7 @@ function trigger()
11671174
echo "work in aot mode"
11681175
# aot
11691176
BUILD_FLAGS="$AOT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
1170-
if [[ ${ENABLE_QEMU} == 0 ]]; then
1177+
if [[ ${ENABLE_QEMU} == 0 ]] && ! [[ "${TARGET_LIST[*]}" =~ "${TARGET}" ]]; then
11711178
build_iwasm_with_cfg $BUILD_FLAGS
11721179
fi
11731180
if [ -z "${WAMRC_CMD}" ]; then

0 commit comments

Comments
 (0)