patch 'test/eal: fix loop coverage for alignment macros' has been queued to stable release 23.11.3

Xueming Li xuemingl at nvidia.com
Sat Dec 7 09:00:50 CET 2024


Hi,

FYI, your patch has been queued to stable release 23.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/10/24. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=d3a710498373cfe91bbd48ad335fe4bc9c076935

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From d3a710498373cfe91bbd48ad335fe4bc9c076935 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Thu, 21 Nov 2024 10:23:27 -0800
Subject: [PATCH] test/eal: fix loop coverage for alignment macros
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit b3e64fe596a3117edf6d3a79a6c5238a9b92dc4f ]

The test loop was much shorter than desired because when
MAX_NUM is defined with out paren's the divide operator /
takes precedence over shift.

But when MAX_NUM is fixed, some tests take too long
and have to be modified to avoid running over full N^2
space of 1<<20.

Note: this is a very old bug, goes back to 2013.

Link: https://pvs-studio.com/en/blog/posts/cpp/1179/
Fixes: 1fb8b07ee511 ("app: add some tests")

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
---
 app/test/test_common.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/app/test/test_common.c b/app/test/test_common.c
index 21eb2285e1..6dbd7fc9a9 100644
--- a/app/test/test_common.c
+++ b/app/test/test_common.c
@@ -9,11 +9,12 @@
 #include <rte_common.h>
 #include <rte_bitops.h>
 #include <rte_hexdump.h>
+#include <rte_random.h>
 #include <rte_pause.h>

 #include "test.h"

-#define MAX_NUM 1 << 20
+#define MAX_NUM (1 << 20)

 #define FAIL(x)\
 	{printf(x "() test failed!\n");\
@@ -218,19 +219,21 @@ test_align(void)
 		}
 	}

-	for (p = 1; p <= MAX_NUM / 2; p++) {
-		for (i = 1; i <= MAX_NUM / 2; i++) {
-			val = RTE_ALIGN_MUL_CEIL(i, p);
-			if (val % p != 0 || val < i)
-				FAIL_ALIGN("RTE_ALIGN_MUL_CEIL", i, p);
-			val = RTE_ALIGN_MUL_FLOOR(i, p);
-			if (val % p != 0 || val > i)
-				FAIL_ALIGN("RTE_ALIGN_MUL_FLOOR", i, p);
-			val = RTE_ALIGN_MUL_NEAR(i, p);
-			if (val % p != 0 || ((val != RTE_ALIGN_MUL_CEIL(i, p))
-				& (val != RTE_ALIGN_MUL_FLOOR(i, p))))
-				FAIL_ALIGN("RTE_ALIGN_MUL_NEAR", i, p);
-		}
+	/* testing the whole space of 2^20^2 takes too long. */
+	for (j = 1; j <= MAX_NUM ; j++) {
+		i = rte_rand_max(MAX_NUM - 1) + 1;
+		p = rte_rand_max(MAX_NUM - 1) + 1;
+
+		val = RTE_ALIGN_MUL_CEIL(i, p);
+		if (val % p != 0 || val < i)
+			FAIL_ALIGN("RTE_ALIGN_MUL_CEIL", i, p);
+		val = RTE_ALIGN_MUL_FLOOR(i, p);
+		if (val % p != 0 || val > i)
+			FAIL_ALIGN("RTE_ALIGN_MUL_FLOOR", i, p);
+		val = RTE_ALIGN_MUL_NEAR(i, p);
+		if (val % p != 0 || ((val != RTE_ALIGN_MUL_CEIL(i, p))
+				     & (val != RTE_ALIGN_MUL_FLOOR(i, p))))
+			FAIL_ALIGN("RTE_ALIGN_MUL_NEAR", i, p);
 	}

 	return 0;
--
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-12-06 23:26:47.120887608 +0800
+++ 0092-test-eal-fix-loop-coverage-for-alignment-macros.patch	2024-12-06 23:26:44.103044826 +0800
@@ -1 +1 @@
-From b3e64fe596a3117edf6d3a79a6c5238a9b92dc4f Mon Sep 17 00:00:00 2001
+From d3a710498373cfe91bbd48ad335fe4bc9c076935 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit b3e64fe596a3117edf6d3a79a6c5238a9b92dc4f ]
@@ -18 +20,0 @@
-Cc: stable at dpdk.org


More information about the stable mailing list