This file is indexed.

/var/lib/pcp/testsuite/252 is in pcp-testsuite 3.9.10.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#! /bin/sh 
# PCP QA Test No. 252
# pmlogger with its new formats for -s and -T stopping conditions
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard filters
. ./common.product
. ./common.filter

status=1	# failure is the default!
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15

pmdumplog='pmdumplog'
pmlogger='pmlogger'
SECS_TOL=2	# number of seconds tolerance
BYTES_TOL=1000	# number of bytes tolerance
#debug=1	# give extra debugging info

#
_clean_archive()
{
rm -f $tmp.log $tmp.0 $tmp.index $tmp.meta
}

# Is given value within tolerance of expected value
_tolerance()
{
  expected=$1
  given=$2
  tolerance=$3
  upper_limit=`expr $expected + $tolerance`
  [ $expected -le $given -a $given -le $upper_limit ]
}

_num_recs()
{
  num_recs=`$pmdumplog $tmp | egrep -c '^[0-9][0-9]:[0-9][0-9]:'`
  # subtract 1 for the preamble
  num_recs=`expr $num_recs - 1`
  [ $debug ] && echo "found $num_recs samples after the preamble"
}

_test_sample_size()
{
  size_arg=$1
  $pmlogger -s $size_arg -c $tmp.config -l $tmp.log $tmp 

  _num_recs
  echo "Expected log sample size: $size_arg"
  echo "Actual log sample size:   $num_recs"
 _clean_archive
}

_test_file_size_old()
{
  size_arg=$1
  num_bytes=$2	# bytes version of size_arg
  $pmlogger -s $size_arg -c $tmp.config -l $tmp.log $tmp 
  if [ -f $tmp.0 ]
  then
    actual_size=`ls -l $tmp.0 | $PCP_AWK_PROG ' {print $5} '`
  else
    actual_size=-1
  fi
  echo "Expected log size of approx: $size_arg"
  [ $debug ] && echo "Actual log size:             $actual_size bytes"
  if _tolerance $num_bytes $actual_size $BYTES_TOL
  then
    echo "Log size is within tolerance"
  else
    echo "Log size is outside tolerance ($actual_size bytes)"
  fi
 _clean_archive
}

# Find out number of records, n,  for given size
# Then make sure for (n-1) records that the size is smaller
_test_file_size()
{
  size_arg=$1
  num_bytes=$2	# bytes version of size_arg
  $pmlogger -s $size_arg -c $tmp.config -l $tmp.log $tmp 
  if [ -f $tmp.0 ]
  then
    bigger_size=`ls -l $tmp.0 | $PCP_AWK_PROG ' {print $5} '`
  else
    bigger_size=-1
  fi
  _num_recs
  num_recs=`expr $num_recs - 1`
  if [ $num_recs -gt 0 ]
  then
    _clean_archive
    $pmlogger -s $num_recs -c $tmp.config -l $tmp.log $tmp 
    if [ -f $tmp.0 ]
    then
      smaller_size=`ls -l $tmp.0 | $PCP_AWK_PROG ' {print $5} '`
    else
      smaller_size=-1
    fi
  else
    smaller_size=-1
  fi
  [ $debug ] && echo "Range: $smaller_size .. $bigger_size"
  if [ $smaller_size -le $num_bytes -a $num_bytes -le $bigger_size ]
  then
    echo "Log size for $size_arg is correct"
  else
    echo "$num_bytes is not within range $smaller_size - $bigger_size"
  fi
  _clean_archive
}

_time_me ()
{
    # return time in seconds
    #
    # /usr/bin/time IS bloody important - dont port-sh it. EVER!
    /usr/bin/time $* 2>&1 >/dev/null | \
	if [ $PCP_PLATFORM = linux ]
	then
	    # 0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2752maxresident)k
	    tr ' ' "\n" | $PCP_AWK_PROG '/elapsed$/ { sub("elapsed", "", $1); 
			                               split ($1,tt,"[:.]");
			                               print (tt[1]*60)+tt[2];}'
	elif [ $PCP_PLATFORM = darwin ]
	then
	    #         0.00 real         0.00 user         0.00 sys
	    $PCP_AWK_PROG '{print $1}' | sed -e 's/\..*//'
	else 
	    # real        0.0
	    # user        0.0
	    # sys         0.0
	    $PCP_AWK_PROG '/^real/ {print $2}' | sed -e 's/\..*//'
	fi
}

# Note: size arg should be given in secs for comparison with /usr/bin/time
_test_time_size()
{
  size_arg=$1
  num_secs=$2	# secs version of size_arg
  time=`_time_me $pmlogger -s $size_arg -c $tmp.config -l $tmp.log $tmp`
  [ -z "$time" ] && time=-1
  echo "Expected time size of: $size_arg"
  [ $debug ] && echo "Actual time : $time"
  if _tolerance $num_secs $time $SECS_TOL
  then
    echo "Log time is within tolerance"
  else
    echo "Log time is outside tolerance - $time secs"
  fi
 _clean_archive
}



# Note: size arg should be given in secs for comparison with /usr/bin/time
_test_time_end()
{
  size_arg=$1
  num_secs=$2	# secs version of size_arg
  time=`_time_me $pmlogger -T $size_arg -c $tmp.config -l $tmp.log $tmp`
  [ -z "$time" ] && time=-1
  echo "Expected time size of: $size_arg"
  [ $debug ] && echo "Actual time : $time"
  if _tolerance $num_secs $time $SECS_TOL
  then
    echo "Log time is within tolerance"
  else
    echo "Log time is outside tolerance - $time secs"
  fi
 _clean_archive
}

# real QA test starts here


# Create a simple configuration file for testing
cat <<EOF >$tmp.config
# pmlogger(1) configuration file for doing QA tests
#
log mandatory on 100 msec {
    sample.control
    sample.milliseconds
    sample.load
    sample.colour
    sample.bin
    sample.bucket
    sample.drift
    sample.step
    sample.write_me
    sample.lights
    sample.magnitude
    sample.pdu
    sample.recv_pdu
    sample.xmit_pdu
    sample.noinst
}
EOF

# Test out -s
_test_file_size 4000bytes 4000
_test_file_size 4K 4096
_test_file_size 4194B 4194
_test_sample_size 2
_test_time_size 3secs 3

# Test out -T
_test_time_end 3secs 3

# success, all done
status=0
exit