lib/procutils: test refactoring

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2013-03-12 15:45:59 +01:00
parent 9e068ce0f1
commit 1bb53a5435
1 changed files with 16 additions and 4 deletions

View 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 */