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 7use warnings; 8use strict; 9 10-d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n"; 11 12my $sed_cmd = 's/^#define \(MBEDTLS_KEY_EXCHANGE_.*_ENABLED\)/\1/p'; 13my $config_h = 'include/mbedtls/config.h'; 14my @kexes = split( /\s+/, `sed -n -e '$sed_cmd' $config_h` ); 15 16system( "cp $config_h $config_h.bak" ) and die; 17sub abort { 18 system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; 19 die $_[0]; 20} 21 22for 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 38 system( "make lib CFLAGS='-Os -Werror'" ) and abort "Failed to build lib: $kex\n"; 39} 40 41system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n"; 42system( "make clean" ) and die; 43exit 0; 44