]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/procutils: test refactoring
authorKarel Zak <kzak@redhat.com>
Tue, 12 Mar 2013 14:45:59 +0000 (15:45 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 12 Mar 2013 14:45:59 +0000 (15:45 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/procutils.c

index 52e9ee383e962711868c37088a9fc082a8c5b73f..486627c50e98d169c83f31006d067f999039798b 100644 (file)
@@ -97,15 +97,13 @@ int proc_next_tid(struct proc_tasks *tasks, pid_t *tid)
 
 #ifdef TEST_PROGRAM
 
-int main(int argc, char *argv[])
+static int test_tasks(int argc, char *argv[])
 {
        pid_t tid, pid;
        struct proc_tasks *ts;
 
-       if (argc != 2) {
-               fprintf(stderr, "usage: %s <pid>\n", argv[0]);
+       if (argc != 2)
                return EXIT_FAILURE;
-       }
 
        pid = strtol(argv[1], (char **) NULL, 10);
        printf("PID=%d, TIDs:", pid);
@@ -121,4 +119,18 @@ int main(int argc, char *argv[])
         proc_close_tasks(ts);
        return EXIT_SUCCESS;
 }
+
+int main(int argc, char *argv[])
+{
+       if (argc < 2) {
+               fprintf(stderr, "usage: %s --tasks <pid>\n",
+                                       program_invocation_short_name);
+               return EXIT_FAILURE;
+       }
+
+       if (strcmp(argv[1], "--tasks") == 0)
+               return test_tasks(argc - 1, argv + 1);
+
+       return EXIT_FAILURE;
+}
 #endif /* TEST_PROGRAM */