perf tests: Add daemon reconfig test

Add a test for daemon reconfiguration. The test changes the
configuration file and checks that the session is changed properly.

Committer testing:

  [root@five ~]# perf test daemon
  76: daemon operations                                               : Ok
  [root@five ~]# time perf test daemon
  76: daemon operations                                               : Ok

  real	0m6.055s
  user	0m0.174s
  sys	0m0.147s
  [root@five ~]# time perf test -v daemon
  76: daemon operations                                               :
  --- start ---
  test child forked, pid 786863
  test daemon list
  test daemon reconfig
  test child finished with 0
  ---- end ----
  daemon operations: Ok

  real	0m6.127s
  user	0m0.222s
  sys	0m0.165s
  [root@five ~]#

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: https://lore.kernel.org/r/20210208200908.1019149-21-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Jiri Olsa 2021-02-08 21:09:04 +01:00 committed by Arnaldo Carvalho de Melo
parent 2291bb915b
commit 91a17d6f63

View file

@ -177,8 +177,127 @@ EOF
rm -f ${config}
}
test_reconfig()
{
echo "test daemon reconfig"
local config=$(mktemp /tmp/perf.daemon.config.XXX)
local base=$(mktemp -d /tmp/perf.daemon.base.XXX)
# prepare config
cat <<EOF > ${config}
[daemon]
base=BASE
[session-size]
run = -e cpu-clock
[session-time]
run = -e task-clock
EOF
sed -i -e "s|BASE|${base}|" ${config}
# start daemon
daemon_start ${config} size
# check 2nd session
# pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0
local line=`perf daemon --config ${config} -x: | head -3 | tail -1`
check_line_other "${line}" time "-e task-clock" ${base}/session-time \
${base}/session-time/output ${base}/session-time/control ${base}/session-time/ack "0"
local pid=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $1 }'`
# prepare new config
local config_new=${config}.new
cat <<EOF > ${config_new}
[daemon]
base=BASE
[session-size]
run = -e cpu-clock
[session-time]
run = -e cpu-clock
EOF
# TEST 1 - change config
sed -i -e "s|BASE|${base}|" ${config_new}
cp ${config_new} ${config}
# wait for old session to finish
tail --pid=${pid} -f /dev/null
# wait for new one to start
local state="FAIL"
while [ "${state}" != "OK" ]; do
state=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'`
done
# check reconfigured 2nd session
# pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0
local line=`perf daemon --config ${config} -x: | head -3 | tail -1`
check_line_other "${line}" time "-e cpu-clock" ${base}/session-time \
${base}/session-time/output ${base}/session-time/control ${base}/session-time/ack "0"
# TEST 2 - empty config
local config_empty=${config}.empty
cat <<EOF > ${config_empty}
[daemon]
base=BASE
EOF
# change config
sed -i -e "s|BASE|${base}|" ${config_empty}
cp ${config_empty} ${config}
# wait for sessions to finish
local state="OK"
while [ "${state}" != "FAIL" ]; do
state=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'`
done
local state="OK"
while [ "${state}" != "FAIL" ]; do
state=`perf daemon ping --config ${config} --session size | awk '{ print $1 }'`
done
local one=`perf daemon --config ${config} -x: | wc -l`
if [ ${one} -ne "1" ]; then
echo "FAILED: wrong list output"
error=1
fi
# TEST 3 - config again
cp ${config_new} ${config}
# wait for size to start
local state="FAIL"
while [ "${state}" != "OK" ]; do
state=`perf daemon ping --config ${config} --session size | awk '{ print $1 }'`
done
# wait for time to start
local state="FAIL"
while [ "${state}" != "OK" ]; do
state=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'`
done
# stop daemon
daemon_exit ${base} ${config}
rm -rf ${base}
rm -f ${config}
rm -f ${config_new}
rm -f ${config_empty}
}
error=0
test_list
test_reconfig
exit ${error}