3 # news pmda ... exercise perl PMDA bits-n-bobs
5 # Copyright (c) 2010 Ken McDonell. All Rights Reserved.
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
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
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 .../' \
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.
46 rm -f $tmp.0 $tmp.1 $tmp.2 $tmp.3 $tmp.4
49 { outname = "'$tmp.
'" part
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
62 [ -f $tmp.
$i ] && cat $tmp.
$i
66 cat >$tmp.pmns
<<End-of-File
67 /* need local pmns in case the news PMDA is not installed */
93 if [ ! -d $home/news
]
95 echo "Where is $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
105 children news.articles
106 children news.articles.count
107 pmid news.articles.total
108 fetch news.articles.total
109 desc news.articles.count
111 fetch news.articles.count
116 fetch news.articles.count
121 cat $tmp.out
>>$here/$seq.full
122 _filter
<$tmp.out | _filter2
124 # ensure news pmda is all done ...
129 echo "=== news.log ==="