2
* Copyright (C) 2008-2009 Karel Zak <kzak@redhat.com>
4
* This file may be redistributed under the terms of the
5
* GNU Lesser General Public License.
7
* Routines for TEST_PROGRAMs
20
int mnt_run_test(struct libmnt_test *tests, int argc, char *argv[])
23
struct libmnt_test *ts;
30
strcmp(argv[1], "--help") == 0 ||
31
strcmp(argv[1], "-h") == 0)
36
for (ts = tests; ts->name; ts++) {
37
if (strcmp(ts->name, argv[1]) == 0) {
38
rc = ts->body(ts, argc - 1, argv + 1);
40
printf("FAILED [rc=%d]", rc);
45
if (rc < 0 && ts->name == NULL)
48
return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
50
printf("\nUsage:\n\t%s <test> [testoptions]\nTests:\n",
51
program_invocation_short_name);
52
for (ts = tests; ts->name; ts++) {
53
printf("\t%-15s", ts->name);
55
printf(" %s\n", ts->usage);