test-ref-configs.pl 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/usr/bin/perl
  2. # test standard configurations:
  3. # - build
  4. # - run test suite
  5. # - run compat.sh
  6. #
  7. # Usage: tests/scripts/test-ref-configs.pl [config-name [...]]
  8. use warnings;
  9. use strict;
  10. my %configs = (
  11. 'config-mini-tls1_1.h' => {
  12. 'compat' => '-m tls1_1 -f \'^DES-CBC3-SHA$\|^TLS-RSA-WITH-3DES-EDE-CBC-SHA$\'',
  13. },
  14. 'config-suite-b.h' => {
  15. 'compat' => "-m tls1_2 -f 'ECDHE-ECDSA.*AES.*GCM' -p mbedTLS",
  16. },
  17. 'config-picocoin.h' => {
  18. },
  19. 'config-ccm-psk-tls1_2.h' => {
  20. 'compat' => '-m tls1_2 -f \'^TLS-PSK-WITH-AES-...-CCM-8\'',
  21. },
  22. 'config-thread.h' => {
  23. 'opt' => '-f ECJPAKE.*nolog',
  24. },
  25. );
  26. # If no config-name is provided, use all known configs.
  27. # Otherwise, use the provided names only.
  28. if ($#ARGV >= 0) {
  29. my %configs_ori = ( %configs );
  30. %configs = ();
  31. foreach my $conf_name (@ARGV) {
  32. if( ! exists $configs_ori{$conf_name} ) {
  33. die "Unknown configuration: $conf_name\n";
  34. } else {
  35. $configs{$conf_name} = $configs_ori{$conf_name};
  36. }
  37. }
  38. }
  39. -d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n";
  40. my $config_h = 'include/mbedtls/config.h';
  41. system( "cp $config_h $config_h.bak" ) and die;
  42. sub abort {
  43. system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
  44. die $_[0];
  45. }
  46. while( my ($conf, $data) = each %configs ) {
  47. system( "cp $config_h.bak $config_h" ) and die;
  48. system( "make clean" ) and die;
  49. print "\n******************************************\n";
  50. print "* Testing configuration: $conf\n";
  51. print "******************************************\n";
  52. system( "cp configs/$conf $config_h" )
  53. and abort "Failed to activate $conf\n";
  54. system( "make CFLAGS='-Os -Werror'" ) and abort "Failed to build: $conf\n";
  55. system( "make test" ) and abort "Failed test suite: $conf\n";
  56. my $compat = $data->{'compat'};
  57. if( $compat )
  58. {
  59. print "\nrunning compat.sh $compat\n";
  60. system( "tests/compat.sh $compat" )
  61. and abort "Failed compat.sh: $conf\n";
  62. }
  63. else
  64. {
  65. print "\nskipping compat.sh\n";
  66. }
  67. my $opt = $data->{'opt'};
  68. if( $opt )
  69. {
  70. print "\nrunning ssl-opt.sh $opt\n";
  71. system( "tests/ssl-opt.sh $opt" )
  72. and abort "Failed ssl-opt.sh: $conf\n";
  73. }
  74. else
  75. {
  76. print "\nskipping ssl-opt.sh\n";
  77. }
  78. }
  79. system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
  80. system( "make clean" );
  81. exit 0;