+ revert-selftests-harness-remove-use-of-line_max.patch added to mm-nonmm-unstable branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: Revert "selftests/harness: remove use of LINE_MAX"
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     revert-selftests-harness-remove-use-of-line_max.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/revert-selftests-harness-remove-use-of-line_max.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Tao Su <tao1.su@xxxxxxxxxxxxxxx>
Subject: Revert "selftests/harness: remove use of LINE_MAX"
Date: Thu, 9 May 2024 13:31:12 +0800

Patch series "Selftests: Fix compilation warnings due to missing
_GNU_SOURCE definition", v2.

Since kselftest_harness.h introduces asprintf()[1], many selftests have
compilation warnings or errors due to missing _GNU_SOURCE definitions.

The issue stems from a lack of a LINE_MAX definition in Android (see
commit 38c957f07038), which is the reason why asprintf() was introduced. 
We tried adding _GNU_SOURCE definitions to more selftests to fix, but
asprintf() may continue to cause problems, and since it is quite late in
the 6.9 cycle, we would like to revert 809216233555 first to provide
testing for forks[2].

[1] https://lore.kernel.org/all/20240411231954.62156-1-edliaw@xxxxxxxxxx
[2] https://lore.kernel.org/linux-kselftest/ZjuA3aY_iHkjP7bQ@xxxxxxxxxx


This patch (of 2):

This reverts commit 8092162335554c8ef5e7f50eff68aa9cfbdbf865.

asprintf() is declared in stdio.h when defining _GNU_SOURCE, but stdio.h
is so common that many files don't define _GNU_SOURCE before including
stdio.h, and defining _GNU_SOURCE after including stdio.h will no longer
take effect, which causes warnings or even errors during compilation in
many selftests.

Revert 'commit 809216233555 ("selftests/harness: remove use of LINE_MAX")'
as that came in quite late in the 6.9 cycle.

Link: https://lkml.kernel.org/r/20240509053113.43462-1-tao1.su@xxxxxxxxxxxxxxx
Link: https://lore.kernel.org/linux-kselftest/ZjuA3aY_iHkjP7bQ@xxxxxxxxxx/
Link: https://lkml.kernel.org/r/20240509053113.43462-2-tao1.su@xxxxxxxxxxxxxxx
Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Signed-off-by: Tao Su <tao1.su@xxxxxxxxxxxxxxx>
Cc: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>
Cc: Bongsu Jeon <bongsu.jeon@xxxxxxxxxxx>
Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: David S. Miller <davem@xxxxxxxxxxxxx>
Cc: Edward Liaw <edliaw@xxxxxxxxxx>
Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
Cc: Ivan Orlov <ivan.orlov0322@xxxxxxxxx>
Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
Cc: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
Cc: Jaroslav Kysela <perex@xxxxxxxx>
Cc: Mark Brown <broonie@xxxxxxxxxx>
Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Cc: Sean Christopherson <seanjc@xxxxxxxxxx>
Cc: Shuah Khan <shuah@xxxxxxxxxx>
Cc: Takashi Iwai <tiwai@xxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 tools/testing/selftests/kselftest_harness.h |   12 ++++--------
 tools/testing/selftests/mm/mdwe_test.c      |    1 -
 2 files changed, 4 insertions(+), 9 deletions(-)

--- a/tools/testing/selftests/kselftest_harness.h~revert-selftests-harness-remove-use-of-line_max
+++ a/tools/testing/selftests/kselftest_harness.h
@@ -56,6 +56,7 @@
 #include <asm/types.h>
 #include <ctype.h>
 #include <errno.h>
+#include <limits.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -1155,7 +1156,7 @@ void __run_test(struct __fixture_metadat
 		struct __test_metadata *t)
 {
 	struct __test_xfail *xfail;
-	char *test_name;
+	char test_name[LINE_MAX];
 	const char *diagnostic;
 
 	/* reset test struct */
@@ -1163,12 +1164,8 @@ void __run_test(struct __fixture_metadat
 	t->trigger = 0;
 	memset(t->results->reason, 0, sizeof(t->results->reason));
 
-	if (asprintf(&test_name, "%s%s%s.%s", f->name,
-		variant->name[0] ? "." : "", variant->name, t->name) == -1) {
-		ksft_print_msg("ERROR ALLOCATING MEMORY\n");
-		t->exit_code = KSFT_FAIL;
-		_exit(t->exit_code);
-	}
+	snprintf(test_name, sizeof(test_name), "%s%s%s.%s",
+		 f->name, variant->name[0] ? "." : "", variant->name, t->name);
 
 	ksft_print_msg(" RUN           %s ...\n", test_name);
 
@@ -1206,7 +1203,6 @@ void __run_test(struct __fixture_metadat
 
 	ksft_test_result_code(t->exit_code, test_name,
 			      diagnostic ? "%s" : "", diagnostic);
-	free(test_name);
 }
 
 static int test_harness_run(int argc, char **argv)
--- a/tools/testing/selftests/mm/mdwe_test.c~revert-selftests-harness-remove-use-of-line_max
+++ a/tools/testing/selftests/mm/mdwe_test.c
@@ -7,7 +7,6 @@
 #include <linux/mman.h>
 #include <linux/prctl.h>
 
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/auxv.h>
_

Patches currently in -mm which might be from tao1.su@xxxxxxxxxxxxxxx are

revert-selftests-harness-remove-use-of-line_max.patch
selftests-harness-use-1024-in-place-of-line_max.patch





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux