From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 8CEF4ADA7 for ; Wed, 10 Jun 2015 17:26:00 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 10 Jun 2015 08:25:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,588,1427785200"; d="scan'208";a="724675570" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 10 Jun 2015 08:25:29 -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 t5AFPS8M024246; Wed, 10 Jun 2015 16:25:28 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t5AFPSlt014876; Wed, 10 Jun 2015 16:25:28 +0100 Received: (from pdelarax@localhost) by sivswdev02.ir.intel.com with id t5AFPS0A014872; Wed, 10 Jun 2015 16:25:28 +0100 From: Pablo de Lara To: dev@dpdk.org Date: Wed, 10 Jun 2015 16:25:27 +0100 Message-Id: <1433949927-14767-11-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1433949927-14767-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1432289771-12799-1-git-send-email-pablo.de.lara.guarch@intel.com> <1433949927-14767-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v6 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: Wed, 10 Jun 2015 15:26:01 -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 file changed, 48 insertions(+) diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c index 8af8601..df7c909 100644 --- a/app/test/test_hash_functions.c +++ b/app/test/test_hash_functions.c @@ -240,6 +240,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 @@ -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; } -- 2.4.2