kdbus-test: -n/--notimeout getopt
authorKonrad Lipinski <konrad.l@samsung.com>
Mon, 16 Jan 2017 13:11:12 +0000 (14:11 +0100)
committerAdrian Szyndela <adrian.s@samsung.com>
Wed, 7 Aug 2019 14:51:15 +0000 (16:51 +0200)
tools/testing/selftests/kdbus/kdbus-test.c

index 90dbd107cae1193cd19baea5cc2805014b5ad0bd..cf2a6b1a8826ab7a293c89ae8a32a87fd1fefc92 100644 (file)
@@ -39,6 +39,7 @@ struct kdbus_test_args {
        bool mntns;
        bool pidns;
        bool userns;
+       bool no_timeout;
        char *uid_map;
        char *gid_map;
        int loop;
@@ -453,12 +454,14 @@ static wur int test_run_forked(const struct kdbus_test *t,
                exit(ret);
        }
 
-       timer_pid = fork();
-       if (timer_pid < 0) {
-               return TEST_ERR;
-       } else if (timer_pid == 0) {
-               sleep(t->timeout);
-               exit(1);
+       if (!kdbus_args->no_timeout) {
+               timer_pid = fork();
+               if (timer_pid < 0) {
+                       return TEST_ERR;
+               } else if (timer_pid == 0) {
+                       sleep(t->timeout);
+                       exit(1);
+               }
        }
 
        result = -1;
@@ -469,6 +472,8 @@ static wur int test_run_forked(const struct kdbus_test *t,
                if (result >= 0)
                        break;
                result = !WIFEXITED(ret) || WEXITSTATUS(ret) ? TEST_ERR + (timer_pid==wpid) : TEST_OK;
+               if (kdbus_args->no_timeout)
+                       break;
                kill(wpid ^ pid ^ timer_pid, SIGKILL);
        }
 
@@ -907,6 +912,7 @@ wur int main(int argc, char *argv[])
                { "list",       no_argument,            NULL, 'l' },
                { "module",     required_argument,      NULL, 'm' },
                { "tap",        no_argument,            NULL, 'a' },
+               { "notimeout",  no_argument,    NULL, 'n' },
                { "mntns",      no_argument,            NULL, ARG_MNTNS },
                { "pidns",      no_argument,            NULL, ARG_PIDNS },
                { "userns",     no_argument,            NULL, ARG_USERNS },
@@ -919,7 +925,7 @@ wur int main(int argc, char *argv[])
 
        bool gotT = 0;
 
-       while ((t = getopt_long(argc, argv, "hxftm:R:b:w:a:l", options, NULL)) >= 0) {
+       while ((t = getopt_long(argc, argv, "xhtflnm:R:b:w:a:", options, NULL)) >= 0) {
                switch (t) {
                case 'x':
                        kdbus_args.loop = 1;
@@ -953,6 +959,10 @@ wur int main(int argc, char *argv[])
                        kdbus_args.tap_output = 1;
                        break;
 
+               case 'n':
+                       kdbus_args.no_timeout = 1;
+                       break;
+
                case 'l':
                        {
                                unsigned i = 0;