From patchwork Wed Dec 4 20:52:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 63575 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4FA89A04F2; Wed, 4 Dec 2019 21:53:24 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9C9FD1BE82; Wed, 4 Dec 2019 21:53:23 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 13B405681 for ; Wed, 4 Dec 2019 21:53:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575492801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4AqKjXfqvehWi+s+gn9xjf6xbwMRP/kmDBKExUbY61s=; b=MDFvFRJjQRTLwv/MA/NoD+jhpoW6kC3+HaOlpMHLa8xMdmhitS3iAg/KgeG8LDvnN6KCnu /81woDqE2fWwok4qH81OqYf/ka/llWKF/uYlkQHDwog/cdJAgRrg2OI5G4Ra3BgsVLFNnE AQ/Sg9R0C+9zC2tPh/6o8Eqvju4WgpM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-92-pjjO1q50PCS7WJU1IEvVDQ-1; Wed, 04 Dec 2019 15:53:20 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41F78100550E; Wed, 4 Dec 2019 20:53:19 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-205-88.brq.redhat.com [10.40.205.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9806C600D1; Wed, 4 Dec 2019 20:53:17 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: aconole@redhat.com, stable@dpdk.org Date: Wed, 4 Dec 2019 21:52:41 +0100 Message-Id: <20191204205241.5691-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: pjjO1q50PCS7WJU1IEvVDQ-1 X-Mimecast-Spam-Score: 0 Subject: [dpdk-dev] [PATCH] test/common: fix log2 check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" We recently started to get random failures on the common_autotest ut with clang on Ubuntu 16.04.6. Example: https://travis-ci.com/DPDK/dpdk/jobs/263177424 Wrong rte_log2_u64(0) val 0, expected ffffffff Test Failed The ut passes 0 to log2() to get an expected value. Quoting log2 / log(3) manual: If x is zero, then a pole error occurs, and the functions return -HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively. rte_log2_uXX helpers handle 0 as a special value and return 0. Let's have dedicated tests for this case. Fixes: 05c4345ef5c2 ("test: add unit test for integer log2 function") Cc: stable@dpdk.org Signed-off-by: David Marchand Acked-by: Aaron Conole --- app/test/test_common.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/test/test_common.c b/app/test/test_common.c index 2b856f8ba5..12bd1cad90 100644 --- a/app/test/test_common.c +++ b/app/test/test_common.c @@ -216,7 +216,19 @@ test_log2(void) const uint32_t max = 0x10000; const uint32_t step = 1; - for (i = 0; i < max; i = i + step) { + compare = rte_log2_u32(0); + if (compare != 0) { + printf("Wrong rte_log2_u32(0) val %x, expected 0\n", compare); + return TEST_FAILED; + } + + compare = rte_log2_u64(0); + if (compare != 0) { + printf("Wrong rte_log2_u64(0) val %x, expected 0\n", compare); + return TEST_FAILED; + } + + for (i = 1; i < max; i = i + step) { uint64_t i64; /* extend range for 64-bit */