summaryrefslogtreecommitdiff
path: root/testing/fulltests/unit-tests/T009large_fd_set_clib.c
blob: eee4d41375a814447c11ee104c6ee9998a2c3a03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* HEADER Testing netsnmp_large_fd_set */

netsnmp_large_fd_set fds;
netsnmp_large_fd_set_init(&fds, 2000);
OKF(fds.lfs_setsize == 2000, ("initialization"));
OKF(netsnmp_large_fd_set_resize(&fds, 2000) == 1, ("resizing to 2000"));
NETSNMP_LARGE_FD_ZERO(&fds);

{
    int i;
    for (i = 0; i < fds.lfs_setsize; ++i) {
        OKF(!NETSNMP_LARGE_FD_ISSET(i, &fds), ("%d is not set", i));
	NETSNMP_LARGE_FD_SET(i, &fds);
	OKF(NETSNMP_LARGE_FD_ISSET(i, &fds), ("%d is set", i));
	NETSNMP_LARGE_FD_CLR(i, &fds);
	OKF(!NETSNMP_LARGE_FD_ISSET(i, &fds), ("%d is not set", i));
    }
}

OKF(netsnmp_large_fd_set_resize(&fds, 3000) == 1, ("resizing to 3000"));

{
    int i;
    for (i = 0; i < fds.lfs_setsize; ++i) {
        OKF(!NETSNMP_LARGE_FD_ISSET(i, &fds), ("%d is not set", i));
	NETSNMP_LARGE_FD_SET(i, &fds);
	OKF(NETSNMP_LARGE_FD_ISSET(i, &fds), ("%d is set", i));
	NETSNMP_LARGE_FD_CLR(i, &fds);
	OKF(!NETSNMP_LARGE_FD_ISSET(i, &fds), ("%d is not set", i));
    }
}

OKF(netsnmp_large_fd_set_resize(&fds, 1000) == 1, ("resizing to 1000"));

{
    int i;
    for (i = 0; i < fds.lfs_setsize; ++i) {
        OKF(!NETSNMP_LARGE_FD_ISSET(i, &fds), ("%d is not set", i));
	NETSNMP_LARGE_FD_SET(i, &fds);
	OKF(NETSNMP_LARGE_FD_ISSET(i, &fds), ("%d is set", i));
	NETSNMP_LARGE_FD_CLR(i, &fds);
	OKF(!NETSNMP_LARGE_FD_ISSET(i, &fds), ("%d is not set", i));
    }
}

netsnmp_large_fd_set_cleanup(&fds);