^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Test cases for <linux/hash.h> and <linux/stringhash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This just verifies that various ways of computing a hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * produce the same thing and, for cases where a k-bit hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * value is requested, is of the requested size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * We fill a buffer with a 255-byte null-terminated string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * and use both full_name_hash() and hashlen_string() to hash the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * substrings from i to j, where 0 <= i < j < 256.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * The returned values are used to check that __hash_32() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * __hash_32_generic() compute the same thing. Likewise hash_32()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * and hash_64().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/stringhash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/printk.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* 32-bit XORSHIFT generator. Seed must not be zero. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static u32 __init __attribute_const__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) xorshift(u32 seed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) seed ^= seed << 13;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) seed ^= seed >> 17;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) seed ^= seed << 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return seed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* Given a non-zero x, returns a non-zero byte. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static u8 __init __attribute_const__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) mod255(u32 x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) x = (x & 0xffff) + (x >> 16); /* 1 <= x <= 0x1fffe */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) x = (x & 0xff) + (x >> 8); /* 1 <= x <= 0x2fd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) x = (x & 0xff) + (x >> 8); /* 1 <= x <= 0x100 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) x = (x & 0xff) + (x >> 8); /* 1 <= x <= 0xff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* Fill the buffer with non-zero bytes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) fill_buf(char *buf, size_t len, u32 seed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) size_t i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) for (i = 0; i < len; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) seed = xorshift(seed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) buf[i] = mod255(seed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * Test the various integer hash functions. h64 (or its low-order bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * is the integer to hash. hash_or accumulates the OR of the hash values,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * which are later checked to see that they cover all the requested bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * Because these functions (as opposed to the string hashes) are all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * inline, the code being tested is actually in the module, and you can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * recompile and re-test the module without rebooting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static bool __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) test_int_hash(unsigned long long h64, u32 hash_or[2][33])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) int k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u32 h0 = (u32)h64, h1, h2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* Test __hash32 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) hash_or[0][0] |= h1 = __hash_32(h0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #ifdef HAVE_ARCH__HASH_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) hash_or[1][0] |= h2 = __hash_32_generic(h0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #if HAVE_ARCH__HASH_32 == 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) if (h1 != h2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) pr_err("__hash_32(%#x) = %#x != __hash_32_generic() = %#x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) h0, h1, h2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* Test k = 1..32 bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) for (k = 1; k <= 32; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) u32 const m = ((u32)2 << (k-1)) - 1; /* Low k bits set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /* Test hash_32 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) hash_or[0][k] |= h1 = hash_32(h0, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) if (h1 > m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) pr_err("hash_32(%#x, %d) = %#x > %#x", h0, k, h1, m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #ifdef HAVE_ARCH_HASH_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) h2 = hash_32_generic(h0, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #if HAVE_ARCH_HASH_32 == 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) if (h1 != h2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) pr_err("hash_32(%#x, %d) = %#x != hash_32_generic() "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) " = %#x", h0, k, h1, h2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (h2 > m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) pr_err("hash_32_generic(%#x, %d) = %#x > %#x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) h0, k, h1, m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* Test hash_64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) hash_or[1][k] |= h1 = hash_64(h64, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (h1 > m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) pr_err("hash_64(%#llx, %d) = %#x > %#x", h64, k, h1, m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #ifdef HAVE_ARCH_HASH_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) h2 = hash_64_generic(h64, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #if HAVE_ARCH_HASH_64 == 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (h1 != h2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) pr_err("hash_64(%#llx, %d) = %#x != hash_64_generic() "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) "= %#x", h64, k, h1, h2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (h2 > m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) pr_err("hash_64_generic(%#llx, %d) = %#x > %#x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) h64, k, h1, m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) (void)h2; /* Suppress unused variable warning */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #define SIZE 256 /* Run time is cubic in SIZE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) test_hash_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) char buf[SIZE+1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) u32 string_or = 0, hash_or[2][33] = { { 0, } };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) unsigned tests = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) unsigned long long h64 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) fill_buf(buf, SIZE, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /* Test every possible non-empty substring in the buffer. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) for (j = SIZE; j > 0; --j) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) buf[j] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) for (i = 0; i <= j; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) u64 hashlen = hashlen_string(buf+i, buf+i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) u32 h0 = full_name_hash(buf+i, buf+i, j-i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /* Check that hashlen_string gets the length right */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) if (hashlen_len(hashlen) != j-i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) pr_err("hashlen_string(%d..%d) returned length"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) " %u, expected %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) i, j, hashlen_len(hashlen), j-i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* Check that the hashes match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) if (hashlen_hash(hashlen) != h0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) pr_err("hashlen_string(%d..%d) = %08x != "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) "full_name_hash() = %08x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) i, j, hashlen_hash(hashlen), h0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) string_or |= h0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) h64 = h64 << 32 | h0; /* For use with hash_64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if (!test_int_hash(h64, hash_or))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) tests++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) } /* i */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) } /* j */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /* The OR of all the hash values should cover all the bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (~string_or) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) pr_err("OR of all string hash results = %#x != %#x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) string_or, -1u);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (~hash_or[0][0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) pr_err("OR of all __hash_32 results = %#x != %#x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) hash_or[0][0], -1u);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #ifdef HAVE_ARCH__HASH_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #if HAVE_ARCH__HASH_32 != 1 /* Test is pointless if results match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (~hash_or[1][0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) pr_err("OR of all __hash_32_generic results = %#x != %#x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) hash_or[1][0], -1u);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /* Likewise for all the i-bit hash values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) for (i = 1; i <= 32; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) u32 const m = ((u32)2 << (i-1)) - 1; /* Low i bits set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (hash_or[0][i] != m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) pr_err("OR of all hash_32(%d) results = %#x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) "(%#x expected)", i, hash_or[0][i], m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (hash_or[1][i] != m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) pr_err("OR of all hash_64(%d) results = %#x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) "(%#x expected)", i, hash_or[1][i], m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /* Issue notices about skipped tests. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) #ifdef HAVE_ARCH__HASH_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) #if HAVE_ARCH__HASH_32 != 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) pr_info("__hash_32() is arch-specific; not compared to generic.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) pr_info("__hash_32() has no arch implementation to test.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #ifdef HAVE_ARCH_HASH_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #if HAVE_ARCH_HASH_32 != 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) pr_info("hash_32() is arch-specific; not compared to generic.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) pr_info("hash_32() has no arch implementation to test.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) #ifdef HAVE_ARCH_HASH_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) #if HAVE_ARCH_HASH_64 != 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) pr_info("hash_64() is arch-specific; not compared to generic.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) pr_info("hash_64() has no arch implementation to test.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) pr_notice("%u tests passed.", tests);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static void __exit test_hash_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) module_init(test_hash_init); /* Does everything */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) module_exit(test_hash_exit); /* Does nothing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) MODULE_LICENSE("GPL");