[exim-cvs] Testsuite: Allow input lines starting with ":<cmd…

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Exim Git Commits Mailing List
Datum:  
To: exim-cvs
Betreff: [exim-cvs] Testsuite: Allow input lines starting with ":<cmd>:", like ":sleep:".
Gitweb: https://git.exim.org/exim.git/commitdiff/d0de84b2d250e2f066286db3a3f5400a0f931b67
Commit:     d0de84b2d250e2f066286db3a3f5400a0f931b67
Parent:     78fb059f567b933e3e8c1898f6f51b1e6c3b5396
Author:     Heiko Schlittermann (HS12-RIPE) <hs@???>
AuthorDate: Mon Oct 5 08:59:25 2020 +0200
Committer:  Heiko Schlittermann (HS12-RIPE) <hs@???>
CommitDate: Mon Oct 5 10:34:45 2020 +0200


    Testsuite: Allow input lines starting with ":<cmd>:", like ":sleep:".


    This somehow mimics the behaviour of the client tool, but works for
    *any* input line that is sent to the application. This reverts the
    unfortunate take abusing the client's special notation '>>> '.


    Currently implemented:


            - :eval:
            - :neol:
            - :sleep:
---
 test/README                           | 27 +++++++++++++++------------
 test/runtest                          | 20 ++++++++++++++++++--
 test/scripts/0000-Basic/0100          |  6 +++---
 test/scripts/0000-Basic/0101          |  6 +++---
 test/scripts/0000-Basic/0242          |  4 ++--
 test/scripts/0000-Basic/0900          |  2 +-
 test/scripts/0000-Basic/0901          |  4 ++--
 test/scripts/1100-Basic-TLS/1101      |  2 +-
 test/scripts/4030-proxy-protocol/4030 |  2 +-
 test/scripts/4030-proxy-protocol/4031 |  4 ++--
 10 files changed, 48 insertions(+), 29 deletions(-)


diff --git a/test/README b/test/README
index a399765..c0f5482 100644
--- a/test/README
+++ b/test/README
@@ -862,15 +862,21 @@ The remaining commands are followed by data lines for their standard input,
terminated by four asterisks ("****"). Even if no data is required for the particular
usage, the asterisks must be given.

-If the input line starts with '>>> ', this prefix and any trailing spaces
-(including line feed) are removed. The reminder is processed with Perl's
-string eval() function, effectivly evaluatiing escape sequences like
-'\x41', or '\r'. If you need a line feed there, you need to encode it
-according to your needs.
+If the input line starts with ':<cmd>:', this prefix is removed and the
+line is processed by the runtest script before sending. The following
+commands are recognised:

-If the input line starts with '\>>> ', the backslash is removed and the
-rest of the line is passed as input. This is used by the client tool,
-which understands the '>>> ' prefix for similar processing.
+- "eval": process the reset of the line with Perl's string eval()
+ function. This can be used to send arbitrary data by encoding it as
+ escape sequences (e.g. "\x41\101"). If you need a line ending, you have
+ to append it accordingly (e.g. "\r\n").
+
+- "noeol": do not terminate the data sent to the application with an end
+ of line character.
+
+- "sleep": interpret the rest of the line as an integer and sleep for
+ that number of seconds before proceeding. No data will be output to
+ the application.


background
@@ -1056,10 +1062,7 @@ Lines in client scripts are of several kinds:

 (5) ">>> ": If a line begins with three '>' characters and a space, the rest of the
     line is input to be sent to the server.  Backslash escaping is done as
-    described below, but no trailing "\r\n" is sent. As the runtest's 
-    input processing catches the '>>> ' for its string eval, you may
-    want to escape from this first stage processing by prefixing your
-    line with '\'.
+    described below, but no trailing "\r\n" is sent.


 (6) "<<< ": If a line begin with three '<' characters and a space, the rest of the
     line is a filename; the content of the file is inserted into the script
diff --git a/test/runtest b/test/runtest
index 26a4047..5fb7cd7 100755
--- a/test/runtest
+++ b/test/runtest
@@ -2807,12 +2807,28 @@ print ">> |${cmd}${stderrsuffix}\n" if ($debug);
 open CMD, "|${cmd}${stderrsuffix}" || tests_exit(1, "Failed to run $cmd");


 CMD->autoflush(1);
-while (<SCRIPT>)
+LINE: while (<SCRIPT>)
   {
   $lineno++;
   last if /^\*{4}\s*$/;
   do_substitute($testno);
-  s/^\\(>>>\s.*)/$1/ or s/^>>>\s(.*)\s*$/$1/ and $_ = eval "\"$1\"";
+  if (my ($cmd, $line) = /^(:\S+?:)(.*)/) {
+    $_ = $line;
+      {
+      $cmd eq ':eval:' and do {
+        $_ = eval "\"$_\"";
+        last;
+      };
+      $cmd eq ':noeol:' and do {
+        s/[\r\n]*$//;
+        last;
+      };
+      $cmd eq ':sleep:' and do {
+        sleep $_;
+        next LINE;
+      };
+    }
+  }
   print CMD;
   }


