libevent/test/test.sh

164 lines
2.6 KiB
Bash
Raw Normal View History

2003-09-25 17:55:17 +00:00
#!/bin/sh
2003-10-05 22:02:49 +00:00
FAILED=no
if test "x$TEST_OUTPUT_FILE" = "x"
then
2009-12-29 18:11:52 -05:00
TEST_OUTPUT_FILE=/dev/null
fi
# /bin/echo is a little more likely to support -n than sh's builtin echo,
# printf is even more likely
2011-02-22 00:31:56 -05:00
if test "`printf %s hello 2>&1`" = "hello"
then
2011-02-22 00:31:56 -05:00
ECHO_N="printf %s"
else
if test -x /bin/echo
then
ECHO_N="/bin/echo -n"
else
ECHO_N="echo -n"
fi
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
2009-12-29 18:11:52 -05:00
TEST_DIR="$T"
fi
2003-10-05 22:02:49 +00:00
setup () {
2009-12-29 18:11:52 -05:00
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
unset EVENT_EPOLL_USE_CHANGELIST
2009-12-29 18:11:52 -05:00
EVENT_NOEVPORT=yes; export EVENT_NOEVPORT
EVENT_NOWIN32=yes; export EVENT_NOWIN32
2003-09-25 17:55:17 +00:00
}
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" ;
2003-09-25 17:55:17 +00:00
then
2009-12-29 18:11:52 -05:00
true
else
announce Skipping test
2003-09-25 17:55:17 +00:00
return
2009-12-29 18:11:52 -05:00
fi
2003-09-25 17:55:17 +00:00
announce_n " test-eof: "
2009-12-29 18:11:52 -05:00
if $TEST_DIR/test-eof >>"$TEST_OUTPUT_FILE" ;
then
announce OKAY ;
else
announce FAILED ;
FAILED=yes
2009-12-29 18:11:52 -05:00
fi
announce_n " test-weof: "
2009-12-29 18:11:52 -05:00
if $TEST_DIR/test-weof >>"$TEST_OUTPUT_FILE" ;
then
announce OKAY ;
else
announce FAILED ;
FAILED=yes
2009-12-29 18:11:52 -05:00
fi
announce_n " test-time: "
2009-12-29 18:11:52 -05:00
if $TEST_DIR/test-time >>"$TEST_OUTPUT_FILE" ;
then
announce OKAY ;
else
announce FAILED ;
FAILED=yes
2009-12-29 18:11:52 -05:00
fi
announce_n " test-changelist: "
if $TEST_DIR/test-changelist >>"$TEST_OUTPUT_FILE" ;
then
announce OKAY ;
else
announce FAILED ;
FAILED=yes
fi
test -x $TEST_DIR/regress || return
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" ;
2009-12-29 18:11:52 -05:00
then
announce OKAY ;
else
announce FAILED ;
FAILED=yes
2009-12-29 18:11:52 -05:00
fi
2003-09-25 17:55:17 +00:00
}
2009-12-29 18:11:52 -05:00
announce "Running tests:"
2003-09-25 17:55:17 +00:00
# Need to do this by hand?
setup
unset EVENT_NOEVPORT
announce "EVPORT"
run_tests
2003-09-25 17:55:17 +00:00
2004-07-30 04:57:21 +00:00
setup
unset EVENT_NOKQUEUE
announce "KQUEUE"
run_tests
2004-07-30 04:57:21 +00:00
2003-09-25 17:55:17 +00:00
setup
unset EVENT_NOEPOLL
announce "EPOLL"
run_tests
2003-09-25 17:55:17 +00:00
setup
unset EVENT_NOEPOLL
EVENT_EPOLL_USE_CHANGELIST=yes; export EVENT_EPOLL_USE_CHANGELIST
announce "EPOLL (changelist)"
run_tests
2003-09-25 17:55:17 +00:00
setup
unset EVENT_NODEVPOLL
announce "DEVPOLL"
run_tests
2003-09-25 17:55:17 +00:00
setup
unset EVENT_NOPOLL
announce "POLL"
run_tests
setup
unset EVENT_NOSELECT
announce "SELECT"
run_tests
setup
unset EVENT_NOWIN32
announce "WIN32"
run_tests
if test "$FAILED" = "yes"; then
exit 1
fi