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/[email protected]
[2] https://lore.kernel.org/linux-kselftest/[email protected]
v1 -> v2:
- Stop defining _GNU_SOURCE in related selftests
- Revert commit 809216233555
- Use 1024 in place of LINE_MAX to fix 38c957f07038
v1: https://lore.kernel.org/all/[email protected]/
Tao Su (2):
Revert "selftests/harness: remove use of LINE_MAX"
selftests/harness: Use 1024 in place of LINE_MAX
tools/testing/selftests/kselftest_harness.h | 11 +++--------
tools/testing/selftests/mm/mdwe_test.c | 1 -
2 files changed, 3 insertions(+), 9 deletions(-)
base-commit: 45db3ab70092637967967bfd8e6144017638563c
--
2.34.1
Android was seeing a compilation error because its C library does not
define LINE_MAX. Since LINE_MAX is only used to determine the size of
test_name[] and 1024 should be enough for the test name, use 1024
instead of LINE_MAX.
Fixes: 38c957f07038 ("selftests: kselftest_harness: generate test name once")
Signed-off-by: Tao Su <[email protected]>
---
tools/testing/selftests/kselftest_harness.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index ba3ddeda24bf..610642f50977 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -56,7 +56,6 @@
#include <asm/types.h>
#include <ctype.h>
#include <errno.h>
-#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@@ -1159,7 +1158,7 @@ void __run_test(struct __fixture_metadata *f,
struct __test_metadata *t)
{
struct __test_xfail *xfail;
- char test_name[LINE_MAX];
+ char test_name[1024];
const char *diagnostic;
/* reset test struct */
--
2.34.1
On Thu, May 09, 2024 at 01:31:13PM +0800, Tao Su wrote:
> Android was seeing a compilation error because its C library does not
> define LINE_MAX. Since LINE_MAX is only used to determine the size of
> test_name[] and 1024 should be enough for the test name, use 1024
> instead of LINE_MAX.
>
> Fixes: 38c957f07038 ("selftests: kselftest_harness: generate test name once")
> Signed-off-by: Tao Su <[email protected]>
Reviewed-by: Simon Horman <[email protected]>