From 99bc957e2876be84937bef41ea7240fd80031c5d Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Tue, 5 Aug 2025 16:04:06 +0200 Subject: [PATCH 1/2] hijack.sh: Track dmesg.txt collection Log dmesg.txt collection done by journalctl, and warn if it is empty. Signed-off-by: Dmitrii Golovanov --- case-lib/hijack.sh | 16 ++++++++++++++-- case-lib/lib.sh | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/case-lib/hijack.sh b/case-lib/hijack.sh index 264edb4b..bdd35655 100644 --- a/case-lib/hijack.sh +++ b/case-lib/hijack.sh @@ -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 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 From 7aaabf74e07b9cef8941ded89da6348bb2c7674c Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Tue, 5 Aug 2025 18:29:14 +0200 Subject: [PATCH 2/2] hijack.sh: Fix missing quotes Fix potential issues at hijack.sh identified by shellcheck as SC2086 Signed-off-by: Dmitrii Golovanov --- case-lib/hijack.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/case-lib/hijack.sh b/case-lib/hijack.sh index bdd35655..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 @@ -197,7 +197,7 @@ function func_exit_handler() fi } - print_test_result_exit $exit_status + print_test_result_exit "$exit_status" } print_test_result_exit()