app/test: verify more jhash functions
Added new test that verifies that rte_jhash_1words, rte_jhash_2words and rte_jhash_3words return the same values as rte_jhash. Note that this patch has been added after the update of the jhash function because these 3 functions did not return the same values as rte_jhash before Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
This commit is contained in:
parent
7530c9eea7
commit
f3d9490098
@ -239,6 +239,51 @@ verify_jhash_32bits(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Verify that rte_jhash and rte_jhash_1word, rte_jhash_2words
|
||||||
|
* and rte_jhash_3words return the same
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
verify_jhash_words(void)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
uint32_t key[3];
|
||||||
|
uint32_t hash, hash_words;
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i++)
|
||||||
|
key[i] = rand();
|
||||||
|
|
||||||
|
/* Test rte_jhash_1word */
|
||||||
|
hash = rte_jhash(key, 4, 0);
|
||||||
|
hash_words = rte_jhash_1word(key[0], 0);
|
||||||
|
if (hash != hash_words) {
|
||||||
|
printf("rte_jhash returns different value (0x%x)"
|
||||||
|
"than rte_jhash_1word (0x%x)\n",
|
||||||
|
hash, hash_words);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* Test rte_jhash_2words */
|
||||||
|
hash = rte_jhash(key, 8, 0);
|
||||||
|
hash_words = rte_jhash_2words(key[0], key[1], 0);
|
||||||
|
if (hash != hash_words) {
|
||||||
|
printf("rte_jhash returns different value (0x%x)"
|
||||||
|
"than rte_jhash_2words (0x%x)\n",
|
||||||
|
hash, hash_words);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* Test rte_jhash_3words */
|
||||||
|
hash = rte_jhash(key, 12, 0);
|
||||||
|
hash_words = rte_jhash_3words(key[0], key[1], key[2], 0);
|
||||||
|
if (hash != hash_words) {
|
||||||
|
printf("rte_jhash returns different value (0x%x)"
|
||||||
|
"than rte_jhash_3words (0x%x)\n",
|
||||||
|
hash, hash_words);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Run all functional tests for hash functions
|
* Run all functional tests for hash functions
|
||||||
*/
|
*/
|
||||||
@ -251,6 +296,9 @@ run_hash_func_tests(void)
|
|||||||
if (verify_jhash_32bits() != 0)
|
if (verify_jhash_32bits() != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (verify_jhash_words() != 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user