blob: 545b3b725856f1d07b4fd3105b522349d80db6f9 [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";
26 system( "make clean" ) and die;
27
28 print "\n******************************************\n";
29 print "* Testing without curve: $curve\n";
30 print "******************************************\n";
31
32 system( "scripts/config.pl unset $curve" )
33 and abort "Failed to disable $curve\n";
34
Manuel Pégourié-Gonnard129db082015-03-09 16:57:18 +000035 system( "make mbedtls" ) and abort "Failed to build lib: $curve\n";
Manuel Pégourié-Gonnard2727dc12014-11-19 20:02:46 +010036 system( "cd tests && make" ) and abort "Failed to build tests: $curve\n";
Manuel Pégourié-Gonnard1780f892015-07-08 22:08:02 +010037 system( "make test" ) and abort "Failed test suite: $curve\n";
Manuel Pégourié-Gonnard2727dc12014-11-19 20:02:46 +010038
39}
40
41system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n";
42system( "make clean" ) and die;
43exit 0;