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 |
| 7 | |
| 8 | use warnings; |
| 9 | use strict; |
| 10 | |
| 11 | my %configs = ( |
Manuel Pégourié-Gonnard | 244c06e | 2014-03-25 14:13:06 +0100 | [diff] [blame^] | 12 | 'config-psk-rc4-tls1_0.h' => '-m tls1 -f \'^PSK.*RC4\|TLS-PSK.*RC4\'', |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 13 | 'config-mini-tls1_1.h' |
Paul Bakker | 20ed0f7 | 2013-12-19 17:45:11 +0100 | [diff] [blame] | 14 | => '-m tls1_1 -f \'^DES-CBC3-SHA$\|^TLS-RSA-WITH-3DES-EDE-CBC-SHA$\'', |
Manuel Pégourié-Gonnard | 244c06e | 2014-03-25 14:13:06 +0100 | [diff] [blame^] | 15 | 'config-suite-b.h' => "-m tls1_2 -f 'ECDHE-ECDSA.*AES.*GCM'", |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 16 | ); |
| 17 | |
Paul Bakker | 30a3062 | 2013-12-19 17:09:49 +0100 | [diff] [blame] | 18 | if ($#ARGV >= 0) { |
| 19 | # filter configs |
| 20 | my @filtered_keys; |
| 21 | my %filtered_configs; |
| 22 | |
| 23 | foreach my $filter (@ARGV) { |
| 24 | push (@filtered_keys, $filter); |
| 25 | } |
| 26 | @filtered_keys = grep { exists $configs{$ARGV[0]} } @filtered_keys; |
| 27 | @filtered_configs{@filtered_keys} = @configs{@filtered_keys}; |
| 28 | |
| 29 | %configs = %filtered_configs; |
| 30 | } |
| 31 | |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 32 | -d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n"; |
| 33 | |
| 34 | my $test = system( "grep -i cmake Makefile >/dev/null" ) ? 'check' : 'test'; |
| 35 | |
| 36 | my $config_h = 'include/polarssl/config.h'; |
| 37 | |
| 38 | system( "cp $config_h $config_h.bak" ) and die; |
| 39 | sub abort { |
| 40 | system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; |
| 41 | die $_[0]; |
| 42 | } |
| 43 | |
| 44 | while( my ($conf, $args) = each %configs ) { |
| 45 | system( "cp $config_h.bak $config_h" ) and die; |
| 46 | system( "make clean" ) and die; |
| 47 | |
| 48 | print "\n******************************************\n"; |
| 49 | print "* Testing configuration: $conf\n"; |
| 50 | print "******************************************\n"; |
| 51 | |
| 52 | system( "cd scripts && ./activate-config.pl data_files/$conf" ) |
| 53 | and abort "Failed to activate $conf\n"; |
| 54 | |
| 55 | system( "make" ) and abort "Failed to build: $conf\n"; |
| 56 | system( "make $test" ) and abort "Failed test suite: $conf\n"; |
Manuel Pégourié-Gonnard | 244c06e | 2014-03-25 14:13:06 +0100 | [diff] [blame^] | 57 | print "\nrunning compat.sh $args\n"; |
Manuel Pégourié-Gonnard | 6498540 | 2013-09-20 16:22:42 +0200 | [diff] [blame] | 58 | system( "cd tests && ./compat.sh $args" ) |
| 59 | and abort "Failed compat.sh: $conf\n"; |
| 60 | } |
| 61 | |
| 62 | system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; |
| 63 | system( "make clean" ); |
| 64 | exit 0; |