+CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): libtool: link: gcc -Wl,-z,relro -o test.so test.c
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): libtool: link: gcc -Wl,-z,relro -o test.so test.c
+LDFLAGS missing (-fPIE -pie -Wl,-z,now): libtool: link: gcc -Wl,-z,relro -o test.so test.c
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): libtool: link: gcc -Wl,-z,relro -o libtest.la test.h test-a.lo test-b.lo test-c.lo test-d.la
+LDFLAGS missing (-fPIE -pie -Wl,-z,now): libtool: link: gcc -Wl,-z,relro -o libtest.la test.h test-a.lo test-b.lo test-c.lo test-d.la
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): libtool: link: gcc -o libtest.la test.h test-a.lo test-b.lo test-c.lo test-d.la
+LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): libtool: link: gcc -o libtest.la test.h test-a.lo test-b.lo test-c.lo test-d.la
+NONVERBOSE BUILD: /usr/share/apr-1.0/build/libtool --silent --mode=compile x86_64-linux-gnu-gcc -std=gnu99 -I/usr/include/libxml2 -pthread -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ... -prefer-pic -c mod_buffer.c
+NONVERBOSE BUILD: /usr/share/apr-1.0/build/libtool --silent --mode=link x86_64-linux-gnu-gcc -std=gnu99 -I/usr/include/libxml2 -pthread -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wl,--as-needed -Wl,-z,relro -o mod_buffer.la -rpath /usr/lib/apache2/modules -module -avoid-version mod_buffer.lo
+NONVERBOSE BUILD: /usr/share/apr-1.0/build/libtool --silent --mode=link x86_64-linux-gnu-gcc -std=gnu99 -pthread -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -lssl -lcrypto -pie -Wl,--as-needed -Wl,-z,relro -o ab ab.lo -lcap /usr/lib/libaprutil-1.la /usr/lib/libapr-1.la -lm
+NONVERBOSE BUILD: /usr/share/apr-1.0/build/libtool --silent --mode=link x86_64-linux-gnu-gcc -std=gnu99 -pthread -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -lssl -lcrypto -pie \ -Wl,--as-needed -Wl,-z,relro -o ab ab.lo -lcap /usr/lib/libaprutil-1.la /usr/lib/libapr-1.la -lm
+NONVERBOSE BUILD: /bin/bash ../libtool --silent --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -MT coloredstderr.lo -MD -MP -MF .deps/coloredstderr.Tpo -c -o coloredstderr.lo coloredstderr.c
+NONVERBOSE BUILD: /bin/bash ../libtool --silent --tag=CC --mode=link gcc -Wall -Wextra -Wconversion -g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIE -pie -Wl,-z,relro -Wl,-z,now -o libcoloredstderr.la -rpath /usr/local/lib coloredstderr.lo -ldl
+';
+
+
+# different architectures
+
+my $arch_avr32 =
+ '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
+';
+is_blhc 'arch-avr32', '', 8,
+ $arch_avr32;
+
+my $arch_i386 =
+ '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
+LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o
+';
+is_blhc 'arch-i386', '', 8,
+ $arch_i386;
+
+my $arch_ia64 =
+ 'CFLAGS missing (-fPIE): gcc -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
+LDFLAGS missing (-pie): gcc -fPIE -o test test.o
+';
+is_blhc 'arch-ia64', '', 8,
+ $arch_ia64;
+
+is_blhc 'arch-mipsel', '', 8,
+ 'CFLAGS missing (-Werror=format-security): gcc -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Wformat-security -Wall -c test.c
+LDFLAGS missing (-Wl,-z,relro): gcc -Wl,-z,now -o test test.o
+';
+
+is_blhc 'arch-ia64', '--arch i386', 8,
+ '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
+LDFLAGS missing (-Wl,-z,relro): gcc -fPIE -pie -o test test.o
+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
+LDFLAGS missing (-pie -Wl,-z,relro): gcc -fPIE -o test test.o
+';
+
+
+# architecture in older buildd logs
+
+is_blhc 'dpkg-buildpackage-architecture-old', '', 0,
+ '';
+
+
+# correct architecture detection
+
+is_blhc 'buildd-architecture', '', 0, '';
+is_blhc 'buildd-architecture-old', '', 0, '';
+
+
+# ignore architecture
+
+is_blhc ['arch-avr32', 'arch-i386', 'empty', 'arch-mipsel'],
+ '--ignore-arch avr32 --ignore-arch mipsel',
+ 9,
+ "checking './t/logs/arch-avr32'...\n"
+ . "ignoring architecture 'avr32'\n"
+ . "checking './t/logs/arch-i386'...\n"
+ . $arch_i386
+ . "checking './t/logs/empty'...\n"
+ . $empty
+ . "checking './t/logs/arch-mipsel'...\n"
+ . "ignoring architecture 'mipsel'\n"
+ ;
+
+is_blhc 'buildd-dpkg-dev', '--ignore-arch i386', 0,
+ "ignoring architecture 'i386'\n";
+
+
+# debian
+
+is_blhc 'debian', '', 8,
+ '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
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c `dpkg-buildflags --get CFLAGS` test.c
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++ -c `dpkg-buildflags --get CXXFLAGS` test.cc
+CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security): gcc -c `dpkg-buildflags --get LDFLAGS` test.c
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c `dpkg-buildflags --get LDFLAGS` test.c
+LDFLAGS missing (-Wl,-z,relro): gcc -o test test.o `dpkg-buildflags --get CFLAGS`
+';
+
+is_blhc 'debian-cmake', '', 32,
+ 'INVALID CMAKE: 2.8.7-1
+';
+is_blhc 'debian-cmake-2', '', 32,
+ 'INVALID CMAKE: 2.8.7-2
+';
+is_blhc 'debian-cmake-ok', '', 0,
+ '';
+
+my $debian_hardening_wrapper =
+ 'HARDENING WRAPPER: no checks possible, aborting
+';
+is_blhc 'debian-hardening-wrapper', '', 16,
+ $debian_hardening_wrapper;
+is_blhc 'debian-hardening-wrapper-old-build-depends', '', 16,
+ $debian_hardening_wrapper;
+is_blhc 'debian-hardening-wrapper-pbuilder', '', 16,
+ $debian_hardening_wrapper;
+
+
+# false positives
+
+is_blhc 'false-positives', '', 1,
+ $empty;
+
+
+# buildd support
+
+is_blhc 'empty', '--buildd', 0,
+ 'I-no-compiler-commands||
+';
+
+is_blhc 'buildd-package-details', '--buildd', 0,
+ '';
+
+is_blhc 'buildd-dpkg-dev', '--buildd', 0,
+ 'W-dpkg-buildflags-missing|CPPFLAGS 7 (of 7), CFLAGS 6 (of 6), CXXFLAGS 1 (of 1), LDFLAGS 2 (of 2) missing|
+';
+
+is_blhc 'buildd-dpkg-dev-old', '--buildd', 0,
+ 'W-dpkg-buildflags-missing|CFLAGS 3 (of 6), CXXFLAGS 1 (of 1) missing|
+';
+
+is_blhc 'buildd-dpkg-dev-missing', '--buildd', 0,
+ 'W-dpkg-buildflags-missing|CFLAGS 3 (of 6), CXXFLAGS 1 (of 1) missing|
+';
+
+is_blhc 'debian-hardening-wrapper', '--buildd', 0,
+ 'I-hardening-wrapper-used||
+';
+is_blhc 'debian-hardening-wrapper-pbuilder', '--buildd', 0,
+ 'I-hardening-wrapper-used||
+';
+
+is_blhc 'buildd-verbose-build', '--buildd', 0,
+ 'W-compiler-flags-hidden|3 (of 5) hidden|
+';
+
+is_blhc 'make', '--buildd', 0,
+ 'I-no-compiler-commands||
+';
+
+is_blhc 'debian-cmake', '--buildd', 0,
+ 'I-invalid-cmake-used|2.8.7-1|
+';
+
+
+# multiple files
+
+is_blhc ['good', 'good-pie', 'good-bindnow', 'good-all', 'good-multiline', 'good-library'], '', 0,
+ "checking './t/logs/good'...
+checking './t/logs/good-pie'...
+checking './t/logs/good-bindnow'...
+checking './t/logs/good-all'...
+checking './t/logs/good-multiline'...
+checking './t/logs/good-library'...
+";
+is_blhc ['good-all', 'good-library'], '--all', 0,
+ "checking './t/logs/good-all'...
+checking './t/logs/good-library'...