key-exchanges.pl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/perl
  2. # test that all configs with only a single key exchange enabled build
  3. #
  4. # Usage: tests/scripts/key-exchanges.pl
  5. use warnings;
  6. use strict;
  7. -d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n";
  8. my $sed_cmd = 's/^#define \(MBEDTLS_KEY_EXCHANGE_.*_ENABLED\)/\1/p';
  9. my $config_h = 'include/mbedtls/config.h';
  10. my @kexes = split( /\s+/, `sed -n -e '$sed_cmd' $config_h` );
  11. system( "cp $config_h $config_h.bak" ) and die;
  12. sub abort {
  13. system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
  14. die $_[0];
  15. }
  16. for my $kex (@kexes) {
  17. system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n";
  18. system( "make clean" ) and die;
  19. print "\n******************************************\n";
  20. print "* Testing with key exchange: $kex\n";
  21. print "******************************************\n";
  22. # full config with all key exchanges disabled except one
  23. system( "scripts/config.pl full" ) and abort "Failed config full\n";
  24. for my $k (@kexes) {
  25. next if $k eq $kex;
  26. system( "scripts/config.pl unset $k" )
  27. and abort "Failed to disable $k\n";
  28. }
  29. system( "make lib CFLAGS='-Os -Werror'" ) and abort "Failed to build lib: $kex\n";
  30. }
  31. system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n";
  32. system( "make clean" ) and die;
  33. exit 0;