3 # SPDX-License-Identifier: GPL-2.0
14 local line_name=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $2 }'`
15 local line_base=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $3 }'`
16 local line_output=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $4 }'`
17 local line_lock=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $5 }'`
18 local line_up=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $6 }'`
20 if [ "${name}" != "${line_name}" ]; then
21 echo "FAILED: wrong name"
25 if [ "${base}" != "${line_base}" ]; then
26 echo "FAILED: wrong base"
30 if [ "${output}" != "${line_output}" ]; then
31 echo "FAILED: wrong output"
35 if [ "${lock}" != "${line_lock}" ]; then
36 echo "FAILED: wrong lock"
40 if [ "${up}" != "${line_up}" ]; then
41 echo "FAILED: wrong up"
57 local line_name=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $2 }'`
58 local line_run=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $3 }'`
59 local line_base=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $4 }'`
60 local line_output=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $5 }'`
61 local line_control=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $6 }'`
62 local line_ack=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $7 }'`
63 local line_up=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $8 }'`
65 if [ "${name}" != "${line_name}" ]; then
66 echo "FAILED: wrong name"
70 if [ "${run}" != "${line_run}" ]; then
71 echo "FAILED: wrong run"
75 if [ "${base}" != "${line_base}" ]; then
76 echo "FAILED: wrong base"
80 if [ "${output}" != "${line_output}" ]; then
81 echo "FAILED: wrong output"
85 if [ "${control}" != "${line_control}" ]; then
86 echo "FAILED: wrong control"
90 if [ "${ack}" != "${line_ack}" ]; then
91 echo "FAILED: wrong ack"
95 if [ "${up}" != "${line_up}" ]; then
96 echo "FAILED: wrong up"
106 perf daemon start --config ${config}
108 # wait for the session to ping
110 while [ "${state}" != "OK" ]; do
111 state=`perf daemon ping --config ${config} --session ${session} | awk '{ print $1 }'`
121 local line=`perf daemon --config ${config} -x: | head -1`
122 local pid=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $1 }'`
125 perf daemon stop --config ${config}
127 # ... and wait for the pid to go away
128 tail --pid=${pid} -f /dev/null
133 echo "test daemon list"
135 local config=$(mktemp /tmp/perf.daemon.config.XXX)
136 local base=$(mktemp -d /tmp/perf.daemon.base.XXX)
138 cat <<EOF > ${config}
143 run = -e cpu-clock -m 1 sleep 10
146 run = -e task-clock -m 1 sleep 10
149 sed -i -e "s|BASE|${base}|" ${config}
152 daemon_start ${config} size
155 # pid:daemon:base:base/output:base/lock
156 local line=`perf daemon --config ${config} -x: | head -1`
157 check_line_first ${line} daemon ${base} ${base}/output ${base}/lock "0"
160 # pid:size:-e cpu-clock:base/size:base/size/output:base/size/control:base/size/ack:0
161 local line=`perf daemon --config ${config} -x: | head -2 | tail -1`
162 check_line_other "${line}" size "-e cpu-clock -m 1 sleep 10" ${base}/session-size \
163 ${base}/session-size/output ${base}/session-size/control \
164 ${base}/session-size/ack "0"
167 # pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0
168 local line=`perf daemon --config ${config} -x: | head -3 | tail -1`
169 check_line_other "${line}" time "-e task-clock -m 1 sleep 10" ${base}/session-time \
170 ${base}/session-time/output ${base}/session-time/control \
171 ${base}/session-time/ack "0"
174 daemon_exit ${base} ${config}
182 echo "test daemon reconfig"
184 local config=$(mktemp /tmp/perf.daemon.config.XXX)
185 local base=$(mktemp -d /tmp/perf.daemon.base.XXX)
188 cat <<EOF > ${config}
193 run = -e cpu-clock -m 1 sleep 10
196 run = -e task-clock -m 1 sleep 10
199 sed -i -e "s|BASE|${base}|" ${config}
202 daemon_start ${config} size
205 # pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0
206 local line=`perf daemon --config ${config} -x: | head -3 | tail -1`
207 check_line_other "${line}" time "-e task-clock -m 1 sleep 10" ${base}/session-time \
208 ${base}/session-time/output ${base}/session-time/control ${base}/session-time/ack "0"
209 local pid=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $1 }'`
212 local config_new=${config}.new
213 cat <<EOF > ${config_new}
218 run = -e cpu-clock -m 1 sleep 10
221 run = -e cpu-clock -m 1 sleep 10
224 # TEST 1 - change config
226 sed -i -e "s|BASE|${base}|" ${config_new}
227 cp ${config_new} ${config}
229 # wait for old session to finish
230 tail --pid=${pid} -f /dev/null
232 # wait for new one to start
234 while [ "${state}" != "OK" ]; do
235 state=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'`
238 # check reconfigured 2nd session
239 # pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0
240 local line=`perf daemon --config ${config} -x: | head -3 | tail -1`
241 check_line_other "${line}" time "-e cpu-clock -m 1 sleep 10" ${base}/session-time \
242 ${base}/session-time/output ${base}/session-time/control ${base}/session-time/ack "0"
244 # TEST 2 - empty config
246 local config_empty=${config}.empty
247 cat <<EOF > ${config_empty}
253 sed -i -e "s|BASE|${base}|" ${config_empty}
254 cp ${config_empty} ${config}
256 # wait for sessions to finish
258 while [ "${state}" != "FAIL" ]; do
259 state=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'`
263 while [ "${state}" != "FAIL" ]; do
264 state=`perf daemon ping --config ${config} --session size | awk '{ print $1 }'`
267 local one=`perf daemon --config ${config} -x: | wc -l`
269 if [ ${one} -ne "1" ]; then
270 echo "FAILED: wrong list output"
274 # TEST 3 - config again
276 cp ${config_new} ${config}
278 # wait for size to start
280 while [ "${state}" != "OK" ]; do
281 state=`perf daemon ping --config ${config} --session size | awk '{ print $1 }'`
284 # wait for time to start
286 while [ "${state}" != "OK" ]; do
287 state=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'`
291 daemon_exit ${base} ${config}
296 rm -f ${config_empty}
301 echo "test daemon stop"
303 local config=$(mktemp /tmp/perf.daemon.config.XXX)
304 local base=$(mktemp -d /tmp/perf.daemon.base.XXX)
307 cat <<EOF > ${config}
312 run = -e cpu-clock -m 1 sleep 10
315 run = -e task-clock -m 1 sleep 10
318 sed -i -e "s|BASE|${base}|" ${config}
321 daemon_start ${config} size
323 local pid_size=`perf daemon --config ${config} -x: | head -2 | tail -1 | awk 'BEGIN { FS = ":" } ; { print $1 }'`
324 local pid_time=`perf daemon --config ${config} -x: | head -3 | tail -1 | awk 'BEGIN { FS = ":" } ; { print $1 }'`
326 # check that sessions are running
327 if [ ! -d "/proc/${pid_size}" ]; then
328 echo "FAILED: session size not up"
331 if [ ! -d "/proc/${pid_time}" ]; then
332 echo "FAILED: session time not up"
336 daemon_exit ${base} ${config}
338 # check that sessions are gone
339 if [ -d "/proc/${pid_size}" ]; then
340 echo "FAILED: session size still up"
343 if [ -d "/proc/${pid_time}" ]; then
344 echo "FAILED: session time still up"
353 echo "test daemon signal"
355 local config=$(mktemp /tmp/perf.daemon.config.XXX)
356 local base=$(mktemp -d /tmp/perf.daemon.base.XXX)
359 cat <<EOF > ${config}
364 run = -e cpu-clock --switch-output -m 1 sleep 10
367 sed -i -e "s|BASE|${base}|" ${config}
370 daemon_start ${config} test
373 perf daemon signal --config ${config} --session test
374 perf daemon signal --config ${config}
377 daemon_exit ${base} ${config}
379 # count is 2 perf.data for signals and 1 for perf record finished
380 count=`ls ${base}/session-test/ | grep perf.data | wc -l`
381 if [ ${count} -ne 3 ]; then
383 echo "FAILED: perf data no generated"
392 echo "test daemon ping"
394 local config=$(mktemp /tmp/perf.daemon.config.XXX)
395 local base=$(mktemp -d /tmp/perf.daemon.base.XXX)
398 cat <<EOF > ${config}
403 run = -e cpu-clock -m 1 sleep 10
406 run = -e task-clock -m 1 sleep 10
409 sed -i -e "s|BASE|${base}|" ${config}
412 daemon_start ${config} size
414 size=`perf daemon ping --config ${config} --session size | awk '{ print $1 }'`
415 type=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'`
417 if [ ${size} != "OK" -o ${type} != "OK" ]; then
419 echo "FAILED: daemon ping failed"
423 daemon_exit ${base} ${config}
431 echo "test daemon lock"
433 local config=$(mktemp /tmp/perf.daemon.config.XXX)
434 local base=$(mktemp -d /tmp/perf.daemon.base.XXX)
437 cat <<EOF > ${config}
442 run = -e cpu-clock -m 1 sleep 10
445 sed -i -e "s|BASE|${base}|" ${config}
448 daemon_start ${config} size
450 # start second daemon over the same config/base
451 failed=`perf daemon start --config ${config} 2>&1 | awk '{ print $1 }'`
453 # check that we failed properly
454 if [ ${failed} != "failed:" ]; then
456 echo "FAILED: daemon lock failed"
460 daemon_exit ${base} ${config}