Skip to content

Commit 6e6500e

Browse files
GustavoARSilvakees
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/c127631a03cdd7f59bfa091b9666a93bf69d0322.1745355442.git.gustavoars@kernel.org Signed-off-by: Kees Cook <[email protected]>
1 parent 190faec commit 6e6500e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/tests/overflow_kunit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,10 @@ static void DEFINE_FLEX_test(struct kunit *test)
12101210
KUNIT_EXPECT_EQ(test, __struct_size(empty->array), 0);
12111211
KUNIT_EXPECT_EQ(test, __member_size(empty->array), 0);
12121212

1213+
KUNIT_EXPECT_EQ(test, STACK_FLEX_ARRAY_SIZE(two, array), 2);
1214+
KUNIT_EXPECT_EQ(test, STACK_FLEX_ARRAY_SIZE(eight, array), 8);
1215+
KUNIT_EXPECT_EQ(test, STACK_FLEX_ARRAY_SIZE(empty, array), 0);
1216+
12131217
/* If __counted_by is not being used, array size will have the on-stack size. */
12141218
if (!IS_ENABLED(CONFIG_CC_HAS_COUNTED_BY))
12151219
array_size_override = 2 * sizeof(s16);

0 commit comments

Comments
 (0)