lib/tests: split randstruct initializer tests
PATCH 1/1 lib/tests: split randstruct initializer tests
From: Arnd Bergmann <[email protected]>
kunit code tents to cause problems with stack usage, especially when sanitizers are enabled.
lib/tests/randstruct_kunit.c:306:1: error: the frame size of 1520 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]
Splitting up the randstruct_initializers() function into two halves helps since each side now stays below 1KB of stack even with sanitizers enabled.
Fixes b370f7eacdcf ("lib/tests: Add randstruct KUnit test")
Signed-off-by Arnd Bergmann <[email protected]>
--- lib/tests/randstruct_kunit.c | 65 +++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 23 deletions(-)
lib/tests/randstruct_kunit.c +42 -23
@@ -249,16 +249,6 @@ static void randstruct_initializers(struct kunit *test)struct randstruct_mixed_shuffled mixed_shuffled = { init_members }; -struct contains_randstruct_untouched contains_untouched = { - .untouched = { - init_members - }, - }; -struct contains_randstruct_shuffled contains_shuffled = { - .shuffled = { - init_members - }, - };#define func_member (x, ignored) \ .x = func_##x,struct randstruct_funcs_untouched funcs_untouched = {
@@ -274,6 +264,47 @@ static void randstruct_initializers(struct kunit *test)init_members }); +test_check_mixed_init (test,"named" , &mixed_untouched, &mixed_shuffled); +test_check_mixed_init (test,"unnamed" , &mixed_untouched, + &(struct randstruct_mixed_shuffled ){ + init_members + }); + +test_check_funcs_init (test,"named" , &funcs_untouched, &funcs_shuffled); +test_check_funcs_init (test,"unnamed" , &funcs_untouched, + &(struct randstruct_funcs_shuffled ){ +DO_MANY_MEMBERS (func_member) + }); + +#undef func_member +#undef init_members +} + +static void randstruct_contains_initializers (struct kunit *test) +{ +#define init_members \ + .a = 1, \ + .b = 3, \ + .c = 5, \ + .d = 7, \ + .e = 11, \ + .f = 13, \ + .g = 17, \ + .h = 19, +struct contains_randstruct_untouched contains_untouched = { + .untouched = { + init_members + }, + }; +struct contains_randstruct_shuffled contains_shuffled = { + .shuffled = { + init_members + }, + }; +struct randstruct_shuffled shuffled = { + init_members + }; +test_check_contained_init (test,"named" , &contains_untouched, &contains_shuffled); test_check_contained_init(test, "unnamed", &contains_untouched, &(struct contains_randstruct_shuffled){
@@ -289,19 +320,6 @@ static void randstruct_initializers(struct kunit *test) .shuffled = shuffled, }); -test_check_mixed_init (test,"named" , &mixed_untouched, &mixed_shuffled); -test_check_mixed_init (test,"unnamed" , &mixed_untouched, - &(struct randstruct_mixed_shuffled ){ - init_members - }); - -test_check_funcs_init (test,"named" , &funcs_untouched, &funcs_shuffled); -test_check_funcs_init (test,"unnamed" , &funcs_untouched, - &(struct randstruct_funcs_shuffled ){ -DO_MANY_MEMBERS (func_member) - }); - -#undef func_member#undef init_members }
@@ -319,6 +337,7 @@ static struct kunit_case randstruct_test_cases[] = {KUNIT_CASE (randstruct_layout_fptr),KUNIT_CASE (randstruct_layout_fptr_deep),KUNIT_CASE (randstruct_initializers), + KUNIT_CASE(randstruct_contains_initializers), {} };
Signature · 1 line
2.39.5