diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2023-05-18 11:52:41 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2023-05-18 11:52:41 +1000 |
commit | 8014ff2d386cdaab7295ff813ba03e8bca8d6333 (patch) | |
tree | 8798c76b4fa9daa8e87c1edb954f49310b2ff35b /lib/fortify_kunit.c | |
parent | 71f38de3915c7a402e52f624dcc199c461d7b80d (diff) | |
parent | 55c84a5cf2c72a821719823ef2ebef01b119025b (diff) | |
download | linux-next-8014ff2d386cdaab7295ff813ba03e8bca8d6333.tar.gz |
Merge branch 'for-next/kspp' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
Diffstat (limited to 'lib/fortify_kunit.c')
-rw-r--r-- | lib/fortify_kunit.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/fortify_kunit.c b/lib/fortify_kunit.c index c8c33cbaae9e..524132f33cf0 100644 --- a/lib/fortify_kunit.c +++ b/lib/fortify_kunit.c @@ -25,6 +25,11 @@ static const char array_of_10[] = "this is 10"; static const char *ptr_of_11 = "this is 11!"; static char array_unknown[] = "compiler thinks I might change"; +/* Handle being built without CONFIG_FORTIFY_SOURCE */ +#ifndef __compiletime_strlen +# define __compiletime_strlen __builtin_strlen +#endif + static void known_sizes_test(struct kunit *test) { KUNIT_EXPECT_EQ(test, __compiletime_strlen("88888888"), 8); @@ -307,6 +312,14 @@ DEFINE_ALLOC_SIZE_TEST_PAIR(kvmalloc) } while (0) DEFINE_ALLOC_SIZE_TEST_PAIR(devm_kmalloc) +static int fortify_test_init(struct kunit *test) +{ + if (!IS_ENABLED(CONFIG_FORTIFY_SOURCE)) + kunit_skip(test, "Not built with CONFIG_FORTIFY_SOURCE=y"); + + return 0; +} + static struct kunit_case fortify_test_cases[] = { KUNIT_CASE(known_sizes_test), KUNIT_CASE(control_flow_split_test), @@ -323,6 +336,7 @@ static struct kunit_case fortify_test_cases[] = { static struct kunit_suite fortify_test_suite = { .name = "fortify", + .init = fortify_test_init, .test_cases = fortify_test_cases, }; |