diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-getopt.h | 23 | ||||
-rw-r--r-- | tests/test-getopt_long.h | 19 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/test-getopt.h b/tests/test-getopt.h index 9c877b3d18..e3fc589f53 100644 --- a/tests/test-getopt.h +++ b/tests/test-getopt.h @@ -1365,5 +1365,28 @@ test_getopt (void) ASSERT (optind == 3); ASSERT (!output); } + + /* Check that 'W' does not dump core: + http://sourceware.org/bugzilla/show_bug.cgi?id=12922 + Technically, POSIX says the presence of ';' in the opt-string + gives unspecified behavior, so we only test this when GNU compliance + is desired. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int argc = 0; + const char *argv[10]; + int c; + int pos = ftell (stderr); + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "dummy"; + argv[argc] = NULL; + optind = start; + opterr = 1; + ASSERT (getopt (argc, (char **) argv, "W;") == 'W'); + ASSERT (ftell (stderr) == pos); + ASSERT (optind == 2); + } #endif /* GNULIB_TEST_GETOPT_GNU */ } diff --git a/tests/test-getopt_long.h b/tests/test-getopt_long.h index 7a748674ae..c1035b1664 100644 --- a/tests/test-getopt_long.h +++ b/tests/test-getopt_long.h @@ -314,6 +314,25 @@ test_getopt_long (void) } } + /* Test that 'W' does not dump core: + http://sourceware.org/bugzilla/show_bug.cgi?id=12922 */ + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "dummy"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "W;", NULL, &option_index); + ASSERT (c == 'W'); + ASSERT (optind == 2); + } + /* Test processing of boolean short options. */ for (start = 0; start <= 1; start++) { |