Skip to content

Commit 9f637e6

Browse files
authored
wamr-test-suites/test_wamr.sh: Add an option to specify wamrc binary (#3635)
1 parent 2879e67 commit 9f637e6

2 files changed

Lines changed: 30 additions & 8 deletions

File tree

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def ignore_the_case(
129129
return False
130130

131131

132-
def preflight_check(aot_flag, eh_flag):
132+
def preflight_check(aot_flag, aot_compiler, eh_flag):
133133
if not pathlib.Path(SPEC_TEST_DIR).resolve().exists():
134134
print(f"Can not find {SPEC_TEST_DIR}")
135135
return False
@@ -138,8 +138,8 @@ def preflight_check(aot_flag, eh_flag):
138138
print(f"Can not find {WAST2WASM_CMD}")
139139
return False
140140

141-
if aot_flag and not pathlib.Path(WAMRC_CMD).resolve().exists():
142-
print(f"Can not find {WAMRC_CMD}")
141+
if aot_flag and not pathlib.Path(aot_compiler).resolve().exists():
142+
print(f"Can not find {aot_compiler}")
143143
return False
144144

145145
return True
@@ -149,6 +149,7 @@ def test_case(
149149
case_path,
150150
target,
151151
aot_flag=False,
152+
aot_compiler=WAMRC_CMD,
152153
sgx_flag=False,
153154
multi_module_flag=False,
154155
multi_thread_flag=False,
@@ -177,7 +178,7 @@ def test_case(
177178
if no_pty:
178179
CMD.append("--no-pty")
179180
CMD.append("--aot-compiler")
180-
CMD.append(WAMRC_CMD)
181+
CMD.append(aot_compiler)
181182

182183
if aot_flag:
183184
CMD.append("--aot")
@@ -274,6 +275,7 @@ def test_case(
274275
def test_suite(
275276
target,
276277
aot_flag=False,
278+
aot_compiler=WAMRC_CMD,
277279
sgx_flag=False,
278280
multi_module_flag=False,
279281
multi_thread_flag=False,
@@ -348,6 +350,7 @@ def test_suite(
348350
str(case_path),
349351
target,
350352
aot_flag,
353+
aot_compiler,
351354
sgx_flag,
352355
multi_module_flag,
353356
multi_thread_flag,
@@ -389,6 +392,7 @@ def test_suite(
389392
str(case_path),
390393
target,
391394
aot_flag,
395+
aot_compiler,
392396
sgx_flag,
393397
multi_module_flag,
394398
multi_thread_flag,
@@ -470,6 +474,12 @@ def main():
470474
dest="aot_flag",
471475
help="Running with AOT mode",
472476
)
477+
parser.add_argument(
478+
"--aot-compiler",
479+
default=WAMRC_CMD,
480+
dest="aot_compiler",
481+
help="AOT compiler",
482+
)
473483
parser.add_argument(
474484
"-x",
475485
action="store_true",
@@ -550,7 +560,7 @@ def main():
550560
if options.target == "x86_32":
551561
options.target = "i386"
552562

553-
if not preflight_check(options.aot_flag, options.eh_flag):
563+
if not preflight_check(options.aot_flag, options.aot_compiler, options.eh_flag):
554564
return False
555565

556566
if not options.cases:
@@ -564,6 +574,7 @@ def main():
564574
ret = test_suite(
565575
options.target,
566576
options.aot_flag,
577+
options.aot_compiler,
567578
options.sgx_flag,
568579
options.multi_module_flag,
569580
options.multi_thread_flag,
@@ -591,6 +602,7 @@ def main():
591602
case,
592603
options.target,
593604
options.aot_flag,
605+
options.aot_compiler,
594606
options.sgx_flag,
595607
options.multi_module_flag,
596608
options.multi_thread_flag,

tests/wamr-test-suites/test_wamr.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function help()
3939
echo "-C enable code coverage collect"
4040
echo "-j set the platform to test"
4141
echo "-T set sanitizer to use in tests(ubsan|tsan|asan)"
42+
echo "-A use the specified wamrc command instead of building it"
4243
echo "-r [requirement name] [N [N ...]] specify a requirement name followed by one or more"
4344
echo " subrequirement IDs, if no subrequirement is specificed,"
4445
echo " it will run all subrequirements. When this optin is used,"
@@ -75,6 +76,7 @@ fi
7576
PARALLELISM=0
7677
ENABLE_QEMU=0
7778
QEMU_FIRMWARE=""
79+
WAMRC_CMD=""
7880
# prod/testsuite-all branch
7981
WASI_TESTSUITE_COMMIT="ee807fc551978490bf1c277059aabfa1e589a6c2"
8082
TARGET_LIST=("AARCH64" "AARCH64_VFP" "ARMV7" "ARMV7_VFP" "THUMBV7" "THUMBV7_VFP" \
@@ -83,7 +85,7 @@ REQUIREMENT_NAME=""
8385
# Initialize an empty array for subrequirement IDs
8486
SUBREQUIREMENT_IDS=()
8587

86-
while getopts ":s:cabgvt:m:MCpSXexwWPGQF:j:T:r:" opt
88+
while getopts ":s:cabgvt:m:MCpSXexwWPGQF:j:T:r:A:" opt
8789
do
8890
OPT_PARSED="TRUE"
8991
case $opt in
@@ -214,6 +216,10 @@ do
214216
echo "Only Test requirement name: ${REQUIREMENT_NAME}"
215217
[[ ${#SUBREQUIREMENT_IDS[@]} -ne 0 ]] && echo "Choose subrequirement IDs: ${SUBREQUIREMENT_IDS[@]}"
216218
;;
219+
A)
220+
echo "Using wamrc ${OPTARG}"
221+
WAMRC_CMD=${OPTARG}
222+
;;
217223
?)
218224
help
219225
exit 1
@@ -251,7 +257,7 @@ else
251257
readonly IWASM_CMD="${WAMR_DIR}/product-mini/platforms/${PLATFORM}/build/iwasm"
252258
fi
253259

254-
readonly WAMRC_CMD="${WAMR_DIR}/wamr-compiler/build/wamrc"
260+
readonly WAMRC_CMD_DEFAULT="${WAMR_DIR}/wamr-compiler/build/wamrc"
255261

256262
readonly CLASSIC_INTERP_COMPILE_FLAGS="\
257263
-DWAMR_BUILD_TARGET=${TARGET} \
@@ -550,6 +556,7 @@ function spec_test()
550556
# require warmc only in aot mode
551557
if [[ $1 == 'aot' ]]; then
552558
ARGS_FOR_SPEC_TEST+="-t "
559+
ARGS_FOR_SPEC_TEST+="--aot-compiler ${WAMRC_CMD} "
553560
fi
554561

555562
if [[ ${PARALLELISM} == 1 ]]; then
@@ -1052,7 +1059,10 @@ function trigger()
10521059
if [[ ${ENABLE_QEMU} == 0 ]]; then
10531060
build_iwasm_with_cfg $BUILD_FLAGS
10541061
fi
1055-
build_wamrc
1062+
if [ -z "${WAMRC_CMD}" ]; then
1063+
build_wamrc
1064+
WAMRC_CMD=${WAMRC_CMD_DEFAULT}
1065+
fi
10561066
for suite in "${TEST_CASE_ARR[@]}"; do
10571067
$suite"_test" aot
10581068
done

0 commit comments

Comments
 (0)