blob: 46826c3de80773be95f58d71080ca139c2c36ee3 [file] [log] [blame]
Manuel Pégourié-Gonnard5df92162015-10-22 16:11:39 +02001#!/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
Manuel Pégourié-Gonnard50bd2602015-10-23 08:53:34 +020038 system( "make lib CFLAGS='-Os -Werror'" ) and abort "Failed to build lib: $kex\n";
Manuel Pégourié-Gonnard5df92162015-10-22 16:11:39 +020039}
40
41system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n";
42system( "make clean" ) and die;
43exit 0;