<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 21, 2022 at 11:50 PM Martin Doucha <<a href="mailto:mdoucha@suse.cz" target="_blank">mdoucha@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Signed-off-by: Martin Doucha <<a href="mailto:mdoucha@suse.cz" target="_blank">mdoucha@suse.cz</a>><br>
---<br>
<br>
Implement tst_supported_fs feature suggested by pvorel in his patch:<br>
tst_test.sh: Fix filesystem support detection<br>
<br>
Although the tst_fs_type_name() functions could use some improvements,<br>
e.g. ext4 must be specified in skiplist as "ext2/ext3/ext4" to get properly<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Yes, that's true, we need to make it keep consistent with two</div><div class="gmail_default" style="font-size:small">skipping ways. Otherwise below test output "ext2/ext3/ext4"</div><div class="gmail_default" style="font-size:small">looks like a bit mess to remember.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Better going with a single FS for matching (i.e. "ext4" for both fs_type and '-d path').</div><div class="gmail_default" style="font-size:small">But we can solve this in a separate patch later.<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">$ df -T . | tail -1 | awk '{print $2}'<br>ext4<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">$ ./tst_supported_fs -s "ext4" ext4<br>tst_supported_fs.c:135: TCONF: ext4 is skipped<br>$ echo $?<br>32<br><br></div><div class="gmail_default" style="font-size:small">$ ./tst_supported_fs -s "ext4" -d .<br>tst_supported_fs.c:137: TINFO: ext2/ext3/ext4 is not skipped</div><div class="gmail_default" style="font-size:small">$ echo $?<br>0<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">$ ./tst_supported_fs -s "ext2/ext3/ext4" -d .<br>tst_supported_fs.c:135: TCONF: ext2/ext3/ext4 is skipped<br></div><div class="gmail_default" style="font-size:small">$ echo $?</div>32<br><div class="gmail_default" style="font-size:small"></div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
skipped and vfat is missing from the list of known filesystems.<br>
<br>
testcases/lib/tst_supported_fs.c | 49 ++++++++++++++++++++++++++------<br>
1 file changed, 41 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c<br>
index 70d4d38c7..5873d0ba1 100644<br>
--- a/testcases/lib/tst_supported_fs.c<br>
+++ b/testcases/lib/tst_supported_fs.c<br>
@@ -32,9 +32,13 @@ static void usage(void)<br>
fprintf(stderr, "tst_supported_fs -s skip_list fs_type\n");<br>
fprintf(stderr, " if fs_type is in skip_list, return 1 otherwise return 0\n\n");<br>
<br>
+ fprintf(stderr, "tst_supported_fs -s skip_list -d path\n");<br>
+ fprintf(stderr, " if filesystem mounted on path is in skip_list, return 1 otherwise return 0\n\n");</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
fprintf(stderr, "fs_type - a specified filesystem type\n");<br>
fprintf(stderr, "skip_list - filesystems to skip, delimiter: '%c'\n",<br>
SKIP_DELIMITER);<br>
+ fprintf(stderr, "path - any valid file or directory\n");<br>
}<br>
<br>
static char **parse_skiplist(char *fs)<br>
@@ -62,10 +66,11 @@ static char **parse_skiplist(char *fs)<br>
int main(int argc, char *argv[])<br>
{<br>
const char *const *filesystems;<br>
+ const char *fsname = NULL;<br>
int i, ret;<br>
char **skiplist = NULL;<br>
<br>
- while ((ret = getopt(argc, argv, "hs:"))) {<br>
+ while ((ret = getopt(argc, argv, "hs:d:"))) {<br>
if (ret < 0)<br>
break;<br>
<br>
@@ -83,9 +88,26 @@ int main(int argc, char *argv[])<br>
if (!skiplist)<br>
return 1;<br>
break;<br>
+<br>
+ case 'd':<br>
+ if (fsname) {<br>
+ fprintf(stderr,<br>
+ "Can't specify multiple paths\n");<br>
+ usage();<br>
+ return 2;<br>
+ }<br>
+<br>
+ fsname = tst_fs_type_name(tst_fs_type(optarg));<br>
+ break;<br>
}<br>
}<br>
<br>
+ if (fsname && !skiplist) {<br>
+ fprintf(stderr, "Parameter -d requires skiplist\n");<br>
+ usage();<br>
+ return 2;<br>
+ }<br>
+<br>
if (argc - optind > 1) {<br>
fprintf(stderr, "Can't specify multiple fs_type\n");<br>
usage();<br>
@@ -94,22 +116,33 @@ int main(int argc, char *argv[])<br>
<br>
/* fs_type */<br>
if (optind < argc) {<br>
- if (argv[optind][0] == '\0')<br>
+ if (fsname) {<br>
+ fprintf(stderr, "Can't specify fs_type and -d together\n");<br>
+ usage();<br>
+ return 2;<br>
+<br>
+ }<br>
+<br>
+ fsname = argv[optind];<br>
+ }<br>
+<br>
+ if (fsname) {<br>
+ if (fsname[0] == '\0')<br>
tst_brk(TCONF, "fs_type is empty");<br>
<br>
if (skiplist) {<br>
- if (tst_fs_in_skiplist(argv[optind], (const char * const*)skiplist))<br>
- tst_brk(TCONF, "%s is skipped", argv[optind]);<br>
+ if (tst_fs_in_skiplist(fsname, (const char * const*)skiplist))<br>
+ tst_brk(TCONF, "%s is skipped", fsname);<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">TCONF does not means return 1, we might need explicitly 'return 1' here.</div><div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
else<br>
- tst_res(TINFO, "%s is not skipped", argv[optind]);<br>
+ tst_res(TINFO, "%s is not skipped", fsname);<br>
<br>
return 0;<br>
}<br>
<br>
- if (tst_fs_is_supported(argv[optind]) == TST_FS_UNSUPPORTED)<br>
- tst_brk(TCONF, "%s is not supported", argv[optind]);<br>
+ if (tst_fs_is_supported(fsname) == TST_FS_UNSUPPORTED)<br>
+ tst_brk(TCONF, "%s is not supported", fsname);<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Same here.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"> <br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
else<br>
- tst_res(TINFO, "%s is supported", argv[optind]);<br>
+ tst_res(TINFO, "%s is supported", fsname);<br>
<br>
return 0;<br>
}<br>
-- <br>
2.37.3<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>