Manuel Pégourié-Gonnard | 2727dc1 | 2014-11-19 20:02:46 +0100 | [diff] [blame] | 1 | #!/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 | |
| 9 | use warnings; |
| 10 | use strict; |
| 11 | |
| 12 | -d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n"; |
| 13 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 14 | my $sed_cmd = 's/^#define \(MBEDTLS_ECP_DP.*_ENABLED\)/\1/p'; |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 15 | my $config_h = 'include/mbedtls/config.h'; |
Manuel Pégourié-Gonnard | 2727dc1 | 2014-11-19 20:02:46 +0100 | [diff] [blame] | 16 | my @curves = split( /\s+/, `sed -n -e '$sed_cmd' $config_h` ); |
| 17 | |
Manuel Pégourié-Gonnard | 2727dc1 | 2014-11-19 20:02:46 +0100 | [diff] [blame] | 18 | system( "cp $config_h $config_h.bak" ) and die; |
| 19 | sub abort { |
| 20 | system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n"; |
| 21 | die $_[0]; |
| 22 | } |
| 23 | |
| 24 | for my $curve (@curves) { |
| 25 | system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n"; |
Manuel Pégourié-Gonnard | 8a7a189 | 2015-10-20 16:56:12 +0200 | [diff] [blame^] | 26 | # 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é-Gonnard | 2727dc1 | 2014-11-19 20:02:46 +0100 | [diff] [blame] | 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 | |
Manuel Pégourié-Gonnard | 6657b8d | 2015-09-17 13:46:21 +0200 | [diff] [blame] | 37 | system( "make lib" ) and abort "Failed to build lib: $curve\n"; |
Manuel Pégourié-Gonnard | 2727dc1 | 2014-11-19 20:02:46 +0100 | [diff] [blame] | 38 | system( "cd tests && make" ) and abort "Failed to build tests: $curve\n"; |
Manuel Pégourié-Gonnard | 1780f89 | 2015-07-08 22:08:02 +0100 | [diff] [blame] | 39 | system( "make test" ) and abort "Failed test suite: $curve\n"; |
Manuel Pégourié-Gonnard | 2727dc1 | 2014-11-19 20:02:46 +0100 | [diff] [blame] | 40 | |
| 41 | } |
| 42 | |
| 43 | system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n"; |
| 44 | system( "make clean" ) and die; |
| 45 | exit 0; |