3 # pmlogger with its new formats for -s and -T stopping conditions
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
9 echo "QA output created by $seq"
11 # get standard filters
15 status
=1 # failure is the default!
16 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20 SECS_TOL
=2 # number of seconds tolerance
21 BYTES_TOL
=1000 # number of bytes tolerance
22 #debug=1 # give extra debugging info
27 rm -f $tmp.log
$tmp.0 $tmp.index
$tmp.meta
30 # Is given value within tolerance of expected value
36 upper_limit
=`expr $expected + $tolerance`
37 [ $expected -le $given -a $given -le $upper_limit ]
42 num_recs
=`$pmdumplog $tmp | egrep -c '^[0-9][0-9]:[0-9][0-9]:'`
43 # subtract 1 for the preamble
44 num_recs
=`expr $num_recs - 1`
45 [ $debug ] && echo "found $num_recs samples after the preamble"
51 $pmlogger -s $size_arg -c $tmp.config
-l $tmp.log
$tmp
54 echo "Expected log sample size: $size_arg"
55 echo "Actual log sample size: $num_recs"
62 num_bytes
=$2 # bytes version of size_arg
63 $pmlogger -s $size_arg -c $tmp.config
-l $tmp.log
$tmp
66 actual_size
=`ls -l $tmp.0 | $PCP_AWK_PROG ' {print $5} '`
70 echo "Expected log size of approx: $size_arg"
71 [ $debug ] && echo "Actual log size: $actual_size bytes"
72 if _tolerance
$num_bytes $actual_size $BYTES_TOL
74 echo "Log size is within tolerance"
76 echo "Log size is outside tolerance ($actual_size bytes)"
81 # Find out number of records, n, for given size
82 # Then make sure for (n-1) records that the size is smaller
86 num_bytes
=$2 # bytes version of size_arg
87 $pmlogger -s $size_arg -c $tmp.config
-l $tmp.log
$tmp
90 bigger_size
=`ls -l $tmp.0 | $PCP_AWK_PROG ' {print $5} '`
95 num_recs
=`expr $num_recs - 1`
96 if [ $num_recs -gt 0 ]
99 $pmlogger -s $num_recs -c $tmp.config
-l $tmp.log
$tmp
102 smaller_size
=`ls -l $tmp.0 | $PCP_AWK_PROG ' {print $5} '`
109 [ $debug ] && echo "Range: $smaller_size .. $bigger_size"
110 if [ $smaller_size -le $num_bytes -a $num_bytes -le $bigger_size ]
112 echo "Log size for $size_arg is correct"
114 echo "$num_bytes is not within range $smaller_size - $bigger_size"
121 # return time in seconds
123 # /usr/bin/time IS bloody important - dont port-sh it. EVER!
124 /usr
/bin
/time $
* 2>&1 >/dev
/null | \
125 if [ $PCP_PLATFORM = linux
]
127 # 0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2752maxresident)k
128 tr ' ' "\n" |
$PCP_AWK_PROG '/elapsed$/ { sub("elapsed", "", $1);
129 split ($1,tt,"[:.]");
130 print (tt[1]*60)+tt[2];}'
131 elif [ $PCP_PLATFORM = darwin
]
133 # 0.00 real 0.00 user 0.00 sys
134 $PCP_AWK_PROG '{print $1}' |
sed -e 's/\..*//'
139 $PCP_AWK_PROG '/^real/ {print $2}' |
sed -e 's/\..*//'
143 # Note: size arg should be given in secs for comparison with /usr/bin/time
147 num_secs
=$2 # secs version of size_arg
148 time=`_time_me $pmlogger -s $size_arg -c $tmp.config -l $tmp.log $tmp`
149 [ -z "$time" ] && time=-1
150 echo "Expected time size of: $size_arg"
151 [ $debug ] && echo "Actual time : $time"
152 if _tolerance
$num_secs $time $SECS_TOL
154 echo "Log time is within tolerance"
156 echo "Log time is outside tolerance - $time secs"
163 # Note: size arg should be given in secs for comparison with /usr/bin/time
167 num_secs
=$2 # secs version of size_arg
168 time=`_time_me $pmlogger -T $size_arg -c $tmp.config -l $tmp.log $tmp`
169 [ -z "$time" ] && time=-1
170 echo "Expected time size of: $size_arg"
171 [ $debug ] && echo "Actual time : $time"
172 if _tolerance
$num_secs $time $SECS_TOL
174 echo "Log time is within tolerance"
176 echo "Log time is outside tolerance - $time secs"
181 # real QA test starts here
184 # Create a simple configuration file for testing
185 cat <<EOF >$tmp.config
186 # pmlogger(1) configuration file for doing QA tests
188 log mandatory on 100 msec {
208 _test_file_size
4000bytes
4000
209 _test_file_size
4K
4096
210 _test_file_size
4194B
4194
212 _test_time_size
3secs
3
215 _test_time_end
3secs
3