This reverts commit a571a9a1b120264e24b41eddf1ac5140131bfa84.
The commit in question breaks kunit for older compilers:
$ gcc --version
gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5)
$ ./tools/testing/kunit/kunit.py run --alltests --json --arch=x86_64
Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=x86_64 O=.kunit olddefconfig
ERROR:root:Not all Kconfig options selected in kunitconfig were in the generated .config.
This is probably due to unsatisfied dependencies.
Missing: CONFIG_INIT_STACK_ALL_PATTERN=y
Link: https://lore.kernel.org/20250529083811.778bc31b@kernel.org
Fixes: a571a9a1b120 ("kunit: configs: Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests")
Signed-off-by: Jakub Kicinski <kuba(a)kernel.org>
---
I'd like to take this in via netdev since it fixes our CI.
We'll send it to Linus next week.
CC: brendan.higgins(a)linux.dev
CC: davidgow(a)google.com
CC: rmoar(a)google.com
CC: broonie(a)kernel.org
CC: rf(a)opensource.cirrus.com
CC: mic(a)digikod.net
CC: skhan(a)linuxfoundation.org
CC: linux-kselftest(a)vger.kernel.org
CC: kunit-dev(a)googlegroups.com
---
tools/testing/kunit/configs/all_tests.config | 1 -
1 file changed, 1 deletion(-)
diff --git a/tools/testing/kunit/configs/all_tests.config b/tools/testing/kunit/configs/all_tests.config
index 48b132cd9d2a..2f093048d985 100644
--- a/tools/testing/kunit/configs/all_tests.config
+++ b/tools/testing/kunit/configs/all_tests.config
@@ -10,7 +10,6 @@ CONFIG_KUNIT_EXAMPLE_TEST=y
CONFIG_KUNIT_ALL_TESTS=y
CONFIG_FORTIFY_SOURCE=y
-CONFIG_INIT_STACK_ALL_PATTERN=y
CONFIG_IIO=y
--
2.49.0
The newly added anon_inode_test test fails to build due to attempting to
include a nonexisting overlayfs/wrapper.h:
anon_inode_test.c:10:10: fatal error: overlayfs/wrappers.h: No such file or directory
10 | #include "overlayfs/wrappers.h"
| ^~~~~~~~~~~~~~~~~~~~~~
This is due to 0bd92b9fe538 ("selftests/filesystems: move wrapper.h out
of overlayfs subdir") which was added in the vfs-6.16.selftests branch
which was based on -rc5 and did not contain the newly added test so once
things were merged into mainline the build started failing - both
parent commits are fine.
Fixes: 3e406741b1989 ("Merge tag 'vfs-6.16-rc1.selftests' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs")
Signed-off-by: Mark Brown <broonie(a)kernel.org>
---
Changes in v2:
- Rebase onto mainline and adjust fixes commit now the two branches got
merged there.
- Link to v1: https://lore.kernel.org/r/20250518-selftests-anon-inode-build-v1-1-71eff818…
---
tools/testing/selftests/filesystems/anon_inode_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/filesystems/anon_inode_test.c b/tools/testing/selftests/filesystems/anon_inode_test.c
index e8e0ef1460d2..73e0a4d4fb2f 100644
--- a/tools/testing/selftests/filesystems/anon_inode_test.c
+++ b/tools/testing/selftests/filesystems/anon_inode_test.c
@@ -7,7 +7,7 @@
#include <sys/stat.h>
#include "../kselftest_harness.h"
-#include "overlayfs/wrappers.h"
+#include "wrappers.h"
TEST(anon_inode_no_chown)
{
---
base-commit: f66bc387efbee59978e076ce9bf123ac353b389c
change-id: 20250516-selftests-anon-inode-build-007e206e8422
Best regards,
--
Mark Brown <broonie(a)kernel.org>
When CONFIG_RANDSTRUCT is not enabled, all randstruct tests are skipped.
Move this logic from run-time to config-time, to avoid people building
and running tests that do not do anything.
Fixes: b370f7eacdcfe1dd ("lib/tests: Add randstruct KUnit test")
Signed-off-by: Geert Uytterhoeven <geert(a)linux-m68k.org>
---
FTR, after adding "select HAVE_GCC_PLUGINS" to arch/m68k/Kconfig and
installing gcc-13-plugin-dev-m68k-linux-gnu, I could enable
CONFIG_RANDSTRUCT_FULL and run the tests (all passed!), so probably I
should send a patch to select HAVE_GCC_PLUGINS?
---
lib/Kconfig.debug | 4 ++--
lib/tests/randstruct_kunit.c | 9 ---------
2 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index a8b4febad716a4be..407f2ed7fcb3e94c 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -2895,10 +2895,10 @@ config OVERFLOW_KUNIT_TEST
config RANDSTRUCT_KUNIT_TEST
tristate "Test randstruct structure layout randomization at runtime" if !KUNIT_ALL_TESTS
depends on KUNIT
+ depends on RANDSTRUCT
default KUNIT_ALL_TESTS
help
- Builds unit tests for the checking CONFIG_RANDSTRUCT=y, which
- randomizes structure layouts.
+ Builds unit tests for checking structure layout randomization.
config STACKINIT_KUNIT_TEST
tristate "Test level of stack variable initialization" if !KUNIT_ALL_TESTS
diff --git a/lib/tests/randstruct_kunit.c b/lib/tests/randstruct_kunit.c
index f3a2d63c4cfbe7dc..2c95eca76d2411bc 100644
--- a/lib/tests/randstruct_kunit.c
+++ b/lib/tests/randstruct_kunit.c
@@ -305,14 +305,6 @@ static void randstruct_initializers(struct kunit *test)
#undef init_members
}
-static int randstruct_test_init(struct kunit *test)
-{
- if (!IS_ENABLED(CONFIG_RANDSTRUCT))
- kunit_skip(test, "Not built with CONFIG_RANDSTRUCT=y");
-
- return 0;
-}
-
static struct kunit_case randstruct_test_cases[] = {
KUNIT_CASE(randstruct_layout_same),
KUNIT_CASE(randstruct_layout_mixed),
@@ -324,7 +316,6 @@ static struct kunit_case randstruct_test_cases[] = {
static struct kunit_suite randstruct_test_suite = {
.name = "randstruct",
- .init = randstruct_test_init,
.test_cases = randstruct_test_cases,
};
--
2.43.0
When CONFIG_FORTIFY_SOURCE is not enabled, all fortify tests are
skipped. Move this logic from run-time to config-time, to avoid people
building and running tests that do not do anything.
This basically reverts commit 1a78f8cb5daac774 ("fortify: Allow KUnit
test to build without FORTIFY") in v6.9, which was v3 of commit
a9dc8d0442294b42 ("fortify: Allow KUnit test to build without FORTIFY")
in v6.5, which was quickly reverted in commit 5e2956ee46244ffb ("Revert
"fortify: Allow KUnit test to build without FORTIFY"").
Signed-off-by: Geert Uytterhoeven <geert(a)linux-m68k.org>
---
Let's keep on playing whack-a-mole ;-)
---
lib/Kconfig.debug | 1 +
lib/tests/fortify_kunit.c | 8 --------
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 407f2ed7fcb3e94c..ca5afd192c9fbf51 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -2912,6 +2912,7 @@ config STACKINIT_KUNIT_TEST
config FORTIFY_KUNIT_TEST
tristate "Test fortified str*() and mem*() function internals at runtime" if !KUNIT_ALL_TESTS
depends on KUNIT
+ depends on FORTIFY_SOURCE
default KUNIT_ALL_TESTS
help
Builds unit tests for checking internals of FORTIFY_SOURCE as used
diff --git a/lib/tests/fortify_kunit.c b/lib/tests/fortify_kunit.c
index 29ffc62a71e3f968..10b0e1b12cdc3ae2 100644
--- a/lib/tests/fortify_kunit.c
+++ b/lib/tests/fortify_kunit.c
@@ -48,11 +48,6 @@ void fortify_add_kunit_error(int write);
#include <linux/string.h>
#include <linux/vmalloc.h>
-/* Handle being built without CONFIG_FORTIFY_SOURCE */
-#ifndef __compiletime_strlen
-# define __compiletime_strlen __builtin_strlen
-#endif
-
static struct kunit_resource read_resource;
static struct kunit_resource write_resource;
static int fortify_read_overflows;
@@ -1071,9 +1066,6 @@ static void fortify_test_kmemdup(struct kunit *test)
static int fortify_test_init(struct kunit *test)
{
- if (!IS_ENABLED(CONFIG_FORTIFY_SOURCE))
- kunit_skip(test, "Not built with CONFIG_FORTIFY_SOURCE=y");
-
fortify_read_overflows = 0;
kunit_add_named_resource(test, NULL, NULL, &read_resource,
"fortify_read_overflows",
--
2.43.0