From d1641460108d8ecfb9c2149bca886e4e8b6a3217 Mon Sep 17 00:00:00 2001 From: Moandor Date: Sat, 4 Jul 2020 00:29:54 +0800 Subject: [PATCH] [test] print debug info when expect tests fail (#5181) This stores debug logs from expect and prints them if a test fails to enable easier debugging. --- .gitignore | 1 + script/test | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 581e43bb8..3f44e28eb 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,4 @@ third_party/nlbuild-autotools/repo/third_party/autoconf/m4/ltsugar.m4 third_party/nlbuild-autotools/repo/third_party/autoconf/m4/ltversion.m4 third_party/nlbuild-autotools/repo/third_party/autoconf/m4/lt~obsolete.m4 third_party/nlbuild-autotools/repo/third_party/autoconf/missing +/tmp/ diff --git a/script/test b/script/test index 85ee827f8..a5b263e39 100755 --- a/script/test +++ b/script/test @@ -219,19 +219,25 @@ do_expect() test_patterns=(-name 'cli-*.exp' -o -name 'simulation-*.exp') fi + local log_file="tmp/log_expect" while read -r script; do sudo rm -rf tmp + mkdir tmp { if [[ ${OT_NATIVE_IP} == 1 ]]; then - OT_COMMAND="${ot_command}" RCP_COMMAND="${rcp_command}" sudo -E "${script}" + OT_COMMAND="${ot_command}" RCP_COMMAND="${rcp_command}" sudo -E expect -df "${script}" 2>"${log_file}" else - OT_COMMAND="${ot_command}" RCP_COMMAND="${rcp_command}" "${script}" + OT_COMMAND="${ot_command}" RCP_COMMAND="${rcp_command}" expect -df "${script}" 2>"${log_file}" fi } || { local exit_code=$? + cat "${log_file}" >&2 echo -e "${COLOR_FAIL}FAIL${COLOR_NONE} ${script}" exit "${exit_code}" } + if [[ ${VERBOSE} == 1 ]]; then + cat "${log_file}" >&2 + fi echo -e "${COLOR_PASS}PASS${COLOR_NONE} ${script}" done < <( if [[ $# != 0 ]]; then