xref: /netbsd-src/tests/lib/libcurses/debug_test (revision 53b02e147d4ed531c0d2a5ca9b3e8026ba3e99b5)
1#!/bin/sh
2#
3#
4BASEDIR="/usr/tests/lib/libcurses"
5CHECK_PATH="${BASEDIR}/check_files/"
6export CHECK_PATH
7INCLUDE_PATH="${BASEDIR}/tests/"
8export INCLUDE_PATH
9#
10CURSES_TRACE_FILE="/tmp/ctrace"
11SLAVE="${BASEDIR}/slave"
12
13usage() {
14	echo "Set up the environment to run the test frame.  Option flags:"
15	echo
16	echo "    -c : Set up curses tracing, assumes the curses lib has been built with"
17	echo "         debug enabled.  Default trace mask traces input, can be overridden"
18	echo "         by setting the trace mask in the environment before calling the"
19	echo "         The trace file output goes to /tmp/ctrace"
20	echo "         script."
21	echo "    -F : Specify the file name for curses tracing the default is"
22	echo "         ${CURSES_TRACE_FILE}"
23	echo "	  -L : Add the argument as a prefix to LD_LIBRARY_PATH to"
24	echo "	       use an alternate libcurses version"
25	echo "    -s : Specify the slave command.  Defaults to \"../slave/slave\""
26	echo "    -v : Enable verbose output"
27	echo "    -g : Enable check file generation if the file does not exists"
28	echo "    -f : Forces check file generation if -g flag is set"
29	echo
30}
31
32# This is needed for getwin/putwin test case and /tmp can be used for any file
33# related tests.
34#rm -rf /tmp/*
35
36#
37#ARGS="-T ${BASEDIR} -I ${INCLUDE_PATH} -C ${CHECK_PATH}"
38ARGS="-T ${BASEDIR} -C ${CHECK_PATH}"
39#
40while getopts cf:L:s:vg opt
41do
42    case "${opt}" in
43	c)
44	    if [ "X$CURSES_TRACE_MASK" = "X" ]; then
45		CURSES_TRACE_MASK=0x00000082
46	    fi
47	    export CURSES_TRACE_FILE
48	    export CURSES_TRACE_MASK
49	    ;;
50
51	F)
52	    CURSES_TRACE_FILE=${OPTARG}
53	    ;;
54
55	L)
56	    LD_LIBRARY_PATH=${OPTARG}:${LD_LIBRARY_PATH}
57	    ;;
58
59	s)
60	    SLAVE=${OPTARG}
61	    ;;
62
63	v)
64	    ARGS="-v ${ARGS}"
65	    ;;
66
67	g)
68	    ARGS="-g ${ARGS}"
69		;;
70
71	f)
72	ARGS="-f ${ARGS}"
73	;;
74
75	\?)
76	    usage
77	    exit 1
78	    ;;
79    esac
80done
81#
82shift $((OPTIND - 1))
83#
84if [ -z "${1}" ]
85then
86	echo
87	echo "A test name needs to be specified."
88	echo
89	usage
90	echo
91	exit 1
92fi
93#
94exec ${BASEDIR}/director ${ARGS} -s ${SLAVE} "${INCLUDE_PATH}/$1"
95