# Tests for blhc.
#
-# Copyright (C) 2012-2020 Simon Ruderich
+# Copyright (C) 2012-2024 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
use strict;
use warnings;
-use Test::More tests => 244;
+use Test::More tests => 248;
sub is_blhc {
$usage;
is_blhc '', '--version', 0,
- 'blhc 0.12 Copyright (C) 2012-2020 Simon Ruderich
+ 'blhc 0.13 Copyright (C) 2012-2024 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
# 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
";
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
NONVERBOSE BUILD: /bin/bash ../libtool --silent --tag=CC --mode=link gcc -Wall -Wextra -Wconversion -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -fPIE -pie -Wl,-z,relro -Wl,-z,now -o libcoloredstderr.la -rpath /usr/local/lib coloredstderr.lo -ldl
';
+# cargo/rust
+
+is_blhc 'cargo', '', 1,
+ $empty;
+
+
# 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
# 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"
. $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