Skip to content
Open
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
13 changes: 6 additions & 7 deletions Runner/suites/Multimedia/DSP_AudioPD/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ check_dependencies adsprpcd
adsprpcd &
PID=$!

sleep 5

if [ -z "$PID" ]; then
echo "Failed to start the binary"
exit 1
Expand All @@ -60,20 +62,17 @@ check_stack_trace() {
return 1
fi
}

# Print overall test result
if check_stack_trace "$PID"; then
log_pass "$TESTNAME : Test Passed"
echo "$TESTNAME PASS" > "$res_file"
kill_process
exit 0
else
log_fail "$TESTNAME : Test Failed"
echo "$TESTNAME FAIL" > "$res_file"
kill_process
exit 1
fi

log_info "Kill the process"
if kill -0 "$PID" 2>/dev/null; then
kill -9 "$PID"
wait "$PID"
fi
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
8 changes: 8 additions & 0 deletions Runner/utils/functestlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3684,3 +3684,11 @@ ensure_network_online() {
unset net_script_path net_ifaces net_wifi net_ifc net_rc net_had_any_ip
return 1
}

kill_process() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This is very very basic, Better you extend it to cover
    • Returns 0 if all targets are gone (or nothing was running).
    • Returns 1 if any target could not be terminated.
    • Sends SIGTERM first, waits KILL_TERM_GRACE seconds, then SIGKILL, waits KILL_KILL_GRACE seconds.
    • Kills children too (via /proc/.../children), and attempts a process-group kill when possible.
    • Safe-guards: never touches PID 1 or self ($$), gracefully handles zombies and non-children (no blocking wait calls).

log_info "Kill the process"
if kill -0 "$PID" 2>/dev/null; then
kill -9 "$PID"
wait "$PID"
fi
}
Loading