MCPcopy Create free account
hub / github.com/ElementsProject/lightning / run_test_

Function run_test_

lightningd/test/run-shuffle_fds.c:121–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119/* AUTOGENERATED MOCKS END */
120
121static void run_test_(int fd0, ...)
122{
123 va_list ap;
124 int fd, i;
125 int *test_fds = tal_arr(tmpctx, int, 1);
126 int **test_fd_ptrs;
127
128 /* They start all closed */
129 memset(test_fd_arr, 0xFF, sizeof(test_fd_arr));
130
131 test_fds[0] = fd0;
132 test_fd_arr[fd0] = fd0;
133
134 va_start(ap, fd0);
135 while ((fd = va_arg(ap, int)) != -1) {
136 tal_arr_expand(&test_fds, fd);
137 test_fd_arr[fd] = fd;
138 }
139 va_end(ap);
140
141 test_fd_ptrs = tal_arr(tmpctx, int *, tal_count(test_fds));
142 for (i = 0; i < tal_count(test_fds); i++)
143 test_fd_ptrs[i] = &test_fds[i];
144
145 assert(shuffle_fds(test_fd_ptrs, tal_count(test_fd_ptrs)));
146
147 /* Make sure fds ended up where expected */
148 i = 0;
149 assert(test_fd_arr[i++] == fd0);
150 va_start(ap, fd0);
151 while ((fd = va_arg(ap, int)) != -1)
152 assert(test_fd_arr[i++] == fd);
153 va_end(ap);
154
155 /* And rest were closed */
156 for (; i < MAX_TEST_FDS; i++)
157 assert(test_fd_arr[i] == -1);
158}
159
160#define run_test(...) \
161 run_test_(__VA_ARGS__, -1)

Callers

nothing calls this directly

Calls 1

shuffle_fdsFunction · 0.85

Tested by

no test coverage detected