sync and sleep for bulkstat
[xfstests-dev.git] / new
1 #! /bin/sh
2 #
3 #-----------------------------------------------------------------------
4 #  Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
5 #-----------------------------------------------------------------------
6 #
7 # Make a new test
8 #
9
10 # generic initialization
11 iam=new
12 . ./common.rc
13
14 trap "rm -f /tmp/$$.; exit" 0 1 2 3 15
15
16 _cleanup()
17 {
18     :
19 }
20
21 if [ ! -f group ]
22 then
23     echo "Creating the group index ..."
24     cat <<'End-of-File' >group
25 # QA groups control
26 #
27 # define groups and default group owners
28 # do not start group name with a digit
29 #
30
31 # catch-all
32 #
33 other           some-user-login
34
35 # test-group association ... one line per test
36 #
37 End-of-File
38 fi
39
40 if [ ! -w group ]
41 then
42     chmod u+w group
43     echo "Warning: making the index file \"group\" writeable"
44 fi
45
46 if make
47 then
48     :
49 else
50     echo "Warning: make failed -- some tests may be missing"
51 fi
52
53 last=`grep '^[0-9][0-9]* ' group | sort | tail -1 | sed -e 's/[         ].*//'`
54 # get rid of leading 0s as can be interpreted as octal
55 last=`echo $last | sed 's/^0*//'`
56 id=`$AWK_PROG </dev/null 'BEGIN{printf "%03d\n",'$last'+1}'`
57 echo "Next test is $id"
58
59 if [ -f $id ]
60 then
61     echo "Error: test $id already exists!"
62     _cleanup
63     exit 1
64 fi
65
66 echo -n "Creating skeletal script for you to edit ..."
67
68 cat <<End-of-File >$id
69 #! /bin/sh
70 # FS QA Test No. $id
71 #
72 # what am I here for?
73 #
74 #-----------------------------------------------------------------------
75 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
76 #-----------------------------------------------------------------------
77 #
78 # creator
79 owner=$USER@`_get_fqdn`
80
81 seq=\`basename \$0\`
82 echo "QA output created by \$seq"
83
84 here=\`pwd\`
85 tmp=/tmp/\$\$
86 status=1        # failure is the default!
87 trap "_cleanup; exit \\\$status" 0 1 2 3 15
88
89 _cleanup()
90 {
91     cd /
92     rm -f \$tmp.*
93 }
94
95 # get standard environment, filters and checks
96 . ./common.rc
97 . ./common.filter
98
99 # real QA test starts here
100
101 # Modify as appropriate.
102 _supported_fs xfs udf nfs
103 _supported_os IRIX Linux
104
105 # if error
106 exit
107
108 # optional stuff if your test has verbose output to help resolve problems
109 #echo
110 #echo "If failure, check \$seq.full (this) and \$seq.full.ok (reference)"
111
112 # success, all done
113 status=0
114 exit
115 End-of-File
116
117 sleep 2         # latency to read messages to this point
118 echo ""
119
120 chmod 755 $id
121 ${EDITOR-vi} $id
122
123 if [ $# -eq 0 ]
124 then
125     while true
126     do
127         echo -n "Add to group(s) [other] (? for list): "
128         read ans
129         [ -z "$ans" ] && ans=other
130         if [ "X$ans" = "X?" ]
131         then
132             $AWK_PROG <group '
133 BEGIN           { text = "# ???" }
134 /^[a-zA-z]/     { printf "%-16.16s %s\n",$1,text; text = "# ???"; next }
135 NF < 2          { next }
136                 { text = $0 }' \
137             | sort
138         else
139             break
140         fi
141     done
142 else
143     # expert mode, groups are on the command line
144     #
145     for g in $*
146     do
147         if grep "^$g[   ]" group >/dev/null
148         then
149             :
150         else
151             echo "Warning: group \"$g\" not defined in ./group"
152         fi
153     done
154     ans="$*"
155 fi
156
157 echo -n "Adding $id to group index ..."
158 echo "$id $ans" >>group
159 echo " done."
160
161 exit 0