From: Karel Zak Date: Tue, 12 Mar 2013 14:45:59 +0000 (+0100) Subject: lib/procutils: test refactoring X-Git-Tag: v2.23-rc1~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bb53a54356e17481d704bc55cbbd31962172a99;p=thirdparty%2Futil-linux.git lib/procutils: test refactoring Signed-off-by: Karel Zak --- diff --git a/lib/procutils.c b/lib/procutils.c index 52e9ee383e..486627c50e 100644 --- a/lib/procutils.c +++ b/lib/procutils.c @@ -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 \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 \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 */