Commit | Line | Data |
---|---|---|
0458ed8c | 1 | /* |
9d16b343 | 2 | * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
0458ed8c | 3 | * |
9d16b343 | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
0458ed8c | 5 | * |
0458ed8c JG |
6 | */ |
7 | ||
8 | #ifndef TEST_UTILS_H | |
9 | #define TEST_UTILS_H | |
10 | ||
d23253ae FD |
11 | #if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)) |
12 | ||
13 | /* | |
14 | * Version using XSI strerror_r. | |
15 | */ | |
16 | #define PERROR_NO_LOGGER(msg, args...) \ | |
17 | do { \ | |
18 | char buf[200]; \ | |
19 | strerror_r(errno, buf, sizeof(buf)); \ | |
20 | fprintf(stderr, msg ": %s\n", ##args, buf); \ | |
21 | } while (0); | |
22 | #else | |
23 | /* | |
24 | * Version using GNU strerror_r, for linux with appropriate defines. | |
25 | */ | |
26 | #define PERROR_NO_LOGGER(msg, args...) \ | |
27 | do { \ | |
28 | char *buf; \ | |
29 | char tmp[200]; \ | |
30 | buf = strerror_r(errno, tmp, sizeof(tmp)); \ | |
31 | fprintf(stderr, msg ": %s\n", ##args, buf); \ | |
32 | } while (0); | |
33 | #endif | |
34 | ||
0458ed8c | 35 | int usleep_safe(useconds_t usec); |
b2047add FD |
36 | int create_file(const char *path); |
37 | int wait_on_file(const char *path); | |
0458ed8c JG |
38 | |
39 | #endif /* TEST_UTILS_H */ |