mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
williequesada
Date:
Tue Jun 04 16:03:38 2019 +0000
Revision:
1:1a219dea6cb5
Parent:
0:cdf462088d13
compartir a Pablo

Who changed what in which revision?

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