From 20f236de37da35e6a5f72c232ddc737b3ffdf8a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 11 Sep 2019 10:01:10 +0200 Subject: [PATCH] Adjust depends-hashes.pl to test NO_SHA384 as well --- tests/scripts/depends-hashes.pl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/scripts/depends-hashes.pl b/tests/scripts/depends-hashes.pl index 7cb41b55c..898ae497c 100755 --- a/tests/scripts/depends-hashes.pl +++ b/tests/scripts/depends-hashes.pl @@ -40,8 +40,18 @@ my @ssl = split( /\s+/, `sed -n -e '$ssl_sed_cmd' $config_h` ); # for md we want to catch MD5_C but not MD_C, hence the extra dot my $mdx_sed_cmd = 's/^#define \(MBEDTLS_MD..*_C\)/\1/p'; my $sha_sed_cmd = 's/^#define \(MBEDTLS_SHA.*_C\)/\1/p'; -my @hashes = split( /\s+/, +my @hash_modules = split( /\s+/, `sed -n -e '$mdx_sed_cmd' -e '$sha_sed_cmd' $config_h` ); + +# there are also negative options for truncated variants, disabled by default +my $sha_trunc_sed_cmd = 's/^\/\/#define \(MBEDTLS_SHA..._NO_.*\)/\1/p'; +my @hash_negatives = split( /\s+/, + `sed -n -e '$sha_trunc_sed_cmd' $config_h` ); + +# list hash options with corresponding actions +my @hashes = ((map { "unset $_" } @hash_modules), + (map { "set $_" } @hash_negatives)); + system( "cp $config_h $config_h.bak" ) and die; sub abort { system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; @@ -55,12 +65,12 @@ for my $hash (@hashes) { system( "make clean" ) and die; print "\n******************************************\n"; - print "* Testing without hash: $hash\n"; + print "* Testing hash option: $hash\n"; print "******************************************\n"; $ENV{MBEDTLS_TEST_CONFIGURATION} = "-$hash"; - system( "scripts/config.py unset $hash" ) - and abort "Failed to disable $hash\n"; + system( "scripts/config.py $hash" ) + and abort "Failed to $hash\n"; for my $opt (@ssl) { system( "scripts/config.py unset $opt" )