[LTP] [PATCH 1/1] tst_test: Fix tests using device without .filesystems
Petr Vorel
pvorel@suse.cz
Tue Jul 9 13:56:09 CEST 2024
> Hi!
> > > + fs = fs ? &dummy : fs;
> This is a stupid typo, it should be fs = fs ? fs : &dummy instead.
Ah, obviously. I was blind not notice this.
> > This looks more elegant, but I get coredump.
> > I also think you need to have count_fs_descs() <= 1 and maybe define fs_type
> > (not sure about it).
> You need count_fs_descs() <= 1 but the fs type is used from the
> tst_device structure instead. So the whole patch should be:
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index b49c248ae..c6ed5d562 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 ? fs: &dummy;
nit: FYI shorten syntax works even on 4.8.5:
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)
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Tested-by: Petr Vorel <pvorel@suse.cz>
Feel free to merge it.
Kind regards,
Petr
More information about the ltp
mailing list