blob: 654bc5c3eb7c5e8bc088c08bd1ddcdca87a5265a [file] [log] [blame]
Manuel Pégourié-Gonnard2727dc12014-11-19 20:02:46 +01001#!/usr/bin/perl
2
3# test dependencies on individual curves in tests
4# - build
5# - run test suite
6#
7# Usage: tests/scripts/curves.pl
8
9use warnings;
10use strict;
11
12-d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n";
13
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020014my $sed_cmd = 's/^#define \(MBEDTLS_ECP_DP.*_ENABLED\)/\1/p';
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000015my $config_h = 'include/mbedtls/config.h';
Manuel Pégourié-Gonnard2727dc12014-11-19 20:02:46 +010016my @curves = split( /\s+/, `sed -n -e '$sed_cmd' $config_h` );
17
Manuel Pégourié-Gonnard2727dc12014-11-19 20:02:46 +010018system( "cp $config_h $config_h.bak" ) and die;
19sub abort {
20 system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
21 die $_[0];
22}
23
24for my $curve (@curves) {
25 system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n";
Manuel Pégourié-Gonnard8a7a1892015-10-20 16:56:12 +020026 # depends on a specific curve. Also, ignore error if it wasn't enabled
27 system( "scripts/config.pl unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED" );
Manuel Pégourié-Gonnard2727dc12014-11-19 20:02:46 +010028 system( "make clean" ) and die;
29
30 print "\n******************************************\n";
31 print "* Testing without curve: $curve\n";
32 print "******************************************\n";
33
34 system( "scripts/config.pl unset $curve" )
35 and abort "Failed to disable $curve\n";
36
Manuel Pégourié-Gonnard6657b8d2015-09-17 13:46:21 +020037 system( "make lib" ) and abort "Failed to build lib: $curve\n";
Manuel Pégourié-Gonnard2727dc12014-11-19 20:02:46 +010038 system( "cd tests && make" ) and abort "Failed to build tests: $curve\n";
Manuel Pégourié-Gonnard1780f892015-07-08 22:08:02 +010039 system( "make test" ) and abort "Failed test suite: $curve\n";
Manuel Pégourié-Gonnard2727dc12014-11-19 20:02:46 +010040
41}
42
43system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n";
44system( "make clean" ) and die;
45exit 0;