Drop unused condition check
[pcp.git] / qa / 416
blob07334470eef7455a90c0367f9373728d9be2b6ad
1 #!/bin/sh
2 # PCP QA Test No. 416
3 # news pmda ... exercise perl PMDA bits-n-bobs
5 # Copyright (c) 2010 Ken McDonell. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 perl -e "use PCP::PMDA" >/dev/null 2>&1
17 [ $? -eq 0 ] || _notrun "perl PCP::PMDA module not installed"
18 [ -f $PCP_PMDAS_DIR/news/pmdanews.pl ] || _notrun "news pmda not installed"
20 status=0 # success is the default!
21 $sudo rm -rf $tmp.* $seq.full
22 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
23 here=`pwd`
25 _filter()
27 sed \
28 -e "s;$tmp;TMP;g" \
29 -e "s;/[a-zA-Z0-9_/.\-]*/perl;PERL;" \
30 -e "s;$PCP_PMDAS_DIR;PCP_PMDAS_DIR;" \
31 -e '/^Log for pmdanews/s/ on .*/ on .../' \
32 -e '/^Log finished/s/ed .*/ed .../' \
33 -e '/^pmResult dump/{
34 s/ 0x[0-9a-f][0-9a-f]* / ADDR /
35 s/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9]/TIMESTAMP/
39 # Made more compilcated by non-determinism in the output from
40 # the PMNS traversal commands "traverse" and "children".
41 # Need to slice output horizontally, sort some sections then
42 # concatenate sections .. yuk.
44 _filter2()
46 rm -f $tmp.0 $tmp.1 $tmp.2 $tmp.3 $tmp.4
47 ${PCP_AWK_PROG} '
48 BEGIN { part=0 }
49 { outname = "'$tmp.'" part
50 print $0 >outname
52 part==0 && /^Metric: news$/ { part=1; next }
53 part==1 && /> children news.articles$/ { part=2; next }
54 part==2 && /^Metric: news.articles$/ { part=3; next }
55 part==3 && /> children news.articles.count$/ { part=4; next }'
57 [ -f $tmp.1 ] && LC_COLLATE=POSIX sort -o $tmp.1 $tmp.1
58 [ -f $tmp.1 ] && LC_COLLATE=POSIX sort -o $tmp.3 $tmp.3
60 for i in 0 1 2 3 4
62 [ -f $tmp.$i ] && cat $tmp.$i
63 done
66 cat >$tmp.pmns <<End-of-File
67 /* need local pmns in case the news PMDA is not installed */
68 root {
69 news
72 news {
73 articles
74 readers
77 news.articles {
78 total 28:0:201
79 count 28:0:301
80 last 28:0:302
83 news.readers {
84 xrn 28:0:113
85 rn 28:0:111
86 nnrpd 28:0:101
87 trn 28:0:112
88 vn 28:0:114
90 End-of-File
92 home=$PCP_PMDAS_DIR
93 if [ ! -d $home/news ]
94 then
95 echo "Where is $home/news?"
96 exit 1
98 cd $home/news
100 # real QA test starts here
102 cat <<End-of-File | $sudo TERM=ansi sh -c ". /etc/pcp.env; dbpmda -ie -n $tmp.pmns" >$tmp.out 2>&1
103 open pipe `which perl` `pwd`/pmdanews.pl
104 traverse news
105 children news.articles
106 children news.articles.count
107 pmid news.articles.total
108 fetch news.articles.total
109 desc news.articles.count
110 instance 28.0
111 fetch news.articles.count
112 profile 28.0 none
113 profile 28.0 add 2
114 profile 28.0 add 4
115 getdesc on
116 fetch news.articles.count
117 close
118 quit
119 End-of-File
121 cat $tmp.out >>$here/$seq.full
122 _filter <$tmp.out | _filter2
124 # ensure news pmda is all done ...
126 sleep 3
128 echo
129 echo "=== news.log ==="
130 _filter <news.log
132 # success, all done
133 status=0
134 exit