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 # curves.pl
markrad 0:cdf462088d13 4 #
markrad 0:cdf462088d13 5 # Copyright (c) 2014-2016, ARM Limited, All Rights Reserved
markrad 0:cdf462088d13 6 #
markrad 0:cdf462088d13 7 # Purpose
markrad 0:cdf462088d13 8 #
markrad 0:cdf462088d13 9 # To test the code dependencies on individual curves in each test suite. This
markrad 0:cdf462088d13 10 # is a verification step to ensure we don't ship test suites that do not work
markrad 0:cdf462088d13 11 # for some build options.
markrad 0:cdf462088d13 12 #
markrad 0:cdf462088d13 13 # The process is:
markrad 0:cdf462088d13 14 # for each possible curve
markrad 0:cdf462088d13 15 # build the library and test suites with the curve disabled
markrad 0:cdf462088d13 16 # execute the test suites
markrad 0:cdf462088d13 17 #
markrad 0:cdf462088d13 18 # And any test suite with the wrong dependencies will fail.
markrad 0:cdf462088d13 19 #
markrad 0:cdf462088d13 20 # Usage: curves.pl
markrad 0:cdf462088d13 21 #
markrad 0:cdf462088d13 22 # This script should be executed from the root of the project directory.
markrad 0:cdf462088d13 23
markrad 0:cdf462088d13 24 use warnings;
markrad 0:cdf462088d13 25 use strict;
markrad 0:cdf462088d13 26
markrad 0:cdf462088d13 27 -d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n";
markrad 0:cdf462088d13 28
markrad 0:cdf462088d13 29 my $sed_cmd = 's/^#define \(MBEDTLS_ECP_DP.*_ENABLED\)/\1/p';
markrad 0:cdf462088d13 30 my $config_h = 'include/mbedtls/config.h';
markrad 0:cdf462088d13 31 my @curves = split( /\s+/, `sed -n -e '$sed_cmd' $config_h` );
markrad 0:cdf462088d13 32
markrad 0:cdf462088d13 33 system( "cp $config_h $config_h.bak" ) and die;
markrad 0:cdf462088d13 34 sub abort {
markrad 0:cdf462088d13 35 system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
markrad 0:cdf462088d13 36 die $_[0];
markrad 0:cdf462088d13 37 }
markrad 0:cdf462088d13 38
markrad 0:cdf462088d13 39 for my $curve (@curves) {
markrad 0:cdf462088d13 40 system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n";
markrad 0:cdf462088d13 41 # depends on a specific curve. Also, ignore error if it wasn't enabled
markrad 0:cdf462088d13 42 system( "scripts/config.pl unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED" );
markrad 0:cdf462088d13 43 system( "make clean" ) and die;
markrad 0:cdf462088d13 44
markrad 0:cdf462088d13 45 print "\n******************************************\n";
markrad 0:cdf462088d13 46 print "* Testing without curve: $curve\n";
markrad 0:cdf462088d13 47 print "******************************************\n";
markrad 0:cdf462088d13 48
markrad 0:cdf462088d13 49 system( "scripts/config.pl unset $curve" )
markrad 0:cdf462088d13 50 and abort "Failed to disable $curve\n";
markrad 0:cdf462088d13 51
markrad 0:cdf462088d13 52 system( "make lib" ) and abort "Failed to build lib: $curve\n";
markrad 0:cdf462088d13 53 system( "cd tests && make" ) and abort "Failed to build tests: $curve\n";
markrad 0:cdf462088d13 54 system( "make test" ) and abort "Failed test suite: $curve\n";
markrad 0:cdf462088d13 55
markrad 0:cdf462088d13 56 }
markrad 0:cdf462088d13 57
markrad 0:cdf462088d13 58 system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n";
markrad 0:cdf462088d13 59 system( "make clean" ) and die;
markrad 0:cdf462088d13 60 exit 0;