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

Function run_test_

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

Source from the content-addressed store, hash-verified

89/* AUTOGENERATED MOCKS END */
90
91static void run_test_(int fd0, ...)
92{
93 va_list ap;
94 int fd, i;
95 int *test_fds = tal_arr(tmpctx, int, 1);
96 int **test_fd_ptrs;
97
98 /* They start all closed */
99 memset(test_fd_arr, 0xFF, sizeof(test_fd_arr));
100
101 test_fds[0] = fd0;
102 test_fd_arr[fd0] = fd0;
103
104 va_start(ap, fd0);
105 while ((fd = va_arg(ap, int)) != -1) {
106 tal_arr_expand(&test_fds, fd);
107 test_fd_arr[fd] = fd;
108 }
109 va_end(ap);
110
111 test_fd_ptrs = tal_arr(tmpctx, int *, tal_count(test_fds));
112 for (i = 0; i < tal_count(test_fds); i++)
113 test_fd_ptrs[i] = &test_fds[i];
114
115 assert(shuffle_fds(test_fd_ptrs, tal_count(test_fd_ptrs)));
116
117 /* Make sure fds ended up where expected */
118 i = 0;
119 assert(test_fd_arr[i++] == fd0);
120 va_start(ap, fd0);
121 while ((fd = va_arg(ap, int)) != -1)
122 assert(test_fd_arr[i++] == fd);
123 va_end(ap);
124
125 /* And rest were closed */
126 for (; i < MAX_TEST_FDS; i++)
127 assert(test_fd_arr[i] == -1);
128}
129
130#define run_test(...) \
131 run_test_(__VA_ARGS__, -1)

Callers

nothing calls this directly

Calls 1

shuffle_fdsFunction · 0.85

Tested by

no test coverage detected