2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
8 # generic initialization
13 trap "rm -f $tmpfile; exit" 0 1 2 3 15
20 SRC_GROUPS=`find tests -not -path tests -type d -printf "%f "`
23 echo "Usage $0 test_dir|test_dir_and_name"
24 echo "Available dirs are: $SRC_GROUPS"
30 if echo "$1" | grep -q '/'; then
31 if [ -e "tests/$1" ]; then
32 echo "$1: test already exists."
35 tdir="tests/$(echo "$1" | cut -d '/' -f 1)"
36 id="$(echo "$1" | cut -d '/' -f 2)"
39 id="$(basename "$(./tools/nextid "$1")")"
45 [ -d "$tdir/" ] || usage
47 export AWK_PROG="$(type -P awk)"
48 [ "$AWK_PROG" = "" ] && { echo "awk not found"; exit; }
50 echo "Next test id is $id"
53 read -p "Append a name to the ID? Test name will be $id-\$name. y,[n]: " -r
54 if [[ $REPLY = [Yy] ]]; then
55 # get the new name from user
57 while [ "$name" = "" ]; do
58 read -p "Enter the name: "
59 if [ "$REPLY" = "" ]; then
60 echo "For canceling, use ctrl+c."
61 elif echo "$id-$REPLY" | grep -q "^$VALID_TEST_NAME$"; then
62 if [ -e "$tdir/$id-$REPLY" ]; then
63 echo "File '$id-$REPLY' already exists, use another one."
69 echo "A name can contain only alphanumeric symbols and dash!"
77 echo "Creating test file '$id'"
81 echo "Error: test $id already exists!"
86 # Extract group names from the documentation.
88 awk '/^[[:lower:][:digit:]_]/ {
89 if ($1 != "" && $1 != "Group" && $2 != "Name:" && $1 != "all")
91 }' doc/group-names.txt
94 # Make sure that the new test's groups fit the correct format and are listed
95 # in the group documentation file.
98 local inval="$(echo "${g}" | tr -d '[:lower:][:space:][:digit:]_')"
99 if [ -n "${inval}" ]; then
100 echo "Invalid characters in group(s): ${inval}"
101 echo "Only lower cases, digits and underscore are allowed in groups, separated by space"
103 elif [ "${g}" = "other" ]; then
104 echo "Do not add more tests to group \"other\""
106 elif ! group_names | grep -q -w "${g}"; then
107 echo "Warning: group \"${g}\" not defined in documentation"
115 if [ $# -eq 0 ]; then
117 prompt="Add to group(s) [auto] (separate by space, ? for list): "
119 read -p "${prompt}" -a new_groups || exit 1
120 case "${#new_groups[@]}" in
125 if [ "${new_groups[0]}" = "?" ]; then
126 echo $(group_names | grep -v -w 'other')
131 check_groups "${new_groups[@]}" && break
134 # expert mode, groups are on the command line
136 check_groups "${new_groups[@]}" || exit 1
139 echo -n "Creating skeletal script for you to edit ..."
143 cat <<End-of-File >$tdir/$id
145 # SPDX-License-Identifier: GPL-2.0
146 # Copyright (c) $year YOUR NAME HERE. All Rights Reserved.
150 # what am I here for?
153 _begin_fstest ${new_groups[@]}
155 # Override the default cleanup function.
162 # Import common functions.
165 # real QA test starts here
167 # Modify as appropriate.
168 _supported_fs generic
174 # optional stuff if your test has verbose output to help resolve problems
176 #echo "If failure, check \$seqres.full (this) and \$seqres.full.ok (reference)"
183 sleep 2 # latency to read messages to this point
187 ${EDITOR-vi} $tdir/$id
189 # Create default .out file
190 cat <<End-of-File >$tdir/$id.out
191 QA output created by $id