Skip to content

Commit 28b95ee

Browse files
Kemeng Shitytso
authored andcommitted
ext4: run mballoc test with different layouts setting
Use KUNIT_CASE_PARAM to run mballoc test with different layouts setting. Signed-off-by: Kemeng Shi <[email protected]> Reviewed-by: "Ritesh Harjani (IBM)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 7c9fa39 commit 28b95ee

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

fs/ext4/mballoc-test.c

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,29 +199,19 @@ ext4_mb_mark_context_stub(handle_t *handle, struct super_block *sb, bool state,
199199
return 0;
200200
}
201201

202-
#define TEST_BLOCKSIZE_BITS 10
203-
#define TEST_CLUSTER_BITS 3
204-
#define TEST_BLOCKS_PER_GROUP 8192
205-
#define TEST_GROUP_COUNT 4
206-
#define TEST_DESC_SIZE 64
207202
#define TEST_GOAL_GROUP 1
208203
static int mbt_kunit_init(struct kunit *test)
209204
{
210-
struct mbt_ext4_block_layout layout = {
211-
.blocksize_bits = TEST_BLOCKSIZE_BITS,
212-
.cluster_bits = TEST_CLUSTER_BITS,
213-
.blocks_per_group = TEST_BLOCKS_PER_GROUP,
214-
.group_count = TEST_GROUP_COUNT,
215-
.desc_size = TEST_DESC_SIZE,
216-
};
205+
struct mbt_ext4_block_layout *layout =
206+
(struct mbt_ext4_block_layout *)(test->param_value);
217207
struct super_block *sb;
218208
int ret;
219209

220210
sb = mbt_ext4_alloc_super_block();
221211
if (sb == NULL)
222212
return -ENOMEM;
223213

224-
mbt_init_sb_layout(sb, &layout);
214+
mbt_init_sb_layout(sb, layout);
225215

226216
ret = mbt_ctx_init(sb);
227217
if (ret != 0) {
@@ -307,9 +297,43 @@ static void test_new_blocks_simple(struct kunit *test)
307297
"unexpectedly get block when no block is available");
308298
}
309299

300+
static const struct mbt_ext4_block_layout mbt_test_layouts[] = {
301+
{
302+
.blocksize_bits = 10,
303+
.cluster_bits = 3,
304+
.blocks_per_group = 8192,
305+
.group_count = 4,
306+
.desc_size = 64,
307+
},
308+
{
309+
.blocksize_bits = 12,
310+
.cluster_bits = 3,
311+
.blocks_per_group = 8192,
312+
.group_count = 4,
313+
.desc_size = 64,
314+
},
315+
{
316+
.blocksize_bits = 16,
317+
.cluster_bits = 3,
318+
.blocks_per_group = 8192,
319+
.group_count = 4,
320+
.desc_size = 64,
321+
},
322+
};
323+
324+
static void mbt_show_layout(const struct mbt_ext4_block_layout *layout,
325+
char *desc)
326+
{
327+
snprintf(desc, KUNIT_PARAM_DESC_SIZE, "block_bits=%d cluster_bits=%d "
328+
"blocks_per_group=%d group_count=%d desc_size=%d\n",
329+
layout->blocksize_bits, layout->cluster_bits,
330+
layout->blocks_per_group, layout->group_count,
331+
layout->desc_size);
332+
}
333+
KUNIT_ARRAY_PARAM(mbt_layouts, mbt_test_layouts, mbt_show_layout);
310334

311335
static struct kunit_case mbt_test_cases[] = {
312-
KUNIT_CASE(test_new_blocks_simple),
336+
KUNIT_CASE_PARAM(test_new_blocks_simple, mbt_layouts_gen_params),
313337
{}
314338
};
315339

0 commit comments

Comments
 (0)