summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2013-03-12 15:45:59 +0100
committerKarel Zak <kzak@redhat.com>2013-03-12 15:45:59 +0100
commit1bb53a54356e17481d704bc55cbbd31962172a99 (patch)
tree7948fc466230f52c78b6f2ff9d31ac8042c6055d /lib
parent9e068ce0f124f5f4c40cb4d8bf59c0b7ac670354 (diff)
downloadutil-linux-1bb53a54356e17481d704bc55cbbd31962172a99.tar.gz
lib/procutils: test refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/procutils.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/procutils.c b/lib/procutils.c
index 52e9ee38..486627c5 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 <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 */