Merge branch 'master' of https://github.com/kmcdonell/pcp into kenj-merge
[pcp.git] / qa / 538
blob5b3541cfe601d9fad3989254a370bcaa4310a57e
1 #! /bin/sh
2 # PCP QA Test No. 538
3 # check pmie atexit problem
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 environment, filters and checks
18 . ./common.product
19 . ./common.filter
21 _cleanup()
23 rm -fr $tmpdir
24 pmstore sample.write_me 2 >/dev/null # reset value
27 tmp=$tmpdir/$$
28 signal=$PCP_BINADM_DIR/pmsignal
29 status=1 # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
31 username=`id -u -n`
32 sync
33 pmstore sample.write_me 2 >/dev/null # initialise value
35 cat <<End-of-File >$tmp.conf
36 ( sample.write_me != 2 ) -> shell "echo sample.write_me changed 1>&2" " %v != 2";
37 End-of-File
39 # real QA test starts here
40 pmieopts="-b"
41 id pcp >/dev/null 2>&1 && pmieopts="$pmieopts -U $username"
42 pmie -t 0.5sec $pmieopts -l $tmp.out $tmp.conf &
43 pid=$!
45 sleep 2
46 pmstore sample.write_me 5 >/dev/null
47 sleep 2
49 echo
50 echo "PMIE IS RUNNING"
51 echo "=== check data file still exists..."
52 [ ! -f $PCP_TMP_DIR/pmie/$pid ] && echo "urk, data file has vanished!"
53 echo "=== check log file after first exit..."
54 _filter_pmie_log < $tmp.out | uniq
56 $signal -s TERM $pid
57 wait
59 echo
60 echo "PMIE HAS NOW EXITED"
61 echo
62 echo "=== check data file has gone..."
63 [ -f $PCP_TMP_DIR/pmie/$pid ] && echo "urk, data file is still there!"
64 echo "=== check log file after real exit..."
65 cp $tmp.out $seq.full
67 # $PCP_AWK_PROG filter filters out repeated messages from pmie - including the
68 # odd one that occurs after or between the termination messages
70 _filter_pmie_log < $tmp.out \
71 | $PCP_AWK_PROG '
72 /write_me/ { if ($0 != before) print
73 before=$0
74 next
76 { print }
79 # success, all done
80 status=0
81 exit