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: a2edd6445f
This commit is contained in:
Thomas Haller 2015-05-04 09:08:32 +02:00
parent e52dac9887
commit f529fedd17

View file

@ -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;
}
}