~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/tests/shell/daemon.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/perf/tests/shell/daemon.sh (Version linux-6.12-rc7) and /tools/perf/tests/shell/daemon.sh (Version linux-6.4.16)


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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php