Skip to content

Commit

Permalink
Testsuite: support TLS cross-library testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Harris committed Aug 9, 2023
1 parent 4e871f9 commit ecb6fe6
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 14 deletions.
10 changes: 6 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
3 changes: 3 additions & 0 deletions src/OS/Makefile-Base
Original file line number Diff line number Diff line change
Expand Up @@ -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) || \
Expand Down
5 changes: 5 additions & 0 deletions test/README
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions test/patchexim
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand All @@ -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>)
{
Expand All @@ -37,6 +45,6 @@ while(<IN>)
close(IN);
close(OUT);

chmod 04755, 'eximdir/exim';
chmod 04755, $outfile;

# End of patchexim script
73 changes: 65 additions & 8 deletions test/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit ecb6fe6

Please sign in to comment.