Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 1 | #!/usr/bin/perl |
| 2 | |
| 3 | # test standard configurations: |
| 4 | # - build |
| 5 | # - run test suite |
| 6 | # - run compat.sh |
Manuel Pégourié-Gonnard | 827b6ce | 2014-04-30 12:05:29 +0200 | [diff] [blame] | 7 | # |
| 8 | # Usage: tests/scripts/test-ref-configs.pl [config-name [...]] |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 9 | |
| 10 | use warnings; |
| 11 | use strict; |
| 12 | |
| 13 | my %configs = ( |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 14 | 'config-mini-tls1_1.h' |
Manuel Pégourié-Gonnard | 827b6ce | 2014-04-30 12:05:29 +0200 | [diff] [blame] | 15 | => '-m tls1_1 -f \'^DES-CBC3-SHA$\|^TLS-RSA-WITH-3DES-EDE-CBC-SHA$\'', |
| 16 | 'config-suite-b.h' |
Manuel Pégourié-Gonnard | e4f6edc | 2015-01-22 16:43:54 +0000 | [diff] [blame] | 17 | => "-m tls1_2 -f 'ECDHE-ECDSA.*AES.*GCM' -p mbedTLS", |
Manuel Pégourié-Gonnard | 43b2986 | 2014-06-24 11:25:43 +0200 | [diff] [blame] | 18 | 'config-picocoin.h' |
| 19 | => 0, |
Manuel Pégourié-Gonnard | 1a74a26 | 2014-06-24 15:51:32 +0200 | [diff] [blame] | 20 | 'config-ccm-psk-tls1_2.h' |
Manuel Pégourié-Gonnard | cc10f4d | 2014-06-30 19:22:44 +0200 | [diff] [blame] | 21 | => '-m tls1_2 -f \'^TLS-PSK-WITH-AES-...-CCM-8\'', |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 22 | ); |
| 23 | |
Manuel Pégourié-Gonnard | 827b6ce | 2014-04-30 12:05:29 +0200 | [diff] [blame] | 24 | # If no config-name is provided, use all known configs. |
| 25 | # Otherwise, use the provided names only. |
Paul Bakker | 30a3062 | 2013-12-19 17:09:49 +0100 | [diff] [blame] | 26 | if ($#ARGV >= 0) { |
Manuel Pégourié-Gonnard | 827b6ce | 2014-04-30 12:05:29 +0200 | [diff] [blame] | 27 | my %configs_ori = ( %configs ); |
| 28 | %configs = (); |
Paul Bakker | 30a3062 | 2013-12-19 17:09:49 +0100 | [diff] [blame] | 29 | |
Manuel Pégourié-Gonnard | 827b6ce | 2014-04-30 12:05:29 +0200 | [diff] [blame] | 30 | foreach my $conf_name (@ARGV) { |
| 31 | if( ! exists $configs_ori{$conf_name} ) { |
| 32 | die "Unknown configuration: $conf_name\n"; |
| 33 | } else { |
| 34 | $configs{$conf_name} = $configs_ori{$conf_name}; |
| 35 | } |
Paul Bakker | 30a3062 | 2013-12-19 17:09:49 +0100 | [diff] [blame] | 36 | } |
Paul Bakker | 30a3062 | 2013-12-19 17:09:49 +0100 | [diff] [blame] | 37 | } |
| 38 | |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 39 | -d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n"; |
| 40 | |
| 41 | my $test = system( "grep -i cmake Makefile >/dev/null" ) ? 'check' : 'test'; |
| 42 | |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 43 | my $config_h = 'include/mbedtls/config.h'; |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 44 | |
| 45 | system( "cp $config_h $config_h.bak" ) and die; |
| 46 | sub abort { |
| 47 | system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; |
| 48 | die $_[0]; |
| 49 | } |
| 50 | |
| 51 | while( my ($conf, $args) = each %configs ) { |
| 52 | system( "cp $config_h.bak $config_h" ) and die; |
| 53 | system( "make clean" ) and die; |
| 54 | |
| 55 | print "\n******************************************\n"; |
| 56 | print "* Testing configuration: $conf\n"; |
| 57 | print "******************************************\n"; |
| 58 | |
Manuel Pégourié-Gonnard | 0bc1f23 | 2014-04-30 11:53:50 +0200 | [diff] [blame] | 59 | system( "cp configs/$conf $config_h" ) |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 60 | and abort "Failed to activate $conf\n"; |
| 61 | |
| 62 | system( "make" ) and abort "Failed to build: $conf\n"; |
| 63 | system( "make $test" ) and abort "Failed test suite: $conf\n"; |
Manuel Pégourié-Gonnard | 43b2986 | 2014-06-24 11:25:43 +0200 | [diff] [blame] | 64 | |
| 65 | if( $args ) |
| 66 | { |
| 67 | print "\nrunning compat.sh $args\n"; |
Manuel Pégourié-Gonnard | 3d404b4 | 2015-07-08 21:59:16 +0100 | [diff] [blame^] | 68 | system( "tests/compat.sh $args" ) |
Manuel Pégourié-Gonnard | 43b2986 | 2014-06-24 11:25:43 +0200 | [diff] [blame] | 69 | and abort "Failed compat.sh: $conf\n"; |
| 70 | } |
| 71 | else |
| 72 | { |
| 73 | print "\nskipping compat.sh\n"; |
| 74 | } |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; |
| 78 | system( "make clean" ); |
| 79 | exit 0; |