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