diff --git a/case-lib/hijack.sh b/case-lib/hijack.sh index 264edb4b..c0b94065 100644 --- a/case-lib/hijack.sh +++ b/case-lib/hijack.sh @@ -21,7 +21,7 @@ function func_exit_handler() line_no=${BASH_LINENO[$((i-1))]} || true # BASH_LINENO doesn't always work - if [ $line_no -gt 1 ]; then line_no=":$line_no"; else line_no=""; fi + if [ "$line_no" -gt 1 ]; then line_no=":$line_no"; else line_no=""; fi dloge " ${FUNCNAME[i]}() @ ${BASH_SOURCE[i]}${line_no}" done @@ -76,7 +76,7 @@ function func_exit_handler() printf \ 'https://github.com/thesofproject/sof/issues/5352\n' | sudo tee -a "$logfile" - if [ $exit_status = 0 ]; then + if [ "$exit_status" = 0 ]; then exit_status=2 # skip fi else # 5352 corruption affects only Zephyr for some unknown reason @@ -132,17 +132,29 @@ function func_exit_handler() storage_checks || exit_status=1 fi + local journalctl_logs="$LOG_ROOT/dmesg.txt" if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then # Do not collect the entire duration of the test but only the # last iteration. - journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "$LOG_ROOT/dmesg.txt" + dlogi "Save kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}" + journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "${journalctl_logs}" elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then - journalctl_cmd > "$LOG_ROOT/dmesg.txt" + dlogi "Save all kernel messages to ${journalctl_logs}" + journalctl_cmd > "${journalctl_logs}" else dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set' dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT" test "$exit_status" -ne 0 || exit_status=1 fi + if test -s "${journalctl_logs}"; then + wcLog=$(wc -l "${journalctl_logs}") + dlogi "nlines=$wcLog" + else + dlogw "Empty ${journalctl_logs}" + fi + # Make sure the logs are written on disk just in case of DUT power reset. + sync + # After log collected, KERNEL_CHECKPOINT will not be used any more unset KERNEL_CHECKPOINT @@ -185,7 +197,7 @@ function func_exit_handler() fi } - print_test_result_exit $exit_status + print_test_result_exit "$exit_status" } print_test_result_exit() diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 4d68d4c1..d2f2f82f 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -280,6 +280,7 @@ setup_kernel_check_point() # the mistake to call this function _after_ checking the logs. KERNEL_CHECKPOINT=$(($(date +%s) - 1)) fi + dlogi "KERNEL_CHECKPOINT=${KERNEL_CHECKPOINT}" } # This function adds a fake error to dmesg (which is always saved by