diff options
author | Gustavo A. R. Silva <gustavoars@kernel.org> | 2025-04-22 15:07:41 -0600 |
---|---|---|
committer | Kees Cook <kees@kernel.org> | 2025-05-08 09:42:05 -0700 |
commit | 6e6500e4e4a7f7431a6d7ab02a332ea5fca5c9fa (patch) | |
tree | 4ee1b6b50b88346749b1ed839908de82c71f0dd5 | |
parent | 190faecf64c54bb5f9d8f0ea2a6628078d0f2c83 (diff) |
kunit/overflow: Add tests for STACK_FLEX_ARRAY_SIZE() helper
Add a couple of tests for new STACK_FLEX_ARRAY_SIZE() helper.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/c127631a03cdd7f59bfa091b9666a93bf69d0322.1745355442.git.gustavoars@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
-rw-r--r-- | lib/tests/overflow_kunit.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/tests/overflow_kunit.c b/lib/tests/overflow_kunit.c index 894691b4411a..19cb03b25dc5 100644 --- a/lib/tests/overflow_kunit.c +++ b/lib/tests/overflow_kunit.c @@ -1210,6 +1210,10 @@ static void DEFINE_FLEX_test(struct kunit *test) KUNIT_EXPECT_EQ(test, __struct_size(empty->array), 0); KUNIT_EXPECT_EQ(test, __member_size(empty->array), 0); + KUNIT_EXPECT_EQ(test, STACK_FLEX_ARRAY_SIZE(two, array), 2); + KUNIT_EXPECT_EQ(test, STACK_FLEX_ARRAY_SIZE(eight, array), 8); + KUNIT_EXPECT_EQ(test, STACK_FLEX_ARRAY_SIZE(empty, array), 0); + /* If __counted_by is not being used, array size will have the on-stack size. */ if (!IS_ENABLED(CONFIG_CC_HAS_COUNTED_BY)) array_size_override = 2 * sizeof(s16); |