3 # Make a new PCP QA test
5 # Copyright (c) 1997-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # Usage: new [base-seq-no group ...]
9 # base-seq-no defaults to some random place in the range $min-$max
12 # generic initialization
19 trap "rm -f $tmp.*; exit" 0 1 2 3 15
26 if [ "$USER" = "pcpqa" ]
28 if [ ! -z "$REMOTEUSER" -a "$REMOTEUSER" != UNKNOWN
]
32 echo "Error: user \"pcpqa\" cannot create tests ... who are you?"
33 $PCP_ECHO_PROG $PCP_ECHO_N "Enter login: ""$PCP_ECHO_C"
37 grep "^$USER:" /etc
/passwd
>/dev
/null || USER
=''
41 echo "If you're not going to be serious, then I won't play"
49 echo "Creating the group index ..."
50 cat <<'End-of-File' >group
55 ## Do not start group name with a digit, expect alphabetic
57 ## Last comment starting with a single # before a group name is the
58 ## one-line summary that "new" will report when asked to list groups
60 ## Comments starting with a ## (or #<anything_other_than_whitesspace>
61 ## are ignored for the purposes of one-line summaries.
66 ## test-group association ... one line per test
67 ## add :retired or :reserved as a tag immediately after the test number
68 ## to keep the test number allocated, but prevent the test from being run
70 ## ... use sort -n from here on down to tidy up this mess
77 echo "Error: cannot write index file \"group\""
82 if [ -f GNUmakefile.
install ]
84 # running QA in the tree
85 ${MAKE:-make} -f GNUmakefile.
install >$tmp.out
2>&1
87 ${MAKE:-make} >$tmp.out
2>&1
92 echo "Warning: ${MAKE:-make} failed -- some tests may be missing"
100 # random in the range $min-$max based on user name convered from alpha
101 # to numeric, prefixed by current clock seconds
105 | tr 'a-z' '0-90-90-9' \
106 | awk '{ srand('"$sec"'+$1); print int('$min'+rand()*('$max'-'$min')) }'`
108 # pick first hole after $try, provided the test does not already exist
113 id
=`sed -n -e 's/:\(retired\|reserved\) / /' -e '/^[0-9]/s/[ ].*//p' <group \
114 | LC_COLLATE=POSIX sort -n \
116 BEGIN { last = '$try' }
117 $1 > '$try' { if ($1 != last+1) {
122 END { printf "%03d\n",last+1 }'`
123 [ ! -f $id ] && break
124 # already exists, move on ...
127 if [ "$try" -gt "$max" ]
129 wrap
=`expr $wrap + 1`
132 echo "Sorry, no unassigned tests in the range $min ... $max. Time to increase \$max"
139 echo "Next test is $id"
143 echo "Error: test $id already exists!"
148 $PCP_ECHO_PROG $PCP_ECHO_N "Creating skeletal script for you to edit ...""$PCP_ECHO_C"
150 cat <<End-of-File >$id
152 # PCP QA Test No. $id
153 # [what am I here for?]
155 # Copyright (c) `date +%Y` [who are you?]. All Rights Reserved.
159 echo "QA output created by \$seq"
161 # get standard environment, filters and checks
166 # test for-some-thing || _notrun No support for some-thing
168 status=1 # failure is the default!
169 \$sudo rm -rf \$tmp \$tmp.* \$seq.full
170 trap "cd \$here; \$sudo rm -rf \$tmp \$tmp.*; exit \\\$status" 0 1 2 3 15
172 # real QA test starts here
177 # optional stuff if your test has verbose output to help resolve problems
179 #echo "If failure, check \$seq.full"
187 sleep 2 # latency to read messages to this point
197 $PCP_ECHO_PROG $PCP_ECHO_N "Add to group(s) [other] (? for list): ""$PCP_ECHO_C"
199 [ -z "$ans" ] && ans
=other
200 if [ "X$ans" = "X?" ]
202 $PCP_AWK_PROG <group
'
203 BEGIN { text = "# ???" }
204 /^[a-zA-Z]/ { printf "%-16.16s %s\n",$1,text; text = "# ???"; next }
206 $1 == "#" { text = $0 }' \
207 | LC_COLLATE
=POSIX
sort
212 $PCP_ECHO_PROG $PCP_ECHO_N "Runs on QA machine alone? (local pmcd, local pmlogger, no ssh, ...) [y] ""$PCP_ECHO_C"
214 if [ -z "$_ans" -o "$_ans" = "y" ]
221 # expert mode, groups are on the command line
225 if grep "^$g[ ]" group
>/dev
/null
229 echo "Warning: group \"$g\" not defined in ./group"
235 $PCP_ECHO_PROG $PCP_ECHO_N "Adding $id to group index ...""$PCP_ECHO_C"
236 echo "$id $ans" >>group
239 # sort the tests numerically
241 $PCP_AWK_PROG <group
'
242 BEGIN { state = "head" }
243 state == "head" && /^[0-9]/ { state = "list" }
244 { print >"'$tmp'." state }'
245 sort -n $tmp.list
>>$tmp.
head