mirror of
https://github.com/espressif/openthread.git
synced 2026-09-15 21:50:08 +00:00
[test] fix reporting expect failure (#6869)
This commit fixes reporting expect failures by adding fail on error flag to the ot_exec_expect_script function in script/test script. This commit also fixes failing expect tests and removes expect tests on macOS for unstable issues.
This commit is contained in:
+43
-40
@@ -35,10 +35,10 @@ set -euo pipefail
|
||||
readonly OT_BUILDDIR="${OT_BUILDDIR:-${PWD}/build}"
|
||||
readonly OT_SRCDIR="${PWD}"
|
||||
|
||||
readonly COLOR_PASS='\033[0;32m'
|
||||
readonly COLOR_FAIL='\033[0;31m'
|
||||
readonly COLOR_SKIP='\033[0;33m'
|
||||
readonly COLOR_NONE='\033[0m'
|
||||
readonly OT_COLOR_PASS='\033[0;32m'
|
||||
readonly OT_COLOR_FAIL='\033[0;31m'
|
||||
readonly OT_COLOR_SKIP='\033[0;33m'
|
||||
readonly OT_COLOR_NONE='\033[0m'
|
||||
|
||||
readonly OT_NODE_TYPE="${OT_NODE_TYPE:-cli}"
|
||||
readonly OT_NATIVE_IP="${OT_NATIVE_IP:-0}"
|
||||
@@ -309,38 +309,39 @@ do_pktverify()
|
||||
ot_exec_expect_script()
|
||||
{
|
||||
local log_file="tmp/log_expect"
|
||||
local script="$1"
|
||||
|
||||
echo -e "\n${COLOR_PASS}EXEC${COLOR_NONE} ${script}"
|
||||
sudo killall ot-rcp || true
|
||||
sudo killall ot-cli || true
|
||||
sudo killall ot-cli-ftd || true
|
||||
sudo killall ot-cli-mtd || true
|
||||
sudo rm -rf tmp
|
||||
mkdir tmp
|
||||
{
|
||||
if [[ ${OT_NATIVE_IP} == 1 ]]; then
|
||||
sudo -E expect -df "${script}" 2>"${log_file}"
|
||||
else
|
||||
expect -df "${script}" 2>"${log_file}"
|
||||
fi
|
||||
} || {
|
||||
local EXIT_CODE=$?
|
||||
for script in "$@"; do
|
||||
echo -e "\n${OT_COLOR_PASS}EXEC${OT_COLOR_NONE} ${script}"
|
||||
sudo killall ot-rcp || true
|
||||
sudo killall ot-cli || true
|
||||
sudo killall ot-cli-ftd || true
|
||||
sudo killall ot-cli-mtd || true
|
||||
sudo rm -rf tmp
|
||||
mkdir tmp
|
||||
{
|
||||
if [[ ${OT_NATIVE_IP} == 1 ]]; then
|
||||
sudo -E expect -df "${script}" 2>"${log_file}"
|
||||
else
|
||||
expect -df "${script}" 2>"${log_file}"
|
||||
fi
|
||||
} || {
|
||||
local EXIT_CODE=$?
|
||||
|
||||
# The exit status 77 for skipping is inherited from automake's test driver for script-based testsuites
|
||||
if [[ ${EXIT_CODE} == 77 ]]; then
|
||||
echo -e "\n${COLOR_SKIP}SKIP${COLOR_NONE} ${script}"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n${COLOR_FAIL}FAIL${COLOR_NONE} ${script}"
|
||||
# The exit status 77 for skipping is inherited from automake's test driver for script-based testsuites
|
||||
if [[ ${EXIT_CODE} == 77 ]]; then
|
||||
echo -e "\n${OT_COLOR_SKIP}SKIP${OT_COLOR_NONE} ${script}"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n${OT_COLOR_FAIL}FAIL${OT_COLOR_NONE} ${script}"
|
||||
cat "${log_file}" >&2
|
||||
return "${EXIT_CODE}"
|
||||
fi
|
||||
}
|
||||
echo -e "\n${OT_COLOR_PASS}PASS${OT_COLOR_NONE} ${script}"
|
||||
if [[ ${VERBOSE} == 1 ]]; then
|
||||
cat "${log_file}" >&2
|
||||
return "${EXIT_CODE}"
|
||||
fi
|
||||
}
|
||||
echo -e "\n${COLOR_PASS}PASS${COLOR_NONE} ${script}"
|
||||
if [[ ${VERBOSE} == 1 ]]; then
|
||||
cat "${log_file}" >&2
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
do_expect()
|
||||
@@ -348,23 +349,25 @@ do_expect()
|
||||
local test_patterns
|
||||
|
||||
if [[ ${OT_NODE_TYPE} == rcp* ]]; then
|
||||
if [[ ${THREAD_VERSION} == "1.2" ]]; then
|
||||
test_patterns=(-name 'v1_2-*.exp')
|
||||
elif [[ ${OT_NATIVE_IP} == 1 ]]; then
|
||||
if [[ ${OT_NATIVE_IP} == 1 ]]; then
|
||||
test_patterns=(-name 'tun-*.exp')
|
||||
else
|
||||
test_patterns=(-name 'posix-*.exp' -o -name 'cli-*.exp')
|
||||
if [[ ${THREAD_VERSION} == "1.2" ]]; then
|
||||
test_patterns+=(-o -name 'v1_2-*.exp')
|
||||
fi
|
||||
fi
|
||||
else
|
||||
test_patterns=(-name 'cli-*.exp' -o -name 'simulation-*.exp')
|
||||
fi
|
||||
|
||||
export -f ot_exec_expect_script
|
||||
|
||||
if [[ $# != 0 ]]; then
|
||||
for script in "$@"; do bash -c "ot_exec_expect_script ${script}"; done
|
||||
ot_exec_expect_script "$@"
|
||||
else
|
||||
find tests/scripts/expect -type f -perm "$([[ $OSTYPE == darwin* ]] && echo '+' || echo '/')"111 \( "${test_patterns[@]}" \) -exec bash -c 'ot_exec_expect_script "$1"' _ {} \;
|
||||
export OT_COLOR_PASS OT_COLOR_FAIL OT_COLOR_SKIP OT_COLOR_NONE OT_NATIVE_IP VERBOSE
|
||||
export -f ot_exec_expect_script
|
||||
|
||||
find tests/scripts/expect -type f -perm "$([[ $OSTYPE == darwin* ]] && echo '+' || echo '/')"111 \( "${test_patterns[@]}" \) -exec bash -c 'set -euo pipefail;ot_exec_expect_script "$@"' _ {} +
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@@ -628,7 +631,7 @@ main()
|
||||
;;
|
||||
*)
|
||||
echo
|
||||
echo -e "${COLOR_FAIL}Warning:${COLOR_NONE} Ignoring: '$1'"
|
||||
echo -e "${OT_COLOR_FAIL}Warning:${OT_COLOR_NONE} Ignoring: '$1'"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
|
||||
Reference in New Issue
Block a user