#include <linux/compiler.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/hash.h>
#include <linux/stringhash.h>
#include <kunit/test.h>
static u32 __attribute_const__
xorshift(u32 seed)
{ … }
static u8 __attribute_const__
mod255(u32 x)
{ … }
static void fill_buf(char *buf, size_t len, u32 seed)
{ … }
struct test_hash_params { … };
#ifdef HAVE_ARCH__HASH_32
static void
test_int__hash_32(struct kunit *test, struct test_hash_params *params)
{
params->hash_or[1][0] |= params->h2 = __hash_32_generic(params->h0);
#if HAVE_ARCH__HASH_32 == 1
KUNIT_EXPECT_EQ_MSG(test, params->h1, params->h2,
"__hash_32(%#x) = %#x != __hash_32_generic() = %#x",
params->h0, params->h1, params->h2);
#endif
}
#endif
#ifdef HAVE_ARCH_HASH_64
static void
test_int_hash_64(struct kunit *test, struct test_hash_params *params, u32 const *m, int *k)
{
params->h2 = hash_64_generic(*params->h64, *k);
#if HAVE_ARCH_HASH_64 == 1
KUNIT_EXPECT_EQ_MSG(test, params->h1, params->h2,
"hash_64(%#llx, %d) = %#x != hash_64_generic() = %#x",
*params->h64, *k, params->h1, params->h2);
#else
KUNIT_EXPECT_LE_MSG(test, params->h1, params->h2,
"hash_64_generic(%#llx, %d) = %#x > %#x",
*params->h64, *k, params->h1, *m);
#endif
}
#endif
static void
test_int_hash(struct kunit *test, unsigned long long h64, u32 hash_or[2][33])
{ … }
#define SIZE …
static void test_string_or(struct kunit *test)
{ … }
static void test_hash_or(struct kunit *test)
{ … }
static struct kunit_case hash_test_cases[] __refdata = …;
static struct kunit_suite hash_test_suite = …;
kunit_test_suite(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;