Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 17 additions & 5 deletions case-lib/hijack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down