]> ruderich.org/simon Gitweb - blhc/blhc.git/blob - t/tests.t
t: Add a few more tests.
[blhc/blhc.git] / t / tests.t
1 # Tests for blhc.
2 #
3 # Copyright (C) 2012  Simon Ruderich
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18
19 use strict;
20 use warnings;
21
22 use Test::More tests => 190;
23
24
25 sub is_blhc {
26     my ($file, $options, $exit, $expected) = @_;
27
28     # Multiple files as array references.
29     if (ref $file eq 'ARRAY') {
30         local $" = ' ./t/logs/';
31         $file = "@{$file}";
32     }
33
34     $file = "./t/logs/$file" if $file;
35     my $output = `./bin/blhc $options $file 2>&1`;
36
37     if ($options) {
38         $options = ' '. $options;
39     }
40     is $? >> 8, $exit,     "$file$options (exit code)";
41     # Perform regex or string match.
42     my $cmd = (ref $expected eq 'Regexp')
43               ? \&like
44               : \&is;
45     &$cmd($output, $expected, "$file$options (output)");
46 }
47
48
49 # Usage, invalid arguments.
50
51 my $usage =
52         'Usage:
53     blhc [*options*] *<dpkg-buildpackage build log file>..*
54
55 ';
56 is_blhc '', '--invalid', 2,
57         "Unknown option: invalid\n"
58         . $usage;
59
60 is_blhc '', '', 2,
61         $usage;
62
63 is_blhc '', '--version', 0,
64         'blhc 0.02  Copyright (C) 2012  Simon Ruderich
65
66 This program is free software: you can redistribute it and/or modify
67 it under the terms of the GNU General Public License as published by
68 the Free Software Foundation, either version 3 of the License, or
69 (at your option) any later version.
70
71 This program is distributed in the hope that it will be useful,
72 but WITHOUT ANY WARRANTY; without even the implied warranty of
73 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
74 GNU General Public License for more details.
75
76 You should have received a copy of the GNU General Public License
77 along with this program.  If not, see <http://www.gnu.org/licenses/>.
78 ';
79
80 is_blhc '', '--help', 1,
81         qr/^Usage:
82     blhc \[\*options\*\] \*<dpkg-buildpackage build log file>\.\.\*
83
84 Options:
85 /s;
86
87 is_blhc 'doesnt-exist', '', 2,
88         qr{^No such file or directory at \./bin/blhc line \d+\.$};
89
90
91 # No compiler commands found.
92
93 my $empty = "No compiler commands!\n";
94 is_blhc 'empty', '', 1,
95         $empty;
96
97
98 # ANSI colored output.
99
100 is_blhc 'arch-avr32', '--color', 8,
101         "\033[31mCFLAGS missing\033[0m (--param=ssp-buffer-size=4)\033[33m:\033[0m gcc -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
102 ";
103
104
105 # Ignore missing compiler flags.
106
107 is_blhc 'ignore-flag', '--ignore-flag -g', 8,
108         'CFLAGS missing (-O2): gcc -g     -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-c.c
109 ';
110
111 is_blhc 'ignore-flag', '--ignore-flag -g --ignore-flag -O2', 0,
112         '';
113
114 is_blhc 'ignore-flag-ldflags', '--ignore-flag -fPIE', 0,
115         '';
116
117 # Ignore missing compiler flags for specific architectures.
118
119 # Invalid option.
120 is_blhc 'ignore-flag', '--ignore-arch-flag -g', 2,
121         'Value "-g" invalid for option ignore-arch-flag ("arch:flag" expected)
122 Usage:
123     blhc [*options*] *<dpkg-buildpackage build log file>..*
124
125 ';
126 is_blhc 'ignore-flag', '--ignore-arch-flag -g:', 2,
127         'Value "-g:" invalid for option ignore-arch-flag ("arch:flag" expected)
128 Usage:
129     blhc [*options*] *<dpkg-buildpackage build log file>..*
130
131 ';
132 is_blhc 'ignore-flag', '--ignore-arch-flag :amd64', 2,
133         'Value ":amd64" invalid for option ignore-arch-flag ("arch:flag" expected)
134 Usage:
135     blhc [*options*] *<dpkg-buildpackage build log file>..*
136
137 ';
138
139 # Wrong architecture.
140 is_blhc 'ignore-flag', '--ignore-arch-flag amd64:-g', 8,
141         'CFLAGS missing (-g): gcc    -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
142 CFLAGS missing (-O2): gcc -g     -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-c.c
143 ';
144
145 is_blhc 'arch-i386', '--ignore-arch-flag i386:-fstack-protector', 8,
146         'LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
147 ';
148 is_blhc 'arch-i386', '--ignore-arch-flag i386:-pie', 8,
149         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
150 ';
151 is_blhc 'arch-i386', '--ignore-arch-flag i386:-fstack-protector --ignore-arch-flag i386:-pie', 0,
152         '';
153
154 # Wrong architecture.
155 is_blhc 'arch-i386', '--ignore-arch-flag amd64:-fstack-protector', 8,
156         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
157 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
158 ';
159 is_blhc 'arch-i386', '--ignore-arch-flag amd64:-pie', 8,
160         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
161 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
162 ';
163 is_blhc 'arch-i386', '--ignore-arch-flag amd64:-fstack-protector --ignore-arch-flag amd64:-pie', 8,
164         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
165 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
166 ';
167
168
169 # Ignore certain lines.
170
171 is_blhc 'ignore-line', '--ignore-line "\./prepare-script gcc test-[a-z]\.c"', 8,
172         'CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security):     ./prepare-script gcc test-a.c test-b.c test-c.c
173 CPPFLAGS missing (-D_FORTIFY_SOURCE=2):     ./prepare-script gcc test-a.c test-b.c test-c.c
174 LDFLAGS missing (-Wl,-z,relro):     ./prepare-script gcc test-a.c test-b.c test-c.c
175 ';
176
177 is_blhc 'ignore-line', '--ignore-line "\./prepare-script gcc test-[a-z]\.c" --ignore-line "\s*\./prepare-script gcc test-[a-z]\.c .+"', 0,
178         '';
179
180 # Ignore certain lines for specific architectures.
181
182 # Invalid option.
183 is_blhc 'ignore-line', '--ignore-arch-line .+', 2,
184         'Value ".+" invalid for option ignore-arch-line ("arch:line" expected)
185 Usage:
186     blhc [*options*] *<dpkg-buildpackage build log file>..*
187
188 ';
189 is_blhc 'ignore-line', '--ignore-arch-line .+:', 2,
190         'Value ".+:" invalid for option ignore-arch-line ("arch:line" expected)
191 Usage:
192     blhc [*options*] *<dpkg-buildpackage build log file>..*
193
194 ';
195 is_blhc 'ignore-line', '--ignore-arch-line :amd64', 2,
196         'Value ":amd64" invalid for option ignore-arch-line ("arch:line" expected)
197 Usage:
198     blhc [*options*] *<dpkg-buildpackage build log file>..*
199
200 ';
201
202 # Wrong architecture.
203 is_blhc 'ignore-line', '--ignore-arch-line "amd64:.+"', 8,
204         'CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security):     ./prepare-script gcc test-a.c test-b.c test-c.c
205 CPPFLAGS missing (-D_FORTIFY_SOURCE=2):     ./prepare-script gcc test-a.c test-b.c test-c.c
206 LDFLAGS missing (-Wl,-z,relro):     ./prepare-script gcc test-a.c test-b.c test-c.c
207 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): ./prepare-script gcc test-a.c
208 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): ./prepare-script gcc test-a.c
209 LDFLAGS missing (-Wl,-z,relro): ./prepare-script gcc test-a.c
210 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): ./prepare-script gcc test-b.c
211 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): ./prepare-script gcc test-b.c
212 LDFLAGS missing (-Wl,-z,relro): ./prepare-script gcc test-b.c
213 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): ./prepare-script gcc test-c.c
214 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): ./prepare-script gcc test-c.c
215 LDFLAGS missing (-Wl,-z,relro): ./prepare-script gcc test-c.c
216 ';
217
218 # Line regex anchored at beginning/end of the line.
219 is_blhc 'arch-i386', '--ignore-arch-line "i386:-fPIE --param=ssp-buffer-size=4"', 8,
220         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
221 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
222 ';
223
224 is_blhc 'arch-i386', '--ignore-arch-line "i386:gcc .+ -fPIE --param=ssp-buffer-size=4 .+ test\.c"', 8,
225         'LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
226 ';
227 is_blhc 'arch-i386', '--ignore-arch-line "i386:gcc .+ -Wl,-z,relro -Wl,-z,now .+"', 8,
228         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
229 ';
230 is_blhc 'arch-i386', '--ignore-arch-line "i386:gcc .+ -fPIE --param=ssp-buffer-size=4 .+ test\.c" --ignore-arch-line "i386:gcc .+ -Wl,-z,relro -Wl,-z,now .+"', 0,
231         '';
232
233 # Wrong architecture.
234 is_blhc 'arch-i386', '--ignore-arch-line "amd64:gcc .+ -fPIE --param=ssp-buffer-size=4 .+ test\.c"', 8,
235         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
236 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
237 ';
238 is_blhc 'arch-i386', '--ignore-arch-line "amd64:gcc .+ -Wl,-z,relro -Wl,-z,now .+"', 8,
239         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
240 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
241 ';
242 is_blhc 'arch-i386', '--ignore-arch-line "amd64:gcc .+ -fPIE --param=ssp-buffer-size=4 .+ test\.c" --ignore-arch-line "amd64:gcc .+ -Wl,-z,relro -Wl,-z,now .+"', 8,
243         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
244 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
245 ';
246
247
248 # Correct build logs.
249
250 is_blhc 'good', '', 0,
251         '';
252 is_blhc 'good-pie', '', 0,
253         '';
254 is_blhc 'good-pie', '--pie', 0,
255         '';
256 is_blhc 'good-bindnow', '', 0,
257         '';
258 is_blhc 'good-bindnow', '--bindnow', 0,
259         '';
260 is_blhc 'good-all', '', 0,
261         '';
262 is_blhc 'good-all', '--all', 0,
263         '';
264 is_blhc 'good-all', '--pie --bindnow', 0,
265         '';
266
267 is_blhc 'good-multiline', '', 0,
268         '';
269 is_blhc 'good-library', '--all', 0,
270         '';
271
272
273 # Build logs with missing flags.
274
275 is_blhc 'bad', '', 8,
276         'CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-a.c
277 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-a.c
278 CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-b.c
279 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-b.c
280 CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-c.c
281 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-c.c
282 LDFLAGS missing (-Wl,-z,relro): gcc -o test test-a.o test-b.o test-c.o -ltest
283 CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-a.c
284 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-a.c
285 CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-b.c
286 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-b.c
287 CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-c.c
288 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-c.c
289 LDFLAGS missing (-Wl,-z,relro): x86_64-linux-gnu-gcc -o test test-a.o test-b.o test-c.o -ltest
290 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -o ./testProgram ../src/test/testProgram.cpp
291 LDFLAGS missing (-Wl,-z,relro): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -o ./testProgram ../src/test/testProgram.cpp
292 LDFLAGS missing (-Wl,-z,relro): gcc -o test test-a.o test-b.o test-c.a
293 LDFLAGS missing (-Wl,-z,relro): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ../src/test/objs/test.o -o ../src/test/bin/test
294 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.S
295 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -E test.c
296 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -S test.c
297 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -S test.c
298 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc test.c
299 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c
300 LDFLAGS missing (-Wl,-z,relro): gcc test.c
301 CXXFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
302 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
303 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MD -c test.c
304 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MD -c test.c
305 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MT -MD -MF test.d -c test.c
306 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MT -MD -MF test.d -c test.c
307 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MMD -c test.c
308 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MMD -c test.c
309 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MT -MMD -MF test.d -c test.c
310 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MT -MMD -MF test.d -c test.c
311 ';
312 is_blhc 'bad', '--pie', 8,
313         'CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-a.c
314 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-a.c
315 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-b.c
316 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-b.c
317 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-c.c
318 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-c.c
319 LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc -o test test-a.o test-b.o test-c.o -ltest
320 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-a.c
321 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-a.c
322 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-b.c
323 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-b.c
324 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-c.c
325 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-c.c
326 LDFLAGS missing (-fPIE -pie -Wl,-z,relro): x86_64-linux-gnu-gcc -o test test-a.o test-b.o test-c.o -ltest
327 CXXFLAGS missing (-fPIE): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -o ./testProgram ../src/test/testProgram.cpp
328 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -o ./testProgram ../src/test/testProgram.cpp
329 LDFLAGS missing (-fPIE -pie -Wl,-z,relro): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -o ./testProgram ../src/test/testProgram.cpp
330 LDFLAGS missing (-fPIE -pie): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -Wl,-z,relro -o ../src/test/bin/test ../src/test/objs/test.o
331 LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc -o test test-a.o test-b.o test-c.a
332 LDFLAGS missing (-fPIE -pie -Wl,-z,relro): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ../src/test/objs/test.o -o ../src/test/bin/test
333 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.S
334 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -E test.c
335 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -S test.c
336 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -S test.c
337 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc test.c
338 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c
339 LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc test.c
340 CXXFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
341 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
342 LDFLAGS missing (-fPIE -pie): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
343 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MD -c test.c
344 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MD -c test.c
345 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MT -MD -MF test.d -c test.c
346 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MT -MD -MF test.d -c test.c
347 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MMD -c test.c
348 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MMD -c test.c
349 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MT -MMD -MF test.d -c test.c
350 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MT -MMD -MF test.d -c test.c
351 ';
352 is_blhc 'bad', '--bindnow', 8,
353         'CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-a.c
354 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-a.c
355 CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-b.c
356 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-b.c
357 CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-c.c
358 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-c.c
359 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc -o test test-a.o test-b.o test-c.o -ltest
360 CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-a.c
361 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-a.c
362 CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-b.c
363 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-b.c
364 CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-c.c
365 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-c.c
366 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): x86_64-linux-gnu-gcc -o test test-a.o test-b.o test-c.o -ltest
367 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -o ./testProgram ../src/test/testProgram.cpp
368 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -o ./testProgram ../src/test/testProgram.cpp
369 LDFLAGS missing (-Wl,-z,now): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -Wl,-z,relro -o ../src/test/bin/test ../src/test/objs/test.o
370 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc -o test test-a.o test-b.o test-c.a
371 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ../src/test/objs/test.o -o ../src/test/bin/test
372 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.S
373 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -E test.c
374 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -S test.c
375 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -S test.c
376 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc test.c
377 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c
378 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc test.c
379 CXXFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
380 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
381 LDFLAGS missing (-Wl,-z,now): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
382 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MD -c test.c
383 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MD -c test.c
384 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MT -MD -MF test.d -c test.c
385 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MT -MD -MF test.d -c test.c
386 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MMD -c test.c
387 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MMD -c test.c
388 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MT -MMD -MF test.d -c test.c
389 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MT -MMD -MF test.d -c test.c
390 ';
391 my $bad_pie_bindnow =
392         'CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-a.c
393 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-a.c
394 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-b.c
395 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-b.c
396 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -g -O2 -c test-c.c
397 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -c test-c.c
398 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc -o test test-a.o test-b.o test-c.o -ltest
399 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-a.c
400 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-a.c
401 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-b.c
402 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-b.c
403 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): x86_64-linux-gnu-gcc -g -O2 -c test-c.c
404 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): x86_64-linux-gnu-gcc -g -O2 -c test-c.c
405 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): x86_64-linux-gnu-gcc -o test test-a.o test-b.o test-c.o -ltest
406 CXXFLAGS missing (-fPIE): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -o ./testProgram ../src/test/testProgram.cpp
407 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -o ./testProgram ../src/test/testProgram.cpp
408 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -o ./testProgram ../src/test/testProgram.cpp
409 LDFLAGS missing (-fPIE -pie -Wl,-z,now): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -pthread -Wl,-z,relro -o ../src/test/bin/test ../src/test/objs/test.o
410 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc -o test test-a.o test-b.o test-c.a
411 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): g++  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ../src/test/objs/test.o -o ../src/test/bin/test
412 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.S
413 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -E test.c
414 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -S test.c
415 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -S test.c
416 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc test.c
417 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c
418 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc test.c
419 CXXFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
420 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
421 LDFLAGS missing (-fPIE -pie -Wl,-z,now): gcc -Wl,-z,relro -o test test-.cpp test-b.cpp.o
422 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MD -c test.c
423 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MD -c test.c
424 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MT -MD -MF test.d -c test.c
425 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MT -MD -MF test.d -c test.c
426 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MMD -c test.c
427 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MMD -c test.c
428 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -MT -MMD -MF test.d -c test.c
429 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -MT -MMD -MF test.d -c test.c
430 ';
431 is_blhc 'bad', '--pie --bindnow', 8,
432         $bad_pie_bindnow;
433 is_blhc 'bad', '--all', 8,
434         $bad_pie_bindnow;
435
436 is_blhc 'bad-cflags', '', 8,
437         'CFLAGS missing (-Wformat): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
438 CFLAGS missing (--param=ssp-buffer-size=4): gcc -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
439 CFLAGS missing (-Werror=format-security): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.c
440 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -Wl,-z,relro -o test test.c -ltest
441 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -Wl,-z,relro -o test test.c -ltest
442 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -shared -fPIC -Wl,-z,relro -o test.so test.c -ltest
443 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -shared -fPIC -Wl,-z,relro -o test.so test.c -ltest
444 CFLAGS missing (-Wformat): gcc -fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -c -D_FORTIFY_SOURCE=2 ../../../../src/test/test.c -o test.so.o
445 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc test.c -o test.output
446 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c -o test.output
447 LDFLAGS missing (-Wl,-z,relro): gcc test.c -o test.output
448 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): (gcc -Wl,-z,relro -o test.output test.c)
449 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): (gcc -Wl,-z,relro -o test.output test.c)
450 ';
451 is_blhc 'bad-cflags', '--pie', 8,
452         'CFLAGS missing (-fPIE -Wformat): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
453 CFLAGS missing (-fPIE --param=ssp-buffer-size=4): gcc -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
454 CFLAGS missing (-fPIE -Werror=format-security): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.c
455 LDFLAGS missing (-fPIE -pie): gcc -Wl,-z,relro -o test test-a.o test-b.o test-c.o -ltest
456 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -Wl,-z,relro -o test test.c -ltest
457 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -Wl,-z,relro -o test test.c -ltest
458 LDFLAGS missing (-fPIE -pie): gcc -Wl,-z,relro -o test test.c -ltest
459 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -shared -fPIC -Wl,-z,relro -o test.so test.c -ltest
460 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -shared -fPIC -Wl,-z,relro -o test.so test.c -ltest
461 CFLAGS missing (-Wformat): gcc -fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -c -D_FORTIFY_SOURCE=2 ../../../../src/test/test.c -o test.so.o
462 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc test.c -o test.output
463 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c -o test.output
464 LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc test.c -o test.output
465 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): (gcc -Wl,-z,relro -o test.output test.c)
466 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): (gcc -Wl,-z,relro -o test.output test.c)
467 LDFLAGS missing (-fPIE -pie): (gcc -Wl,-z,relro -o test.output test.c)
468 ';
469 is_blhc 'bad-cflags', '--bindnow', 8,
470         'CFLAGS missing (-Wformat): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
471 CFLAGS missing (--param=ssp-buffer-size=4): gcc -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
472 CFLAGS missing (-Werror=format-security): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.c
473 LDFLAGS missing (-Wl,-z,now): gcc -Wl,-z,relro -o test test-a.o test-b.o test-c.o -ltest
474 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -Wl,-z,relro -o test test.c -ltest
475 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -Wl,-z,relro -o test test.c -ltest
476 LDFLAGS missing (-Wl,-z,now): gcc -Wl,-z,relro -o test test.c -ltest
477 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -shared -fPIC -Wl,-z,relro -o test.so test.c -ltest
478 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -shared -fPIC -Wl,-z,relro -o test.so test.c -ltest
479 LDFLAGS missing (-Wl,-z,now): gcc -shared -fPIC -Wl,-z,relro -o test.so test.c -ltest
480 CFLAGS missing (-Wformat): gcc -fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -c -D_FORTIFY_SOURCE=2 ../../../../src/test/test.c -o test.so.o
481 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc test.c -o test.output
482 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c -o test.output
483 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc test.c -o test.output
484 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): (gcc -Wl,-z,relro -o test.output test.c)
485 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): (gcc -Wl,-z,relro -o test.output test.c)
486 LDFLAGS missing (-Wl,-z,now): (gcc -Wl,-z,relro -o test.output test.c)
487 ';
488 is_blhc 'bad-cflags', '--pie --bindnow', 8,
489         'CFLAGS missing (-fPIE -Wformat): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
490 CFLAGS missing (-fPIE --param=ssp-buffer-size=4): gcc -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
491 CFLAGS missing (-fPIE -Werror=format-security): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.c
492 LDFLAGS missing (-fPIE -pie -Wl,-z,now): gcc -Wl,-z,relro -o test test-a.o test-b.o test-c.o -ltest
493 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -Wl,-z,relro -o test test.c -ltest
494 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -Wl,-z,relro -o test test.c -ltest
495 LDFLAGS missing (-fPIE -pie -Wl,-z,now): gcc -Wl,-z,relro -o test test.c -ltest
496 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -shared -fPIC -Wl,-z,relro -o test.so test.c -ltest
497 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -shared -fPIC -Wl,-z,relro -o test.so test.c -ltest
498 LDFLAGS missing (-Wl,-z,now): gcc -shared -fPIC -Wl,-z,relro -o test.so test.c -ltest
499 CFLAGS missing (-Wformat): gcc -fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -c -D_FORTIFY_SOURCE=2 ../../../../src/test/test.c -o test.so.o
500 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc test.c -o test.output
501 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c -o test.output
502 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc test.c -o test.output
503 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): (gcc -Wl,-z,relro -o test.output test.c)
504 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): (gcc -Wl,-z,relro -o test.output test.c)
505 LDFLAGS missing (-fPIE -pie -Wl,-z,now): (gcc -Wl,-z,relro -o test.output test.c)
506 ';
507
508 is_blhc 'bad-cppflags', '', 8,
509         'CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-a.c
510 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-b.c
511 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-c.c
512 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c ../../../../src/test/test.c -o test.so.o
513 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++ -o test -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security test-a.cxx test-b.o test-c.o -Wl,-z,relro
514 ';
515
516 my $bad_ldflags =
517         'LDFLAGS missing (-Wl,-z,relro): gcc -o test test-a.o test-b.o test-c.o -ltest
518 ';
519 is_blhc 'bad-ldflags', '', 8,
520         $bad_ldflags;
521 is_blhc 'bad-ldflags', '--pie', 8,
522         'CFLAGS missing (-fPIE): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
523 CFLAGS missing (-fPIE): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
524 CFLAGS missing (-fPIE): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-c.c
525 LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc -o test test-a.o test-b.o test-c.o -ltest
526 ';
527 is_blhc 'bad-ldflags', '--bindnow', 8,
528         'LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc -o test test-a.o test-b.o test-c.o -ltest
529 ';
530 is_blhc 'bad-ldflags', '--pie --bindnow', 8,
531         'CFLAGS missing (-fPIE): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
532 CFLAGS missing (-fPIE): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
533 CFLAGS missing (-fPIE): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-c.c
534 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc -o test test-a.o test-b.o test-c.o -ltest
535 ';
536
537 is_blhc 'bad-multiline', '', 8,
538         'CFLAGS missing (-Wformat): gcc \               -g -O2 -fstack-protector\     --param=ssp-buffer-size=4 -Wformat-security\ -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
539 CFLAGS missing (--param=ssp-buffer-size=4): gcc -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security\ -D_FORTIFY_SOURCE=2\ -c test-b.c
540 CFLAGS missing (-Werror=format-security): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.c
541 LDFLAGS missing (-Wl,-z,relro): gcc -o\ test test-c.o test-a.o test-b.o\        -ltest
542 LDFLAGS missing (-Wl,-z,relro): gcc -o \ test test-c.o test-b.o test-a.o\       
543 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -o \ test test-b.o test-a.o test-c.c\         
544 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -o \ test test-b.o test-a.o test-c.c\       
545 LDFLAGS missing (-Wl,-z,relro): gcc -o \ test test-b.o test-a.o test-c.c\       
546 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-a.c
547 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security):  gcc -D_FORTIFY_SOURCE=2 -c test-b.c
548 CFLAGS missing (-Werror=format-security): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -D_FORTIFY_SOURCE=2 -c test-a.c
549 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat):  gcc -Wformat-security -Werror=format-security -c test-b.c
550 CPPFLAGS missing (-D_FORTIFY_SOURCE=2):  gcc -Wformat-security -Werror=format-security -c test-b.c
551 CFLAGS missing (-O2): gcc -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-a.c
552 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-a.c
553 CFLAGS missing (-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): \ gcc -O2 -D_FORTIFY_SOURCE=2 -c test-b.c
554 CFLAGS missing (-fstack-protector): gcc -g -O2 --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-a.c
555 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-a.c
556 CFLAGS missing (-g -O2 --param=ssp-buffer-size=4 -Wformat -Werror=format-security):  \ gcc -D_FORTIFY_SOURCE=2 -fstack-protector -c test-b.c
557 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security \; -Werror=format-security -D_FORTIFY_SOURCE=1 -c test-a.c
558 CPPFLAGS missing (-D_FORTIFY_SOURCE=2):  \ gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=1 -c test-b.c
559 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c test.c `echo -g -O2 -fstack-protector --param=ssp-buffer-size=4 echo -Wformat -Wformat-security -Werror=format-security | sed \'s/.../; s/.../\'` -o test.o
560 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c test.c `echo -g -O2 -fstack-protector --param=ssp-buffer-size=4 echo -Wformat -Wformat-security -Werror=format-security | sed "s/.../; s/.../"` -o test.o
561 ';
562
563 is_blhc 'bad-library', '--all', 8,
564         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security test.c -fPIC -DPIC -o libtest.so
565 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc -D_FORTIFY_SOURCE=2 -g -O2 --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security test.c -fPIC -DPIC -o libtest.so
566 LDFLAGS missing (-Wl,-z,now): gcc -shared -fPIC -DPIC libtest.o -lpthread -O2 -Wl,relro -Wl,--as-needed -o libtest.so
567 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc -shared -fPIC -DPIC libtest.o -lpthread -O2 -Wl,--as-needed -o libtest.so
568 LDFLAGS missing (-Wl,-z,now): gcc -shared -fPIC test.o -Wl,-z -Wl,relro -o .libs/libtest.so.1.0.0
569 LDFLAGS missing (-Wl,-z,relro): gcc -shared -o libtest.so.0d ./test-a.o test/./test-b.o -Wl,-z,now -lpthread -ldl
570 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): /usr/bin/g++ -shared -fpic -o libtest-6.1.so.0 test.o -ltiff -lz
571 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc -Wl,--as-needed  -fPIE -pie -o test.cgi test.o -lgcrypt
572 CFLAGS missing (-fPIE): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security test.c -o lib`basename test/test`.so
573 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security test.c -o lib`basename test/test`.so
574 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security test.c -o lib`basename test/test`.so
575 ';
576
577
578 # check the build log is verbose
579
580 is_blhc 'verbose-build', '', 12,
581         'NONVERBOSE BUILD: checking if you want to see long compiling messages... no
582 NONVERBOSE BUILD:   CC     libtest-a.lo
583 NONVERBOSE BUILD:   CC     libtest-b.lo
584 NONVERBOSE BUILD:   CC     libtest_c.lo
585 NONVERBOSE BUILD:   CC     libtest-d.lo
586 NONVERBOSE BUILD:   CCLD   libtest.la
587 NONVERBOSE BUILD:   LINK   libtest.la
588 NONVERBOSE BUILD:   CXX    libtest-a.lo
589 NONVERBOSE BUILD:   CXX    libtest-b.lo
590 NONVERBOSE BUILD:   CXX    libtest_c.lo
591 NONVERBOSE BUILD:   CXX    libtest-d.lo
592 NONVERBOSE BUILD:   CXXLD  libtest.la
593 NONVERBOSE BUILD:       [CC]   src/test-a.o
594 NONVERBOSE BUILD:       [CC]   src/test-b.o
595 NONVERBOSE BUILD:       [CC]   src/test_c.o
596 NONVERBOSE BUILD:       [CXX]  src/test-d.o
597 NONVERBOSE BUILD:       [LD]   src/test.o
598 NONVERBOSE BUILD:       [CC]   src/test-a.o
599 NONVERBOSE BUILD:       [CC]   src/test-b.o
600 NONVERBOSE BUILD:       [CC]   src/test_c.o
601 NONVERBOSE BUILD:       [LD]   src/test.o
602 NONVERBOSE BUILD:       [CC]   src/test-a.o
603 NONVERBOSE BUILD:       [CC]   src/test-b.o
604 NONVERBOSE BUILD:       [CC]   src/test_c.o
605 NONVERBOSE BUILD:       [LD]   src/test.o
606 NONVERBOSE BUILD: CC modules/server/test.c
607 NONVERBOSE BUILD:     C++      test/test.o
608 NONVERBOSE BUILD: C++ test.cpp
609 NONVERBOSE BUILD: Building program ../build/bin/test
610 NONVERBOSE BUILD: Compiling test/test.cc to ../build/test/test.o
611 NONVERBOSE BUILD: Compiling test/test.cc to ../build/test/test.o
612 NONVERBOSE BUILD: Building shared library ../build/test/libtest.so.1.2.3
613 NONVERBOSE BUILD: Compiling test.cc to ../build/test/test.o
614 NONVERBOSE BUILD: Building program ../build/bin/test
615 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++ -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -o ../build/test/test.o test/test.cc
616 LDFLAGS missing (-Wl,-z,relro): g++ -fPIC -DPIC \            -o ../build/test/libtest.so.1.2.3 -shared \                       ../build/obj/test/test-a.o ../build/obj/test/test-b.o ../build/obj/test/test-c.o
617 CXXFLAGS missing (-Wformat): g++ -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -o ../build/test/test.o test.cc
618 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++ -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -o ../build/test/test.o test.cc
619 LDFLAGS missing (-Wl,-z,relro): g++ ../build/obj/test/test.o -o /../build/bin/test
620 NONVERBOSE BUILD: Compiling test_file.cxx...
621 CXXFLAGS missing (-fstack-protector): g++ -g -O2 -fPIC --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test_file.cxx
622 NONVERBOSE BUILD: [ 22%] Building CXX object src/CMakeFiles/test/test.cpp.o
623 NONVERBOSE BUILD: [ 82%] Building C object src/CMakeFiles/test/test.c.o
624 CXXFLAGS missing (-Wformat): cd /tmp/test/src && /usr/bin/c++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -o CMakeFiles/test-verbose.dir/verbose.cpp.o -c -D_FORTIFY_SOURCE=2 /tmp/test/src/test-verbose/verbose.cpp
625 CFLAGS missing (-Werror=format-security): cd /tmp/test/src && /usr/bin/gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -o CMakeFiles/test-verbose-c.dir/verbose-c.c.o -c -D_FORTIFY_SOURCE=2 /tmp/test/src/test-verbose-c/verbose-c.c
626 ';
627
628
629 # configure/make
630
631 is_blhc 'configure', '', 1,
632         $empty;
633
634 is_blhc 'make', '', 1,
635         $empty;
636
637
638
639 # cc
640
641 is_blhc 'cc', '--pie --bindnow', 8,
642         'CXXFLAGS missing (-fPIE -Wformat): cc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.cc
643 CFLAGS missing (-fPIE -Wformat): cc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
644 CFLAGS missing (-fPIE --param=ssp-buffer-size=4): cc -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
645 CFLAGS missing (-fPIE -Werror=format-security): cc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.c
646 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): cc -Wl,-z,defs -o test test-a.o test-b.o test-c.o -ltest
647 CXXFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): cc\     test.cc
648 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): cc\     test.cc
649 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): cc\     test.cc
650 CXXFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): cc\ test.cc
651 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): cc\ test.cc
652 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): cc\ test.cc
653 LDFLAGS missing (-fPIE -pie -Wl,-z,now): cc -Wl,-z,defs test-a.o test-b.o test-c.o -ltest -Wl,-z,relro -o test/test-4.2~_4711/test.so test.o
654 ';
655
656
657 # gcc
658
659 is_blhc 'gcc', '--pie --bindnow', 8,
660         'CXXFLAGS missing (-fPIE -Wformat): gcc-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.cc
661 CFLAGS missing (-fPIE -Wformat): gcc-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
662 CFLAGS missing (-fPIE --param=ssp-buffer-size=4): gcc-4.6 -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
663 CFLAGS missing (-fPIE -Werror=format-security): gcc-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.c
664 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc-4.6 -Wl,-z,defs -o test test-a.o test-b.o test-c.o -ltest
665 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc\     test.c
666 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc\     test.c
667 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc\     test.c
668 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc\ test.c
669 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc\ test.c
670 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc\ test.c
671 LDFLAGS missing (-fPIE -pie -Wl,-z,now): gcc-4.6 -Wl,-z,defs test-a.o test-b.o test-c.o -ltest -Wl,-z,relro -o test/test-4.2~_4711/test.so test.o
672 ';
673
674
675 # c++
676
677 is_blhc 'c++', '--pie --bindnow', 8,
678         'CXXFLAGS missing (-fPIE -Wformat): c++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.cpp
679 CXXFLAGS missing (-fPIE --param=ssp-buffer-size=4): c++ -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.cpp
680 CXXFLAGS missing (-fPIE -Werror=format-security): c++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.cpp
681 CXXFLAGS missing (-fPIE): c++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-d.cc
682 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): c++ -Wl,-z,defs -o test test-a.o test-b.o test-c.o test-d.o -ltest
683 LDFLAGS missing (-fPIE -pie -Wl,-z,now): c++ -Wl,-z,defs test-a.o test-b.o test-c.o -ltest -Wl,-z,relro -o test/test-4.2~_4711/test.so test.o
684 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): c++\     test.c
685 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): c++\     test.c
686 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): c++\     test.c
687 CXXFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): c++\     test.c++
688 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): c++\     test.c++
689 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): c++\     test.c++
690 CXXFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): c++\ test.c++
691 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): c++\ test.c++
692 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): c++\ test.c++
693 CXXFLAGS missing (-fPIE -Wformat): c++-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.cpp
694 CXXFLAGS missing (-fPIE --param=ssp-buffer-size=4): c++-4.6 -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.cpp
695 CXXFLAGS missing (-fPIE -Werror=format-security): c++-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.cpp
696 CXXFLAGS missing (-fPIE): c++-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-d.cc
697 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): c++-4.6 -Wl,-z,defs -o test test-a.o test-b.o test-c.o test-d.o -ltest
698 ';
699
700
701 # g++
702
703 is_blhc 'g++', '--pie --bindnow', 8,
704         'CXXFLAGS missing (-fPIE -Wformat): g++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.cpp
705 CXXFLAGS missing (-fPIE --param=ssp-buffer-size=4): g++ -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.cpp
706 CXXFLAGS missing (-fPIE -Werror=format-security): g++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.cpp
707 CXXFLAGS missing (-fPIE): g++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-d.cc
708 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): g++ -Wl,-z,defs -o test test-a.o test-b.o test-c.o test-d.o -ltest
709 CXXFLAGS missing (-fPIE -Wformat): x86_64-linux-gnu-g++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.cpp
710 CXXFLAGS missing (-fPIE --param=ssp-buffer-size=4): x86_64-linux-gnu-g++ -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.cpp
711 CXXFLAGS missing (-fPIE -Werror=format-security): x86_64-linux-gnu-g++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.cpp
712 CXXFLAGS missing (-fPIE): x86_64-linux-gnu-g++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-d.cc
713 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): x86_64-linux-gnu-g++ -Wl,-z,defs -o test test-a.o test-b.o test-c.o test-d.o -ltest
714 LDFLAGS missing (-fPIE -pie -Wl,-z,now): g++ -Wl,-z,defs test-a.o test-b.o test-c.o -ltest -Wl,-z,relro -o test/test-4.2~_4711/test.so test.o
715 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): g++\     test.c
716 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++\     test.c
717 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): g++\     test.c
718 CXXFLAGS missing (-fPIE -Wformat): g++-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.cpp
719 CXXFLAGS missing (-fPIE --param=ssp-buffer-size=4): g++-4.6 -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.cpp
720 CXXFLAGS missing (-fPIE -Werror=format-security): g++-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.cpp
721 CXXFLAGS missing (-fPIE): g++-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-d.cc
722 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): g++-4.6 -Wl,-z,defs -o test test-a.o test-b.o test-c.o test-d.o -ltest
723 ';
724
725
726 # libtool
727
728 is_blhc 'libtool', '--bindnow', 8,
729         'CFLAGS missing (-fPIE -Wformat): /bin/bash ../../libtool --tag=CC   --mode=compile x86_64-linux-gnu-gcc -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -c test.c
730 CXXFLAGS missing (-fPIE -Wformat): /bin/bash ../../libtool --tag=CC   --mode=compile x86_64-linux-gnu-g++ -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -c test.cpp
731 CFLAGS missing (-fPIE -Wformat): /bin/bash ../../libtool --tag=CC   --mode=compile gcc-4.6 -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -c test.c
732 CFLAGS missing (-fPIE -Wformat): /bin/bash ../../libtool --tag=CXX  --mode=compile g++-4.6 -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -c test.c
733 LDFLAGS missing (-Wl,-z,now): libtool: link: g++ -shared test-a.o test-b.o test-b.o test-c.o -O2 -Wl,relro -o test.so
734 LDFLAGS missing (-fPIE -pie -Wl,-z,now): libtool: link: gcc -Wl,-z -Wl,relro -o test test.o
735 LDFLAGS missing (-fPIE -pie -Wl,-z,now): /bin/bash ../../../libtool  --mode=link cc -Wl,-z,relro -o test.so test.o
736 LDFLAGS missing (-fPIE -pie -Wl,-z,now): /bin/bash ../../../libtool  --mode=link gcc-4.6 -Wl,-z,relro -o test.so test.o
737 LDFLAGS missing (-fPIE -pie -Wl,-z,now): /bin/bash ../libtool --tag=CXX --mode=link x86_64-linux-gnu-g++ -Wl,-z,relro -o test.so test.o
738 LDFLAGS missing (-fPIE -pie -Wl,-z,now): /bin/bash ../libtool --tag=CC --mode=link gcc -Wl,-z,relro -o test.so test.o
739 LDFLAGS missing (-fPIE -pie -Wl,-z,now): /bin/bash ../libtool --tag=CC --mode=link gcc -Wl,-z,relro -o test/test-4.2~_4711/test.so test.o
740 LDFLAGS missing (-fPIE -pie -Wl,-z,now): /bin/bash ../libtool --tag=CC   --mode=link gcc -Wl,-z,relro -o test.so test.o
741 LDFLAGS missing (-fPIE -pie -Wl,-z,now):   /bin/bash ../libtool --tag=CC   --mode=link gcc -Wl,-z,relro -o test.so test.o
742 LDFLAGS missing (-fPIE -pie -Wl,-z,now): /bin/bash ../../libtool  --tag=CC --preserve-dup-deps  --mode=link gcc -Wl,-z,relro -o test.so test.o
743 LDFLAGS missing (-fPIE -pie -Wl,-z,now):  /bin/bash /tmp/test/build/libtool  --silent --tag CC --mode=relink gcc -Wl,-z,relro -o test.so test.o
744 LDFLAGS missing (-fPIE -pie -Wl,-z,now):  /bin/bash /tmp/test/build/libtool  --tag CXX --mode=relink g++ -Wl,-z,relro -o test.la test.o
745 LDFLAGS missing (-fPIE -pie -Wl,-z,now): /bin/bash ../libtool --tag=CC   --mode=link gcc  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security   -Wl,-z,relro -o test test.o
746 LDFLAGS missing (-fPIE -pie -Wl,-z,now): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wl,-z -Wl,relro -o .libs/test test.o
747 CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): /bin/bash ../libtool --tag=CC   --mode=link gcc -Wl,-z,relro -o test.so test.c
748 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): /bin/bash ../libtool --tag=CC   --mode=link gcc -Wl,-z,relro -o test.so test.c
749 LDFLAGS missing (-fPIE -pie -Wl,-z,now): /bin/bash ../libtool --tag=CC   --mode=link gcc -Wl,-z,relro -o test.so test.c
750 ';
751
752
753 # different architectures
754
755 my $arch_avr32 =
756         'CFLAGS missing (--param=ssp-buffer-size=4): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
757 ';
758 is_blhc 'arch-avr32', '', 8,
759         $arch_avr32;
760
761 my $arch_i386 =
762         'CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
763 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
764 ';
765 is_blhc 'arch-i386', '', 8,
766         $arch_i386;
767
768 my $arch_ia64 =
769         'CFLAGS missing (-fPIE): gcc -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
770 LDFLAGS missing (-pie): gcc -fPIE -o test test.o
771 ';
772 is_blhc 'arch-ia64', '', 8,
773         $arch_ia64;
774
775 is_blhc 'arch-mipsel', '', 8,
776         'CFLAGS missing (-Werror=format-security): gcc -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Wformat-security -Wall -c test.c
777 LDFLAGS missing (-Wl,-z,relro): gcc -Wl,-z,now -o test test.o
778 ';
779
780 is_blhc 'arch-ia64', '--arch i386', 8,
781         'CFLAGS missing (-fstack-protector --param=ssp-buffer-size=4): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
782 LDFLAGS missing (-Wl,-z,relro): gcc -fPIE -pie -o test test.o
783 CFLAGS missing (-fPIE -fstack-protector --param=ssp-buffer-size=4): gcc -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
784 LDFLAGS missing (-pie -Wl,-z,relro): gcc -fPIE -o test test.o
785 ';
786
787
788 # ignore architecture
789
790 is_blhc ['arch-avr32', 'arch-i386', 'empty', 'arch-mipsel'],
791         '--ignore-arch avr32 --ignore-arch mipsel',
792         9,
793         "checking './t/logs/arch-avr32'...\n"
794         . "ignoring architecture 'avr32'\n"
795         . "checking './t/logs/arch-i386'...\n"
796         . $arch_i386
797         . "checking './t/logs/empty'...\n"
798         . $empty
799         . "checking './t/logs/arch-mipsel'...\n"
800         . "ignoring architecture 'mipsel'\n"
801         ;
802
803 is_blhc 'buildd-dpkg-dev', '--ignore-arch i386', 0,
804         "ignoring architecture 'i386'\n";
805
806
807 # debian
808
809 is_blhc 'debian', '', 8,
810         'CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
811 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c `dpkg-buildflags --get CFLAGS` test.c
812 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++ -c `dpkg-buildflags --get CXXFLAGS` test.cc
813 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -c `dpkg-buildflags --get LDFLAGS` test.c
814 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c `dpkg-buildflags --get LDFLAGS` test.c
815 LDFLAGS missing (-Wl,-z,relro): gcc -o test test.o `dpkg-buildflags --get CFLAGS`
816 ';
817
818 is_blhc 'debian-cmake', '', 32,
819         'INVALID CMAKE: 2.8.7-1
820 ';
821 is_blhc 'debian-cmake-2', '', 32,
822         'INVALID CMAKE: 2.8.7-2
823 ';
824 is_blhc 'debian-cmake-ok', '', 0,
825         '';
826
827 my $debian_hardening_wrapper =
828         'HARDENING WRAPPER: no checks possible, aborting
829 ';
830 is_blhc 'debian-hardening-wrapper', '', 16,
831         $debian_hardening_wrapper;
832
833
834 # false positives
835
836 is_blhc 'false-positives', '', 1,
837         $empty;
838
839
840 # buildd support
841
842 is_blhc 'empty', '--buildd', 1,
843         'I-no-compiler-commands
844 ';
845
846 is_blhc 'buildd-package-details', '--buildd', 0,
847         '';
848
849 is_blhc 'buildd-dpkg-dev', '--buildd', 8,
850         'W-dpkg-buildflags-missing CPPFLAGS 7 (of 7), CFLAGS 6 (of 6), CXXFLAGS 1 (of 1), LDFLAGS 2 (of 2) missing
851 ';
852
853 is_blhc 'buildd-dpkg-dev-old', '--buildd', 8,
854         'W-dpkg-buildflags-missing CFLAGS 3 (of 6), CXXFLAGS 1 (of 1) missing
855 ';
856
857 is_blhc 'buildd-dpkg-dev-missing', '--buildd', 8,
858         'W-dpkg-buildflags-missing CFLAGS 3 (of 6), CXXFLAGS 1 (of 1) missing
859 ';
860
861 is_blhc 'debian-hardening-wrapper', '--buildd', 16,
862         'I-hardening-wrapper-used
863 ';
864
865 is_blhc 'buildd-verbose-build', '--buildd', 4,
866         'W-compiler-flags-hidden 1 (of 5) hidden
867 ';
868
869 is_blhc 'make', '--buildd', 1,
870         'I-no-compiler-commands
871 ';
872
873 is_blhc 'debian-cmake', '--buildd', 32,
874         'I-invalid-cmake-used 2.8.7-1
875 ';
876
877
878 # multiple files
879
880 is_blhc ['good', 'good-pie', 'good-bindnow', 'good-all', 'good-multiline', 'good-library'], '', 0,
881         "checking './t/logs/good'...
882 checking './t/logs/good-pie'...
883 checking './t/logs/good-bindnow'...
884 checking './t/logs/good-all'...
885 checking './t/logs/good-multiline'...
886 checking './t/logs/good-library'...
887 ";
888 is_blhc ['good-all', 'good-library'], '--all', 0,
889         "checking './t/logs/good-all'...
890 checking './t/logs/good-library'...
891 ";
892
893 is_blhc ['arch-i386', 'arch-ia64'], '', 8,
894         "checking './t/logs/arch-i386'...\n"
895         . $arch_i386
896         . "checking './t/logs/arch-ia64'...\n"
897         . $arch_ia64;
898
899 # No exit when multiple files are specified.
900 is_blhc ['bad-ldflags', 'empty', 'arch-avr32', 'debian-hardening-wrapper'], '', 25,
901         "checking './t/logs/bad-ldflags'...\n"
902         . $bad_ldflags
903         . "checking './t/logs/empty'...\n"
904         . $empty
905         . "checking './t/logs/arch-avr32'...\n"
906         . $arch_avr32
907         . "checking './t/logs/debian-hardening-wrapper'...\n"
908         . $debian_hardening_wrapper
909         ;
910
911 # Ignore works correctly with multiple architectures.
912 is_blhc ['arch-i386', 'arch-amd64', 'arch-avr32', 'ignore-flag'],
913         '--ignore-arch-flag i386:-fstack-protector --ignore-arch-flag mipsel:-Werror=format-security', 8,
914         "checking './t/logs/arch-i386'...
915 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
916 checking './t/logs/arch-amd64'...
917 CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
918 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
919 checking './t/logs/arch-avr32'...
920 CFLAGS missing (--param=ssp-buffer-size=4): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
921 checking './t/logs/ignore-flag'...
922 CFLAGS missing (-g): gcc    -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
923 CFLAGS missing (-O2): gcc -g     -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-c.c
924 "
925         ;
926
927 is_blhc ['arch-i386', 'arch-amd64', 'arch-avr32', 'ignore-line'],
928         '--ignore-arch-line "i386:gcc .+ -fPIE --param=ssp-buffer-size=4 .+" --ignore-arch-line "mipsel:gcc .+ -Wl,-z,relro -Wl,-z,now .+"', 8,
929         "checking './t/logs/arch-i386'...
930 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
931 checking './t/logs/arch-amd64'...
932 CFLAGS missing (-fstack-protector): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
933 LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
934 checking './t/logs/arch-avr32'...
935 CFLAGS missing (--param=ssp-buffer-size=4): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
936 checking './t/logs/ignore-line'...
937 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security):     ./prepare-script gcc test-a.c test-b.c test-c.c
938 CPPFLAGS missing (-D_FORTIFY_SOURCE=2):     ./prepare-script gcc test-a.c test-b.c test-c.c
939 LDFLAGS missing (-Wl,-z,relro):     ./prepare-script gcc test-a.c test-b.c test-c.c
940 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): ./prepare-script gcc test-a.c
941 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): ./prepare-script gcc test-a.c
942 LDFLAGS missing (-Wl,-z,relro): ./prepare-script gcc test-a.c
943 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): ./prepare-script gcc test-b.c
944 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): ./prepare-script gcc test-b.c
945 LDFLAGS missing (-Wl,-z,relro): ./prepare-script gcc test-b.c
946 CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): ./prepare-script gcc test-c.c
947 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): ./prepare-script gcc test-c.c
948 LDFLAGS missing (-Wl,-z,relro): ./prepare-script gcc test-c.c
949 "
950         ;