summaryrefslogtreecommitdiff
path: root/tests/test-getopt.h
diff options
context:
space:
mode:
authorLi Jinjing <jinjingx.li@intel.com>2014-10-26 22:28:15 +0800
committerLi Jinjing <jinjingx.li@intel.com>2014-10-26 22:28:15 +0800
commit931b01b091932a1f796c23379ea32abb68bd5895 (patch)
tree3aa9e1125da84f7e3bd764bbff577c42a766508b /tests/test-getopt.h
parent7be93f2d05131d061bd4790ae33c8d50f50010d7 (diff)
downloadm4-931b01b091932a1f796c23379ea32abb68bd5895.tar.gz
m4-931b01b091932a1f796c23379ea32abb68bd5895.tar.bz2
m4-931b01b091932a1f796c23379ea32abb68bd5895.zip
Imported Upstream version 1.4.17upstream/1.4.17sandbox/jinjingx/upstream
Diffstat (limited to 'tests/test-getopt.h')
-rw-r--r--tests/test-getopt.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/test-getopt.h b/tests/test-getopt.h
index 9c877b3..450cf0d 100644
--- a/tests/test-getopt.h
+++ b/tests/test-getopt.h
@@ -1,5 +1,5 @@
/* Test of command line argument processing.
- Copyright (C) 2009-2011 Free Software Foundation, Inc.
+ Copyright (C) 2009-2013 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
@@ -1365,5 +1365,27 @@ 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 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 */
}