X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-getopt_long.h;h=c1035b166473dbbe1915a66267b424068080c93b;hb=b067a2ba8fa66bf01717a4e8561c4db858055069;hp=097f9cf2c40101de4b1445582f4d98140d06cb75;hpb=a8ec28b6975fc065b84c511b8108dc3658d2ccd4;p=gnulib.git diff --git a/tests/test-getopt_long.h b/tests/test-getopt_long.h index 097f9cf2c..c1035b166 100644 --- a/tests/test-getopt_long.h +++ b/tests/test-getopt_long.h @@ -1,5 +1,5 @@ /* Test of command line argument processing. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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++) { @@ -1151,8 +1170,7 @@ test_getopt_long (void) &non_options_count, non_options, &unrecognized); ASSERT (a_seen == 0); ASSERT (b_seen == 0); - /* glibc bug http://sources.redhat.com/bugzilla/show_bug.cgi?id=11041 */ - /* ASSERT (p_value == NULL); */ + ASSERT (p_value == NULL); ASSERT (q_value == NULL); ASSERT (non_options_count == 0); ASSERT (unrecognized == 0); @@ -1748,7 +1766,7 @@ test_getopt_long (void) ASSERT (q_value == NULL); ASSERT (non_options_count == 0); ASSERT (unrecognized == 0); - ASSERT (optind = 1); + ASSERT (optind == 1); } /* Check that the '+' flag has to come first. */ @@ -2079,8 +2097,11 @@ test_getopt_long_only (void) opterr = 0; c = do_getopt_long_only (argc, argv, "ab", long_options_required, &option_index); - /* glibc bug http://sources.redhat.com/bugzilla/show_bug.cgi?id=11041 */ - /* ASSERT (c == 1003); */ + /* glibc getopt_long_only is intentionally different from + getopt_long when handling a prefix that is common to two + spellings, when both spellings have the same option directives. + BSD getopt_long_only treats both cases the same. */ + ASSERT (c == 1003 || c == '?'); ASSERT (optind == 2); } { @@ -2096,8 +2117,11 @@ test_getopt_long_only (void) opterr = 0; c = do_getopt_long_only (argc, argv, "abx::", long_options_required, &option_index); - /* glibc bug http://sources.redhat.com/bugzilla/show_bug.cgi?id=11041 */ - /* ASSERT (c == 1003); */ + /* glibc getopt_long_only is intentionally different from + getopt_long when handling a prefix that is common to two + spellings, when both spellings have the same option directives. + BSD getopt_long_only treats both cases the same. */ + ASSERT (c == 1003 || c == '?'); ASSERT (optind == 2); ASSERT (optarg == NULL); }