Lines Matching +full:- +full:seed

1 // SPDX-License-Identifier: GPL-2.0-only
5 * produce the same thing and, for cases where a k-bit hash
8 * We fill a buffer with a 255-byte null-terminated string,
24 /* 32-bit XORSHIFT generator. Seed must not be zero. */
26 xorshift(u32 seed) in xorshift() argument
28 seed ^= seed << 13; in xorshift()
29 seed ^= seed >> 17; in xorshift()
30 seed ^= seed << 5; in xorshift()
31 return seed; in xorshift()
34 /* Given a non-zero x, returns a non-zero byte. */
45 /* Fill the buffer with non-zero bytes. */
46 static void fill_buf(char *buf, size_t len, u32 seed) in fill_buf() argument
51 seed = xorshift(seed); in fill_buf()
52 buf[i] = mod255(seed); in fill_buf()
60 /* Low 32-bits of integer to be hashed. */
62 /* Arch-specific hash result. */
74 params->hash_or[1][0] |= params->h2 = __hash_32_generic(params->h0); in test_int__hash_32()
76 KUNIT_EXPECT_EQ_MSG(test, params->h1, params->h2, in test_int__hash_32()
78 params->h0, params->h1, params->h2); in test_int__hash_32()
87 params->h2 = hash_64_generic(*params->h64, *k); in test_int_hash_64()
89 KUNIT_EXPECT_EQ_MSG(test, params->h1, params->h2, in test_int_hash_64()
91 *params->h64, *k, params->h1, params->h2); in test_int_hash_64()
93 KUNIT_EXPECT_LE_MSG(test, params->h1, params->h2, in test_int_hash_64()
95 *params->h64, *k, params->h1, *m); in test_int_hash_64()
101 * Test the various integer hash functions. h64 (or its low-order bits)
107 * recompile and re-test the module without rebooting.
123 u32 const m = ((u32)2 << (k-1)) - 1; /* Low k bits set */ in test_int_hash()
152 /* Test every possible non-empty substring in the buffer. */ in test_string_or()
153 for (j = SIZE; j > 0; --j) { in test_string_or()
157 u32 h0 = full_name_hash(buf+i, buf+i, j-i); in test_string_or()
164 KUNIT_EXPECT_EQ_MSG(test, string_or, -1u, in test_string_or()
166 string_or, -1u); in test_string_or()
178 /* Test every possible non-empty substring in the buffer. */ in test_hash_or()
179 for (j = SIZE; j > 0; --j) { in test_hash_or()
184 u32 h0 = full_name_hash(buf+i, buf+i, j-i); in test_hash_or()
187 KUNIT_EXPECT_EQ_MSG(test, hashlen_len(hashlen), j-i, in test_hash_or()
189 i, j, hashlen_len(hashlen), j-i); in test_hash_or()
200 KUNIT_EXPECT_EQ_MSG(test, hash_or[0][0], -1u, in test_hash_or()
202 hash_or[0][0], -1u); in test_hash_or()
205 KUNIT_EXPECT_EQ_MSG(test, hash_or[1][0], -1u, in test_hash_or()
207 hash_or[1][0], -1u); in test_hash_or()
211 /* Likewise for all the i-bit hash values */ in test_hash_or()
213 u32 const m = ((u32)2 << (i-1)) - 1; /* Low i bits set */ in test_hash_or()