xref: /netbsd-src/tests/lib/libcurses/debug_test (revision 53d1339bf7f9c7367b35a9e1ebe693f9b047a47b)
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/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.
34rm -rf /tmp/*
35
36#
37ARGS="-T ${BASEDIR} -I ${INCLUDE_PATH} -C ${CHECK_PATH}"
38#
39while getopts cf:L:s:vg opt
40do
41    case "${opt}" in
42	c)
43	    if [ "X$CURSES_TRACE_MASK" = "X" ]; then
44		CURSES_TRACE_MASK=0x00000082
45	    fi
46	    export CURSES_TRACE_FILE
47	    export CURSES_TRACE_MASK
48	    ;;
49
50	F)
51	    CURSES_TRACE_FILE=${OPTARG}
52	    ;;
53
54	L)
55	    LD_LIBRARY_PATH=${OPTARG}:${LD_LIBRARY_PATH}
56	    ;;
57
58	s)
59	    SLAVE=${OPTARG}
60	    ;;
61
62	v)
63	    ARGS="-v ${ARGS}"
64	    ;;
65
66	g)
67	    ARGS="-g ${ARGS}"
68		;;
69
70	f)
71	ARGS="-f ${ARGS}"
72	;;
73
74	\?)
75	    usage
76	    exit 1
77	    ;;
78    esac
79done
80#
81shift $((OPTIND - 1))
82#
83if [ -z "${1}" ]
84then
85	echo
86	echo "A test name needs to be specified."
87	echo
88	usage
89	echo
90	exit 1
91fi
92#
93exec ${BASEDIR}/director/director ${ARGS} -s ${SLAVE} "${INCLUDE_PATH}/$1"
94