X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=t%2Ftests.t;h=8102a7aa6d1b077b0f92d3e8d17b082ff4753b2b;hb=fb2c46d23c6052c714729d70d33d54011374689b;hp=cd5e345a3d15ed7ce589837b6a0edcf251a8f83e;hpb=c16e86feba1469ae7ccac10e425953b055408a44;p=blhc%2Fblhc.git diff --git a/t/tests.t b/t/tests.t index cd5e345..8102a7a 100644 --- a/t/tests.t +++ b/t/tests.t @@ -1,6 +1,6 @@ # Tests for blhc. # -# Copyright (C) 2012-2018 Simon Ruderich +# Copyright (C) 2012-2023 Simon Ruderich # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ use strict; use warnings; -use Test::More tests => 236; +use Test::More tests => 246; sub is_blhc { @@ -67,7 +67,7 @@ is_blhc '', '', 2, $usage; is_blhc '', '--version', 0, - 'blhc 0.09 Copyright (C) 2012-2018 Simon Ruderich + 'blhc 0.13 Copyright (C) 2012-2023 Simon Ruderich This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -103,8 +103,9 @@ is_blhc 'empty', '', 1, # ANSI colored output. -is_blhc 'arch-avr32', '--color', 8, - "\033[31mCFLAGS missing\033[0m (-fstack-protector-strong)\033[33m:\033[0m gcc -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c +is_blhc 'arch-amd64', '--color', 8, + "\033[31mCFLAGS missing\033[0m (-fstack-protector-strong)\033[33m:\033[0m gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE -Wformat -Wformat-security -Werror=format-security -Wall -c test.c +\033[31mLDFLAGS missing\033[0m (-pie)\033[33m:\033[0m gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o "; @@ -162,6 +163,17 @@ is_blhc 'arch-i386', '--ignore-arch-flag amd64:-fstack-protector-strong --ignore LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o '; +# Ignore certain lines (through inline command). + +is_blhc 'ignore-line-inline', '', 8, + 'CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): ./prepare-script gcc test-a.c test-b.c test-c.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): ./prepare-script gcc test-a.c test-b.c test-c.c +LDFLAGS missing (-Wl,-z,relro): ./prepare-script gcc test-a.c test-b.c test-c.c +'; + +is_blhc 'ignore-line-inline2', '', 0, + ''; + # Ignore certain lines. @@ -435,6 +447,15 @@ CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test.c -o test.output LDFLAGS missing (-Wl,-z,relro): gcc test.c -o test.output CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): (gcc -Wl,-z,relro -o test.output test.c) CPPFLAGS missing (-D_FORTIFY_SOURCE=2): (gcc -Wl,-z,relro -o test.output test.c) +CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): gcc test-comma.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-comma.c +LDFLAGS missing (-Wl,-z,relro): gcc test-comma.c +CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): gcc test-and.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-and.c +LDFLAGS missing (-Wl,-z,relro): gcc test-and.c +CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): gcc test-or.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-or.c +LDFLAGS missing (-Wl,-z,relro): gcc test-or.c '; is_blhc 'bad-cflags', '--pie', 8, 'CFLAGS missing (-fPIE -Wformat): gcc -g -O2 -fstack-protector-strong -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c @@ -453,6 +474,15 @@ LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc test.c -o test.output CFLAGS missing (-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security): (gcc -Wl,-z,relro -o test.output test.c) CPPFLAGS missing (-D_FORTIFY_SOURCE=2): (gcc -Wl,-z,relro -o test.output test.c) LDFLAGS missing (-fPIE -pie): (gcc -Wl,-z,relro -o test.output test.c) +CFLAGS missing (-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security): gcc test-comma.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-comma.c +LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc test-comma.c +CFLAGS missing (-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security): gcc test-and.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-and.c +LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc test-and.c +CFLAGS missing (-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security): gcc test-or.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-or.c +LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc test-or.c '; is_blhc 'bad-cflags', '--bindnow', 8, 'CFLAGS missing (-Wformat): gcc -g -O2 -fstack-protector-strong -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c @@ -472,6 +502,15 @@ LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc test.c -o test.output CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): (gcc -Wl,-z,relro -o test.output test.c) CPPFLAGS missing (-D_FORTIFY_SOURCE=2): (gcc -Wl,-z,relro -o test.output test.c) LDFLAGS missing (-Wl,-z,now): (gcc -Wl,-z,relro -o test.output test.c) +CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): gcc test-comma.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-comma.c +LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc test-comma.c +CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): gcc test-and.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-and.c +LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc test-and.c +CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): gcc test-or.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-or.c +LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): gcc test-or.c '; is_blhc 'bad-cflags', '--pie --bindnow', 8, 'CFLAGS missing (-fPIE -Wformat): gcc -g -O2 -fstack-protector-strong -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c @@ -491,6 +530,15 @@ LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc test.c -o test.output CFLAGS missing (-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security): (gcc -Wl,-z,relro -o test.output test.c) CPPFLAGS missing (-D_FORTIFY_SOURCE=2): (gcc -Wl,-z,relro -o test.output test.c) LDFLAGS missing (-fPIE -pie -Wl,-z,now): (gcc -Wl,-z,relro -o test.output test.c) +CFLAGS missing (-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security): gcc test-comma.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-comma.c +LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc test-comma.c +CFLAGS missing (-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security): gcc test-and.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-and.c +LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc test-and.c +CFLAGS missing (-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security): gcc test-or.c +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc test-or.c +LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc test-or.c '; is_blhc 'bad-cflags-stackprotector', '', 8, 'CFLAGS missing (-fstack-protector-strong): gcc -g -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c -fno-stack-protector test-a.c @@ -586,6 +634,10 @@ CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector-strong -Wfo LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc -g -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security test.c -o lib`basename test/test`.so '; +is_blhc 'env', '--all', 8, + 'CPPFLAGS missing (-D_FORTIFY_SOURCE=2): VERSION="`echo hi`" CPP="gcc -x assembler-with-cpp -E -P -Wdate-time -D_FORTIFY_SOURCE=2" CPPFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2" ../../config/gen-posix-names.sh _SC_ ml_sysconf.h +'; + # check the build log is verbose @@ -633,10 +685,12 @@ NONVERBOSE BUILD: Compiling test_file.cxx... CXXFLAGS missing (-fstack-protector-strong): g++ -g -O2 -fPIC -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test_file.cxx NONVERBOSE BUILD: [ 22%] Building CXX object src/CMakeFiles/test/test.cpp.o NONVERBOSE BUILD: [ 82%] Building C object src/CMakeFiles/test/test.c.o -CXXFLAGS missing (-Wformat): cd /tmp/test/src && /usr/bin/c++ -g -O2 -fstack-protector-strong -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 -CFLAGS missing (-Werror=format-security): cd /tmp/test/src && /usr/bin/gcc -g -O2 -fstack-protector-strong -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 +CXXFLAGS missing (-Wformat): /usr/bin/c++ -g -O2 -fstack-protector-strong -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 +CFLAGS missing (-Werror=format-security): /usr/bin/gcc -g -O2 -fstack-protector-strong -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 NONVERBOSE BUILD: Compiling test.c \ gcc test.c NONVERBOSE BUILD: [ 3%] Building CXX object scribus/text/CMakeFiles/scribus_text_lib.dir/frect.cpp.o +NONVERBOSE BUILD: [ 1/13] Compiling src/instance.c +NONVERBOSE BUILD: [11/13] Compiling suil.pc.in '; is_blhc 'parallel', '', 0, ''; @@ -787,6 +841,16 @@ LDFLAGS missing (-Wl,-z,relro): gfortran -g -w -O2 -Wtabs -ffixed-line-length-13 CFLAGS missing (-fstack-protector-strong): mpifort -cpp -DDOUB -g -O2 -fdebug-prefix-map=/«PKGBUILDDIR»=. -c -o transform.o transform.f90 '; +is_blhc 'fortran-no-build-deps', '', 8, + 'CFLAGS missing (-fstack-protector-strong): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -Wl,-z,relro -o balls balls.f +CFLAGS missing (-fstack-protector-strong): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -c -o quadric.o quadric.f +CFLAGS missing (-fstack-protector-strong): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -c -o suv.o suv.f +CFLAGS missing (-fstack-protector-strong): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 \ rastep.f quadric.o suv.o -Wl,-z,relro \ -o rastep +CFLAGS missing (-fstack-protector-strong): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -c -o render.o render.f +LDFLAGS missing (-Wl,-z,relro): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -fstack-protector-strong -o balls-without-ldflags balls.f +CFLAGS missing (-fstack-protector-strong): mpifort -cpp -DDOUB -g -O2 -fdebug-prefix-map=/«PKGBUILDDIR»=. -c -o transform.o transform.f90 +'; + # libtool @@ -824,11 +888,9 @@ NONVERBOSE BUILD: /bin/bash ../libtool --silent --tag=CC --mode=link gcc -Wal # different architectures -my $arch_avr32 = - 'CFLAGS missing (-fstack-protector-strong): gcc -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c -'; -is_blhc 'arch-avr32', '', 8, - $arch_avr32; +my $arch_hppa = ''; +is_blhc 'arch-hppa', '', 0, + $arch_hppa; my $arch_i386 = 'CFLAGS missing (-fstack-protector-strong): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE -Wformat -Wformat-security -Werror=format-security -Wall -c test.c @@ -857,6 +919,11 @@ LDFLAGS missing (-pie -Wl,-z,relro): gcc -fPIE -o test test.o is_blhc 'dpkg-buildpackage-architecture-old', '', 0, ''; +# architecture in newer buildd logs + +is_blhc 'dpkg-buildpackage-architecture-new', '', 0, + ''; + # correct architecture detection @@ -866,11 +933,11 @@ is_blhc 'buildd-architecture-old', '', 0, ''; # ignore architecture -is_blhc ['arch-avr32', 'arch-i386', 'empty', 'arch-mipsel'], - '--ignore-arch avr32 --ignore-arch mipsel', +is_blhc ['arch-hppa', 'arch-i386', 'empty', 'arch-mipsel'], + '--ignore-arch hppa --ignore-arch mipsel', 9, - "checking './t/logs/arch-avr32'...\n" - . "ignoring architecture 'avr32'\n" + "checking './t/logs/arch-hppa'...\n" + . "ignoring architecture 'hppa'\n" . "checking './t/logs/arch-i386'...\n" . $arch_i386 . "checking './t/logs/empty'...\n" @@ -1013,42 +1080,40 @@ is_blhc ['arch-i386', 'arch-ia64'], '', 8, . $arch_ia64; # No exit when multiple files are specified. -is_blhc ['bad-ldflags', 'empty', 'arch-avr32', 'debian-hardening-wrapper'], '', 25, +is_blhc ['bad-ldflags', 'empty', 'arch-hppa', 'debian-hardening-wrapper'], '', 25, "checking './t/logs/bad-ldflags'...\n" . $bad_ldflags . "checking './t/logs/empty'...\n" . $empty - . "checking './t/logs/arch-avr32'...\n" - . $arch_avr32 + . "checking './t/logs/arch-hppa'...\n" + . $arch_hppa . "checking './t/logs/debian-hardening-wrapper'...\n" . $debian_hardening_wrapper ; # Ignore works correctly with multiple architectures. -is_blhc ['arch-i386', 'arch-amd64', 'arch-avr32', 'ignore-flag'], +is_blhc ['arch-i386', 'arch-amd64', 'arch-hppa', 'ignore-flag'], '--ignore-arch-flag i386:-fstack-protector-strong --ignore-arch-flag mipsel:-Werror=format-security', 8, "checking './t/logs/arch-i386'... LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o checking './t/logs/arch-amd64'... CFLAGS missing (-fstack-protector-strong): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE -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 -checking './t/logs/arch-avr32'... -CFLAGS missing (-fstack-protector-strong): gcc -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c +checking './t/logs/arch-hppa'... checking './t/logs/ignore-flag'... CFLAGS missing (-g): gcc -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c CFLAGS missing (-O2): gcc -g -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-c.c " ; -is_blhc ['arch-i386', 'arch-amd64', 'arch-avr32', 'ignore-line'], +is_blhc ['arch-i386', 'arch-amd64', 'arch-hppa', 'ignore-line'], '--ignore-arch-line "i386:gcc .+ -fPIE .+" --ignore-arch-line "mipsel:gcc .+ -Wl,-z,relro -Wl,-z,now .+"', 8, "checking './t/logs/arch-i386'... LDFLAGS missing (-pie): gcc -fPIE -Wl,-z,relro -Wl,-z,now -o test test.o checking './t/logs/arch-amd64'... CFLAGS missing (-fstack-protector-strong): gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE -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 -checking './t/logs/arch-avr32'... -CFLAGS missing (-fstack-protector-strong): gcc -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c +checking './t/logs/arch-hppa'... checking './t/logs/ignore-line'... CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): ./prepare-script gcc test-a.c test-b.c test-c.c CPPFLAGS missing (-D_FORTIFY_SOURCE=2): ./prepare-script gcc test-a.c test-b.c test-c.c