Drop unused condition check
[pcp.git] / qa / 185
blobb2667ecf044df117e5c015ac6d8d6d3ff1632534
1 #! /bin/sh
2 # PCP QA Test No. 185
3 # pmnewlog config save/restore checks
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # create our own tmpdir to ensure we can write to it
12 tmpdir=/tmp/$seq-$$
13 rm -rf $tmpdir
14 mkdir -p $tmpdir/pmlogger
15 export PCP_TMP_DIR=$tmpdir
17 # get standard filters
18 . ./common.product
19 . ./common.filter
21 tmp=$tmpdir/$$
22 signal=$PCP_BINADM_DIR/pmsignal
23 trap "$signal -a pmlogger >/dev/null 2>&1; cd; rm -rf $tmpdir; exit" 0 1 2 3 15
25 _filter_dumplog()
27 sed \
28 -e '/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9]/s//TIMESTAMP/' \
29 -e 's/^\(log started *\).*/\1DATESTAMP/' \
30 -e 's/^\(last log entry *\).*/\1DATESTAMP/' \
31 -e 's/^\(current time *\).*/\1DATESTAMP/' \
32 -e 's/^\( *commencing *\).*/\1DATESTAMP/' \
33 -e 's/^\( *ending *\).*/\1DATESTAMP/' \
34 -e '/^Performance metrics/s/host .*/host HOST/'
37 _filter_newlog()
39 sed \
40 -e 's/pid [0-9][0-9]*/pid PID/' \
41 -e '/ \/usr\/pcp\/bin\/pmlogger /s/.*/-- ps line removed --/' \
42 -e '/^\/usr\/pcp\/bin\/pmlogger/s/[0-9][0-9]*/PID/g' \
43 -e '/configuration file saved as/s/[0-9][0-9]*/PID/g' \
44 -e 's/\[[0-9][0-9]*]/[PID]/' \
45 -e 's/ host [^ ]*/ host HOST/g' \
46 -e '/^Getting logged/s/host HOST/host name/' \
47 -e 's/ -h [^ ]*/ -h HOST/g' \
48 -e 's/ SIG.* done/ signal stuff ... done/' \
49 -e '/Error \[<stdin>,/d' \
50 -e '/Warning \[<stdin>,/d' \
51 -e '/Not connected to any/d' \
52 -e '/Logging statement ignored/d' \
53 -e '/Problem with lookup for metric/d' \
54 -e '/Reason: Unknown metric name/d' \
55 -e '/Try again. Information not currently available/d' \
56 -e '/Unknown or illegal metric identifier/d' \
57 -e '/Metric not supported by this version/d' \
58 -e '/^log size/s/[0-9][0-9]*/BYTES/' \
59 -e '/^Contacting pmlogger /d' \
60 -e '/^pmnewlog: Warning: errors from talking /d' \
61 -e '/^continuing .../d' \
62 -e '/New pmlogger configuration file saved /d' \
63 -e '/^[ ]*$/d'
66 # real QA test starts here
67 cat <<End-of-File >$tmp.config
68 # singular instances
69 log mandatory off sample.control
70 log mandatory on 10 sec sample.load
71 log advisory on once sample.seconds
72 # multiple instances
73 log mandatory off sample.colour
74 log mandatory on 20 sec sample.bin
75 log advisory on 1 min sample.bucket
76 End-of-File
77 rm -f $tmp.arch.*
78 pmlogger -L -c $tmp.config -l $tmp.log $tmp.arch &
79 pid=$!
80 sleep 1
82 echo
83 echo "=== pmnewlog #1 =="
84 rm -f $tmp.arch.1.*
85 # ps $PCP_PS_ALL_FLAGS | grep pmlogger
86 # echo "pid=$pid"
87 pmnewlog -C $tmp.config.1 -p $pid $tmp.arch.1 2>&1 >$tmp.out
88 _filter_newlog <$tmp.out | _filter_dumplog >$tmp.check
89 if [ -s $tmp.check ]
90 then
91 echo "Unexpected output!"
92 echo
93 echo "Filtered residual ..."
94 cat $tmp.check
95 echo
96 echo "Unfiltered output from pmnewlog ..."
97 cat $tmp.out
98 else
99 echo "Nothing unexpected in the pmnewlog output"
102 echo
103 echo "=== config differences ==="
104 diff $tmp.config $tmp.config.1
106 echo
107 echo "=== pmnewlog #2 =="
108 rm -f $tmp.arch.2.*
110 hostname=`hostname`
111 pid=`ps $PCP_PS_ALL_FLAGS \
112 | tee $tmp.ps \
113 | grep -v grep \
114 | $PCP_AWK_PROG "/pmlogger.*-h $hostname.*-c \/tmp\// "'{print $2}'`
115 # ps $PCP_PS_ALL_FLAGS | grep pmlogger
116 # echo "pid=$pid"
117 if [ "X$pid" = X ]
118 then
119 echo "Error: no pid matching \"pmlogger.*-h `hostname`.*-c /tmp/\" from ps!"
120 cat $tmp.ps
121 exit 1
124 pmnewlog -C $tmp.config.2 -p $pid $tmp.arch.2 2>&1 >$tmp.out
125 _filter_newlog <$tmp.out | _filter_dumplog >$tmp.check
126 if [ -s $tmp.check ]
127 then
128 echo "Unexpected output!"
129 echo
130 echo "Filtered residual ..."
131 cat $tmp.check
132 echo
133 echo "Unfiltered output from pmnewlog ..."
134 cat $tmp.out
135 else
136 echo "Nothing unexpected in the pmnewlog output"
139 echo
140 echo "=== config differences (expect none!) ==="
141 diff $tmp.config.1 $tmp.config.2