Skip to content

Commit ea9e11c

Browse files
authored
fix: enhance test case execution handling in test_wamr.sh (#4712)
1 parent 6d63869 commit ea9e11c

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

tests/wamr-test-suites/test_wamr.sh

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
#
77

8+
# Run script like DEBUG=1 ./test_wamr.sh ... to enable debug mode
89
function DEBUG() {
9-
[[ -n $(env | grep "\<DEBUG\>") ]] && $@
10+
env | grep -q "\<DEBUG\>" && "$@"
1011
}
11-
DEBUG set -exv pipefail
12+
DEBUG set -exv
13+
DEBUG set -o pipefail
1214

1315
function help()
1416
{
@@ -996,6 +998,18 @@ function do_execute_in_running_mode()
996998

997999
function trigger()
9981000
{
1001+
# return if TEST_CASE_ARR is empty
1002+
if [[ -z "${TEST_CASE_ARR[@]}" ]]; then
1003+
echo "TEST_CASE_ARR is empty, NO test case to run"
1004+
return
1005+
fi
1006+
1007+
# Print all the test cases to be executed
1008+
echo "Following test cases to be executed: "
1009+
for suite in "${TEST_CASE_ARR[@]}"; do
1010+
echo " - " $suite"_test"
1011+
done
1012+
9991013
# Check if REQUIREMENT_NAME is set, if set, only calling requirement test and early return
10001014
if [[ -n $REQUIREMENT_NAME ]]; then
10011015
python ${REQUIREMENT_SCRIPT_DIR}/run_requirement.py -o ${REPORT_DIR}/ -r "$REQUIREMENT_NAME" "${SUBREQUIREMENT_IDS[@]}"
@@ -1187,21 +1201,32 @@ function trigger()
11871201
done
11881202
}
11891203

1204+
function remove_empty_elements()
1205+
{
1206+
# Remove empty elements from the array
1207+
local arr=("$@")
1208+
local new_arr=()
1209+
for element in "${arr[@]}"; do
1210+
if [[ -n "$element" ]]; then
1211+
new_arr+=("$element")
1212+
fi
1213+
done
1214+
echo "${new_arr[@]}"
1215+
}
1216+
11901217
if [[ $TEST_CASE_ARR ]];then
11911218
# Check if 'unit' is in TEST_CASE_ARR
11921219
if [[ " ${TEST_CASE_ARR[@]} " =~ " unit " ]]; then
11931220
# unit test cases are designed with specific compilation flags
11941221
# and run under specific modes.
11951222
# There is no need to loop through all running modes in this script.
11961223
unit_test || (echo "TEST FAILED"; exit 1)
1197-
if [[ ${COLLECT_CODE_COVERAGE} == 1 ]]; then
1198-
collect_coverage unit
1199-
fi
1224+
collect_coverage unit
12001225

12011226
# remove 'unit' from TEST_CASE_ARR
12021227
TEST_CASE_ARR=("${TEST_CASE_ARR[@]/unit}")
12031228
# remove empty elements from TEST_CASE_ARR
1204-
TEST_CASE_ARR=("${TEST_CASE_ARR[@]:-}")
1229+
TEST_CASE_ARR=($(remove_empty_elements "${TEST_CASE_ARR[@]}"))
12051230
fi
12061231

12071232
# loop others through all running modes
@@ -1223,6 +1248,7 @@ else
12231248
fi
12241249

12251250
echo -e "Test finish. Reports are under ${REPORT_DIR}"
1226-
DEBUG set +exv pipefail
1251+
DEBUG set +exv
1252+
DEBUG set +o pipefail
12271253
echo "TEST SUCCESSFUL"
12281254
exit 0

0 commit comments

Comments
 (0)