1#!/usr/bin/perl 2 3# test standard configurations: 4# - build 5# - run test suite 6# - run compat.sh 7# 8# Usage: tests/scripts/test-ref-configs.pl [config-name [...]] 9 10use warnings; 11use strict; 12 13my %configs = ( 14 'config-mini-tls1_1.h' => { 15 'compat' => '-m tls1_1 -f \'^DES-CBC3-SHA$\|^TLS-RSA-WITH-3DES-EDE-CBC-SHA$\'', 16 }, 17 'config-suite-b.h' => { 18 'compat' => "-m tls1_2 -f 'ECDHE-ECDSA.*AES.*GCM' -p mbedTLS", 19 }, 20 'config-picocoin.h' => { 21 }, 22 'config-ccm-psk-tls1_2.h' => { 23 'compat' => '-m tls1_2 -f \'^TLS-PSK-WITH-AES-...-CCM-8\'', 24 }, 25 'config-thread.h' => { 26 'opt' => '-f ECJPAKE.*nolog', 27 }, 28); 29 30# If no config-name is provided, use all known configs. 31# Otherwise, use the provided names only. 32if ($#ARGV >= 0) { 33 my %configs_ori = ( %configs ); 34 %configs = (); 35 36 foreach my $conf_name (@ARGV) { 37 if( ! exists $configs_ori{$conf_name} ) { 38 die "Unknown configuration: $conf_name\n"; 39 } else { 40 $configs{$conf_name} = $configs_ori{$conf_name}; 41 } 42 } 43} 44 45-d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n"; 46 47my $config_h = 'include/mbedtls/config.h'; 48 49system( "cp $config_h $config_h.bak" ) and die; 50sub abort { 51 system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; 52 die $_[0]; 53} 54 55while( my ($conf, $data) = each %configs ) { 56 system( "cp $config_h.bak $config_h" ) and die; 57 system( "make clean" ) and die; 58 59 print "\n******************************************\n"; 60 print "* Testing configuration: $conf\n"; 61 print "******************************************\n"; 62 63 system( "cp configs/$conf $config_h" ) 64 and abort "Failed to activate $conf\n"; 65 66 system( "make CFLAGS='-Os -Werror'" ) and abort "Failed to build: $conf\n"; 67 system( "make test" ) and abort "Failed test suite: $conf\n"; 68 69 my $compat = $data->{'compat'}; 70 if( $compat ) 71 { 72 print "\nrunning compat.sh $compat\n"; 73 system( "tests/compat.sh $compat" ) 74 and abort "Failed compat.sh: $conf\n"; 75 } 76 else 77 { 78 print "\nskipping compat.sh\n"; 79 } 80 81 my $opt = $data->{'opt'}; 82 if( $opt ) 83 { 84 print "\nrunning ssl-opt.sh $opt\n"; 85 system( "tests/ssl-opt.sh $opt" ) 86 and abort "Failed ssl-opt.sh: $conf\n"; 87 } 88 else 89 { 90 print "\nskipping ssl-opt.sh\n"; 91 } 92} 93 94system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; 95system( "make clean" ); 96exit 0; 97