2 * tools/testing/selftests/kvm/include/test_util.h
4 * Copyright (C) 2018, Google LLC.
6 * This work is licensed under the terms of the GNU GPL, version 2.
22 #include "kselftest.h"
24 ssize_t test_write(int fd, const void *buf, size_t count);
25 ssize_t test_read(int fd, void *buf, size_t count);
26 int test_seq_read(const char *path, char **bufp, size_t *sizep);
28 void test_assert(bool exp, const char *exp_str,
29 const char *file, unsigned int line, const char *fmt, ...);
31 #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
33 #define TEST_ASSERT(e, fmt, ...) \
34 test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
36 #define ASSERT_EQ(a, b) do { \
37 typeof(a) __a = (a); \
38 typeof(b) __b = (b); \
39 TEST_ASSERT(__a == __b, \
40 "ASSERT_EQ(%s, %s) failed.\n" \
43 #a, #b, #a, (unsigned long) __a, #b, (unsigned long) __b); \
46 #endif /* TEST_UTIL_H */