Skip to content

Commit 99bc957

Browse files
committed
hijack.sh: Track dmesg.txt collection
Log dmesg.txt collection done by journalctl, and warn if it is empty. Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
1 parent d675ecf commit 99bc957

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

case-lib/hijack.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,29 @@ function func_exit_handler()
132132
storage_checks || exit_status=1
133133
fi
134134

135+
local journalctl_logs="$LOG_ROOT/dmesg.txt"
135136
if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then
136137
# Do not collect the entire duration of the test but only the
137138
# last iteration.
138-
journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "$LOG_ROOT/dmesg.txt"
139+
dlogi "Save kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}"
140+
journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "${journalctl_logs}"
139141
elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then
140-
journalctl_cmd > "$LOG_ROOT/dmesg.txt"
142+
dlogi "Save all kernel messages to ${journalctl_logs}"
143+
journalctl_cmd > "${journalctl_logs}"
141144
else
142145
dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set'
143146
dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT"
144147
test "$exit_status" -ne 0 || exit_status=1
145148
fi
149+
if test -s "${journalctl_logs}"; then
150+
wcLog=$(wc -l "${journalctl_logs}")
151+
dlogi "nlines=$wcLog"
152+
else
153+
dlogw "Empty ${journalctl_logs}"
154+
fi
155+
# Make sure the logs are written on disk just in case of DUT power reset.
156+
sync
157+
146158
# After log collected, KERNEL_CHECKPOINT will not be used any more
147159
unset KERNEL_CHECKPOINT
148160

case-lib/lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ setup_kernel_check_point()
280280
# the mistake to call this function _after_ checking the logs.
281281
KERNEL_CHECKPOINT=$(($(date +%s) - 1))
282282
fi
283+
dlogi "KERNEL_CHECKPOINT=${KERNEL_CHECKPOINT}"
283284
}
284285

285286
# This function adds a fake error to dmesg (which is always saved by

0 commit comments

Comments
 (0)