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 A8CD69A9C for ; Wed, 25 Feb 2015 12:34:37 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 25 Feb 2015 03:28:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,644,1418112000"; d="scan'208";a="671368643" Received: from bricha3-mobl3.ger.corp.intel.com ([10.243.20.32]) by fmsmga001.fm.intel.com with SMTP; 25 Feb 2015 03:34:32 -0800 Received: by (sSMTP sendmail emulation); Wed, 25 Feb 2015 11:34:32 +0025 Date: Wed, 25 Feb 2015 11:34:31 +0000 From: Bruce Richardson To: Yerden Zhumabekov Message-ID: <20150225113431.GA9512@bricha3-MOBL3> References: <1424781388-7485-1-git-send-email-e_zhumabekov@sts.kz> <1424837312-23029-1-git-send-email-e_zhumabekov@sts.kz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424837312-23029-1-git-send-email-e_zhumabekov@sts.kz> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v2] app/test: add crc32 algorithms equivalence check 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, 25 Feb 2015 11:34:38 -0000 On Wed, Feb 25, 2015 at 10:08:32AM +0600, Yerden Zhumabekov wrote: > New function test_crc32_hash_alg_equiv() checks whether software, > 4-byte operand and 8-byte operand versions of CRC32 hash function > implementations return the same result value. > > Signed-off-by: Yerden Zhumabekov Two small notes below for improving output on error. Acked-by: Bruce Richardson > --- > app/test/test_hash.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 63 insertions(+) > > diff --git a/app/test/test_hash.c b/app/test/test_hash.c > index 76b1b8f..3e94af1 100644 > --- a/app/test/test_hash.c > +++ b/app/test/test_hash.c > @@ -177,6 +177,66 @@ static struct rte_hash_parameters ut_params = { > .socket_id = 0, > }; > > +#define CRC32_ITERATIONS (1U << 20) > +#define CRC32_DWORDS (1U << 6) > +/* > + * Test if all CRC32 implementations yield the same hash value > + */ > +static int > +test_crc32_hash_alg_equiv(void) > +{ > + uint32_t hash_val; > + uint32_t init_val; > + uint64_t data64[CRC32_DWORDS]; > + unsigned i, j; > + size_t data_len; > + > + printf("# CRC32 implementations equivalence test\n"); > + for (i = 0; i < CRC32_ITERATIONS; i++) { > + /* Randomizing data_len of data set */ > + data_len = (size_t) ((rte_rand() % sizeof(data64)) + 1); > + init_val = (uint32_t) rte_rand(); > + > + /* Fill the data set */ > + for (j = 0; j < CRC32_DWORDS; j++) > + data64[j] = rte_rand(); > + > + /* Calculate software CRC32 */ > + rte_hash_crc_set_alg(CRC32_SW); > + hash_val = rte_hash_crc(data64, data_len, init_val); > + > + /* Check against 4-byte-operand sse4.2 CRC32 if available */ > + rte_hash_crc_set_alg(CRC32_SSE42); > + if (hash_val != rte_hash_crc(data64, data_len, init_val)) { > + printf("Failed checking CRC32_SW against CRC32_SSE42\n"); > + break; > + } > + > + /* Check against 8-byte-operand sse4.2 CRC32 if available */ > + rte_hash_crc_set_alg(CRC32_SSE42_x64); > + if (hash_val != rte_hash_crc(data64, data_len, init_val)) { > + printf("Failed checking CRC32_SW against CRC32_SSE42_x64\n"); > + break; > + } > + } > + > + /* Resetting to best available algorithm */ > + rte_hash_crc_set_alg(CRC32_SSE42_x64); > + > + if (i == CRC32_ITERATIONS) > + return 0; > + > + printf("Failed test data (hex):\n"); > + > + for (j = 0; j < data_len; j++) { > + printf("%02X", ((uint8_t *)data64)[j]); Put in a space after each hex character, otherwise it comes out like: Failed test data (hex): AAD292776348010C7A18D3080DB3A300 FD Test Failed [I forced a failure by changing a != to == to test it, don't worry, the hash calculations are fine! :-)] > + if ((j+1) % 16 == 0 || j == data_len - 1) > + printf("\n"); > + } Maybe also print out here, or before the hex digits, the length of the data that was tested. e.g. "printf("%u bytes total\n", data_len);" or similar. > + > + return -1; > +} > + > /* > * Test a hash function. > */ > @@ -1356,6 +1416,9 @@ test_hash(void) > > run_hash_func_tests(); > > + if (test_crc32_hash_alg_equiv() < 0) > + return -1; > + > return 0; > } > > -- > 1.7.9.5 >