From 66678169356df6c4166a48e0da1a65baf6da1f3d Mon Sep 17 00:00:00 2001 From: Cyril Hrubis Date: Tue, 9 Jul 2024 14:37:03 +0200 Subject: [PATCH] tst_test: Fix test using a device without .filesystems cce618891 introduced a regression for tests which use the test loop device (e.g. .mount_device = 1 or .format_device = 1) without .filesystems array (execveat03, ioctl04, inotify0[378], fanotify10, mount02, umount0[1-3], umount2_02). Call in that case prepare_device() with the default filesystem type. Fixes: cce618891 ("lib: tst_test: Add per filesystem mkfs and mount opts") Signed-off-by: Cyril Hrubis Signed-off-by: Petr Vorel Reviewed-by: Petr Vorel Tested-by: Petr Vorel --- lib/tst_test.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/tst_test.c b/lib/tst_test.c index b49c248aee7..e5bc5bf4da1 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -1101,6 +1101,9 @@ static void prepare_device(struct tst_fs *fs) { const char *mnt_data; char buf[1024]; + struct tst_fs dummy = {}; + + fs = fs ?: &dummy; const char *const extra[] = {fs->mkfs_size_opt, NULL}; @@ -1355,8 +1358,8 @@ static void do_setup(int argc, char *argv[]) tdev.fs_type = default_fs_type(); - if (!tst_test->all_filesystems && count_fs_descs() == 1) - prepare_device(&tst_test->filesystems[0]); + if (!tst_test->all_filesystems && count_fs_descs() <= 1) + prepare_device(tst_test->filesystems); } if (tst_test->needs_overlay && !tst_test->mount_device)