Skip to content

Commit 5704306

Browse files
committed
lib.sh: run func_exit_handler on sigterm
Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
1 parent fca480c commit 5704306

File tree

2 files changed

+53
-26
lines changed

2 files changed

+53
-26
lines changed

case-lib/hijack.sh

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,37 @@ SUDO_CMD=$(command -v sudo)
88
# re-use separately instead of all this or nothing.
99
function func_exit_handler()
1010
{
11+
trap - EXIT SIGTERM
1112
local exit_status=${1:-0}
1213

1314
dlogi "Starting func_exit_handler($exit_status)"
1415

16+
local journalctl_logs="$LOG_ROOT/dmesg.txt"
17+
if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then
18+
# Do not collect the entire duration of the test but only the
19+
# last iteration.
20+
dlogi "Save kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}"
21+
journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "${journalctl_logs}"
22+
elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then
23+
dlogi "Save all kernel messages to ${journalctl_logs}"
24+
journalctl_cmd > "${journalctl_logs}"
25+
else
26+
dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set'
27+
dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT"
28+
test "$exit_status" -ne 0 || exit_status=1
29+
fi
30+
if test -s "${journalctl_logs}"; then
31+
wcLog=$(wc -l "${journalctl_logs}")
32+
dlogi "nlines=$wcLog"
33+
else
34+
dlogw "Empty ${journalctl_logs}"
35+
fi
36+
# Make sure the logs are written on disk just in case of DUT power reset.
37+
sync
38+
39+
# After log collected, KERNEL_CHECKPOINT will not be used any more
40+
unset KERNEL_CHECKPOINT
41+
1542
func_lib_check_and_disable_pipewire
1643

1744
# call trace
@@ -134,31 +161,31 @@ function func_exit_handler()
134161
storage_checks || exit_status=1
135162
fi
136163

137-
local journalctl_logs="$LOG_ROOT/dmesg.txt"
138-
if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then
139-
# Do not collect the entire duration of the test but only the
140-
# last iteration.
141-
dlogi "Save kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}"
142-
journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "${journalctl_logs}"
143-
elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then
144-
dlogi "Save all kernel messages to ${journalctl_logs}"
145-
journalctl_cmd > "${journalctl_logs}"
146-
else
147-
dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set'
148-
dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT"
149-
test "$exit_status" -ne 0 || exit_status=1
150-
fi
151-
if test -s "${journalctl_logs}"; then
152-
wcLog=$(wc -l "${journalctl_logs}")
153-
dlogi "nlines=$wcLog"
154-
else
155-
dlogw "Empty ${journalctl_logs}"
156-
fi
157-
# Make sure the logs are written on disk just in case of DUT power reset.
158-
sync
159-
160-
# After log collected, KERNEL_CHECKPOINT will not be used any more
161-
unset KERNEL_CHECKPOINT
164+
# local journalctl_logs="$LOG_ROOT/dmesg.txt"
165+
# if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then
166+
# # Do not collect the entire duration of the test but only the
167+
# # last iteration.
168+
# dlogi "Save kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}"
169+
# journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "${journalctl_logs}"
170+
# elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then
171+
# dlogi "Save all kernel messages to ${journalctl_logs}"
172+
# journalctl_cmd > "${journalctl_logs}"
173+
# else
174+
# dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set'
175+
# dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT"
176+
# test "$exit_status" -ne 0 || exit_status=1
177+
# fi
178+
# if test -s "${journalctl_logs}"; then
179+
# wcLog=$(wc -l "${journalctl_logs}")
180+
# dlogi "nlines=$wcLog"
181+
# else
182+
# dlogw "Empty ${journalctl_logs}"
183+
# fi
184+
# # Make sure the logs are written on disk just in case of DUT power reset.
185+
# sync
186+
187+
# # After log collected, KERNEL_CHECKPOINT will not be used any more
188+
# unset KERNEL_CHECKPOINT
162189

163190
# get ps command result as list
164191
local -a cmd_lst

case-lib/lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ start_test()
9797
}
9898

9999
# func_exit_handler() is in hijack.sh
100-
trap 'func_exit_handler $?' EXIT
100+
trap 'func_exit_handler $?' EXIT SIGTERM
101101

102102
if test -z "$MAX_WAIT_FW_LOADING"; then
103103
local _pltf; _pltf=$("$SCRIPT_HOME/tools/sof-dump-status.py" -p)

0 commit comments

Comments
 (0)