diff options
author | rwatson <rwatson@FreeBSD.org> | 2006-03-26 15:49:35 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2006-03-26 15:49:35 +0000 |
commit | 73eedc13f0fba3fd6e8ae2358378cd0f6516ba79 (patch) | |
tree | e3cf3146c93b20924dac6fcab5a998b88f0b1d49 /tools | |
parent | aa0485c22be44d024eac93dcbe7efbb48dcc55b2 (diff) | |
download | FreeBSD-src-73eedc13f0fba3fd6e8ae2358378cd0f6516ba79.zip FreeBSD-src-73eedc13f0fba3fd6e8ae2358378cd0f6516ba79.tar.gz |
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.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/netipx/ipxsocket/ipxsocket.c | 65 |
1 files changed, 43 insertions, 22 deletions
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 <sys/types.h> @@ -39,34 +41,53 @@ #include <err.h> #include <unistd.h> +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); } |