Testsuite: move dynamic_socket to Exim::Runtest
[exim.git] / test / runtest
index 96867ff3acf594c5798a31e9be58eb90a9e23f8b..38047b1ebc90789568e3e4836096b3260010f173 100755 (executable)
@@ -21,11 +21,15 @@ use warnings;
 
 use Errno;
 use FileHandle;
-use IO::Socket::INET;
 use Socket;
 use Time::Local;
 use Cwd;
 use File::Basename;
+use FindBin qw'$Bin';
+
+use lib "$Bin/lib";
+use Exim::Runtest;
+
 use if $ENV{DEBUG} && $ENV{DEBUG} =~ /\bruntest\b/ => ('Smart::Comments' => '####');
 
 
@@ -88,6 +92,10 @@ $parm_port_d3 = 1227;        # Additional for daemon
 $parm_port_d4 = 1228;        # Additional for daemon
 my $dynamic_socket;          # allocated later for PORT_DYNAMIC
 
+# Find a suiteable group name for test (currently only 0001
+# uses a group name. A numeric group id would do
+my $parm_mailgroup = Exim::Runtest::mailgroup('mail');
+
 # Manually set locale
 $ENV{LC_ALL} = 'C';
 
@@ -149,6 +157,7 @@ s?\bTESTNUM\b?$_[0]?g;
 s?(\b|_)V4NET([\._])?$1$parm_ipv4_test_net$2?g;
 s?\bV6NET:?$parm_ipv6_test_net:?g;
 s?\bPORT_DYNAMIC\b?$dynamic_socket->sockport()?eg;
+s?\bMAILGROUP\b?$parm_mailgroup?g;
 }
 
 
@@ -1046,12 +1055,20 @@ RESET_AFTER_EXTRA_LINE_READ:
     s/^((?:spool|log) directory space =) -?\d+K (inodes =)\s*-?\d+/$1 nnnnnK $2 nnnnn/;
 
     # Non-TLS builds have different expansions for received_header_text
-    if (s/( \{with \$received_protocol)}\} \$\{if def:tls_cipher \{\(\$tls_cipher\)\n$/$1/)
+    if (s/(with \$received_protocol)\}\} \$\{if def:tls_cipher \{\(\$tls_cipher\)\n$/$1/)
       {
       $_ .= <IN>;
-      s/\s+(?=\}\}\{Exim)//;
+      s/\s+\}\}(?=\(Exim )/\}\} /;
+      }
+    if (/^  condition: def:tls_cipher$/)
+      {
+      <IN>; <IN>; <IN>; <IN>; <IN>; <IN>;
+      <IN>; <IN>; <IN>; <IN>; <IN>; next;
       }
 
+    # Not all platforms build with DKIM enabled
+    next if /^PDKIM >> Body data for hash, canonicalized/;
+
     # Not all platforms support TCP Fast Open, and the compile omits the check
     if (s/\S+ in hosts_try_fastopen\? no \(option unset\)\n$//)
       {
@@ -3606,7 +3623,12 @@ closedir(DIR);
 # contains ****. We open input from the terminal so that we can read responses
 # to prompts.
 
-open(T, "/dev/tty") || tests_exit(-1, "Failed to open /dev/tty: $!");
+if (not $force_continue) {
+  # runtest needs to interact if we're not in continue
+  # mode. It does so by communicate to /dev/tty
+  open(T, "/dev/tty") or tests_exit(-1, "Failed to open /dev/tty: $!");
+}
+
 
 print "\nPress RETURN to run the tests: ";
 $_ = $force_continue ? "c" : <T>;
@@ -3696,16 +3718,7 @@ foreach $test (@test_list)
     if (/^no_stdout_check/)  { $stdout_skip = 1; next; }
     if (/^rmfiltertest/)     { $rmfiltertest = 1; next; }
     if (/^sortlog/)          { $sortlog = 1; next; }
-    if (/\bPORT_DYNAMIC\b/)  {
-      for (my $port = 1024; $port < 65000; $port++) {
-        $dynamic_socket = IO::Socket::INET->new(
-          LocalHost => '127.0.0.1',
-          LocalPort => $port,
-          Listen => 10,
-          ReuseAddr => 1,
-        ) and last;
-      }
-      }
+    if (/\bPORT_DYNAMIC\b/)  { $dynamic_socket = Exim::Runtest::dynamic_socket(); next; }
     }
   # Reset to beginning of file for per test interpreting/processing
   seek(SCRIPT, 0, 0);