blob: 65871407dcc50a4ffd04e059e3a8d9e4527dac18 [file] [log] [blame]
Manuel Pégourié-Gonnard64985402013-09-20 16:22:42 +02001#!/usr/bin/perl
2
3# test standard configurations:
4# - build
5# - run test suite
6# - run compat.sh
Manuel Pégourié-Gonnard827b6ce2014-04-30 12:05:29 +02007#
8# Usage: tests/scripts/test-ref-configs.pl [config-name [...]]
Manuel Pégourié-Gonnard64985402013-09-20 16:22:42 +02009
10use warnings;
11use strict;
12
13my %configs = (
Manuel Pégourié-Gonnard827b6ce2014-04-30 12:05:29 +020014 'config-psk-rc4-tls1_0.h'
15 => '-m tls1 -f \'^PSK.*RC4\|TLS-PSK.*RC4\'',
Manuel Pégourié-Gonnard64985402013-09-20 16:22:42 +020016 'config-mini-tls1_1.h'
Manuel Pégourié-Gonnard827b6ce2014-04-30 12:05:29 +020017 => '-m tls1_1 -f \'^DES-CBC3-SHA$\|^TLS-RSA-WITH-3DES-EDE-CBC-SHA$\'',
18 'config-suite-b.h'
19 => "-m tls1_2 -f 'ECDHE-ECDSA.*AES.*GCM'",
Manuel Pégourié-Gonnard43b29862014-06-24 11:25:43 +020020 'config-picocoin.h'
21 => 0,
Manuel Pégourié-Gonnard64985402013-09-20 16:22:42 +020022);
23
Manuel Pégourié-Gonnard827b6ce2014-04-30 12:05:29 +020024# If no config-name is provided, use all known configs.
25# Otherwise, use the provided names only.
Paul Bakker30a30622013-12-19 17:09:49 +010026if ($#ARGV >= 0) {
Manuel Pégourié-Gonnard827b6ce2014-04-30 12:05:29 +020027 my %configs_ori = ( %configs );
28 %configs = ();
Paul Bakker30a30622013-12-19 17:09:49 +010029
Manuel Pégourié-Gonnard827b6ce2014-04-30 12:05:29 +020030 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 Bakker30a30622013-12-19 17:09:49 +010036 }
Paul Bakker30a30622013-12-19 17:09:49 +010037}
38
Manuel Pégourié-Gonnard64985402013-09-20 16:22:42 +020039-d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n";
40
41my $test = system( "grep -i cmake Makefile >/dev/null" ) ? 'check' : 'test';
42
43my $config_h = 'include/polarssl/config.h';
44
45system( "cp $config_h $config_h.bak" ) and die;
46sub abort {
47 system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
48 die $_[0];
49}
50
51while( 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é-Gonnard0bc1f232014-04-30 11:53:50 +020059 system( "cp configs/$conf $config_h" )
Manuel Pégourié-Gonnard64985402013-09-20 16:22:42 +020060 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é-Gonnard43b29862014-06-24 11:25:43 +020064
65 if( $args )
66 {
67 print "\nrunning compat.sh $args\n";
68 system( "cd tests && ./compat.sh $args" )
69 and abort "Failed compat.sh: $conf\n";
70 }
71 else
72 {
73 print "\nskipping compat.sh\n";
74 }
Manuel Pégourié-Gonnard64985402013-09-20 16:22:42 +020075}
76
77system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
78system( "make clean" );
79exit 0;