Module Name: src
Committed By: blymn
Date: Mon Jan 21 21:21:13 UTC 2019
Modified Files:
src/tests/lib/libcurses: debug_test
Log Message:
Fix script to use getopts instead of a hand rolled argument parser,
add option to set curses debug output file and other general fixes.
Thanks to [email protected] for comments and help with this.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/debug_test
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/libcurses/debug_test
diff -u src/tests/lib/libcurses/debug_test:1.1 src/tests/lib/libcurses/debug_test:1.2
--- src/tests/lib/libcurses/debug_test:1.1 Fri Nov 30 04:57:02 2018
+++ src/tests/lib/libcurses/debug_test Mon Jan 21 21:21:13 2019
@@ -1,13 +1,5 @@
#!/bin/sh
#
-# Set up the environment to run the test frame. Option flags:
-#
-# -c : Set up curses tracing, assumes the curses lib has been built with
-# debug enabled. Default trace mask traces input, can be overridden
-# by setting the trace mask in the environment before calling the
-# script.
-# -s : Specify the slave command. Defaults to "../slave/slave"
-# -v : Enable verbose output
#
BASEDIR="/usr/tests/lib/libcurses"
CHECK_PATH="${BASEDIR}/check_files/"
@@ -15,15 +7,31 @@ export CHECK_PATH
INCLUDE_PATH="${BASEDIR}/tests/"
export INCLUDE_PATH
#
+CURSES_TRACE_FILE="/tmp/ctrace"
SLAVE="${BASEDIR}/slave"
+
+usage() {
+ echo "Set up the environment to run the test frame. Option flags:"
+ echo
+ echo " -c : Set up curses tracing, assumes the curses lib has been built with"
+ echo " debug enabled. Default trace mask traces input, can be overridden"
+ echo " by setting the trace mask in the environment before calling the"
+ echo " The trace file output goes to /tmp/ctrace"
+ echo " script."
+ echo " -f : Specify the file name for curses tracing the default is"
+ echo " ${CURSES_TRACE_FILE}"
+ echo " -s : Specify the slave command. Defaults to \"../slave/slave\""
+ echo " -v : Enable verbose output"
+ echo
+}
+
#
ARGS=""
#
-while /usr/bin/true
+while getopts cf:s:v opt
do
- case $1 in
- -c)
- CURSES_TRACE_FILE="/tmp/ctrace"
+ case "${opt}" in
+ c)
if [ "X$CURSES_TRACE_MASK" = "X" ]; then
CURSES_TRACE_MASK=0x00000082
fi
@@ -31,21 +39,35 @@ do
export CURSES_TRACE_MASK
;;
- -s)
- SLAVE=$2
- shift
+ f)
+ CURSES_TRACE_FILE=${OPTARG}
+ ;;
+
+ s)
+ SLAVE=${OPTARG}
;;
- -v)
+ v)
ARGS="-v"
;;
- *)
- break
+ \?)
+ usage
+ exit 1
;;
esac
-
- shift
done
#
-exec ${BASEDIR}/director ${ARGS} -s ${SLAVE} ${INCLUDE_PATH}/$@
+shift $((OPTIND - 1))
+#
+if [ -z "${1}" ]
+then
+ echo
+ echo "A test name needs to be specified."
+ echo
+ usage
+ echo
+ exit 1
+fi
+#
+exec ${BASEDIR}/director ${ARGS} -s ${SLAVE} "${INCLUDE_PATH}/$1"