From: Pablo de Lara Date: Wed, 10 Jun 2015 15:25:27 +0000 (+0100) Subject: app/test: verify more jhash functions X-Git-Tag: spdx-start~9067 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f3d9490098d0ce6b274c410bb3856916677d1890;p=dpdk.git 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 Acked-by: Bruce Richardson --- diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c index 8af8601d2f..df7c909936 100644 --- a/app/test/test_hash_functions.c +++ b/app/test/test_hash_functions.c @@ -239,6 +239,51 @@ verify_jhash_32bits(void) 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 */ @@ -251,6 +296,9 @@ run_hash_func_tests(void) if (verify_jhash_32bits() != 0) return -1; + if (verify_jhash_words() != 0) + return -1; + return 0; }