[exim-cvs] Testsuite: support TLS cross-library testing

Góra strony
Delete this message
Reply to this message
Autor: Exim Git Commits Mailing List
Data:  
Dla: exim-cvs
Temat: [exim-cvs] Testsuite: support TLS cross-library testing
Gitweb: https://git.exim.org/exim.git/commitdiff/ecb6fe6728708adefdf4f2f2aad134e36f09fc28
Commit:     ecb6fe6728708adefdf4f2f2aad134e36f09fc28
Parent:     4e871f9b28dff4cacfd012aede1d092cc8cfbd36
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Fri Jan 20 17:41:14 2023 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Wed Aug 9 12:08:39 2023 +0100


    Testsuite: support TLS cross-library testing
---
 src/Makefile         | 10 ++++---
 src/OS/Makefile-Base |  3 +++
 test/README          |  5 ++++
 test/patchexim       | 12 +++++++--
 test/runtest         | 73 ++++++++++++++++++++++++++++++++++++++++++++++------
 5 files changed, 89 insertions(+), 14 deletions(-)


diff --git a/src/Makefile b/src/Makefile
index d190d9aa0..b8d88054d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -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 ""
diff --git a/src/OS/Makefile-Base b/src/OS/Makefile-Base
index c01e911ce..e0aa1dc6c 100644
--- a/src/OS/Makefile-Base
+++ b/src/OS/Makefile-Base
@@ -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) || \
diff --git a/test/README b/test/README
index 6c9a2d8da..d013f7823 100644
--- a/test/README
+++ b/test/README
@@ -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
diff --git a/test/patchexim b/test/patchexim
index 2a4077820..a006022e0 100755
--- a/test/patchexim
+++ b/test/patchexim
@@ -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
diff --git a/test/runtest b/test/runtest
index 74c53e229..23551861a 100755
--- a/test/runtest
+++ b/test/runtest
@@ -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.


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/