use strict;
use warnings;
-use Test::More tests => 92;
+use Test::More tests => 98;
sub is_blhc {
my ($file, $options, $exit, $expected) = @_;
+ # Multiple files as array references.
+ if (ref $file eq 'ARRAY') {
+ local $" = ' ./t/logs/';
+ $file = "@{$file}";
+ }
+
my $output = `./bin/blhc $options ./t/logs/$file 2>&1`;
if ($options) {
is_blhc 'empty', '--invalid', 2,
'Unknown option: invalid
Usage:
- blhc [options] <dpkg-buildpackage build log file>
+ blhc [options] <dpkg-buildpackage build log file>..
--all force +all (+pie, +bindnow) check
--arch set architecture (autodetected)
# No compiler commands found.
+my $empty = "No compiler commands!\n";
is_blhc 'empty', '', 1,
- "No compiler commands!\n";
+ $empty;
# Correct build logs.
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
';
-is_blhc 'bad-ldflags', '', 8,
+my $bad_ldflags =
'LDFLAGS missing (-Wl,-z,relro): gcc -o test test-a.o test-b.o test-c.o -ltest
';
+is_blhc 'bad-ldflags', '', 8,
+ $bad_ldflags;
is_blhc 'bad-ldflags', '--pie', 8,
'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
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
# different architectures
-is_blhc 'arch-avr32', '', 8,
+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;
is_blhc 'arch-i386', '', 8,
'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 (-Wl,-z,relro): gcc -o test test.o `dpkg-buildflags --get CFLAGS`
';
-is_blhc 'debian-hardening-wrapper', '', 16,
+my $debian_hardening_wrapper =
'HARDENING WRAPPER: no checks possible, aborting
';
+is_blhc 'debian-hardening-wrapper', '', 16,
+ $debian_hardening_wrapper;
# buildd support
CFLAGS missing (-O2): gcc -g -c test-b.c
CFLAGS missing (-O2): gcc -g -c test-c.c
';
+
+# multiple files
+
+is_blhc ['good', 'good-pie', 'good-bindnow', 'good-all', 'good-multiline', 'good-library'], '', 0,
+ '';
+is_blhc ['good-all', 'good-library'], '--all', 0,
+ '';
+
+# No exit when multiple files are specified.
+is_blhc ['bad-ldflags', 'empty', 'arch-avr32', 'debian-hardening-wrapper'], '', 25,
+ $bad_ldflags
+ . $empty
+ . $arch_avr32
+ . $debian_hardening_wrapper
+ ;