diff --git a/test/scripts/0000-Basic/0100 b/test/scripts/0000-Basic/0100
index e31e980..7abf091 100644
--- a/test/scripts/0000-Basic/0100
+++ b/test/scripts/0000-Basic/0100
@@ -78,7 +78,7 @@ exim -odi userx@??? <test-data
****
exim -odi userx@???
Last line ending without a newline and with a partial match:
->>> From
+:noeol:From
****
exim -odi filter-userx@???
Test message
@@ -91,11 +91,11 @@ From: is how headers start
****
exim -odi filter-userx@???
Last line ending without a newline and with a partial match:
->>> From
+:noeol:From
****
exim -odi userx@???
Last line ending without a newline and being a single dot:
->>> .
+:noeol:.
****
exim -odi mmdf-userx@???
Line consisting of four ^A characters
diff --git a/test/scripts/0000-Basic/0101 b/test/scripts/0000-Basic/0101
index 512a60e..c3143ee 100644
--- a/test/scripts/0000-Basic/0101
+++ b/test/scripts/0000-Basic/0101
@@ -61,7 +61,7 @@ exim -odi userx@??? <test-data
****
exim -odi userx@???
Last line ending without a newline and with a partial match:
->>> From
+:noeol:From
****
exim -odi filter-userx@???
Test message
@@ -74,11 +74,11 @@ From: is how headers start
****
exim -odi filter-userx@???
Last line ending without a newline and with a partial match:
->>> From
+:noeol:From
****
exim -odi userx@???
Last line ending without a newline and being a single dot:
->>> .
+:noeol:.
****
exim -odi mmdf-userx@???
Line consisting of four ^A characters
diff --git a/test/scripts/0000-Basic/0242 b/test/scripts/0000-Basic/0242
index 995f5cc..785e8e8 100644
--- a/test/scripts/0000-Basic/0242
+++ b/test/scripts/0000-Basic/0242
@@ -17,7 +17,7 @@ QUIT
250 OK
****
exim -odi abc@???
->>> Test message
+:noeol:Test message
****
server PORT_S
220 Server ready
@@ -35,5 +35,5 @@ QUIT
250 OK
****
exim -odi abc@???
->>> Subject: Test message
+:noeol:Subject: Test message
****
diff --git a/test/scripts/0000-Basic/0900 b/test/scripts/0000-Basic/0900
index af78404..4503ae0 100644
--- a/test/scripts/0000-Basic/0900
+++ b/test/scripts/0000-Basic/0900
@@ -231,7 +231,7 @@ mail from:someone@???
rcpt to:CALLER@???
??? 250
bdat 87 last
-\>>> To: Susan@???\n
+>>> To: Susan@???\n
From: Sam@???
Subject: This is a Bodyless test message

diff --git a/test/scripts/0000-Basic/0901 b/test/scripts/0000-Basic/0901
index 10c582a..f5a6fff 100644
--- a/test/scripts/0000-Basic/0901
+++ b/test/scripts/0000-Basic/0901
@@ -58,7 +58,7 @@ mail from:someone3@???
rcpt to:CALLER@???
??? 250
bdat 10
-\>>> To: Susan@
+>>> To: Susan@
??? 250
bdat 78 last
random.com
@@ -103,7 +103,7 @@ mail from:someone3A@???
rcpt to:CALLER@???
??? 250
bdat 10
-\>>> To: Susan@
+>>> To: Susan@
??? 250
bdat 78 last
random.com
diff --git a/test/scripts/1100-Basic-TLS/1101 b/test/scripts/1100-Basic-TLS/1101
index a1ed5a4..41407e8 100644
--- a/test/scripts/1100-Basic-TLS/1101
+++ b/test/scripts/1100-Basic-TLS/1101
@@ -10,7 +10,7 @@ STARTTLS
??? 220
EHLO rhu.barb
????250
-\>>> MAIL FROM:<>\r\nRCPT TO:test@???\r\n
+>>> MAIL FROM:<>\r\nRCPT TO:test@???\r\n
??? 250 OK
??? 250 Accepted (rcpt via callout)
QUIT
diff --git a/test/scripts/4030-proxy-protocol/4030 b/test/scripts/4030-proxy-protocol/4030
index 154e056..1eece11 100644
--- a/test/scripts/4030-proxy-protocol/4030
+++ b/test/scripts/4030-proxy-protocol/4030
@@ -50,7 +50,7 @@ QUIT
#
# protocol v2 plain receive
client HOSTIPV4 PORT_D
-\>>> \x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A\x21\x11\x00\x0c\x7f\x00\x00\x02\x7f\x2a\x2a\x2a\xc2\x95\x04\x01
+>>> \x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A\x21\x11\x00\x0c\x7f\x00\x00\x02\x7f\x2a\x2a\x2a\xc2\x95\x04\x01
??? 220
HELO clientname
??? 250
diff --git a/test/scripts/4030-proxy-protocol/4031 b/test/scripts/4030-proxy-protocol/4031
index ecf3e82..f3d2456 100644
--- a/test/scripts/4030-proxy-protocol/4031
+++ b/test/scripts/4030-proxy-protocol/4031
@@ -14,7 +14,7 @@ QUIT
****
### protocol v1 receive
exim -bh HOSTIPV4
->>> PROXY TCP4 127.0.0.2 127.42.42.42 64000 25\r\n
+:eval:PROXY TCP4 127.0.0.2 127.42.42.42 64000 25\r\n
HELO clientname
MAIL FROM: <a@???>
RCPT TO:<b@???>
@@ -27,7 +27,7 @@ QUIT
****
### protocol v2 receive
exim -bh HOSTIPV4
->>> \x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A\x21\x11\x00\x0c\x7f\x00\x00\x02\x7f\x2a\x2a\x2a\xc2\x95\x04\x01
+:eval:\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A\x21\x11\x00\x0c\x7f\x00\x00\x02\x7f\x2a\x2a\x2a\xc2\x95\x04\x01
HELO clientname
MAIL FROM: <a@???>
RCPT TO:<b@???>