Lines Matching +full:j +full:- +full:to +full:- +full:k

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,
9 * and use both full_name_hash() and hashlen_string() to hash the
10 * substrings from i to j, where 0 <= i < j < 256.
12 * The returned values are used to check that __hash_32() and
24 /* 32-bit XORSHIFT generator. Seed must not be zero. */
34 /* Given a non-zero x, returns a non-zero byte. */
45 /* Fill the buffer with non-zero bytes. */
58 /* Pointer to integer to be hashed. */
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()
85 test_int_hash_64(struct kunit *test, struct test_hash_params *params, u32 const *m, int *k) in test_int_hash_64() argument
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)
102 * is the integer to hash. hash_or accumulates the OR of the hash values,
103 * which are later checked to see that they cover all the requested bits.
105 * Because these functions (as opposed to the string hashes) are all
107 * recompile and re-test the module without rebooting.
112 int k; in test_int_hash() local
121 /* Test k = 1..32 bits */ in test_int_hash()
122 for (k = 1; k <= 32; k++) { in test_int_hash()
123 u32 const m = ((u32)2 << (k-1)) - 1; /* Low k bits set */ in test_int_hash()
126 hash_or[0][k] |= params.h1 = hash_32(params.h0, k); in test_int_hash()
129 params.h0, k, params.h1, m); in test_int_hash()
132 hash_or[1][k] |= params.h1 = hash_64(h64, k); in test_int_hash()
135 h64, k, params.h1, m); in test_int_hash()
137 test_int_hash_64(test, &params, &m, &k); in test_int_hash()
148 int i, j; in test_string_or() local
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()
154 buf[j] = '\0'; in test_string_or()
156 for (i = 0; i <= j; i++) { in test_string_or()
157 u32 h0 = full_name_hash(buf+i, buf+i, j-i); in test_string_or()
161 } /* j */ 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()
174 int i, j; in test_hash_or() local
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()
180 buf[j] = '\0'; in test_hash_or()
182 for (i = 0; i <= j; i++) { 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()
193 i, j, hashlen_hash(hashlen), h0); in test_hash_or()
198 } /* j */ 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()