Update hashes dependencies testing script.

Since SHA384 depends on SHA512, depends-hashes script
should not generate configuration where SHA384 is defined
without SHA512.

Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
diff --git a/tests/scripts/depends-hashes.pl b/tests/scripts/depends-hashes.pl
index f8b750a..a57d75d 100755
--- a/tests/scripts/depends-hashes.pl
+++ b/tests/scripts/depends-hashes.pl
@@ -50,14 +50,18 @@
 my $ssl_sed_cmd = 's/^#define \(MBEDTLS_SSL.*\)/\1/p';
 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 @hash_modules = split( /\s+/,
-                    `sed -n -e '$mdx_sed_cmd' -e '$sha_sed_cmd' $config_h` );
-
-# list hash options with corresponding actions
-my @hashes = ((map { "unset $_" } @hash_modules));
+# Each element of this array holds list of configuration options that
+# should be tested together. Certain options depend on eachother and
+# separating them would generate invalid configurations.
+my @hash_configs = (
+    ['unset MBEDTLS_MD2_C'],
+    ['unset MBEDTLS_MD4_C'],
+    ['unset MBEDTLS_MD5_C'],
+    ['unset MBEDTLS_SHA512_C', 'unset MBEDTLS_SHA384_C '],
+    ['unset MBEDTLS_SHA384_C'],
+    ['unset MBEDTLS_SHA256_C'],
+    ['unset MBEDTLS_SHA1_C'],
+);
 
 system( "cp $config_h $config_h.bak" ) and die;
 sub abort {
@@ -67,17 +71,21 @@
     exit 1;
 }
 
-for my $hash (@hashes) {
+for my $hash_config (@hash_configs) {
     system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n";
     system( "make clean" ) and die;
 
-    print "\n******************************************\n";
-    print "* Testing hash option: $hash\n";
-    print "******************************************\n";
-    $ENV{MBEDTLS_TEST_CONFIGURATION} = "-$hash";
+    my $hash_config_string = join(', ', @$hash_config);
 
-    system( "scripts/config.py $hash" )
-        and abort "Failed to $hash\n";
+    print "\n******************************************\n";
+    print "* Testing hash options: $hash_config_string\n";
+    print "******************************************\n";
+    $ENV{MBEDTLS_TEST_CONFIGURATION} = "-$hash_config_string";
+
+    for my $hash (@$hash_config) {
+        system( "scripts/config.py $hash" )
+            and abort "Failed to $hash\n";
+    }
 
     for my $opt (@ssl) {
         system( "scripts/config.py unset $opt" )
@@ -85,9 +93,9 @@
     }
 
     system( "CFLAGS='-Werror -Wall -Wextra' make lib" )
-        and abort "Failed to build lib: $hash\n";
-    system( "cd tests && make" ) and abort "Failed to build tests: $hash\n";
-    system( "make test" ) and abort "Failed test suite: $hash\n";
+        and abort "Failed to build lib: $hash_config_string\n";
+    system( "cd tests && make" ) and abort "Failed to build tests: $hash_config_string\n";
+    system( "make test" ) and abort "Failed test suite: $hash_config_string\n";
 }
 
 system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n";