]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Allow ./make-new-test.sh to take the test name as $1
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 28 Sep 2016 10:57:51 +0000 (11:57 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 28 Sep 2016 10:57:51 +0000 (11:57 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
make-new-test.sh

index eb0e26bcaf714a3da9db40098fa7f6fe1a409126..39a199d54e031bec5598028837fab214f956e3d2 100755 (executable)
@@ -1,15 +1,23 @@
 #!/bin/sh -e
 
-[ $# -ne 0 ] && { echo "Interactive script to create new XTF tests"; exit 1; }
+fail () { echo "$1"; exit 1; }
+
+[ $# -gt 1 ] && fail "Interactive script to create new XTF tests\n  Usage: $0 [\$NAME]"
 
 cd $(dirname $(readlink -f $0))
 
 # Test name
-echo -n "Test name: "
-read NAME
+if [ $# -eq 1 ]
+then
+    NAME=$1
+    echo "Test name: $NAME"
+else
+    echo -n "Test name: "
+    read NAME
+fi
 
-[ -z "$NAME" ] && { echo "No name given"; exit 1; }
-[ -e tests/$NAME ] && { echo "Test $NAME already exists"; exit 1; }
+[ -z "$NAME" ] && fail "No name given"
+[ -e tests/$NAME ] && fail "Test $NAME already exists"
 mkdir -p tests/$NAME
 
 # Category