X-Git-Url: https://ruderich.org/simon/gitweb/?p=blhc%2Fblhc.git;a=blobdiff_plain;f=t%2Ftests.t;h=d9c15c311f23ee4dfb0c61682e9385293eced2e9;hp=7fc4f9e534a11f8ab724623fd1577808de1ce9ed;hb=fd2822367ae3c4bcc451d2f82e4b1cee87a741d6;hpb=53e64de60f08fcb752b1f3ccb41c9e8555be8866 diff --git a/t/tests.t b/t/tests.t index 7fc4f9e..d9c15c3 100644 --- a/t/tests.t +++ b/t/tests.t @@ -19,7 +19,7 @@ use strict; use warnings; -use Test::More tests => 110; +use Test::More tests => 122; sub is_blhc { @@ -31,7 +31,8 @@ sub is_blhc { $file = "@{$file}"; } - my $output = `./bin/blhc $options ./t/logs/$file 2>&1`; + $file = "./t/logs/$file" if $file; + my $output = `./bin/blhc $options $file 2>&1`; if ($options) { $options = ' '. $options; @@ -41,14 +42,19 @@ sub is_blhc { } -# Usage. +# Usage, invalid arguments. -is_blhc 'empty', '--invalid', 2, - 'Unknown option: invalid -Usage: +my $usage = + 'Usage: blhc [*options*] *..* '; +is_blhc '', '--invalid', 2, + "Unknown option: invalid\n" + . $usage; + +is_blhc '', '', 2, + $usage; # No compiler commands found. @@ -58,6 +64,13 @@ is_blhc 'empty', '', 1, $empty; +# ANSI colored output. + +is_blhc 'arch-avr32', '--color', 8, + "\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 +"; + + # Correct build logs. is_blhc 'good', '', 0, @@ -104,8 +117,10 @@ CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++ -g -O2 -fstack-protector --param=ss 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 LDFLAGS missing (-Wl,-z,relro): gcc -o test test-a.o test-b.o test-c.a 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 -CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.s +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.S CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -E test.c +CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc -S test.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -S test.c CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc test.c CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c LDFLAGS missing (-Wl,-z,relro): gcc test.c @@ -141,8 +156,10 @@ LDFLAGS missing (-fPIE -pie -Wl,-z,relro): g++ -g -O2 -fstack-protector --param 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 LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc -o test test-a.o test-b.o test-c.a 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 -CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.s +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.S CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -E test.c +CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc -S test.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -S test.c CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc test.c CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc test.c @@ -178,8 +195,10 @@ LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): g++ -g -O2 -fstack-protector --param 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 LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc -o test test-a.o test-b.o test-c.a 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 -CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.s +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.S CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -E test.c +CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc -S test.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -S test.c CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc test.c CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc test.c @@ -216,8 +235,10 @@ LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): g++ -g -O2 -fstack-protec 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 LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc -o test test-a.o test-b.o test-c.a 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 -CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.s +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -o test test.S CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -E test.c +CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc -S test.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -S test.c CFLAGS missing (-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc test.c CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc test.c @@ -602,8 +623,13 @@ 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 @@ -629,6 +655,14 @@ is_blhc 'buildd-dpkg-dev-old', '--buildd', 8, 'W-dpkg-buildflags-missing CFLAGS 3 (of 6), CXXFLAGS 1 (of 1) missing '; +is_blhc 'buildd-dpkg-dev-missing', '--buildd', 8, + 'W-dpkg-buildflags-missing CFLAGS 3 (of 6), CXXFLAGS 1 (of 1) missing +'; + +is_blhc 'debian-hardening-wrapper', '--buildd', 16, + 'I-hardening-wrapper-used +'; + is_blhc 'buildd-verbose-build', '--buildd', 4, 'W-compiler-flags-hidden 1 (of 5) hidden '; @@ -638,7 +672,7 @@ is_blhc 'make', '--buildd', 1, '; is_blhc 'debian-cmake', '--buildd', 32, - 'W-invalid-cmake-used 2.8.7-2 + 'W-invalid-cmake-used 2.8.7-1 ';