X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=test-tool%2Ftest-tool.c;h=93aaca20162b270cf753e918166ded7ab86c0595;hb=f4619c24e2a5cceaf030ee015a5c005b5a84280c;hp=3dc03289ff14bb07d244786513b82404dda33bb0;hpb=2f1a50d81671810256dce0852e6b1e0810ac44af;p=libguestfs.git diff --git a/test-tool/test-tool.c b/test-tool/test-tool.c index 3dc0328..93aaca2 100644 --- a/test-tool/test-tool.c +++ b/test-tool/test-tool.c @@ -41,6 +41,16 @@ #define N_(str) str #endif +#define STREQ(a,b) (strcmp((a),(b)) == 0) +#define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0) +#define STRNEQ(a,b) (strcmp((a),(b)) != 0) +#define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0) +#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0) +#define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0) +#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0) +#define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0) +#define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0) + #define DEFAULT_TIMEOUT 120 static const char *helper = DEFAULT_HELPER; @@ -75,7 +85,7 @@ usage (void) int main (int argc, char *argv[]) { - static const char *options = "?"; + static const char *options = "t:?"; static const struct option long_options[] = { { "help", 0, 0, '?' }, { "helper", 1, 0, 0 }, @@ -100,11 +110,11 @@ main (int argc, char *argv[]) switch (c) { case 0: /* options which are long only */ - if (strcmp (long_options[option_index].name, "helper") == 0) + if (STREQ (long_options[option_index].name, "helper")) helper = optarg; - else if (strcmp (long_options[option_index].name, "qemu") == 0) + else if (STREQ (long_options[option_index].name, "qemu")) set_qemu (optarg, 0); - else if (strcmp (long_options[option_index].name, "qemudir") == 0) + else if (STREQ (long_options[option_index].name, "qemudir")) set_qemu (optarg, 1); else { fprintf (stderr, @@ -145,7 +155,7 @@ main (int argc, char *argv[]) /* Print out any environment variables which may relate to this test. */ for (i = 0; environ[i] != NULL; ++i) - if (strncmp (environ[i], "LIBGUESTFS_", 11) == 0) + if (STREQLEN (environ[i], "LIBGUESTFS_", 11)) printf ("%s\n", environ[i]); /* Create the handle and configure it. */ @@ -186,20 +196,14 @@ main (int argc, char *argv[]) printf ("guestfs_get_verbose: %d\n", guestfs_get_verbose (g)); /* Launch the guest handle. */ - if (guestfs_launch (g) == -1) { - fprintf (stderr, - _("libguestfs-test-tool: failed to launch appliance\n")); - exit (1); - } - printf ("Launching appliance, timeout set to %d seconds.\n", timeout); fflush (stdout); alarm (timeout); - if (guestfs_wait_ready (g) == -1) { + if (guestfs_launch (g) == -1) { fprintf (stderr, - _("libguestfs-test-tool: failed or timed out in 'wait_ready'\n")); + _("libguestfs-test-tool: failed to launch appliance\n")); exit (1); }