| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#ifndef _LIBNVME_TEST_IOCTL_UTIL_H |
| 4 |
#define _LIBNVME_TEST_IOCTL_UTIL_H |
| 5 |
|
| 6 |
#include <stddef.h> |
| 7 |
#include <stdlib.h> |
| 8 |
#include <stdnoreturn.h> |
| 9 |
|
| 10 |
noreturn void fail(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
| 11 |
|
| 12 |
#define check(condition, fmt...) ((condition) || (fail(fmt), 0)) |
| 13 |
|
| 14 |
void cmp(const void *actual, const void *expected, size_t len, const char *msg); |
| 15 |
|
| 16 |
void arbitrary(void *buf, size_t len); |
| 17 |
|
| 18 |
size_t arbitrary_range(size_t max); |
| 19 |
|
| 20 |
#define __cleanup__(fn) __attribute__((cleanup(fn))) |
| 21 |
|
| 22 |
static inline void freep(void *p) |
| 23 |
{ |
| 24 |
free(*(void **)p); |
| 25 |
} |
| 26 |
#define _cleanup_free_ __cleanup__(freep) |
| 27 |
|
| 28 |
#endif /* #ifndef _LIBNVME_TEST_IOCTL_UTIL_H */ |