Adjust depends-hashes.pl to test NO_SHA384 as well

This commit is contained in:
Manuel Pégourié-Gonnard 2019-09-11 10:01:10 +02:00
parent d602084cde
commit 20f236de37

View File

@ -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 # 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 $mdx_sed_cmd = 's/^#define \(MBEDTLS_MD..*_C\)/\1/p';
my $sha_sed_cmd = 's/^#define \(MBEDTLS_SHA.*_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` ); `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; system( "cp $config_h $config_h.bak" ) and die;
sub abort { sub abort {
system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; 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; system( "make clean" ) and die;
print "\n******************************************\n"; print "\n******************************************\n";
print "* Testing without hash: $hash\n"; print "* Testing hash option: $hash\n";
print "******************************************\n"; print "******************************************\n";
$ENV{MBEDTLS_TEST_CONFIGURATION} = "-$hash"; $ENV{MBEDTLS_TEST_CONFIGURATION} = "-$hash";
system( "scripts/config.py unset $hash" ) system( "scripts/config.py $hash" )
and abort "Failed to disable $hash\n"; and abort "Failed to $hash\n";
for my $opt (@ssl) { for my $opt (@ssl) {
system( "scripts/config.py unset $opt" ) system( "scripts/config.py unset $opt" )