]>
Commit | Line | Data |
---|---|---|
f1717362 | 1 | # Copyright (C) 2005-2016 Free Software Foundation, Inc. |
fcdee8f1 | 2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with GCC; see the file COPYING3. If not see | |
15 | # <http://www.gnu.org/licenses/>. | |
16 | ||
17 | # This file contains a set of test that check that gcc options are | |
18 | # documented in --help, and that the various --help* options work. | |
19 | ||
20 | load_lib options.exp | |
eb9bd3cc | 21 | load_lib gcc-defs.exp |
22 | ||
23 | # These tests don't run runtest_file_p consistently if it | |
24 | # doesn't return the same values, so disable parallelization | |
25 | # of this *.exp file. The first parallel runtest to reach | |
26 | # this will run all the tests serially. | |
27 | if ![gcc_parallel_test_run_p help] { | |
28 | return | |
29 | } | |
30 | gcc_parallel_test_enable 0 | |
fcdee8f1 | 31 | |
377ecba0 | 32 | # GCC breaks up --help output into lines at most $COLUMNS characters |
33 | # wide (or 80 when COLUMNS is not defined), set the COLUMNS environment | |
34 | # variable to a value large enough to prevent this (and restore it when | |
35 | # done). | |
36 | global env | |
37 | ||
38 | if [ info exists env(COLUMNS) ] { | |
39 | set prev_columns $env(COLUMNS) | |
40 | } | |
41 | ||
42 | set env(COLUMNS) 1024 | |
43 | ||
fcdee8f1 | 44 | # Document --version. Ideally, there should be no undocumented switches |
45 | # in --help. | |
8fb42bbc | 46 | check_for_options c "--help" "--version" "This option lacks documentation" "" |
fcdee8f1 | 47 | |
48 | # Output from different subprocesses should not be intermingled | |
49 | # (we check for some patterns that could be seen with a missing | |
50 | # fflush in gcc.c). | |
51 | check_for_options c "-v --help" "" { | |
52 | [^\n]The following options | |
53 | -Wconversion[^\n]*lacks documentation | |
54 | " -g " | |
55 | } "" | |
56 | ||
57 | # There are still undocumented switches in -v --help. | |
8fb42bbc | 58 | check_for_options c "-v --help" "" "This option lacks documentation" "xfail" |
fcdee8f1 | 59 | |
60 | # Check whether multiline conversion in optc-gen is broken. | |
61 | check_for_options c "-v --help" "" {are likely to\n -std} "" | |
62 | ||
63 | # Try various --help= classes and qualifiers. | |
64 | check_for_options c "--help=optimizers" "-O" " -g " "" | |
65 | check_for_options c "--help=params" "maximum number of" "-Wunsafe-loop-optimizations" "" | |
66 | check_for_options c "--help=C" "-ansi" "-gnatO" "" | |
67 | check_for_options c {--help=C++} {-std=c\+\+} "-gnatO" "" | |
68 | check_for_options c "--help=common" "-dumpbase" "-gnatO" "" | |
8fb42bbc | 69 | check_for_options c "--help=undocumented" "This option lacks documentation" "" "" |
fcdee8f1 | 70 | |
71 | # Undocumented flags are not yet consistently marked as such. | |
8fb42bbc | 72 | check_for_options c "--help=^undocumented" "-Wall" "This option lacks documentation" "xfail" |
fcdee8f1 | 73 | |
74 | # Try some --help=* examples from the manual. | |
75 | check_for_options c "--help=target,undocumented" "" "" "" | |
76 | check_for_options c "--help=target,optimizers" "" "" "" | |
77 | check_for_options c "--help=warnings,^joined,^undocumented" "" "" "" | |
78 | check_for_options c "-Q -O2 --help=optimizers" { | |
79 | -O | |
043115ec | 80 | -ftree-loop-vectorize[^\n]*disabled |
fcdee8f1 | 81 | } " -g " "" |
82 | check_for_options c "-Q -O3 --help=optimizers" { | |
83 | -O | |
043115ec | 84 | -ftree-loop-vectorize[^\n]*enabled |
fcdee8f1 | 85 | } " -g " "" |
86 | # Try repeated --help=. | |
87 | check_for_options c "--help=params --help=optimizers" { | |
88 | maximum number of | |
89 | -O | |
90 | } "" "" | |
91 | ||
92 | # Ensure PR 37805 is fixed. | |
8fb42bbc | 93 | # Specify patterns (arguments 3 and later) that match option names |
94 | # at the beginning of the line and not when they are referenced by | |
95 | # some other options later on. | |
8fb42bbc | 96 | check_for_options c "--help=joined" \ |
377ecba0 | 97 | "^ +-Wformat=" "^ +-fstrict-prototype" "" |
8fb42bbc | 98 | check_for_options c "--help=separate" \ |
377ecba0 | 99 | "^ +-MF" "^ +-fstrict-prototype" "" |
8fb42bbc | 100 | check_for_options c "--help=warnings,joined" \ |
377ecba0 | 101 | "^ +-Wformat=" "^ +-Wtrigraphs" "" |
8fb42bbc | 102 | check_for_options c "--help=warnings,^joined" \ |
377ecba0 | 103 | "^ +-Wtrigraphs" "^ +-Wformat=" "" |
8fb42bbc | 104 | check_for_options c "--help=joined,separate" \ |
377ecba0 | 105 | "^ +-I" "" "" |
8fb42bbc | 106 | check_for_options c "--help=^joined,separate" \ |
377ecba0 | 107 | "^ +--param " "" "" |
8fb42bbc | 108 | check_for_options c "--help=joined,^separate" \ |
377ecba0 | 109 | "^ +--help=" "" "" |
fcdee8f1 | 110 | check_for_options c "--help=joined,undocumented" "" "" "" |
8fb42bbc | 111 | |
377ecba0 | 112 | # Check to make sure the description for every option is a complete |
113 | # sentence ending in a period. This matters not just for consistency | |
114 | # but also because other sentences may be appended to it by the help | |
115 | # subsystem. Do this one help class at a time to make it easier to | |
116 | # find the source a failure. | |
117 | ||
118 | foreach cls { "ada" "c" "c++" "fortran" "go" \ | |
119 | "optimizers" "param" "target" "warnings" } { | |
120 | ||
121 | check_for_options c "--help=$cls" "" "^ +-.*\[^:.\]$" "" | |
122 | } | |
123 | ||
fcdee8f1 | 124 | # Listing only excludes gives empty results. |
125 | check_for_options c "--help=^joined,^separate" "" "" "" | |
eb9bd3cc | 126 | |
377ecba0 | 127 | if [ info exists prev_columns ] { |
128 | # Reset the enviroment variable to its oriuginal value. | |
129 | set env(COLUMNS) $prev_columns | |
130 | } else { | |
131 | # Remove the variable from the environment if it didn't exist | |
132 | # to begin with to avoid affecting subsequent tests. | |
133 | array unset env COLUMNS | |
134 | } | |
135 | ||
eb9bd3cc | 136 | gcc_parallel_test_enable 1 |