From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 759EDA04F2 for ; Wed, 4 Dec 2019 21:53:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3B17A1BF70; Wed, 4 Dec 2019 21:53:25 +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 BF13A1BECF for ; Wed, 4 Dec 2019 21:53:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575492803; 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=btp/hGuzFBc20TQBxNSK0Qaa8d0yRdHf4131+6/EKSG4DmL1lAFdj9ckchHWmFx7MOPMRi pF7DIPHsUMZDyWn7zDRDueVP0DgPjlUookW8FEGYrAv/CYeo8ZypgvFcsHa5JCd9ODO3A+ V46e5AVwqDoltFdq02ponbnaVnlUy6A= 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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] [PATCH] test/common: fix log2 check X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 --- 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) =09const uint32_t max =3D 0x10000; =09const uint32_t step =3D 1; =20 -=09for (i =3D 0; i < max; i =3D i + step) { +=09compare =3D rte_log2_u32(0); +=09if (compare !=3D 0) { +=09=09printf("Wrong rte_log2_u32(0) val %x, expected 0\n", compare); +=09=09return TEST_FAILED; +=09} + +=09compare =3D rte_log2_u64(0); +=09if (compare !=3D 0) { +=09=09printf("Wrong rte_log2_u64(0) val %x, expected 0\n", compare); +=09=09return TEST_FAILED; +=09} + +=09for (i =3D 1; i < max; i =3D i + step) { =09=09uint64_t i64; =20 =09=09/* extend range for 64-bit */ --=20 2.23.0