mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
3689bd2d49
The default behavior of test.sh was to suppress all output from test/regress, and say nothing but OKAY or FAILED. This wasn't so good for getting bugs reported, since lots of people didn't know to set TEST_OUTPUT_FILE, or re-run ./test/regress on its own. Now, when you don't specify an output file for test.sh, it runs regress with the --quiet option. This option makes the unit tests only print output on failure, which is what we probably wanted.
142 lines
2.1 KiB
Bash
Executable File
142 lines
2.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
FAILED=no
|
|
|
|
if test "x$TEST_OUTPUT_FILE" = "x"
|
|
then
|
|
TEST_OUTPUT_FILE=/dev/null
|
|
fi
|
|
|
|
# /bin/echo is a little more likely to support -n than sh's builtin echo.
|
|
if test -x /bin/echo
|
|
then
|
|
ECHO=/bin/echo
|
|
else
|
|
ECHO=echo
|
|
fi
|
|
|
|
if test "$TEST_OUTPUT_FILE" != "/dev/null"
|
|
then
|
|
touch "$TEST_OUTPUT_FILE" || exit 1
|
|
fi
|
|
|
|
TEST_DIR=.
|
|
|
|
T=`echo "$0" | sed -e 's/test.sh$//'`
|
|
if test -x "$T/test-init"
|
|
then
|
|
TEST_DIR="$T"
|
|
fi
|
|
|
|
setup () {
|
|
EVENT_NOKQUEUE=yes; export EVENT_NOKQUEUE
|
|
EVENT_NODEVPOLL=yes; export EVENT_NODEVPOLL
|
|
EVENT_NOPOLL=yes; export EVENT_NOPOLL
|
|
EVENT_NOSELECT=yes; export EVENT_NOSELECT
|
|
EVENT_NOEPOLL=yes; export EVENT_NOEPOLL
|
|
EVENT_NOEVPORT=yes; export EVENT_NOEVPORT
|
|
EVENT_NOWIN32=yes; export EVENT_NOWIN32
|
|
}
|
|
|
|
announce () {
|
|
echo $@
|
|
echo $@ >>"$TEST_OUTPUT_FILE"
|
|
}
|
|
|
|
announce_n () {
|
|
$ECHO -n $@
|
|
echo $@ >>"$TEST_OUTPUT_FILE"
|
|
}
|
|
|
|
|
|
run_tests () {
|
|
if $TEST_DIR/test-init 2>>"$TEST_OUTPUT_FILE" ;
|
|
then
|
|
true
|
|
else
|
|
announce Skipping test
|
|
return
|
|
fi
|
|
|
|
announce_n " test-eof: "
|
|
if $TEST_DIR/test-eof >>"$TEST_OUTPUT_FILE" ;
|
|
then
|
|
announce OKAY ;
|
|
else
|
|
announce FAILED ;
|
|
FAILED=yes
|
|
fi
|
|
announce_n " test-weof: "
|
|
if $TEST_DIR/test-weof >>"$TEST_OUTPUT_FILE" ;
|
|
then
|
|
announce OKAY ;
|
|
else
|
|
announce FAILED ;
|
|
FAILED=yes
|
|
fi
|
|
announce_n " test-time: "
|
|
if $TEST_DIR/test-time >>"$TEST_OUTPUT_FILE" ;
|
|
then
|
|
announce OKAY ;
|
|
else
|
|
announce FAILED ;
|
|
FAILED=yes
|
|
fi
|
|
announce_n " regress: "
|
|
if test "$TEST_OUTPUT_FILE" = "/dev/null" ;
|
|
then
|
|
$TEST_DIR/regress --quiet
|
|
else
|
|
$TEST_DIR/regress >>"$TEST_OUTPUT_FILE"
|
|
fi
|
|
if test "$?" = "0" ;
|
|
then
|
|
announce OKAY ;
|
|
else
|
|
announce FAILED ;
|
|
FAILED=yes
|
|
fi
|
|
}
|
|
|
|
announce "Running tests:"
|
|
|
|
# Need to do this by hand?
|
|
setup
|
|
unset EVENT_NOKQUEUE
|
|
announce "KQUEUE"
|
|
run_tests
|
|
|
|
setup
|
|
unset EVENT_NODEVPOLL
|
|
announce "DEVPOLL"
|
|
run_tests
|
|
|
|
setup
|
|
unset EVENT_NOPOLL
|
|
announce "POLL"
|
|
run_tests
|
|
|
|
setup
|
|
unset EVENT_NOSELECT
|
|
announce "SELECT"
|
|
run_tests
|
|
|
|
setup
|
|
unset EVENT_NOEPOLL
|
|
announce "EPOLL"
|
|
run_tests
|
|
|
|
setup
|
|
unset EVENT_NOEVPORT
|
|
announce "EVPORT"
|
|
run_tests
|
|
|
|
setup
|
|
unset EVENT_NOWIN32
|
|
announce "WIN32"
|
|
run_tests
|
|
|
|
if test "$FAILED" = "yes"; then
|
|
exit 1
|
|
fi
|