diff --git a/TODO b/TODO index 60edc1b..d94db58 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ - keepalive performance against ab sucks - keepalive+TCP_NODELAY hangs! - send headers using sendfile syscall - fewer packets -- add test for timeout diff --git a/devel/run-tests b/devel/run-tests index a8b66a1..8742689 100755 --- a/devel/run-tests +++ b/devel/run-tests @@ -97,6 +97,15 @@ runtests() { kill $PID wait $PID + echo "===> run --timeout tests" + ./a.out $DIR --port $PORT --timeout 1 \ + >>test.out.stdout 2>>test.out.stderr & + PID=$! + kill -0 $PID || exit 1 + python test_timeout.py + kill $PID + wait $PID + if [[ -s test.out.stderr ]]; then echo "FAIL: stderr should have been empty." exit 1 diff --git a/devel/test_timeout.py b/devel/test_timeout.py new file mode 100755 index 0000000..ae32298 --- /dev/null +++ b/devel/test_timeout.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# This is run by the "run-tests" script. +import unittest +import signal +import socket + +class TestTimeout(unittest.TestCase): + def test_timeout(self): + port = 12346 + s = socket.socket() + s.connect(("0.0.0.0", port)) + # Assumes the server has --timeout 1 + signal.alarm(3) + # Expect to get EOF before the alarm fires. + ret = s.recv(1024) + signal.alarm(0) + self.assertEquals(ret, '') + +if __name__ == '__main__': + unittest.main() + +# vim:set ts=4 sw=4 et: