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 kre@netbsd.org for comments and help with this.
This commit is contained in:
blymn 2019-01-21 21:21:13 +00:00
parent 0a4f449bbb
commit 3e0ce67bf9
1 changed files with 43 additions and 21 deletions

View File

@ -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}
;;
-v)
s)
SLAVE=${OPTARG}
;;
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"