]> ruderich.org/simon Gitweb - blhc/blhc.git/blobdiff - t/tests.t
Support multiple log files as arguments.
[blhc/blhc.git] / t / tests.t
index 326021334db0c81a970caaa1c122ae5675472c7c..e3acca2da9ea3dcc4aae1e8f49af075fd11c0fcd 100644 (file)
--- a/t/tests.t
+++ b/t/tests.t
 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) {
@@ -40,7 +46,7 @@ sub is_blhc {
 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)
@@ -56,8 +62,9 @@ Usage:
 
 # No compiler commands found.
 
+my $empty = "No compiler commands!\n";
 is_blhc 'empty', '', 1,
-        "No compiler commands!\n";
+        $empty;
 
 
 # Correct build logs.
@@ -277,9 +284,11 @@ CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -fPIC -g -O2 -fstack-protector --par
 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
@@ -513,9 +522,11 @@ LDFLAGS missing (-fPIE -pie -Wl,-z,now): /bin/bash ../libtool --tag=CC   --mode=
 
 # 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
@@ -551,9 +562,11 @@ CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c `dpkg-buildflags --get LDFLAGS` t
 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
@@ -583,3 +596,18 @@ is_blhc 'buildd-dpkg-dev-old', '--buildd', 8,
 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
+        ;