Skip to content
Open
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
40 changes: 33 additions & 7 deletions tests/wamr-test-suites/test_wamr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

# Run script like DEBUG=1 ./test_wamr.sh ... to enable debug mode
function DEBUG() {
[[ -n $(env | grep "\<DEBUG\>") ]] && $@
env | grep -q "\<DEBUG\>" && "$@"
}
DEBUG set -exv pipefail
DEBUG set -exv
DEBUG set -o pipefail

function help()
{
Expand Down Expand Up @@ -996,6 +998,18 @@ function do_execute_in_running_mode()

function trigger()
{
# return if TEST_CASE_ARR is empty
if [[ -z "${TEST_CASE_ARR[@]}" ]]; then
echo "TEST_CASE_ARR is empty, NO test case to run"
return
fi

# Print all the test cases to be executed
echo "Following test cases to be executed: "
for suite in "${TEST_CASE_ARR[@]}"; do
echo " - " $suite"_test"
done

# Check if REQUIREMENT_NAME is set, if set, only calling requirement test and early return
if [[ -n $REQUIREMENT_NAME ]]; then
python ${REQUIREMENT_SCRIPT_DIR}/run_requirement.py -o ${REPORT_DIR}/ -r "$REQUIREMENT_NAME" "${SUBREQUIREMENT_IDS[@]}"
Expand Down Expand Up @@ -1187,21 +1201,32 @@ function trigger()
done
}

function remove_empty_elements()
{
# Remove empty elements from the array
local arr=("$@")
local new_arr=()
for element in "${arr[@]}"; do
if [[ -n "$element" ]]; then
new_arr+=("$element")
fi
done
echo "${new_arr[@]}"
}

if [[ $TEST_CASE_ARR ]];then
# Check if 'unit' is in TEST_CASE_ARR
if [[ " ${TEST_CASE_ARR[@]} " =~ " unit " ]]; then
# unit test cases are designed with specific compilation flags
# and run under specific modes.
# There is no need to loop through all running modes in this script.
unit_test || (echo "TEST FAILED"; exit 1)
if [[ ${COLLECT_CODE_COVERAGE} == 1 ]]; then
collect_coverage unit
fi
collect_coverage unit

# remove 'unit' from TEST_CASE_ARR
TEST_CASE_ARR=("${TEST_CASE_ARR[@]/unit}")
# remove empty elements from TEST_CASE_ARR
TEST_CASE_ARR=("${TEST_CASE_ARR[@]:-}")
TEST_CASE_ARR=($(remove_empty_elements "${TEST_CASE_ARR[@]}"))
fi

# loop others through all running modes
Expand All @@ -1223,6 +1248,7 @@ else
fi

echo -e "Test finish. Reports are under ${REPORT_DIR}"
DEBUG set +exv pipefail
DEBUG set +exv
DEBUG set +o pipefail
echo "TEST SUCCESSFUL"
exit 0
Loading