Skip to content

Commit

Permalink
perf test: Cleanup daemon if test is interrupted.
Browse files Browse the repository at this point in the history
Reorder daemon_start and daemon_exit as the trap handler is added in
daemon_start referencing daemon_exit.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20210317005505.2794804-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Ian Rogers authored and Arnaldo Carvalho de Melo committed Mar 17, 2021
1 parent 87cb88d commit 078cbb6
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions tools/perf/tests/shell/daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,33 @@ check_line_other()
fi
}

daemon_exit()
{
local config=$1

local line=`perf daemon --config ${config} -x: | head -1`
local pid=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $1 }'`

# Reset trap handler.
trap - SIGINT SIGTERM

# stop daemon
perf daemon stop --config ${config}

# ... and wait for the pid to go away
tail --pid=${pid} -f /dev/null
}

daemon_start()
{
local config=$1
local session=$2

perf daemon start --config ${config}

# Clean up daemon if interrupted.
trap "echo 'FAILED: Signal caught'; daemon_exit ${config}; exit 1" SIGINT SIGTERM

# wait for the session to ping
local state="FAIL"
while [ "${state}" != "OK" ]; do
Expand All @@ -113,20 +133,6 @@ daemon_start()
done
}

daemon_exit()
{
local config=$1

local line=`perf daemon --config ${config} -x: | head -1`
local pid=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $1 }'`

# stop daemon
perf daemon stop --config ${config}

# ... and wait for the pid to go away
tail --pid=${pid} -f /dev/null
}

test_list()
{
echo "test daemon list"
Expand Down

0 comments on commit 078cbb6

Please sign in to comment.