Drop unused condition check
[pcp.git] / qa / 514
blobbc2246b4c45de2a79f4d7ff0723057d8aeb6dc1d
1 #!/bin/sh
2 # PCP QA Test No. 514
4 # pmie - lots of expressions, checking pmie -d output and %v binding
5 # - see also QA 520
7 # Copyright (c) 2012 Ken McDonell. All Rights Reserved.
10 seq=`basename $0`
11 echo "QA output created by $seq"
13 # get standard filters
14 . ./common.product
15 . ./common.filter
16 . ./common.check
18 status=1 # failure is the default!
19 $sudo rm -rf $tmp.* $seq.full
20 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
22 LOCALHOST=`hostname`
24 case $PCP_PLATFORM
26 linux|solaris)
27 # same syslog options for Linux and OpenSolaris
28 SYSLOG_OPT='"-p daemon.info"'
30 darwin)
31 SYSLOG_OPT=''
34 echo "Arrgh ... need syslog option for $PCP_PLATFORM"
35 exit 1
37 esac
39 # may be using journalctl, and so no syslog in the file system
41 if `which journalctl >/dev/null 2>&1`
42 then
43 echo "Using journalctl ..." >>$seq.full
44 have_journalctl=true
45 else
46 have_journalctl=false
47 SYSLOG=''
48 for f in /var/adm/SYSLOG /var/log/daemon.log /var/log/messages /var/log/syslog /var/log/system.log
50 if [ -f $f ]
51 then
52 SYSLOG=$f
53 break
55 done
56 if [ -z "$SYSLOG" ]
57 then
58 echo "Arrgh! Cannot find your syslog file"
59 exit 1
63 _filter()
65 sed \
66 -e "s/\([:@ ]\)$LOCALHOST/\1LOCALHOST/g" \
67 -e "s/\([:@ ]\)local:/\1LOCALHOST/g" \
68 -e 's/[A-Z][a-z][a-z] [A-Z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/DATE/' \
69 -e 's/DATE [12][0-9][0-9][0-9]/DATE/' \
70 -e '/evaluator exiting/s/pmie([0-9][0-9]*)/pmie(PID)/' \
71 -e '/Performance Co-Pilot Inference Engine/s/Version .*/Version .../' \
72 -e 's/\[red] 1[0-9][0-9]/[red] >=100/' \
73 -e 's/\[green] 2[0-9][0-9]/[green] >=200/' \
74 -e 's/\[blue] 3[0-9][0-9]/[blue] >=300/' \
75 -e 's/level=[0-9][0-9]* tag=/level=N tag=/' \
76 # end
79 # mapping to 0x0 -> (nil) needed for C compilers that don't do the
80 # (nil) translation automatically for a printf %p
82 _filter2()
84 sed \
85 -e 's/0x0\([ (]\)/(nil)\1/g' \
86 -e 's/0x0$/(nil)/' \
87 | $PCP_AWK_PROG '
88 $1 == "pmie:" { print; next }
89 /failed: / { print; next }
90 $1 == "initMetric:" { skip=1 }
91 skip == 1 { if ($1 == "Rule:") skip = 0 }
92 skip == 1 { next }
93 { print }' >$tmp.tmp
94 tr ' =' '\012' <$tmp.tmp \
95 | grep '0x' \
96 | $PCP_AWK_PROG >$tmp.sed '
97 BEGIN { n = 0 }
98 { if (seen[$1] == 1) next
99 printf "s/%s/ADDR%03d/\n",$1,n
101 seen[$1] = 1
103 sed -f $tmp.sed <$tmp.tmp
106 cat <<End-of-File >$tmp.pmie
107 some_inst sample.part_bin > 500 -> print "some > 500:" " [%i] %v";
108 all_inst sample.part_bin > 0 -> shell "echo 'all > 0:'" " [%i] %v";
109 some_sample hinv.ncpu @0..2 == hinv.ncpu -> syslog 10sec $SYSLOG_OPT "PCP QA $seq - please ignore: some sample ncpu equal" " [%i] %v";
110 ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "arith %v";
111 // true && true
112 sample.long.one != 2 && ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean1 %v";
113 // false && true
114 sample.long.one <= 0 && ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean2 %v";
115 // true && false
116 sample.long.one < 9 && ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean3 %v";
117 // false && false
118 sample.long.one < 1 && ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean4 %v";
119 // pmns error || true
120 min_inst no_such_metric == 100 || sample.long.million > 0 -> print "error1 %v";
121 // true || true
122 min_inst sample.part_bin == 100 || ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean5:" " [%i] %v";
123 // false || true
124 // NOTE instance bindings here will be for the _left_ subexpression
125 // (which is always false) ... this is odd but not unexpected
126 max_inst sample.part_bin == 100 || ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean6:" " [%i] %v";
127 // true || false
128 sum_inst sample.part_bin > 500 || ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean7:" " [%i] %v";
129 // false || false
130 avg_inst(sample.part_bin) == 0 || ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean8:" " [%i] %v";
131 count_inst(sample.part_bin > 0) > 0 -> print "count_inst:" "[%i] %v";
132 some_inst match_inst "bin-[12345]" sample.part_bin > 100 -> print "match_inst:" " [%i] %v";
133 some_inst nomatch_inst "bin-[12345]" sample.part_bin > 200 -> print "nomatch_inst:" " [%i] %v";
134 // rising, falling - see QA 515
135 all_inst rate sample.bin == 0 -> print "rate:" " [%i] %v";
136 66%_inst sample.colour >= 200 -> print "66%_inst:" " [%i] %v";
137 all_sample sample.long.ten @0..2 == 10 -> print "all_sample: " " [%i] %v";
138 60%_sample some_inst sample.part_bin #'bin-300' #'bin-500' #'bin-700' @0..1 >= 500 -> print "60%_sample: " " [%i] %v";
139 min_sample sample.long.hundred @0..1 == 100 -> print "min_sample: " " [%i] %v";
140 max_sample sample.long.hundred @0..1 == 100 -> print "max_sample: " " [%i] %v";
141 sum_sample sample.bin #'bin-100' @0..3 == 400 -> print "sum_sample: " " [%i] %v";
142 avg_sample sample.bin #'bin-200' @0..1 == 200 -> print "avg_sample: " " [%i] %v";
143 count_sample(some_inst sample.bin #'bin-200' #'bin-300' #'bin-400' @0..2 == 300) == 3 -> print "count_sample: " " [%i] %v";
144 min_inst sample.part_bin > 0 -> print "min_inst:" " @%h [%i] %v";
145 max_inst sample.part_bin > 0 -> print "max_inst:" " @%h [%i] %v";
146 sample.long.one == 1 -> shell "false" | print "false |: %v";
147 sample.long.ten == 10 -> shell "true" & print "true &: %v";
148 sample.long.hundred == 100 -> print "print |:" " %v" | print "bozo don't execute me!";
150 // TODO at some other time ... alarm and stomp actions
151 End-of-File
153 # real QA test starts here
154 cat <<End-of-File | pmie -t 250msec -d -Dappl1 >$tmp.out 2>$tmp.err &
155 f $tmp.pmie
157 r 1sec
159 End-of-File
161 wait
163 # strange but true ... sometimes don't need an echo here to deal
164 # with the pmie> (and no newline) prompt ...
166 case $PCP_PLATFORM
168 darwin)
169 : no
172 : yes
173 echo >>$tmp.out
175 esac
177 echo >>$seq.full
178 echo "pmie PID $!" >>$seq.full
179 echo >>$seq.full
180 echo "=== pmie output ===" >>$seq.full
181 cat $tmp.out >>$seq.full
182 echo >>$seq.full
183 echo "=== pmie errors ===" >>$seq.full
184 cat $tmp.err >>$seq.full
186 _filter2 <$tmp.err | _filter
187 _filter <$tmp.out
189 echo "SYSLOG ..."
190 if $have_journalctl
191 then
192 # be careful ... --boot not supported in all versions, -l not
193 # supported in all versions
194 $sudo journalctl -b --full | tail -100 >$tmp.syslog
195 else
196 $sudo tail -100 $SYSLOG >$tmp.syslog
198 sed <$tmp.syslog -n \
199 -e 's/PCP QA '"$seq"'/PCP QA xxx/' \
200 -e '/ncpu equal/s/ [0-9][0-9]*/ N/g' \
201 -e 's/PCP QA xxx/PCP QA '"$seq"'/' \
202 -e '/\['$!']: PCP QA '"$seq"' - please ignore/{
203 s/.*please ignore/.../
205 }' \
206 | LC_COLLATE=POSIX sort -u
208 echo >>$seq.full
209 if $have_journalctl
210 then
211 echo "=== tail journalctl -b --full ===" >>$seq.full
212 else
213 echo "=== tail SYSLOG ($SYSLOG) ===" >>$seq.full
215 echo "`wc -l <$tmp.syslog | sed -e 's/ //g'` lines ... expect 100" >>$seq.full
216 cat $tmp.syslog >>$seq.full
218 # success, all done
219 status=0
220 exit