From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 2C0DB5A8B for ; Fri, 22 May 2015 12:16:17 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 22 May 2015 03:16:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,474,1427785200"; d="scan'208";a="730138321" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 22 May 2015 03:16:16 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t4MAGFFt008122; Fri, 22 May 2015 11:16:15 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t4MAGFoB013124; Fri, 22 May 2015 11:16:15 +0100 Received: (from pdelarax@localhost) by sivswdev02.ir.intel.com with id t4MAGFTI013120; Fri, 22 May 2015 11:16:15 +0100 From: Pablo de Lara To: dev@dpdk.org Date: Fri, 22 May 2015 11:16:11 +0100 Message-Id: <1432289771-12799-11-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1432289771-12799-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1431428560-25426-1-git-send-email-pablo.de.lara.guarch@intel.com> <1432289771-12799-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v5 10/10] test/hash: verify rte_jhash_1word/2words/3words X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2015 10:16:19 -0000 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 --- app/test/test_hash_functions.c | 48 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-) diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c index 04b2862..7c830b2 100644 --- a/app/test/test_hash_functions.c +++ b/app/test/test_hash_functions.c @@ -241,6 +241,51 @@ verify_jhash_32bits(void) } /* + * 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 */ static int @@ -252,6 +297,9 @@ run_hash_func_tests(void) if (verify_jhash_32bits() != 0) return -1; + if (verify_jhash_words() != 0) + return -1; + return 0; } -- 1.7.4.1