1 #!/bin/bash 1 #!/bin/bash 2 # daemon operations 2 # daemon operations 3 # SPDX-License-Identifier: GPL-2.0 3 # SPDX-License-Identifier: GPL-2.0 4 4 5 check_line_first() 5 check_line_first() 6 { 6 { 7 local line=$1 7 local line=$1 8 local name=$2 8 local name=$2 9 local base=$3 9 local base=$3 10 local output=$4 10 local output=$4 11 local lock=$5 11 local lock=$5 12 local up=$6 12 local up=$6 13 13 14 local line_name !! 14 local line_name=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $2 }'` 15 line_name=`echo "${line}" | awk 'BEGIN !! 15 local line_base=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $3 }'` 16 local line_base !! 16 local line_output=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $4 }'` 17 line_base=`echo "${line}" | awk 'BEGIN !! 17 local line_lock=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $5 }'` 18 local line_output !! 18 local line_up=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $6 }'` 19 line_output=`echo "${line}" | awk 'BEG << 20 local line_lock << 21 line_lock=`echo "${line}" | awk 'BEGIN << 22 local line_up << 23 line_up=`echo "${line}" | awk 'BEGIN { << 24 19 25 if [ "${name}" != "${line_name}" ]; th 20 if [ "${name}" != "${line_name}" ]; then 26 echo "FAILED: wrong name" 21 echo "FAILED: wrong name" 27 error=1 22 error=1 28 fi 23 fi 29 24 30 if [ "${base}" != "${line_base}" ]; th 25 if [ "${base}" != "${line_base}" ]; then 31 echo "FAILED: wrong base" 26 echo "FAILED: wrong base" 32 error=1 27 error=1 33 fi 28 fi 34 29 35 if [ "${output}" != "${line_output}" ] 30 if [ "${output}" != "${line_output}" ]; then 36 echo "FAILED: wrong output" 31 echo "FAILED: wrong output" 37 error=1 32 error=1 38 fi 33 fi 39 34 40 if [ "${lock}" != "${line_lock}" ]; th 35 if [ "${lock}" != "${line_lock}" ]; then 41 echo "FAILED: wrong lock" 36 echo "FAILED: wrong lock" 42 error=1 37 error=1 43 fi 38 fi 44 39 45 if [ "${up}" != "${line_up}" ]; then 40 if [ "${up}" != "${line_up}" ]; then 46 echo "FAILED: wrong up" 41 echo "FAILED: wrong up" 47 error=1 42 error=1 48 fi 43 fi 49 } 44 } 50 45 51 check_line_other() 46 check_line_other() 52 { 47 { 53 local line=$1 48 local line=$1 54 local name=$2 49 local name=$2 55 local run=$3 50 local run=$3 56 local base=$4 51 local base=$4 57 local output=$5 52 local output=$5 58 local control=$6 53 local control=$6 59 local ack=$7 54 local ack=$7 60 local up=$8 55 local up=$8 61 56 62 local line_name !! 57 local line_name=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $2 }'` 63 line_name=`echo "${line}" | awk 'BEGIN !! 58 local line_run=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $3 }'` 64 local line_run !! 59 local line_base=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $4 }'` 65 line_run=`echo "${line}" | awk 'BEGIN !! 60 local line_output=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $5 }'` 66 local line_base !! 61 local line_control=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $6 }'` 67 line_base=`echo "${line}" | awk 'BEGIN !! 62 local line_ack=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $7 }'` 68 local line_output !! 63 local line_up=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $8 }'` 69 line_output=`echo "${line}" | awk 'BEG << 70 local line_control << 71 line_control=`echo "${line}" | awk 'BE << 72 local line_ack << 73 line_ack=`echo "${line}" | awk 'BEGIN << 74 local line_up << 75 line_up=`echo "${line}" | awk 'BEGIN { << 76 64 77 if [ "${name}" != "${line_name}" ]; th 65 if [ "${name}" != "${line_name}" ]; then 78 echo "FAILED: wrong name" 66 echo "FAILED: wrong name" 79 error=1 67 error=1 80 fi 68 fi 81 69 82 if [ "${run}" != "${line_run}" ]; then 70 if [ "${run}" != "${line_run}" ]; then 83 echo "FAILED: wrong run" 71 echo "FAILED: wrong run" 84 error=1 72 error=1 85 fi 73 fi 86 74 87 if [ "${base}" != "${line_base}" ]; th 75 if [ "${base}" != "${line_base}" ]; then 88 echo "FAILED: wrong base" 76 echo "FAILED: wrong base" 89 error=1 77 error=1 90 fi 78 fi 91 79 92 if [ "${output}" != "${line_output}" ] 80 if [ "${output}" != "${line_output}" ]; then 93 echo "FAILED: wrong output" 81 echo "FAILED: wrong output" 94 error=1 82 error=1 95 fi 83 fi 96 84 97 if [ "${control}" != "${line_control}" 85 if [ "${control}" != "${line_control}" ]; then 98 echo "FAILED: wrong control" 86 echo "FAILED: wrong control" 99 error=1 87 error=1 100 fi 88 fi 101 89 102 if [ "${ack}" != "${line_ack}" ]; then 90 if [ "${ack}" != "${line_ack}" ]; then 103 echo "FAILED: wrong ack" 91 echo "FAILED: wrong ack" 104 error=1 92 error=1 105 fi 93 fi 106 94 107 if [ "${up}" != "${line_up}" ]; then 95 if [ "${up}" != "${line_up}" ]; then 108 echo "FAILED: wrong up" 96 echo "FAILED: wrong up" 109 error=1 97 error=1 110 fi 98 fi 111 } 99 } 112 100 113 daemon_exit() << 114 { << 115 local config=$1 << 116 << 117 local line << 118 line=`perf daemon --config ${config} - << 119 local pid << 120 pid=`echo "${line}" | awk 'BEGIN { FS << 121 << 122 # Reset trap handler. << 123 trap - SIGINT SIGTERM << 124 << 125 # stop daemon << 126 perf daemon stop --config ${config} << 127 << 128 # ... and wait for the pid to go away << 129 tail --pid=${pid} -f /dev/null << 130 } << 131 << 132 daemon_start() 101 daemon_start() 133 { 102 { 134 local config=$1 103 local config=$1 135 local session=$2 104 local session=$2 136 105 137 perf daemon start --config ${config} 106 perf daemon start --config ${config} 138 107 139 # Clean up daemon if interrupted. << 140 trap 'echo "FAILED: Signal caught"; da << 141 << 142 # wait for the session to ping 108 # wait for the session to ping 143 local state="FAIL" 109 local state="FAIL" 144 local retries=0 << 145 while [ "${state}" != "OK" ]; do 110 while [ "${state}" != "OK" ]; do 146 state=`perf daemon ping --conf 111 state=`perf daemon ping --config ${config} --session ${session} | awk '{ print $1 }'` 147 sleep 0.05 112 sleep 0.05 148 retries=$((${retries} +1)) << 149 if [ ${retries} -ge 600 ]; the << 150 echo "FAILED: Timeout << 151 daemon_exit ${config} << 152 exit 1 << 153 fi << 154 done 113 done 155 } 114 } 156 115 >> 116 daemon_exit() >> 117 { >> 118 local base=$1 >> 119 local config=$2 >> 120 >> 121 local line=`perf daemon --config ${config} -x: | head -1` >> 122 local pid=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $1 }'` >> 123 >> 124 # stop daemon >> 125 perf daemon stop --config ${config} >> 126 >> 127 # ... and wait for the pid to go away >> 128 tail --pid=${pid} -f /dev/null >> 129 } >> 130 157 test_list() 131 test_list() 158 { 132 { 159 echo "test daemon list" 133 echo "test daemon list" 160 134 161 local config !! 135 local config=$(mktemp /tmp/perf.daemon.config.XXX) 162 config=$(mktemp /tmp/perf.daemon.confi !! 136 local base=$(mktemp -d /tmp/perf.daemon.base.XXX) 163 local base << 164 base=$(mktemp -d /tmp/perf.daemon.base << 165 137 166 cat <<EOF > ${config} 138 cat <<EOF > ${config} 167 [daemon] 139 [daemon] 168 base=BASE 140 base=BASE 169 141 170 [session-size] 142 [session-size] 171 run = -e cpu-clock -m 1 sleep 10 143 run = -e cpu-clock -m 1 sleep 10 172 144 173 [session-time] 145 [session-time] 174 run = -e task-clock -m 1 sleep 10 146 run = -e task-clock -m 1 sleep 10 175 EOF 147 EOF 176 148 177 sed -i -e "s|BASE|${base}|" ${config} 149 sed -i -e "s|BASE|${base}|" ${config} 178 150 179 # start daemon 151 # start daemon 180 daemon_start ${config} size 152 daemon_start ${config} size 181 153 182 # check first line 154 # check first line 183 # pid:daemon:base:base/output:base/loc 155 # pid:daemon:base:base/output:base/lock 184 local line !! 156 local line=`perf daemon --config ${config} -x: | head -1` 185 line=`perf daemon --config ${config} - << 186 check_line_first ${line} daemon ${base 157 check_line_first ${line} daemon ${base} ${base}/output ${base}/lock "0" 187 158 188 # check 1st session 159 # check 1st session 189 # pid:size:-e cpu-clock:base/size:base 160 # pid:size:-e cpu-clock:base/size:base/size/output:base/size/control:base/size/ack:0 190 local line !! 161 local line=`perf daemon --config ${config} -x: | head -2 | tail -1` 191 line=`perf daemon --config ${config} - << 192 check_line_other "${line}" size "-e cp 162 check_line_other "${line}" size "-e cpu-clock -m 1 sleep 10" ${base}/session-size \ 193 ${base}/session-size/ 163 ${base}/session-size/output ${base}/session-size/control \ 194 ${base}/session-size/ 164 ${base}/session-size/ack "0" 195 165 196 # check 2nd session 166 # check 2nd session 197 # pid:time:-e task-clock:base/time:bas 167 # pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0 198 local line !! 168 local line=`perf daemon --config ${config} -x: | head -3 | tail -1` 199 line=`perf daemon --config ${config} - << 200 check_line_other "${line}" time "-e ta 169 check_line_other "${line}" time "-e task-clock -m 1 sleep 10" ${base}/session-time \ 201 ${base}/session-time/ 170 ${base}/session-time/output ${base}/session-time/control \ 202 ${base}/session-time/ 171 ${base}/session-time/ack "0" 203 172 204 # stop daemon 173 # stop daemon 205 daemon_exit ${config} !! 174 daemon_exit ${base} ${config} 206 175 207 rm -rf ${base} 176 rm -rf ${base} 208 rm -f ${config} 177 rm -f ${config} 209 } 178 } 210 179 211 test_reconfig() 180 test_reconfig() 212 { 181 { 213 echo "test daemon reconfig" 182 echo "test daemon reconfig" 214 183 215 local config !! 184 local config=$(mktemp /tmp/perf.daemon.config.XXX) 216 config=$(mktemp /tmp/perf.daemon.confi !! 185 local base=$(mktemp -d /tmp/perf.daemon.base.XXX) 217 local base << 218 base=$(mktemp -d /tmp/perf.daemon.base << 219 186 220 # prepare config 187 # prepare config 221 cat <<EOF > ${config} 188 cat <<EOF > ${config} 222 [daemon] 189 [daemon] 223 base=BASE 190 base=BASE 224 191 225 [session-size] 192 [session-size] 226 run = -e cpu-clock -m 1 sleep 10 193 run = -e cpu-clock -m 1 sleep 10 227 194 228 [session-time] 195 [session-time] 229 run = -e task-clock -m 1 sleep 10 196 run = -e task-clock -m 1 sleep 10 230 EOF 197 EOF 231 198 232 sed -i -e "s|BASE|${base}|" ${config} 199 sed -i -e "s|BASE|${base}|" ${config} 233 200 234 # start daemon 201 # start daemon 235 daemon_start ${config} size 202 daemon_start ${config} size 236 203 237 # check 2nd session 204 # check 2nd session 238 # pid:time:-e task-clock:base/time:bas 205 # pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0 239 local line !! 206 local line=`perf daemon --config ${config} -x: | head -3 | tail -1` 240 line=`perf daemon --config ${config} - << 241 check_line_other "${line}" time "-e ta 207 check_line_other "${line}" time "-e task-clock -m 1 sleep 10" ${base}/session-time \ 242 ${base}/session-time/ 208 ${base}/session-time/output ${base}/session-time/control ${base}/session-time/ack "0" 243 local pid !! 209 local pid=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $1 }'` 244 pid=`echo "${line}" | awk 'BEGIN { FS << 245 210 246 # prepare new config 211 # prepare new config 247 local config_new=${config}.new 212 local config_new=${config}.new 248 cat <<EOF > ${config_new} 213 cat <<EOF > ${config_new} 249 [daemon] 214 [daemon] 250 base=BASE 215 base=BASE 251 216 252 [session-size] 217 [session-size] 253 run = -e cpu-clock -m 1 sleep 10 218 run = -e cpu-clock -m 1 sleep 10 254 219 255 [session-time] 220 [session-time] 256 run = -e cpu-clock -m 1 sleep 10 221 run = -e cpu-clock -m 1 sleep 10 257 EOF 222 EOF 258 223 259 # TEST 1 - change config 224 # TEST 1 - change config 260 225 261 sed -i -e "s|BASE|${base}|" ${config_n 226 sed -i -e "s|BASE|${base}|" ${config_new} 262 cp ${config_new} ${config} 227 cp ${config_new} ${config} 263 228 264 # wait for old session to finish 229 # wait for old session to finish 265 tail --pid=${pid} -f /dev/null 230 tail --pid=${pid} -f /dev/null 266 231 267 # wait for new one to start 232 # wait for new one to start 268 local state="FAIL" 233 local state="FAIL" 269 while [ "${state}" != "OK" ]; do 234 while [ "${state}" != "OK" ]; do 270 state=`perf daemon ping --conf 235 state=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'` 271 done 236 done 272 237 273 # check reconfigured 2nd session 238 # check reconfigured 2nd session 274 # pid:time:-e task-clock:base/time:bas 239 # pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0 275 local line !! 240 local line=`perf daemon --config ${config} -x: | head -3 | tail -1` 276 line=`perf daemon --config ${config} - << 277 check_line_other "${line}" time "-e cp 241 check_line_other "${line}" time "-e cpu-clock -m 1 sleep 10" ${base}/session-time \ 278 ${base}/session-time/ 242 ${base}/session-time/output ${base}/session-time/control ${base}/session-time/ack "0" 279 243 280 # TEST 2 - empty config 244 # TEST 2 - empty config 281 245 282 local config_empty=${config}.empty 246 local config_empty=${config}.empty 283 cat <<EOF > ${config_empty} 247 cat <<EOF > ${config_empty} 284 [daemon] 248 [daemon] 285 base=BASE 249 base=BASE 286 EOF 250 EOF 287 251 288 # change config 252 # change config 289 sed -i -e "s|BASE|${base}|" ${config_e 253 sed -i -e "s|BASE|${base}|" ${config_empty} 290 cp ${config_empty} ${config} 254 cp ${config_empty} ${config} 291 255 292 # wait for sessions to finish 256 # wait for sessions to finish 293 local state="OK" 257 local state="OK" 294 while [ "${state}" != "FAIL" ]; do 258 while [ "${state}" != "FAIL" ]; do 295 state=`perf daemon ping --conf 259 state=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'` 296 done 260 done 297 261 298 local state="OK" 262 local state="OK" 299 while [ "${state}" != "FAIL" ]; do 263 while [ "${state}" != "FAIL" ]; do 300 state=`perf daemon ping --conf 264 state=`perf daemon ping --config ${config} --session size | awk '{ print $1 }'` 301 done 265 done 302 266 303 local one !! 267 local one=`perf daemon --config ${config} -x: | wc -l` 304 one=`perf daemon --config ${config} -x << 305 268 306 if [ ${one} -ne "1" ]; then 269 if [ ${one} -ne "1" ]; then 307 echo "FAILED: wrong list outpu 270 echo "FAILED: wrong list output" 308 error=1 271 error=1 309 fi 272 fi 310 273 311 # TEST 3 - config again 274 # TEST 3 - config again 312 275 313 cp ${config_new} ${config} 276 cp ${config_new} ${config} 314 277 315 # wait for size to start 278 # wait for size to start 316 local state="FAIL" 279 local state="FAIL" 317 while [ "${state}" != "OK" ]; do 280 while [ "${state}" != "OK" ]; do 318 state=`perf daemon ping --conf 281 state=`perf daemon ping --config ${config} --session size | awk '{ print $1 }'` 319 done 282 done 320 283 321 # wait for time to start 284 # wait for time to start 322 local state="FAIL" 285 local state="FAIL" 323 while [ "${state}" != "OK" ]; do 286 while [ "${state}" != "OK" ]; do 324 state=`perf daemon ping --conf 287 state=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'` 325 done 288 done 326 289 327 # stop daemon 290 # stop daemon 328 daemon_exit ${config} !! 291 daemon_exit ${base} ${config} 329 292 330 rm -rf ${base} 293 rm -rf ${base} 331 rm -f ${config} 294 rm -f ${config} 332 rm -f ${config_new} 295 rm -f ${config_new} 333 rm -f ${config_empty} 296 rm -f ${config_empty} 334 } 297 } 335 298 336 test_stop() 299 test_stop() 337 { 300 { 338 echo "test daemon stop" 301 echo "test daemon stop" 339 302 340 local config !! 303 local config=$(mktemp /tmp/perf.daemon.config.XXX) 341 config=$(mktemp /tmp/perf.daemon.confi !! 304 local base=$(mktemp -d /tmp/perf.daemon.base.XXX) 342 local base << 343 base=$(mktemp -d /tmp/perf.daemon.base << 344 305 345 # prepare config 306 # prepare config 346 cat <<EOF > ${config} 307 cat <<EOF > ${config} 347 [daemon] 308 [daemon] 348 base=BASE 309 base=BASE 349 310 350 [session-size] 311 [session-size] 351 run = -e cpu-clock -m 1 sleep 10 312 run = -e cpu-clock -m 1 sleep 10 352 313 353 [session-time] 314 [session-time] 354 run = -e task-clock -m 1 sleep 10 315 run = -e task-clock -m 1 sleep 10 355 EOF 316 EOF 356 317 357 sed -i -e "s|BASE|${base}|" ${config} 318 sed -i -e "s|BASE|${base}|" ${config} 358 319 359 # start daemon 320 # start daemon 360 daemon_start ${config} size 321 daemon_start ${config} size 361 322 362 local pid_size !! 323 local pid_size=`perf daemon --config ${config} -x: | head -2 | tail -1 | awk 'BEGIN { FS = ":" } ; { print $1 }'` 363 pid_size=`perf daemon --config ${confi !! 324 local pid_time=`perf daemon --config ${config} -x: | head -3 | tail -1 | awk 'BEGIN { FS = ":" } ; { print $1 }'` 364 awk 'BEGIN { FS = ":" } ; { << 365 local pid_time << 366 pid_time=`perf daemon --config ${confi << 367 awk 'BEGIN { FS = ":" } ; { << 368 325 369 # check that sessions are running 326 # check that sessions are running 370 if [ ! -d "/proc/${pid_size}" ]; then 327 if [ ! -d "/proc/${pid_size}" ]; then 371 echo "FAILED: session size not 328 echo "FAILED: session size not up" 372 fi 329 fi 373 330 374 if [ ! -d "/proc/${pid_time}" ]; then 331 if [ ! -d "/proc/${pid_time}" ]; then 375 echo "FAILED: session time not 332 echo "FAILED: session time not up" 376 fi 333 fi 377 334 378 # stop daemon 335 # stop daemon 379 daemon_exit ${config} !! 336 daemon_exit ${base} ${config} 380 337 381 # check that sessions are gone 338 # check that sessions are gone 382 if [ -d "/proc/${pid_size}" ]; then 339 if [ -d "/proc/${pid_size}" ]; then 383 echo "FAILED: session size sti 340 echo "FAILED: session size still up" 384 fi 341 fi 385 342 386 if [ -d "/proc/${pid_time}" ]; then 343 if [ -d "/proc/${pid_time}" ]; then 387 echo "FAILED: session time sti 344 echo "FAILED: session time still up" 388 fi 345 fi 389 346 390 rm -rf ${base} 347 rm -rf ${base} 391 rm -f ${config} 348 rm -f ${config} 392 } 349 } 393 350 394 test_signal() 351 test_signal() 395 { 352 { 396 echo "test daemon signal" 353 echo "test daemon signal" 397 354 398 local config !! 355 local config=$(mktemp /tmp/perf.daemon.config.XXX) 399 config=$(mktemp /tmp/perf.daemon.confi !! 356 local base=$(mktemp -d /tmp/perf.daemon.base.XXX) 400 local base << 401 base=$(mktemp -d /tmp/perf.daemon.base << 402 357 403 # prepare config 358 # prepare config 404 cat <<EOF > ${config} 359 cat <<EOF > ${config} 405 [daemon] 360 [daemon] 406 base=BASE 361 base=BASE 407 362 408 [session-test] 363 [session-test] 409 run = -e cpu-clock --switch-output -m 1 sleep 364 run = -e cpu-clock --switch-output -m 1 sleep 10 410 EOF 365 EOF 411 366 412 sed -i -e "s|BASE|${base}|" ${config} 367 sed -i -e "s|BASE|${base}|" ${config} 413 368 414 # start daemon 369 # start daemon 415 daemon_start ${config} test 370 daemon_start ${config} test 416 371 417 # send 2 signals then exit. Do this in !! 372 # send 2 signals 418 # files to avoid races. If the loop re !! 373 perf daemon signal --config ${config} --session test 419 # give up. !! 374 perf daemon signal --config ${config} 420 local retries=0 !! 375 421 local signals=0 !! 376 # stop daemon 422 local success=0 !! 377 daemon_exit ${base} ${config} 423 while [ ${retries} -lt 600 ] && [ ${su !! 378 424 local files !! 379 # count is 2 perf.data for signals and 1 for perf record finished 425 files=`ls ${base}/session-test !! 380 count=`ls ${base}/session-test/ | grep perf.data | wc -l` 426 if [ ${signals} -eq 0 ]; then !! 381 if [ ${count} -ne 3 ]; then 427 perf daemon signal --c << 428 signals=1 << 429 elif [ ${signals} -eq 1 ] && [ << 430 perf daemon signal --c << 431 signals=2 << 432 elif [ ${signals} -eq 2 ] && [ << 433 daemon_exit ${config} << 434 signals=3 << 435 elif [ ${signals} -eq 3 ] && [ << 436 success=1 << 437 fi << 438 retries=$((${retries} +1)) << 439 done << 440 if [ ${success} -eq 0 ]; then << 441 error=1 382 error=1 442 echo "FAILED: perf data no gen 383 echo "FAILED: perf data no generated" 443 fi 384 fi 444 385 445 rm -rf ${base} 386 rm -rf ${base} 446 rm -f ${config} 387 rm -f ${config} 447 } 388 } 448 389 449 test_ping() 390 test_ping() 450 { 391 { 451 echo "test daemon ping" 392 echo "test daemon ping" 452 393 453 local config !! 394 local config=$(mktemp /tmp/perf.daemon.config.XXX) 454 config=$(mktemp /tmp/perf.daemon.confi !! 395 local base=$(mktemp -d /tmp/perf.daemon.base.XXX) 455 local base << 456 base=$(mktemp -d /tmp/perf.daemon.base << 457 396 458 # prepare config 397 # prepare config 459 cat <<EOF > ${config} 398 cat <<EOF > ${config} 460 [daemon] 399 [daemon] 461 base=BASE 400 base=BASE 462 401 463 [session-size] 402 [session-size] 464 run = -e cpu-clock -m 1 sleep 10 403 run = -e cpu-clock -m 1 sleep 10 465 404 466 [session-time] 405 [session-time] 467 run = -e task-clock -m 1 sleep 10 406 run = -e task-clock -m 1 sleep 10 468 EOF 407 EOF 469 408 470 sed -i -e "s|BASE|${base}|" ${config} 409 sed -i -e "s|BASE|${base}|" ${config} 471 410 472 # start daemon 411 # start daemon 473 daemon_start ${config} size 412 daemon_start ${config} size 474 413 475 size=`perf daemon ping --config ${conf 414 size=`perf daemon ping --config ${config} --session size | awk '{ print $1 }'` 476 type=`perf daemon ping --config ${conf 415 type=`perf daemon ping --config ${config} --session time | awk '{ print $1 }'` 477 416 478 if [ ${size} != "OK" ] || [ ${type} != !! 417 if [ ${size} != "OK" -o ${type} != "OK" ]; then 479 error=1 418 error=1 480 echo "FAILED: daemon ping fail 419 echo "FAILED: daemon ping failed" 481 fi 420 fi 482 421 483 # stop daemon 422 # stop daemon 484 daemon_exit ${config} !! 423 daemon_exit ${base} ${config} 485 424 486 rm -rf ${base} 425 rm -rf ${base} 487 rm -f ${config} 426 rm -f ${config} 488 } 427 } 489 428 490 test_lock() 429 test_lock() 491 { 430 { 492 echo "test daemon lock" 431 echo "test daemon lock" 493 432 494 local config !! 433 local config=$(mktemp /tmp/perf.daemon.config.XXX) 495 config=$(mktemp /tmp/perf.daemon.confi !! 434 local base=$(mktemp -d /tmp/perf.daemon.base.XXX) 496 local base << 497 base=$(mktemp -d /tmp/perf.daemon.base << 498 435 499 # prepare config 436 # prepare config 500 cat <<EOF > ${config} 437 cat <<EOF > ${config} 501 [daemon] 438 [daemon] 502 base=BASE 439 base=BASE 503 440 504 [session-size] 441 [session-size] 505 run = -e cpu-clock -m 1 sleep 10 442 run = -e cpu-clock -m 1 sleep 10 506 EOF 443 EOF 507 444 508 sed -i -e "s|BASE|${base}|" ${config} 445 sed -i -e "s|BASE|${base}|" ${config} 509 446 510 # start daemon 447 # start daemon 511 daemon_start ${config} size 448 daemon_start ${config} size 512 449 513 # start second daemon over the same co 450 # start second daemon over the same config/base 514 failed=`perf daemon start --config ${c 451 failed=`perf daemon start --config ${config} 2>&1 | awk '{ print $1 }'` 515 452 516 # check that we failed properly 453 # check that we failed properly 517 if [ ${failed} != "failed:" ]; then 454 if [ ${failed} != "failed:" ]; then 518 error=1 455 error=1 519 echo "FAILED: daemon lock fail 456 echo "FAILED: daemon lock failed" 520 fi 457 fi 521 458 522 # stop daemon 459 # stop daemon 523 daemon_exit ${config} !! 460 daemon_exit ${base} ${config} 524 461 525 rm -rf ${base} 462 rm -rf ${base} 526 rm -f ${config} 463 rm -f ${config} 527 } 464 } 528 465 529 error=0 466 error=0 530 467 531 test_list 468 test_list 532 test_reconfig 469 test_reconfig 533 test_stop 470 test_stop 534 test_signal 471 test_signal 535 test_ping 472 test_ping 536 test_lock 473 test_lock 537 474 538 exit ${error} 475 exit ${error}
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.