mbed TLS Build
tests/scripts/key-exchanges.pl@0:cdf462088d13, 2017-01-05 (annotated)
- Committer:
- markrad
- Date:
- Thu Jan 05 00:18:44 2017 +0000
- Revision:
- 0:cdf462088d13
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
markrad | 0:cdf462088d13 | 1 | #!/usr/bin/perl |
markrad | 0:cdf462088d13 | 2 | |
markrad | 0:cdf462088d13 | 3 | # test that all configs with only a single key exchange enabled build |
markrad | 0:cdf462088d13 | 4 | # |
markrad | 0:cdf462088d13 | 5 | # Usage: tests/scripts/key-exchanges.pl |
markrad | 0:cdf462088d13 | 6 | |
markrad | 0:cdf462088d13 | 7 | use warnings; |
markrad | 0:cdf462088d13 | 8 | use strict; |
markrad | 0:cdf462088d13 | 9 | |
markrad | 0:cdf462088d13 | 10 | -d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n"; |
markrad | 0:cdf462088d13 | 11 | |
markrad | 0:cdf462088d13 | 12 | my $sed_cmd = 's/^#define \(MBEDTLS_KEY_EXCHANGE_.*_ENABLED\)/\1/p'; |
markrad | 0:cdf462088d13 | 13 | my $config_h = 'include/mbedtls/config.h'; |
markrad | 0:cdf462088d13 | 14 | my @kexes = split( /\s+/, `sed -n -e '$sed_cmd' $config_h` ); |
markrad | 0:cdf462088d13 | 15 | |
markrad | 0:cdf462088d13 | 16 | system( "cp $config_h $config_h.bak" ) and die; |
markrad | 0:cdf462088d13 | 17 | sub abort { |
markrad | 0:cdf462088d13 | 18 | system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; |
markrad | 0:cdf462088d13 | 19 | die $_[0]; |
markrad | 0:cdf462088d13 | 20 | } |
markrad | 0:cdf462088d13 | 21 | |
markrad | 0:cdf462088d13 | 22 | for my $kex (@kexes) { |
markrad | 0:cdf462088d13 | 23 | system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n"; |
markrad | 0:cdf462088d13 | 24 | system( "make clean" ) and die; |
markrad | 0:cdf462088d13 | 25 | |
markrad | 0:cdf462088d13 | 26 | print "\n******************************************\n"; |
markrad | 0:cdf462088d13 | 27 | print "* Testing with key exchange: $kex\n"; |
markrad | 0:cdf462088d13 | 28 | print "******************************************\n"; |
markrad | 0:cdf462088d13 | 29 | |
markrad | 0:cdf462088d13 | 30 | # full config with all key exchanges disabled except one |
markrad | 0:cdf462088d13 | 31 | system( "scripts/config.pl full" ) and abort "Failed config full\n"; |
markrad | 0:cdf462088d13 | 32 | for my $k (@kexes) { |
markrad | 0:cdf462088d13 | 33 | next if $k eq $kex; |
markrad | 0:cdf462088d13 | 34 | system( "scripts/config.pl unset $k" ) |
markrad | 0:cdf462088d13 | 35 | and abort "Failed to disable $k\n"; |
markrad | 0:cdf462088d13 | 36 | } |
markrad | 0:cdf462088d13 | 37 | |
markrad | 0:cdf462088d13 | 38 | system( "make lib CFLAGS='-Os -Werror'" ) and abort "Failed to build lib: $kex\n"; |
markrad | 0:cdf462088d13 | 39 | } |
markrad | 0:cdf462088d13 | 40 | |
markrad | 0:cdf462088d13 | 41 | system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n"; |
markrad | 0:cdf462088d13 | 42 | system( "make clean" ) and die; |
markrad | 0:cdf462088d13 | 43 | exit 0; |