mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Add test for --timeout.
This commit is contained in:
parent
f0a8dc6c6c
commit
ba63a6d60f
1
TODO
1
TODO
@ -1,4 +1,3 @@
|
|||||||
- keepalive performance against ab sucks
|
- keepalive performance against ab sucks
|
||||||
- keepalive+TCP_NODELAY hangs!
|
- keepalive+TCP_NODELAY hangs!
|
||||||
- send headers using sendfile syscall - fewer packets
|
- send headers using sendfile syscall - fewer packets
|
||||||
- add test for timeout
|
|
||||||
|
@ -97,6 +97,15 @@ runtests() {
|
|||||||
kill $PID
|
kill $PID
|
||||||
wait $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
|
if [[ -s test.out.stderr ]]; then
|
||||||
echo "FAIL: stderr should have been empty."
|
echo "FAIL: stderr should have been empty."
|
||||||
exit 1
|
exit 1
|
||||||
|
22
devel/test_timeout.py
Executable file
22
devel/test_timeout.py
Executable file
@ -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:
|
Loading…
Reference in New Issue
Block a user