diff options
author | Xiao Yang <yangx.jy@cn.fujitsu.com> | 2018-07-20 18:40:12 +0800 |
---|---|---|
committer | Cyril Hrubis <chrubis@suse.cz> | 2018-07-23 16:51:44 +0200 |
commit | d1e84cabf078b22cf070688a8a2dec74de309065 (patch) | |
tree | 85344fdb5039d771a522ffc18e6ffcdaef3fdd13 /testcases/lib | |
parent | 69effa05b8a4a9c53beb10d08cbc74875671cc1b (diff) |
lib: Factor out is_supported() && Add tst_supported_fs
1) Factor out is_supported() and rename it as tst_fs_is_supported(),
so that some tests can check a specified filesystem by it.
2) Add tst_supported_fs binary for shell tests to check a specified
filesystem or all supported fielsystems.
PS: hint messages from tst_supported_fs binary is targeted as stderr,
so we can filter them by "2> /dev/null".
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Diffstat (limited to 'testcases/lib')
-rw-r--r-- | testcases/lib/Makefile | 2 | ||||
-rw-r--r-- | testcases/lib/tst_supported_fs.c | 47 |
2 files changed, 48 insertions, 1 deletions
diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile index 77b7b2ef1..3547e16dc 100644 --- a/testcases/lib/Makefile +++ b/testcases/lib/Makefile @@ -28,6 +28,6 @@ INSTALL_TARGETS := *.sh MAKE_TARGETS := tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\ tst_device tst_net_iface_prefix tst_net_ip_prefix tst_net_vars\ - tst_getconf + tst_getconf tst_supported_fs include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c new file mode 100644 index 000000000..ebebcbb37 --- /dev/null +++ b/testcases/lib/tst_supported_fs.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. + * Author: Xiao Yang <yangx.jy@cn.fujitsu.com> + */ + +#include <stdio.h> +#include <string.h> + +#define TST_NO_DEFAULT_MAIN +#include "tst_test.h" +#include "tst_fs.h" + +static void usage(void) +{ + fprintf(stderr, "Usage: tst_supported_fs [fs_type]\n"); + fprintf(stderr, " If fs_type is supported, return 0\n"); + fprintf(stderr, " If fs_type isn't supported, return 1\n"); + fprintf(stderr, " If fs_type isn't specified, print the list of supported filesystems\n"); + fprintf(stderr, " fs_type - a specified filesystem type\n"); +} + +int main(int argc, char *argv[]) +{ + const char *const *filesystems; + int i; + + if (argc > 2) { + fprintf(stderr, "Can't specify multiple fs_type\n"); + usage(); + return 2; + } + + if (argv[1] && !strcmp(argv[1], "-h")) { + usage(); + return 0; + } + + if (argv[1]) + return !tst_fs_is_supported(argv[1]); + + filesystems = tst_get_supported_fs_types(); + for (i = 0; filesystems[i]; i++) + printf("%s\n", filesystems[i]); + + return 0; +} |