@@ -199,29 +199,19 @@ ext4_mb_mark_context_stub(handle_t *handle, struct super_block *sb, bool state,
199
199
return 0 ;
200
200
}
201
201
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
207
202
#define TEST_GOAL_GROUP 1
208
203
static int mbt_kunit_init (struct kunit * test )
209
204
{
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 );
217
207
struct super_block * sb ;
218
208
int ret ;
219
209
220
210
sb = mbt_ext4_alloc_super_block ();
221
211
if (sb == NULL )
222
212
return - ENOMEM ;
223
213
224
- mbt_init_sb_layout (sb , & layout );
214
+ mbt_init_sb_layout (sb , layout );
225
215
226
216
ret = mbt_ctx_init (sb );
227
217
if (ret != 0 ) {
@@ -307,9 +297,43 @@ static void test_new_blocks_simple(struct kunit *test)
307
297
"unexpectedly get block when no block is available" );
308
298
}
309
299
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 );
310
334
311
335
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 ),
313
337
{}
314
338
};
315
339
0 commit comments