[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411231954.62156-1-edliaw@google.com>
Date: Thu, 11 Apr 2024 23:19:49 +0000
From: Edward Liaw <edliaw@...gle.com>
To: linux-kernel@...r.kernel.org, Kees Cook <keescook@...omium.org>,
Andy Lutomirski <luto@...capital.net>, Will Drewry <wad@...omium.org>, Shuah Khan <shuah@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>, Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>, Bill Wendling <morbo@...gle.com>,
Justin Stitt <justinstitt@...gle.com>, Peter Xu <peterx@...hat.com>,
David Hildenbrand <david@...hat.com>, Axel Rasmussen <axelrasmussen@...gle.com>,
"Mike Rapoport (IBM)" <rppt@...nel.org>
Cc: linux-kselftest@...r.kernel.org, kernel-team@...roid.com,
Edward Liaw <edliaw@...gle.com>, linux-mm@...ck.org, llvm@...ts.linux.dev
Subject: [PATCH] selftests/harness: remove use of LINE_MAX
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@...gle.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
Powered by blists - more mailing lists