1/*-
2 * Copyright (c) 2006 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 9 unchanged lines hidden (view full) ---
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/tools/regression/netipx/ipxsocket/ipxsocket.c 157146 2006-03-26 15:49:35Z rwatson $
27 */
28
29/*
30 * Simple regression test to open and then immediately close various types of
31 * PF_IPX sockets. Run with various waits in order to make sure that the
32 * various IPX/SPX timers have a chance to walk the pcb lists and hit the
33 * sockets.
34 */
35
36#include <sys/types.h>
37#include <sys/socket.h>
38
39#include <netipx/ipx.h>
40
41#include <err.h>
42#include <unistd.h>
43
44static int
45maybe_sleep(int sec)
46{
47
48 if (sec == 0)
49 return (0);
50 return (sleep(sec));
51}
52
53int
54main(int argc, char *argv[])
55{
56 int delay, s;
57
58 for (delay = 0; delay < 5; delay++) {
59 s = socket(PF_IPX, SOCK_DGRAM, 0);
60 if (s < 0)
61 warn("socket(PF_IPX, SOCK_DGRAM, 0)");
62 else {
63 maybe_sleep(delay);
64 close(s);
65 }
66
67 s = socket(PF_IPX, SOCK_STREAM, 0);
68 if (s < 0)
69 warn("socket(PF_IPX, SOCK_STREAM, 0)");
70 else {
71 maybe_sleep(delay);
72 close(s);
73 }
74
75 s = socket(PF_IPX, SOCK_SEQPACKET, 0);
76 if (s < 0)
77 warn("socket(PF_IPX, SOCK_SEQPACKET, 0)");
78 else {
79 maybe_sleep(delay);
80 close(s);
81 }
82
83 s = socket(PF_IPX, SOCK_RAW, 0);
84 if (s < 0)
85 warn("socket(PF_IPX, SOCK_RAW, 0)");
86 else {
87 maybe_sleep(delay);
88 close(s);
89 }
90 }
91
92 return (0);
93}
2 * Copyright (c) 2006 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 9 unchanged lines hidden (view full) ---
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/tools/regression/netipx/ipxsocket/ipxsocket.c 157146 2006-03-26 15:49:35Z rwatson $
27 */
28
29/*
30 * Simple regression test to open and then immediately close various types of
31 * PF_IPX sockets. Run with various waits in order to make sure that the
32 * various IPX/SPX timers have a chance to walk the pcb lists and hit the
33 * sockets.
34 */
35
36#include <sys/types.h>
37#include <sys/socket.h>
38
39#include <netipx/ipx.h>
40
41#include <err.h>
42#include <unistd.h>
43
44static int
45maybe_sleep(int sec)
46{
47
48 if (sec == 0)
49 return (0);
50 return (sleep(sec));
51}
52
53int
54main(int argc, char *argv[])
55{
56 int delay, s;
57
58 for (delay = 0; delay < 5; delay++) {
59 s = socket(PF_IPX, SOCK_DGRAM, 0);
60 if (s < 0)
61 warn("socket(PF_IPX, SOCK_DGRAM, 0)");
62 else {
63 maybe_sleep(delay);
64 close(s);
65 }
66
67 s = socket(PF_IPX, SOCK_STREAM, 0);
68 if (s < 0)
69 warn("socket(PF_IPX, SOCK_STREAM, 0)");
70 else {
71 maybe_sleep(delay);
72 close(s);
73 }
74
75 s = socket(PF_IPX, SOCK_SEQPACKET, 0);
76 if (s < 0)
77 warn("socket(PF_IPX, SOCK_SEQPACKET, 0)");
78 else {
79 maybe_sleep(delay);
80 close(s);
81 }
82
83 s = socket(PF_IPX, SOCK_RAW, 0);
84 if (s < 0)
85 warn("socket(PF_IPX, SOCK_RAW, 0)");
86 else {
87 maybe_sleep(delay);
88 close(s);
89 }
90 }
91
92 return (0);
93}