| Manuel Pégourié-Gonnard | 5df9216 | 2015-10-22 16:11:39 +0200 | [diff] [blame] | 1 | #!/usr/bin/perl | 
|  | 2 |  | 
|  | 3 | # test that all configs with only a single key exchange enabled build | 
|  | 4 | # | 
|  | 5 | # Usage: tests/scripts/key-exchanges.pl | 
|  | 6 |  | 
|  | 7 | use warnings; | 
|  | 8 | use strict; | 
|  | 9 |  | 
|  | 10 | -d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n"; | 
|  | 11 |  | 
|  | 12 | my $sed_cmd = 's/^#define \(MBEDTLS_KEY_EXCHANGE_.*_ENABLED\)/\1/p'; | 
|  | 13 | my $config_h = 'include/mbedtls/config.h'; | 
|  | 14 | my @kexes = split( /\s+/, `sed -n -e '$sed_cmd' $config_h` ); | 
|  | 15 |  | 
|  | 16 | system( "cp $config_h $config_h.bak" ) and die; | 
|  | 17 | sub abort { | 
|  | 18 | system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; | 
|  | 19 | die $_[0]; | 
|  | 20 | } | 
|  | 21 |  | 
|  | 22 | for my $kex (@kexes) { | 
|  | 23 | system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n"; | 
|  | 24 | system( "make clean" ) and die; | 
|  | 25 |  | 
|  | 26 | print "\n******************************************\n"; | 
|  | 27 | print "* Testing with key exchange: $kex\n"; | 
|  | 28 | print "******************************************\n"; | 
|  | 29 |  | 
|  | 30 | # full config with all key exchanges disabled except one | 
|  | 31 | system( "scripts/config.pl full" ) and abort "Failed config full\n"; | 
|  | 32 | for my $k (@kexes) { | 
|  | 33 | next if $k eq $kex; | 
|  | 34 | system( "scripts/config.pl unset $k" ) | 
|  | 35 | and abort "Failed to disable $k\n"; | 
|  | 36 | } | 
|  | 37 |  | 
| Manuel Pégourié-Gonnard | 50bd260 | 2015-10-23 08:53:34 +0200 | [diff] [blame] | 38 | system( "make lib CFLAGS='-Os -Werror'" ) and abort "Failed to build lib: $kex\n"; | 
| Manuel Pégourié-Gonnard | 5df9216 | 2015-10-22 16:11:39 +0200 | [diff] [blame] | 39 | } | 
|  | 40 |  | 
|  | 41 | system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n"; | 
|  | 42 | system( "make clean" ) and die; | 
|  | 43 | exit 0; |