2003-09-25 17:55:17 +00:00
|
|
|
#!/bin/sh
|
2003-10-05 22:02:49 +00:00
|
|
|
|
2020-04-22 19:44:45 -07:00
|
|
|
BACKENDS="EVPORT KQUEUE EPOLL DEVPOLL POLL SELECT WIN32 WEPOLL"
|
Implemented EV_CLOSED event for epoll backend (EPOLLRDHUP).
- Added new EV_CLOSED event - detects premature connection close
by clients without the necessity of reading all the pending
data. Does not depend on EV_READ and/or EV_WRITE.
- Added new EV_FEATURE_EARLY_CLOSED feature for epoll.
Must be supported for listening to EV_CLOSED event.
- Added new regression test: test-closed.c
- All regression tests passed (test/regress and test/test.sh)
- strace output of test-closed using EV_CLOSED:
socketpair(PF_LOCAL, SOCK_STREAM, 0, [6, 7]) = 0
sendto(6, "test string\0", 12, 0, NULL, 0) = 12
shutdown(6, SHUT_WR) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 7, {EPOLLRDHUP, {u32=7, u64=7}}) = 0
epoll_wait(3, {{EPOLLRDHUP, {u32=7, u64=7}}}, 32, 3000) = 1
epoll_ctl(3, EPOLL_CTL_MOD, 7, {EPOLLRDHUP, {u32=7, u64=7}}) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 4), ...})
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYM...
write(1, "closed_cb: detected connection close "..., 45) = 45
2014-01-17 23:20:42 -02:00
|
|
|
TESTS="test-eof test-closed test-weof test-time test-changelist test-fdleak"
|
2024-04-29 13:35:33 +08:00
|
|
|
KQUEUE_TESTS="test-kq-collision"
|
2010-05-26 13:31:41 -04:00
|
|
|
FAILED=no
|
2012-04-07 17:32:00 +02:00
|
|
|
TEST_OUTPUT_FILE=${TEST_OUTPUT_FILE:-/dev/null}
|
2012-06-28 13:18:28 -04:00
|
|
|
REGRESS_ARGS=${REGRESS_ARGS:-}
|
2009-12-29 17:59:55 -05:00
|
|
|
|
2011-02-01 01:15:48 -05:00
|
|
|
# /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"
|
2010-01-12 15:58:36 -05:00
|
|
|
then
|
2011-02-22 00:31:56 -05:00
|
|
|
ECHO_N="printf %s"
|
2010-01-12 15:58:36 -05:00
|
|
|
else
|
2011-02-01 01:15:48 -05:00
|
|
|
if test -x /bin/echo
|
|
|
|
then
|
|
|
|
ECHO_N="/bin/echo -n"
|
|
|
|
else
|
|
|
|
ECHO_N="echo -n"
|
|
|
|
fi
|
2010-01-12 15:58:36 -05:00
|
|
|
fi
|
|
|
|
|
2010-05-08 18:00:26 -04:00
|
|
|
if test "$TEST_OUTPUT_FILE" != "/dev/null"
|
|
|
|
then
|
|
|
|
touch "$TEST_OUTPUT_FILE" || exit 1
|
|
|
|
fi
|
2009-12-29 18:07:51 -05:00
|
|
|
|
|
|
|
TEST_DIR=.
|
2012-04-03 14:51:51 -04:00
|
|
|
TEST_SRC_DIR=.
|
2009-12-29 18:07:51 -05:00
|
|
|
|
2017-01-20 16:29:02 +03:00
|
|
|
T=`echo "$0" | sed -e 's/test.sh$//'`
|
2009-12-29 18:07:51 -05:00
|
|
|
if test -x "$T/test-init"
|
|
|
|
then
|
2009-12-29 18:11:52 -05:00
|
|
|
TEST_DIR="$T"
|
2012-11-19 09:07:13 -05:00
|
|
|
elif test -x "./test/test-init"
|
|
|
|
then
|
|
|
|
TEST_DIR="./test"
|
2009-12-29 18:07:51 -05:00
|
|
|
fi
|
2012-08-02 15:02:27 -04:00
|
|
|
if test -f "$T/check-dumpevents.py"
|
2012-04-03 14:51:51 -04:00
|
|
|
then
|
|
|
|
TEST_SRC_DIR="$T"
|
2012-11-19 09:07:13 -05:00
|
|
|
elif test -f "./test/check-dumpevents.py"
|
|
|
|
then
|
|
|
|
TEST_SRC_DIR="./test"
|
2012-04-03 14:51:51 -04:00
|
|
|
fi
|
2009-12-29 17:59:55 -05:00
|
|
|
|
2003-10-05 22:02:49 +00:00
|
|
|
setup () {
|
2012-04-07 17:32:00 +02:00
|
|
|
for i in $BACKENDS; do
|
|
|
|
eval "EVENT_NO$i=yes; export EVENT_NO$i"
|
|
|
|
done
|
2010-11-22 14:10:01 -05:00
|
|
|
unset EVENT_EPOLL_USE_CHANGELIST
|
2012-04-26 16:22:03 -04:00
|
|
|
unset EVENT_PRECISE_TIMER
|
2023-07-10 10:40:49 +02:00
|
|
|
unset EVENT_USE_SIGNALFD
|
2003-09-25 17:55:17 +00:00
|
|
|
}
|
|
|
|
|
2009-12-29 17:59:55 -05:00
|
|
|
announce () {
|
2010-11-22 14:10:01 -05:00
|
|
|
echo "$@"
|
|
|
|
echo "$@" >>"$TEST_OUTPUT_FILE"
|
2009-12-29 17:59:55 -05:00
|
|
|
}
|
|
|
|
|
2010-01-12 15:58:36 -05:00
|
|
|
announce_n () {
|
2011-02-01 01:15:48 -05:00
|
|
|
$ECHO_N "$@"
|
2010-11-22 14:10:01 -05:00
|
|
|
echo "$@" >>"$TEST_OUTPUT_FILE"
|
2010-01-12 15:58:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-29 18:07:51 -05:00
|
|
|
run_tests () {
|
2024-04-29 13:35:33 +08:00
|
|
|
backend="$1" && shift
|
|
|
|
ALL_TESTS="$TESTS"
|
|
|
|
|
2009-12-29 18:07:51 -05:00
|
|
|
if $TEST_DIR/test-init 2>>"$TEST_OUTPUT_FILE" ;
|
2003-09-25 17:55:17 +00:00
|
|
|
then
|
2024-04-29 13:35:33 +08:00
|
|
|
announce "Running $backend $*"
|
2005-09-02 05:34:01 +00:00
|
|
|
else
|
2024-04-29 13:35:33 +08:00
|
|
|
announce "Skipping test $backend $*"
|
2003-09-25 17:55:17 +00:00
|
|
|
return
|
2009-12-29 18:11:52 -05:00
|
|
|
fi
|
2024-04-29 13:35:33 +08:00
|
|
|
|
|
|
|
if [ "$backend" = "KQUEUE" ]; then
|
|
|
|
ALL_TESTS="$ALL_TESTS $KQUEUE_TESTS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in $ALL_TESTS; do
|
2012-04-07 17:32:00 +02:00
|
|
|
announce_n " $i: "
|
|
|
|
if $TEST_DIR/$i >>"$TEST_OUTPUT_FILE" ;
|
|
|
|
then
|
|
|
|
announce OKAY ;
|
|
|
|
else
|
|
|
|
announce FAILED ;
|
|
|
|
FAILED=yes
|
|
|
|
fi
|
|
|
|
done
|
2012-03-23 17:56:23 -04:00
|
|
|
announce_n " test-dumpevents: "
|
2017-09-14 17:39:20 -05:00
|
|
|
if python -c 'import sys; assert(sys.version_info >= (2, 4))' 2>/dev/null && test -f $TEST_SRC_DIR/check-dumpevents.py; then
|
|
|
|
if $TEST_DIR/test-dumpevents | $TEST_SRC_DIR/check-dumpevents.py >> "$TEST_OUTPUT_FILE" ;
|
2012-03-23 17:56:23 -04:00
|
|
|
then
|
|
|
|
announce OKAY ;
|
|
|
|
else
|
|
|
|
announce FAILED ;
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# no python
|
|
|
|
if $TEST_DIR/test-dumpevents >/dev/null; then
|
|
|
|
announce "OKAY (output not checked)" ;
|
|
|
|
else
|
|
|
|
announce "FAILED (output not checked)" ;
|
|
|
|
fi
|
|
|
|
fi
|
2015-09-02 11:51:00 +03:00
|
|
|
|
2011-02-13 02:05:04 -05:00
|
|
|
test -x $TEST_DIR/regress || return
|
2010-01-12 15:58:36 -05:00
|
|
|
announce_n " regress: "
|
2010-05-26 13:32:32 -04:00
|
|
|
if test "$TEST_OUTPUT_FILE" = "/dev/null" ;
|
|
|
|
then
|
2012-06-28 13:18:28 -04:00
|
|
|
$TEST_DIR/regress --quiet $REGRESS_ARGS
|
2010-05-26 13:32:32 -04:00
|
|
|
else
|
2012-06-28 13:18:28 -04:00
|
|
|
$TEST_DIR/regress $REGRESS_ARGS >>"$TEST_OUTPUT_FILE"
|
2010-05-26 13:32:32 -04:00
|
|
|
fi
|
|
|
|
if test "$?" = "0" ;
|
2009-12-29 18:11:52 -05:00
|
|
|
then
|
|
|
|
announce OKAY ;
|
|
|
|
else
|
|
|
|
announce FAILED ;
|
2010-05-26 13:31:41 -04:00
|
|
|
FAILED=yes
|
2009-12-29 18:11:52 -05:00
|
|
|
fi
|
2015-09-02 11:51:00 +03:00
|
|
|
|
|
|
|
announce_n " regress_debug: "
|
|
|
|
if test "$TEST_OUTPUT_FILE" = "/dev/null" ;
|
|
|
|
then
|
|
|
|
EVENT_DEBUG_MODE=1 $TEST_DIR/regress --quiet $REGRESS_ARGS
|
|
|
|
else
|
|
|
|
EVENT_DEBUG_MODE=1 $TEST_DIR/regress $REGRESS_ARGS >>"$TEST_OUTPUT_FILE"
|
|
|
|
fi
|
|
|
|
if test "$?" = "0" ;
|
|
|
|
then
|
|
|
|
announce OKAY ;
|
|
|
|
else
|
|
|
|
announce FAILED ;
|
|
|
|
FAILED=yes
|
|
|
|
fi
|
2003-09-25 17:55:17 +00:00
|
|
|
}
|
|
|
|
|
2011-07-05 14:41:46 -04:00
|
|
|
do_test() {
|
2024-04-29 13:35:33 +08:00
|
|
|
backend="$1" && shift
|
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
backend_conf="$2" && shift
|
|
|
|
else
|
|
|
|
backend_conf=""
|
|
|
|
fi
|
|
|
|
|
2011-07-05 14:41:46 -04:00
|
|
|
setup
|
2024-04-29 13:35:33 +08:00
|
|
|
unset EVENT_NO$backend
|
|
|
|
if test "$backend_conf" = "(changelist)" ; then
|
2011-07-05 14:41:46 -04:00
|
|
|
EVENT_EPOLL_USE_CHANGELIST=yes; export EVENT_EPOLL_USE_CHANGELIST
|
2024-04-29 13:35:33 +08:00
|
|
|
elif test "$backend_conf" = "(timerfd)" ; then
|
2012-04-26 16:22:03 -04:00
|
|
|
EVENT_PRECISE_TIMER=1; export EVENT_PRECISE_TIMER
|
2024-04-29 13:35:33 +08:00
|
|
|
elif test "$backend_conf" = "(signalfd)" ; then
|
2023-07-10 10:40:49 +02:00
|
|
|
EVENT_USE_SIGNALFD=1; export EVENT_USE_SIGNALFD
|
2024-04-29 13:35:33 +08:00
|
|
|
elif test "$backend_conf" = "(timerfd+changelist)" ; then
|
2012-04-26 16:22:03 -04:00
|
|
|
EVENT_EPOLL_USE_CHANGELIST=yes; export EVENT_EPOLL_USE_CHANGELIST
|
|
|
|
EVENT_PRECISE_TIMER=1; export EVENT_PRECISE_TIMER
|
2023-07-10 10:40:49 +02:00
|
|
|
fi
|
2012-04-26 16:22:03 -04:00
|
|
|
|
2024-04-29 13:35:33 +08:00
|
|
|
run_tests "$backend" "$backend_conf"
|
2011-07-05 14:41:46 -04:00
|
|
|
}
|
|
|
|
|
2017-01-20 16:29:02 +03:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<EOL
|
|
|
|
-b - specify backends
|
|
|
|
-t - run timerfd test
|
|
|
|
-c - run changelist test
|
|
|
|
-T - run timerfd+changelist test
|
2023-07-10 10:40:49 +02:00
|
|
|
-S - run signalfd test
|
2017-01-20 16:29:02 +03:00
|
|
|
EOL
|
|
|
|
}
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
backends=$BACKENDS
|
|
|
|
timerfd=0
|
|
|
|
changelist=0
|
|
|
|
timerfd_changelist=0
|
2023-07-10 10:40:49 +02:00
|
|
|
signalfd=0
|
2017-01-20 16:29:02 +03:00
|
|
|
|
2023-07-10 10:40:49 +02:00
|
|
|
while getopts "b:tcTS" c; do
|
2017-01-20 16:29:02 +03:00
|
|
|
case "$c" in
|
|
|
|
b) backends="$OPTARG";;
|
|
|
|
t) timerfd=1;;
|
|
|
|
c) changelist=1;;
|
|
|
|
T) timerfd_changelist=1;;
|
2023-07-10 10:40:49 +02:00
|
|
|
S) signalfd=1;;
|
2017-01-20 16:29:02 +03:00
|
|
|
?*) usage && exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
2003-09-25 17:55:17 +00:00
|
|
|
|
2024-04-29 13:35:33 +08:00
|
|
|
set -e
|
|
|
|
|
2017-01-20 16:29:02 +03:00
|
|
|
announce "Running tests:"
|
2010-05-26 13:31:41 -04:00
|
|
|
|
2017-01-20 16:29:02 +03:00
|
|
|
[ $timerfd -eq 0 ] || do_test EPOLL "(timerfd)"
|
|
|
|
[ $changelist -eq 0 ] || do_test EPOLL "(changelist)"
|
|
|
|
[ $timerfd_changelist -eq 0 ] || do_test EPOLL "(timerfd+changelist)"
|
|
|
|
for i in $backends; do
|
|
|
|
do_test $i
|
2023-07-10 10:40:49 +02:00
|
|
|
[ $signalfd -eq 0 ] || do_test $i "(signalfd)"
|
2017-01-20 16:29:02 +03:00
|
|
|
done
|
|
|
|
|
|
|
|
if test "$FAILED" = "yes"; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
main "$@"
|