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

Function verify_jhash_words

dpdk/app/test/test_hash_functions.c:222–261  ·  view source on GitHub ↗

* Verify that rte_jhash and rte_jhash_1word, rte_jhash_2words * and rte_jhash_3words return the same */

Source from the content-addressed store, hash-verified

220 * and rte_jhash_3words return the same
221 */
222static int
223verify_jhash_words(void)
224{
225 unsigned i;
226 uint32_t key[3];
227 uint32_t hash, hash_words;
228
229 for (i = 0; i < 3; i++)
230 key[i] = rand();
231
232 /* Test rte_jhash_1word */
233 hash = rte_jhash(key, 4, 0);
234 hash_words = rte_jhash_1word(key[0], 0);
235 if (hash != hash_words) {
236 printf("rte_jhash returns different value (0x%x)"
237 "than rte_jhash_1word (0x%x)\n",
238 hash, hash_words);
239 return -1;
240 }
241 /* Test rte_jhash_2words */
242 hash = rte_jhash(key, 8, 0);
243 hash_words = rte_jhash_2words(key[0], key[1], 0);
244 if (hash != hash_words) {
245 printf("rte_jhash returns different value (0x%x)"
246 "than rte_jhash_2words (0x%x)\n",
247 hash, hash_words);
248 return -1;
249 }
250 /* Test rte_jhash_3words */
251 hash = rte_jhash(key, 12, 0);
252 hash_words = rte_jhash_3words(key[0], key[1], key[2], 0);
253 if (hash != hash_words) {
254 printf("rte_jhash returns different value (0x%x)"
255 "than rte_jhash_3words (0x%x)\n",
256 hash, hash_words);
257 return -1;
258 }
259
260 return 0;
261}
262
263/*
264 * Run all functional tests for hash functions

Callers 1

run_hash_func_testsFunction · 0.85

Calls 5

rte_jhashFunction · 0.50
rte_jhash_1wordFunction · 0.50
printfFunction · 0.50
rte_jhash_2wordsFunction · 0.50
rte_jhash_3wordsFunction · 0.50

Tested by

no test coverage detected