1 CRASH_PATH="@CRASH_PATH@"
2 CRASH_STACK=$(rpm -ql crash-worker | grep "/crash-stack$")
4 function wait_for_dump {
5 KERNEL_DEFINED_TASK_COMM_LEN=16
6 crash_file=${1:0:$((KERNEL_DEFINED_TASK_COMM_LEN - 1))}
8 end=$((SECONDS+${3:-30}))
9 while [ $SECONDS -lt $end ]; do
11 filename=$(find "$CRASH_PATH" -name ${crash_file}_${pid}_*.zip -type f -newermt '-2 seconds' 2>/dev/null)
12 if [ "$filename" ]; then
20 function check_crash_pid {
21 crash_stack_output="$1"
23 grep -q "Callstack Information (PID:$pid)" "$crash_stack_output"
24 test_result $? callstack present
26 function check_crash_stack {
27 crash_stack_output="$1"
29 funcno=$((funcno - 1))
30 grep -qE "Call Stack Count: ($funcno)" "$crash_stack_output"
31 test_result $? callstack count
33 for func in "${@:2}"; do
34 grep -qE " $idx: $func" "$crash_stack_output"
35 test_result $? $idx $func backtraced in $filename
39 function test_crash_stack {
41 "$SCRIPTPATH/$filename" &
44 crash_stack_output="$(mktemp -p /tmp -q test_crash_stack.XXXXXXXXXX)"
45 $CRASH_STACK --pid $pid > "$crash_stack_output"
46 test_result $? crash-stack result
47 check_crash_pid "$crash_stack_output" $pid
48 check_crash_stack "$crash_stack_output" ${@:2}
49 rm -r "$crash_stack_output"
53 function test_crash_worker {
55 "$SCRIPTPATH/$filename" &
58 dump_file=$(wait_for_dump $filename $pid $timeout)
59 test ! -z "$dump_file"
60 test_result $? $filename dump generated in less than $timeout seconds
61 dump_basename=$(basename "$dump_file" .zip)
62 crash_stack_dir="$(mktemp -d -p /tmp -q test_crash_worker.XXXXXXXXXX)"
63 unzip -qq -d "$crash_stack_dir" "$dump_file"
64 crash_stack_output="$crash_stack_dir/$dump_basename/$dump_basename.info"
65 check_crash_pid "$crash_stack_output" $pid
66 check_crash_stack "$crash_stack_output" ${@:2}
67 rm -r "$dump_file" "$crash_stack_dir"