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