diff options
author | Thomas Haller <thaller@redhat.com> | 2015-05-04 09:08:32 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-05-04 09:16:31 +0200 |
commit | f529fedd178515bf3529ba1e758fc3f6e217b708 (patch) | |
tree | 5ed2af56d75dec09853eb0cfc5241008173a35b1 | |
parent | e52dac9887c99951c65dadffa4c6d9375c550a98 (diff) | |
download | NetworkManager-f529fedd178515bf3529ba1e758fc3f6e217b708.tar.gz |
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
-rw-r--r-- | include/nm-test-utils.h | 15 |
1 files 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; } } |