linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/harness: remove use of LINE_MAX
@ 2024-04-11 23:19 Edward Liaw
  2024-04-11 23:34 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Edward Liaw @ 2024-04-11 23:19 UTC (permalink / raw)
  To: linux-kernel, Kees Cook, Andy Lutomirski, Will Drewry,
	Shuah Khan, Andrew Morton, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Peter Xu, David Hildenbrand,
	Axel Rasmussen, Mike Rapoport (IBM)
  Cc: linux-kselftest, kernel-team, Edward Liaw, linux-mm, llvm

Android was seeing a compliation error because its C library does not
define LINE_MAX.  This replaces the use of LINE_MAX / snprintf with
asprintf, which will change the behavior to not truncate the test name
if it is over 2048 chars long.

See also:
https://github.com/llvm/llvm-project/issues/88119

Signed-off-by: Edward Liaw <edliaw@google.com>
---
 tools/testing/selftests/kselftest_harness.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 4fd735e48ee7..70fedd2411ed 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -1156,7 +1156,7 @@ void __run_test(struct __fixture_metadata *f,
 		struct __test_metadata *t)
 {
 	struct __test_xfail *xfail;
-	char test_name[LINE_MAX];
+	char *test_name;
 	const char *diagnostic;
 
 	/* reset test struct */
@@ -1164,8 +1164,8 @@ void __run_test(struct __fixture_metadata *f,
 	t->trigger = 0;
 	memset(t->results->reason, 0, sizeof(t->results->reason));
 
-	snprintf(test_name, sizeof(test_name), "%s%s%s.%s",
-		 f->name, variant->name[0] ? "." : "", variant->name, t->name);
+	asprintf(&test_name, "%s%s%s.%s", f->name,
+	         variant->name[0] ? "." : "", variant->name, t->name);
 
 	ksft_print_msg(" RUN           %s ...\n", test_name);
 
@@ -1203,6 +1203,7 @@ void __run_test(struct __fixture_metadata *f,
 
 	ksft_test_result_code(t->exit_code, test_name,
 			      diagnostic ? "%s" : "", diagnostic);
+	free(test_name);
 }
 
 static int test_harness_run(int argc, char **argv)
-- 
2.44.0.683.g7961c838ac-goog



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/harness: remove use of LINE_MAX
  2024-04-11 23:19 [PATCH] selftests/harness: remove use of LINE_MAX Edward Liaw
@ 2024-04-11 23:34 ` Andrew Morton
  2024-04-12 19:30   ` Edward Liaw
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2024-04-11 23:34 UTC (permalink / raw)
  To: Edward Liaw
  Cc: linux-kernel, Kees Cook, Andy Lutomirski, Will Drewry,
	Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Peter Xu, David Hildenbrand, Axel Rasmussen,
	Mike Rapoport (IBM),
	linux-kselftest, kernel-team, linux-mm, llvm

On Thu, 11 Apr 2024 23:19:49 +0000 Edward Liaw <edliaw@google.com> wrote:

> Android was seeing a compliation error because its C library does not
> define LINE_MAX.  This replaces the use of LINE_MAX / snprintf with
> asprintf, which will change the behavior to not truncate the test name
> if it is over 2048 chars long.

Thanks, I'll grab and shall send it Linuswards for 6.9-rcX.

I added

Fixes: 38c957f07038 ("selftests: kselftest_harness: generate test name once")



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/harness: remove use of LINE_MAX
  2024-04-11 23:34 ` Andrew Morton
@ 2024-04-12 19:30   ` Edward Liaw
  2024-04-12 22:54     ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Edward Liaw @ 2024-04-12 19:30 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, Kees Cook, Andy Lutomirski, Will Drewry,
	Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Peter Xu, David Hildenbrand, Axel Rasmussen,
	Mike Rapoport (IBM),
	linux-kselftest, kernel-team, linux-mm, llvm

On Thu, Apr 11, 2024 at 4:34 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> Thanks, I'll grab and shall send it Linuswards for 6.9-rcX.
>
> I added
>
> Fixes: 38c957f07038 ("selftests: kselftest_harness: generate test name once")
>

Thanks, I just realized I forgot to remove the <limits.h> includes.
Should I send another patch for that or send a v2 of this one?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/harness: remove use of LINE_MAX
  2024-04-12 19:30   ` Edward Liaw
@ 2024-04-12 22:54     ` Andrew Morton
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2024-04-12 22:54 UTC (permalink / raw)
  To: Edward Liaw
  Cc: linux-kernel, Kees Cook, Andy Lutomirski, Will Drewry,
	Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Peter Xu, David Hildenbrand, Axel Rasmussen,
	Mike Rapoport (IBM),
	linux-kselftest, kernel-team, linux-mm, llvm

On Fri, 12 Apr 2024 12:30:15 -0700 Edward Liaw <edliaw@google.com> wrote:

> On Thu, Apr 11, 2024 at 4:34 PM Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > Thanks, I'll grab and shall send it Linuswards for 6.9-rcX.
> >
> > I added
> >
> > Fixes: 38c957f07038 ("selftests: kselftest_harness: generate test name once")
> >
> 
> Thanks, I just realized I forgot to remove the <limits.h> includes.
> Should I send another patch for that or send a v2 of this one?

I fixed it up, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-12 22:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-11 23:19 [PATCH] selftests/harness: remove use of LINE_MAX Edward Liaw
2024-04-11 23:34 ` Andrew Morton
2024-04-12 19:30   ` Edward Liaw
2024-04-12 22:54     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox