Go to the documentation of this file.
33 #if defined(_MSC_VER) && _MSC_VER < 1600
40 # include <sys/time.h>
41 # include <sys/resource.h>
45 # pragma clang diagnostic ignored "-Wvariadic-macros"
46 # pragma clang diagnostic ignored "-Wc99-extensions"
50 # pragma GCC diagnostic ignored "-Wvariadic-macros"
53 #define TEST_PORT 9123
54 #define TEST_PORT_2 9124
57 # define TEST_PIPENAME "\\\\?\\pipe\\uv-test"
58 # define TEST_PIPENAME_2 "\\\\?\\pipe\\uv-test2"
59 # define TEST_PIPENAME_3 "\\\\?\\pipe\\uv-test3"
61 # define TEST_PIPENAME "/tmp/uv-test-sock"
62 # define TEST_PIPENAME_2 "/tmp/uv-test-sock2"
63 # define TEST_PIPENAME_3 "/tmp/uv-test-sock3"
69 # define S_IRUSR _S_IREAD
72 # define S_IWUSR _S_IWRITE
76 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
78 #define container_of(ptr, type, member) \
79 ((type *) ((char *) (ptr) - offsetof(type, member)))
91 "Fatal error in %s on line %d: %s\n", \
102 #define ASSERT(expr) \
106 "Assertion failed in %s on line %d: %s\n", \
114 #define ASSERT_BASE(expr, a, operator, b, type, conv) \
118 "Assertion failed in %s on line %d: `%s %s %s` " \
119 "(%"conv" %s %"conv")\n", \
132 #define ASSERT_BASE_LEN(expr, a, operator, b, conv, len) \
136 "Assertion failed in %s on line %d: `%s %s %s` " \
137 "(%.*"#conv" %s %.*"#conv")\n", \
152 #define ASSERT_BASE_HEX(expr, a, operator, b, size) \
156 unsigned char* a_ = (unsigned char*)a; \
157 unsigned char* b_ = (unsigned char*)b; \
159 "Assertion failed in %s on line %d: `%s %s %s` (", \
165 for (i = 0; i < size; ++i) { \
166 if (i > 0) fprintf(stderr, ":"); \
167 fprintf(stderr, "%02X", a_[i]); \
169 fprintf(stderr, " %s ", #operator); \
170 for (i = 0; i < size; ++i) { \
171 if (i > 0) fprintf(stderr, ":"); \
172 fprintf(stderr, "%02X", b_[i]); \
174 fprintf(stderr, ")\n"); \
179 #define ASSERT_INT_BASE(a, operator, b, type, conv) \
180 ASSERT_BASE(a operator b, a, operator, b, type, conv)
182 #define ASSERT_EQ(a, b) ASSERT_INT_BASE(a, ==, b, int64_t, PRId64)
183 #define ASSERT_GE(a, b) ASSERT_INT_BASE(a, >=, b, int64_t, PRId64)
184 #define ASSERT_GT(a, b) ASSERT_INT_BASE(a, >, b, int64_t, PRId64)
185 #define ASSERT_LE(a, b) ASSERT_INT_BASE(a, <=, b, int64_t, PRId64)
186 #define ASSERT_LT(a, b) ASSERT_INT_BASE(a, <, b, int64_t, PRId64)
187 #define ASSERT_NE(a, b) ASSERT_INT_BASE(a, !=, b, int64_t, PRId64)
189 #define ASSERT_UINT64_EQ(a, b) ASSERT_INT_BASE(a, ==, b, uint64_t, PRIu64)
190 #define ASSERT_UINT64_GE(a, b) ASSERT_INT_BASE(a, >=, b, uint64_t, PRIu64)
191 #define ASSERT_UINT64_GT(a, b) ASSERT_INT_BASE(a, >, b, uint64_t, PRIu64)
192 #define ASSERT_UINT64_LE(a, b) ASSERT_INT_BASE(a, <=, b, uint64_t, PRIu64)
193 #define ASSERT_UINT64_LT(a, b) ASSERT_INT_BASE(a, <, b, uint64_t, PRIu64)
194 #define ASSERT_UINT64_NE(a, b) ASSERT_INT_BASE(a, !=, b, uint64_t, PRIu64)
196 #define ASSERT_STR_EQ(a, b) \
197 ASSERT_BASE(strcmp(a, b) == 0, a, ==, b, char*, "s")
199 #define ASSERT_STR_NE(a, b) \
200 ASSERT_BASE(strcmp(a, b) != 0, a, !=, b, char*, "s")
202 #define ASSERT_MEM_EQ(a, b, size) \
203 ASSERT_BASE_LEN(memcmp(a, b, size) == 0, a, ==, b, s, size)
205 #define ASSERT_MEM_NE(a, b, size) \
206 ASSERT_BASE_LEN(memcmp(a, b, size) != 0, a, !=, b, s, size)
208 #define ASSERT_MEM_HEX_EQ(a, b, size) \
209 ASSERT_BASE_HEX(memcmp(a, b, size) == 0, a, ==, b, size)
211 #define ASSERT_MEM_HEX_NE(a, b, size) \
212 ASSERT_BASE_HEX(memcmp(a, b, size) != 0, a, !=, b, size)
214 #define ASSERT_NULL(a) \
215 ASSERT_BASE(a == NULL, a, ==, NULL, void*, "p")
217 #define ASSERT_NOT_NULL(a) \
218 ASSERT_BASE(a != NULL, a, !=, NULL, void*, "p")
220 #define ASSERT_PTR_EQ(a, b) \
221 ASSERT_BASE((void*)a == (void*)b, a, ==, b, void*, "p")
223 #define ASSERT_PTR_NE(a, b) \
224 ASSERT_BASE((void*)a != (void*)b, a, !=, b, void*, "p")
229 #define MAKE_VALGRIND_HAPPY() \
231 close_loop(uv_default_loop()); \
232 ASSERT(0 == uv_loop_close(uv_default_loop())); \
236 #define TEST_IMPL(name) \
237 int run_test_##name(void); \
238 int run_test_##name(void)
240 #define BENCHMARK_IMPL(name) \
241 int run_benchmark_##name(void); \
242 int run_benchmark_##name(void)
244 #define HELPER_IMPL(name) \
245 int run_helper_##name(void); \
246 int run_helper_##name(void)
249 const char*
fmt(
double d);
257 #define RETURN_OK() \
262 #define RETURN_SKIP(explanation) \
264 fprintf(stderr, "%s\n", explanation); \
271 # define TEST_FILE_LIMIT(num) \
274 lim.rlim_cur = (num); \
275 lim.rlim_max = lim.rlim_cur; \
276 if (setrlimit(RLIMIT_NOFILE, &lim)) \
277 RETURN_SKIP("File descriptor limit too low."); \
282 # define TEST_FILE_LIMIT(num) do {} while (0)
286 #if !defined(snprintf) && defined(_MSC_VER) && _MSC_VER < 1900
287 extern int snprintf(
char*,
size_t,
const char*, ...);
290 #if defined(__clang__) || \
291 defined(__GNUC__) || \
292 defined(__INTEL_COMPILER)
293 # define UNUSED __attribute__((unused))
299 #define notify_parent_process() ((void) 0)
325 for (
i = 0; supported == 0 &&
i <
count;
i += 1)
326 supported = (
AF_INET6 ==
addr[
i].address.address6.sin6_family);
332 #if defined(__CYGWIN__) || defined(__MSYS__) || defined(__PASE__)
333 # define NO_FS_EVENTS "Filesystem watching not supported on this platform."
336 #if defined(__MSYS__)
337 # define NO_SEND_HANDLE_ON_PIPE \
338 "MSYS2 runtime does not support sending handles on pipes."
339 #elif defined(__CYGWIN__)
340 # define NO_SEND_HANDLE_ON_PIPE \
341 "Cygwin runtime does not support sending handles on pipes."
344 #if defined(__MSYS__)
345 # define NO_SELF_CONNECT \
346 "MSYS2 runtime hangs on listen+connect in same process."
347 #elif defined(__CYGWIN__)
348 # define NO_SELF_CONNECT \
349 "Cygwin runtime hangs on listen+connect in same process."
static UNUSED void close_loop(uv_loop_t *loop)
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
UV_EXTERN int uv_interface_addresses(uv_interface_address_t **addresses, int *count)
UV_EXTERN int uv_is_closing(const uv_handle_t *handle)
UV_EXTERN void uv_close(uv_handle_t *handle, uv_close_cb close_cb)
UV_EXTERN void uv_walk(uv_loop_t *loop, uv_walk_cb walk_cb, void *arg)
UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t *addresses, int count)
const char * fmt(double d)
void notify_parent_process(void)
static void close_walk_cb(uv_handle_t *handle, void *arg)
static UNUSED int can_ipv6(void)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:29