Testsuite: support TLS cross-library testing
authorJeremy Harris <jgh146exb@wizmail.org>
Fri, 20 Jan 2023 17:41:14 +0000 (17:41 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Wed, 9 Aug 2023 11:08:39 +0000 (12:08 +0100)
src/Makefile
src/OS/Makefile-Base
test/README
test/patchexim
test/runtest

index d190d9aa06768a03cd349d732ebfa984b2db55b3..b8d88054d4016e2583fc41675be27bd3d10e0c4f 100644 (file)
@@ -37,10 +37,12 @@ all: Local/Makefile configure
        @cd build-$(buildname); $(MAKE) SHELL=$(SHELL) $(MFLAGS)
 
 # This pair for the convenience of of the Debian maintainers
-exim: Local/Makefile configure
-       @cd build-$(buildname); $(MAKE) SHELL=$(SHELL) $(MFLAGS) exim
-utils: Local/Makefile configure
-       @cd build-$(buildname); $(MAKE) SHELL=$(SHELL) $(MFLAGS) utils
+exim utils: Local/Makefile configure
+       @cd build-$(buildname); $(MAKE) SHELL=$(SHELL) $(MFLAGS) $@
+
+# For testsuite builds
+exim_openssl exim_gnutls: Local/Makefile configure
+       @cd build-$(buildname); $(MAKE) SHELL=$(SHELL) $(MFLAGS) $@
 
 Local/Makefile:
        @echo ""
index c01e911ceaedb29ab923ddd052208b342b12e671..e0aa1dc6ce77263028827a679d5bb644d4cc32c6 100644 (file)
@@ -39,6 +39,9 @@ FE       = $(FULLECHO)
 all:       utils exim
 config:    $(EDITME) checklocalmake Makefile os.c config.h version.h version.sh macro.c
 
+exim_openssl exim_gnutls: clean exim
+       cp exim $@
+
 checklocalmake:
        @if $(SHELL) $(SCRIPTS)/newer $(EDITME)-$(OSTYPE) $(EDITME) || \
          $(SHELL) $(SCRIPTS)/newer $(EDITME)-$(ARCHTYPE) $(EDITME) || \
index 6c9a2d8da52189ef53723f03365c48c50442a29b..d013f78233f21640451c78bd8122e13c29802f12 100644 (file)
@@ -301,6 +301,11 @@ There are some options for the ./runtest script itself:
   -SLOW     For very slow hosts that appear to have Heisenbugs, delay before
             comparing output files from a testcase
 
+  -TLS <client>  For cross-library testing. Specify 'openssl" or 'gnutls'
+            as the client; the other is used as the server (assumes that
+           both have been built: set up Local/Makefile for OpenSSL and
+           "make exim_openssl", then for GnuTLS and "make exim_gnutls")
+
 The options for ./runtest must be given first (but after the name of the
 binary, if present). Any further options, that is, items on the command line
 that start with a hyphen, are passed to the Exim binary when it is run as part
index 2a40778205781b737a2c84d8d991e6a8b53e0b69..a006022e0453bc73d93e916c1b204f16405d5dae 100755 (executable)
@@ -2,6 +2,7 @@
 
 use strict;
 use warnings;
+use Getopt::Std;
 
 ###############################################################################
 # This is an auxiliary script that is part of the Exim test suite. It must be #
@@ -11,10 +12,17 @@ use warnings;
 #                                                                             #
 # The only argument to this script is the name of the Exim binary that is to  #
 # be copied. The script must be run in the correct current directory.         #
+#                                                                            #
+# One option, -o <outfile> can be given.  Default is "eximdir/exim"           #
 ###############################################################################
 
+our ($opt_o);
+getopts('o:');
+
+my $outfile = defined($opt_o) ? $opt_o : 'eximdir/exim';
+
 open(IN, $ARGV[0]) || die "** Failed to open $ARGV[0]: $!\n";
-open(OUT, '>eximdir/exim') || die "** Failed to open eximdir/exim: $!\n";
+open(OUT, ">$outfile") || die "** Failed to open $outfile: $!\n";
 
 while(<IN>)
   {
@@ -37,6 +45,6 @@ while(<IN>)
 close(IN);
 close(OUT);
 
-chmod 04755, 'eximdir/exim';
+chmod 04755, $outfile;
 
 # End of patchexim script
index 74c53e229a86ea613dcdf63a609ae51d1a9c817d..23551861ad2b0d6fc2013e8fe3b86f19a9aad4b2 100755 (executable)
@@ -2759,6 +2759,10 @@ if (/^(cat)?write\s+(\S+)(?:\s+(.*))?\s*$/)
 
 if (/^client/ || /^(sudo\s+)?perl\b/)
   {
+  if (defined($tls)) {
+    s/^client-anytls/client-ssl/ if ($tls eq 'openssl');
+    s/^client-anytls/client-gnutls/ if ($tls eq 'gnutls');
+    }
   s"client"./bin/client";
   $cmd = "$_ >>test-stdout 2>>test-stderr";
   }
@@ -2812,15 +2816,15 @@ elsif (/^((?i:[A-Z\d_]+=\S+\s+)+)?(\d+)?\s*(sudo(?:\s+-u\s+(\w+))?\s+)?exim(_\S+
 
     if (defined $queuespec)
       {
-      @listcmd  = ("$parm_cwd/eximdir/exim", '-bp',
+      @listcmd  = ("$parm_cwd/$exim_server", '-bp',
                   $queuespec,
-                   "-DEXIM_PATH=$parm_cwd/eximdir/exim",
+                   "-DEXIM_PATH=$parm_cwd$exim_server",
                    -C => "$parm_cwd/test-config");
       }
     else
       {
-      @listcmd  = ("$parm_cwd/eximdir/exim", '-bp',
-                   "-DEXIM_PATH=$parm_cwd/eximdir/exim",
+      @listcmd  = ("$parm_cwd/$exim_server", '-bp',
+                   "-DEXIM_PATH=$parm_cwd/$exim_server",
                    -C => "$parm_cwd/test-config");
       }
     print ">> Getting queue list from:\n>>    @listcmd\n" if $debug;
@@ -2852,11 +2856,24 @@ elsif (/^((?i:[A-Z\d_]+=\S+\s+)+)?(\d+)?\s*(sudo(?:\s+-u\s+(\w+))?\s+)?exim(_\S+
 
   my $opt_valgrind = $valgrind ? "valgrind --leak-check=yes --suppressions=$parm_cwd/aux-fixed/valgrind.supp " : '';
 
-  $cmd = "$envset$sudo$opt_valgrind" .
-         "$parm_cwd/eximdir/exim$special$optargs " .
-         "-DEXIM_PATH=$parm_cwd/eximdir/exim$special " .
-         "-C $parm_cwd/test-config $args " .
+  $cmd = "$envset$sudo$opt_valgrind";
+
+  if ($special ne '') {
+    $cmd .= "$parm_cwd/eximdir/exim$special$optargs " .
+           "-DEXIM_PATH=$parm_cwd/eximdir/exim$special ";
+    }
+  elsif ($args =~ /(^|\s)-DSERVER=server\s/) {
+    $cmd .= "$parm_cwd/$exim_server$optargs " .
+           "-DEXIM_PATH=$parm_cwd/$exim_server ";
+    }
+  else {
+    $cmd .= "$parm_cwd/$exim_client$optargs " .
+           "-DEXIM_PATH=$parm_cwd/$exim_client ";
+    }
+
+  $cmd .= "-C $parm_cwd/test-config $args " .
          ">>test-stdout 2>>test-stderr";
+
   # If the command is starting an Exim daemon, we run it in the same
   # way as the "server" command above, that is, we don't want to wait
   # for the process to finish. That happens when "killdaemon" is obeyed later
@@ -3335,6 +3352,7 @@ GetOptions(
     'ipv6!'    => \$have_ipv6,
     'keep'     => \$save_output,
     'slow'     => \$slow,
+    'tls=s'    => \my $tls,
     'valgrind' => \$valgrind,
     'range=s{2}'       => \my @range_wanted,
     'test=i@'          => \my @tests_wanted,
@@ -3912,6 +3930,45 @@ else
 die "** Unable to make patched exim: $!\n"
   if (system("sudo ./patchexim $parm_exim") != 0);
 
+# If TLS-library-specific binaries have been made, grab them too
+
+$suff = 'openssl';
+$f = $parm_exim . '_' . $suff;
+if (-f $f) {
+  $exim_openssl = "eximdir/exim_$suff";
+  die "** Unable to make patched exim: $!\n"
+    if (system("sudo ./patchexim -o $exim_openssl $f") != 0);
+  }
+$suff = 'gnutls';
+$f = $parm_exim . '_' . $suff;
+if (-f $f) {
+  $exim_gnutls = "eximdir/exim_$suff";
+  die "** Unable to make patched exim: $!\n"
+    if (system("sudo ./patchexim -o $exim_gnutls $f") != 0);
+  }
+
+if (defined($tls))
+  {
+  die "** Need both $exim_openssl and $exim_gnutls for cross-library teting\n"
+    if ( !defined($exim_openssl) || !defined($exim_gnutls) );
+  if ($tls eq 'openssl')
+    {
+    $exim_client = $exim_openssl;
+    $exim_server = $exim_gnutls;
+    }
+  elsif ($tls eq 'gnutls')
+    {
+    $exim_client = $exim_gnutls;
+    $exim_server = $exim_openssl;
+    }
+  else
+    { die "** need eother openssl or gnutls speified as the client for cross-library testing, saw $tls\n"; }
+  }
+else
+  { $exim_client = $exim_server = 'eximdir/exim'; }
+print ">> \$exim_client <$exim_client>\n";;
+print ">> \$exim_server <$exim_server>\n";;
+
 # From this point on, exits from the program must go via the subroutine
 # tests_exit(), so that suitable cleaning up can be done when required.
 # Arrange to catch interrupting signals, to assist with this.