blob: 1f489a38799c91a2c0c03c1a22ce73fea220db4d [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
14my $sed_cmd = 's/^#define \(POLARSSL_ECP_DP.*_ENABLED\)/\1/p';
15my $config_h = 'include/polarssl/config.h';
16my @curves = split( /\s+/, `sed -n -e '$sed_cmd' $config_h` );
17
18my $test = system( "grep -i cmake Makefile >/dev/null" ) ? 'check' : 'test';
19
20system( "cp $config_h $config_h.bak" ) and die;
21sub abort {
22 system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
23 die $_[0];
24}
25
26for my $curve (@curves) {
27 system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n";
28 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
37 system( "make polarssl" ) and abort "Failed to build lib: $curve\n";
38 system( "cd tests && make" ) and abort "Failed to build tests: $curve\n";
39 system( "make $test" ) and abort "Failed test suite: $curve\n";
40
41}
42
43system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n";
44system( "make clean" ) and die;
45exit 0;