MCPcopy Create free account
hub / github.com/F-Stack/f-stack / verify_jhash_32bits

Function verify_jhash_32bits

dpdk/app/test/test_hash_functions.c:185–216  ·  view source on GitHub ↗

* Verify that rte_jhash and rte_jhash_32b return the same */

Source from the content-addressed store, hash-verified

183 * Verify that rte_jhash and rte_jhash_32b return the same
184 */
185static int
186verify_jhash_32bits(void)
187{
188 unsigned i, j;
189 uint8_t key[64];
190 uint32_t hash, hash32;
191
192 for (i = 0; i < 64; i++)
193 key[i] = rand() & 0xff;
194
195 for (i = 0; i < RTE_DIM(hashtest_key_lens); i++) {
196 for (j = 0; j < RTE_DIM(hashtest_initvals); j++) {
197 /* Key size must be multiple of 4 (32 bits) */
198 if ((hashtest_key_lens[i] & 0x3) == 0) {
199 hash = rte_jhash(key, hashtest_key_lens[i],
200 hashtest_initvals[j]);
201 /* Divide key length by 4 in rte_jhash for 32 bits */
202 hash32 = rte_jhash_32b((const unaligned_uint32_t *)key,
203 hashtest_key_lens[i] >> 2,
204 hashtest_initvals[j]);
205 if (hash != hash32) {
206 printf("rte_jhash returns different value (0x%x)"
207 "than rte_jhash_32b (0x%x)\n",
208 hash, hash32);
209 return -1;
210 }
211 }
212 }
213 }
214
215 return 0;
216}
217
218/*
219 * Verify that rte_jhash and rte_jhash_1word, rte_jhash_2words

Callers 1

run_hash_func_testsFunction · 0.85

Calls 3

rte_jhashFunction · 0.50
rte_jhash_32bFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected