#include <linux/kernel.h>
#include <linux/module.h>
#define for_each_test(i, test) \
for (i = 0; i < ARRAY_SIZE(test); i++)
#define DEFINE_TEST_FAIL(test) \
const struct test_fail test[] __initconst
#define DECLARE_TEST_OK(type, test_type) \
#define DEFINE_TEST_OK(type, test) \
const type test[] __initconst
#define TEST_FAIL(fn, type, fmt, test) \
for_each_test(i, test) { \
const struct test_fail *t = &test[i]; \
rv = fn(t->str, t->base, &tmp); \
WARN(1, "str '%s', base %u, expected -E, got %d/" fmt "\n", \
t->str, t->base, rv, tmp); \
#define TEST_OK(fn, type, fmt, test) \
for_each_test(i, test) { \
const typeof(test[0]) *t = &test[i]; \
rv = fn(t->str, t->base, &res); \
WARN(1, "str '%s', base %u, expected 0/" fmt ", got %d\n", \
t->str, t->base, t->expected_res, rv); \
if (res != t->expected_res) { \
WARN(1, "str '%s', base %u, expected " fmt ", got " fmt "\n", \
t->str, t->base, t->expected_res, res); \