From f529fedd178515bf3529ba1e758fc3f6e217b708 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 4 May 2015 09:08:32 +0200 Subject: [PATCH] test: fix parsing of command line arguments for setting nmtst_test_quick() glib interprets the options either as "-m arg" or "-m=arg". Fix parsing to check for both cases. Also, g_test_init() removes the parsed options from argv, hence we must check our original copy in __nmtst_internal.orig_argv. Now the following all have the same outcome: $ NMTST_DEBUG=no-debug,quick ./src/rdisc/tests/test-rdisc-fake $ ./src/rdisc/tests/test-rdisc-fake -m quick $ ./src/rdisc/tests/test-rdisc-fake -m=quick Fixes: a2edd6445f6683af3226ec6e097b2c5f387cbd27 --- include/nm-test-utils.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index 6f0bc5ffd1..04c5d5f1c5 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -328,20 +328,21 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_ g_free (nmtst_debug_copy); } - if (argv && *argv) { - char **a = *argv; + if (__nmtst_internal.orig_argv) { + char **a = __nmtst_internal.orig_argv; for (; *a; a++) { if (!g_ascii_strcasecmp (*a, "--debug")) is_debug = TRUE; else if (!g_ascii_strcasecmp (*a, "--no-debug")) is_debug = FALSE; - else if ( !strcmp (*a, "-mslow") - || !strcmp (*a, "-m=slow") - || !strcmp (*a, "-mthorough") + else if ( !strcmp (*a, "-m=slow") || !strcmp (*a, "-m=thorough") - || !strcmp (*a, "-mquick") - || !strcmp (*a, "-m=quick")) + || !strcmp (*a, "-m=quick") + || (!strcmp (*a, "-m") && *(a+1) + && ( !strcmp (*(a+1), "quick") + || !strcmp (*(a+1), "slow") + || !strcmp (*(a+1), "thorough")))) test_quick_argv = TRUE; } }