Skip to content

Commit 5e2956e

Browse files
committed
Revert "fortify: Allow KUnit test to build without FORTIFY"
This reverts commit a9dc8d0. The standard for KUnit is to not build tests at all when required functionality is missing, rather than doing test "skip". Restore this for the fortify tests, so that architectures without CONFIG_ARCH_HAS_FORTIFY_SOURCE do not emit unsolvable warnings. Reported-by: Geert Uytterhoeven <[email protected]> Closes: https://lore.kernel.org/all/CAMuHMdUrxOEroHVUt7-mAnKSBjY=a-D3jr+XiAifuwv06Ob9Pw@mail.gmail.com Signed-off-by: Kees Cook <[email protected]>
1 parent 47f0461 commit 5e2956e

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

lib/Kconfig.debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2645,7 +2645,7 @@ config STACKINIT_KUNIT_TEST
26452645

26462646
config FORTIFY_KUNIT_TEST
26472647
tristate "Test fortified str*() and mem*() function internals at runtime" if !KUNIT_ALL_TESTS
2648-
depends on KUNIT
2648+
depends on KUNIT && FORTIFY_SOURCE
26492649
default KUNIT_ALL_TESTS
26502650
help
26512651
Builds unit tests for checking internals of FORTIFY_SOURCE as used

lib/fortify_kunit.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ static const char array_of_10[] = "this is 10";
2525
static const char *ptr_of_11 = "this is 11!";
2626
static char array_unknown[] = "compiler thinks I might change";
2727

28-
/* Handle being built without CONFIG_FORTIFY_SOURCE */
29-
#ifndef __compiletime_strlen
30-
# define __compiletime_strlen __builtin_strlen
31-
#endif
32-
3328
static void known_sizes_test(struct kunit *test)
3429
{
3530
KUNIT_EXPECT_EQ(test, __compiletime_strlen("88888888"), 8);
@@ -312,14 +307,6 @@ DEFINE_ALLOC_SIZE_TEST_PAIR(kvmalloc)
312307
} while (0)
313308
DEFINE_ALLOC_SIZE_TEST_PAIR(devm_kmalloc)
314309

315-
static int fortify_test_init(struct kunit *test)
316-
{
317-
if (!IS_ENABLED(CONFIG_FORTIFY_SOURCE))
318-
kunit_skip(test, "Not built with CONFIG_FORTIFY_SOURCE=y");
319-
320-
return 0;
321-
}
322-
323310
static struct kunit_case fortify_test_cases[] = {
324311
KUNIT_CASE(known_sizes_test),
325312
KUNIT_CASE(control_flow_split_test),
@@ -336,7 +323,6 @@ static struct kunit_case fortify_test_cases[] = {
336323

337324
static struct kunit_suite fortify_test_suite = {
338325
.name = "fortify",
339-
.init = fortify_test_init,
340326
.test_cases = fortify_test_cases,
341327
};
342328

0 commit comments

Comments
 (0)