<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 Fri, Sep 23, 2022 at 5:09 AM Petr Vorel <<a href="mailto:pvorel@suse.cz" target="_blank">pvorel@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">Most of the messages used fprintf() instead of tst_{res,brk}(),<br>
thus convert all messages to fprintf().<br>
<br>
Add macros to shorten code.<br>
<br>
Fixes: eb47b4497 ("tst_supported_fs: Support skip list when query single fs")<br>
<br>
Signed-off-by: Petr Vorel <<a href="mailto:pvorel@suse.cz" target="_blank">pvorel@suse.cz</a>><br>
---<br>
I'm not sure about this myself. Shouldn't we rather use tst_brk() and<br>
tst_res() instead? It's show tst_supported_fs as command.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Not exactly, looking at testcase/lib/* tools, most of them are not written</div><div class="gmail_default" style="font-size:small">by LTP standard API, some even do not include tst_test.h.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I personally think if we want more flexibility for those small programs</div><div class="gmail_default" style="font-size:small">as auxiliary tool, we should not apply API as dogmatism for everything.</div><br></div><div><div class="gmail_default" style="font-size:small">Btw, there is patch confliction when performing git-am, if you can</div><div class="gmail_default" style="font-size:small">rebase accordingly for solving that, the whole patchset will be</div><div class="gmail_default" style="font-size:small">great for me.</div><br></div><div><div class="gmail_default" style="font-size:small">Reviewed-by: Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>></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">
<br>
<br>
 testcases/lib/tst_supported_fs.c | 61 ++++++++++++++++----------------<br>
 1 file changed, 30 insertions(+), 31 deletions(-)<br>
<br>
diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c<br>
index 26577c726..947aa4dae 100644<br>
--- a/testcases/lib/tst_supported_fs.c<br>
+++ b/testcases/lib/tst_supported_fs.c<br>
@@ -15,6 +15,22 @@<br>
 #include "tst_test.h"<br>
 #include "tst_fs.h"<br>
<br>
+#define err(...) ({ \<br>
+       fprintf(stderr, __VA_ARGS__); \<br>
+       fprintf(stderr, "\n"); \<br>
+       usage(); \<br>
+       return 2; })<br>
+<br>
+#define fail(...) ({ \<br>
+       fprintf(stderr, __VA_ARGS__); \<br>
+       fprintf(stderr, "\n"); \<br>
+       return 1; })<br>
+<br>
+#define info(...) ({ \<br>
+       fprintf(stderr, __VA_ARGS__); \<br>
+       fprintf(stderr, "\n"); \<br>
+       return 0; })<br>
+<br>
 static void usage(void)<br>
 {<br>
        fprintf(stderr, "Usage:\n");<br>
@@ -90,67 +106,50 @@ int main(int argc, char *argv[])<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>
+                       if (fsname)<br>
+                               err("Can't specify multiple paths");<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>
+       if (fsname && !skiplist)<br>
+               err("Parameter -d requires skiplist");<br>
<br>
-       if (argc - optind > 1) {<br>
-               fprintf(stderr, "Can't specify multiple fs_type\n");<br>
-               usage();<br>
-               return 2;<br>
-       }<br>
+       if (argc - optind > 1)<br>
+               err("Can't specify multiple fs_type");<br>
<br>
        /* fs_type */<br>
        if (optind < argc) {<br>
-               if (fsname) {<br>
-                       fprintf(stderr, "Can't specify fs_type and -d together\n");<br>
-                       usage();<br>
-                       return 2;<br>
-               }<br>
+               if (fsname)<br>
+                       err("Can't specify fs_type and -d together");<br>
<br>
                fsname = argv[optind];<br>
        }<br>
<br>
        if (fsname) {<br>
                if (fsname[0] == '\0')<br>
-                       tst_brk(TCONF, "fs_type is empty");<br>
+                       err("fs_type is empty");<br>
<br>
                if (skiplist) {<br>
                        if (tst_fs_in_skiplist(fsname, (const char * const*)skiplist))<br>
-                               tst_brk(TCONF, "%s is skipped", fsname);<br>
-                       else<br>
-                               tst_res(TINFO, "%s is not skipped", fsname);<br>
+                               fail("%s is skipped", fsname);<br>
<br>
-                       return 0;<br>
+                       info("%s is not skipped", fsname);<br>
                }<br>
<br>
                if (tst_fs_is_supported(fsname) == TST_FS_UNSUPPORTED)<br>
-                       tst_brk(TCONF, "%s is not supported", fsname);<br>
-               else<br>
-                       tst_res(TINFO, "%s is supported", fsname);<br>
+                       fail("%s is not supported", fsname);<br>
<br>
-               return 0;<br>
+               info("%s is supported", fsname);<br>
        }<br>
<br>
        /* all filesystems */<br>
        filesystems = tst_get_supported_fs_types((const char * const*)skiplist);<br>
<br>
        if (!filesystems[0])<br>
-               tst_brk(TCONF, "There are no supported filesystems or all skipped");<br>
+               fail("There are no supported filesystems or all skipped");<br>
<br>
        for (i = 0; filesystems[i]; i++)<br>
                printf("%s\n", filesystems[i]);<br>
-- <br>
2.37.3<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>