From 73eedc13f0fba3fd6e8ae2358378cd0f6516ba79 Mon Sep 17 00:00:00 2001 From: rwatson Date: Sun, 26 Mar 2006 15:49:35 +0000 Subject: Modify ipxsocket regression test to create and close sockets several times, with variable length sleeps between socket() and close(). This will help to ensure that IPX/SPX timers fire while the sockets are open, and hence have PCB's on the IPX pcb list, so that if timers are going to stumble over PCB types they don't expect, it will happen as part of this test. --- tools/regression/netipx/ipxsocket/ipxsocket.c | 65 ++++++++++++++++++--------- 1 file changed, 43 insertions(+), 22 deletions(-) (limited to 'tools/regression') diff --git a/tools/regression/netipx/ipxsocket/ipxsocket.c b/tools/regression/netipx/ipxsocket/ipxsocket.c index 2b9c4e0..afcd2dc 100644 --- a/tools/regression/netipx/ipxsocket/ipxsocket.c +++ b/tools/regression/netipx/ipxsocket/ipxsocket.c @@ -28,7 +28,9 @@ /* * Simple regression test to open and then immediately close various types of - * PF_IPX sockets. + * PF_IPX sockets. Run with various waits in order to make sure that the + * various IPX/SPX timers have a chance to walk the pcb lists and hit the + * sockets. */ #include @@ -39,34 +41,53 @@ #include #include +static int +maybe_sleep(int sec) +{ + + if (sec == 0) + return (0); + return (sleep(sec)); +} + int main(int argc, char *argv[]) { - int s; + int delay, s; - s = socket(PF_IPX, SOCK_DGRAM, 0); - if (s < 0) - warn("socket(PF_IPX, SOCK_DGRAM, 0)"); - else - close(s); + for (delay = 0; delay < 5; delay++) { + s = socket(PF_IPX, SOCK_DGRAM, 0); + if (s < 0) + warn("socket(PF_IPX, SOCK_DGRAM, 0)"); + else { + maybe_sleep(delay); + close(s); + } - s = socket(PF_IPX, SOCK_STREAM, 0); - if (s < 0) - warn("socket(PF_IPX, SOCK_STREAM, 0)"); - else - close(s); + s = socket(PF_IPX, SOCK_STREAM, 0); + if (s < 0) + warn("socket(PF_IPX, SOCK_STREAM, 0)"); + else { + maybe_sleep(delay); + close(s); + } - s = socket(PF_IPX, SOCK_SEQPACKET, 0); - if (s < 0) - warn("socket(PF_IPX, SOCK_SEQPACKET, 0)"); - else - close(s); + s = socket(PF_IPX, SOCK_SEQPACKET, 0); + if (s < 0) + warn("socket(PF_IPX, SOCK_SEQPACKET, 0)"); + else { + maybe_sleep(delay); + close(s); + } - s = socket(PF_IPX, SOCK_RAW, 0); - if (s < 0) - warn("socket(PF_IPX, SOCK_RAW, 0)"); - else - close(s); + s = socket(PF_IPX, SOCK_RAW, 0); + if (s < 0) + warn("socket(PF_IPX, SOCK_RAW, 0)"); + else { + maybe_sleep(delay); + close(s); + } + } return (0); } -- cgit v1.1