Testsuite: Provide '>>> ' for script input to allow binary data (take 2)
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sat, 3 Oct 2020 17:43:48 +0000 (19:43 +0200)
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sun, 4 Oct 2020 09:20:55 +0000 (11:20 +0200)
This mimics the '>>> ' prefix known for the test client. Any line prefixed
with '>>> ' will be processed by Perl's string eval().

As '>>> ' is generic and documented, it replaces the (undocumented)
'\NONL\' tag.

The client input lines starting with '>>> ' are now changed to '\>>> '
to avoid evaluation by the runtest script. (Test 4030, 1101).

test/README
test/runtest
test/scripts/0000-Basic/0100
test/scripts/0000-Basic/0101
test/scripts/0000-Basic/0242
test/scripts/0000-Basic/0900
test/scripts/0000-Basic/0901
test/scripts/1100-Basic-TLS/1101
test/scripts/4030-proxy-protocol/4030

index d944b29ac8ec792b96908499f8b84f2275228c66..7a852ee43ed074956c17ae8eb81f3f6b3fd2c5d7 100644 (file)
@@ -862,6 +862,16 @@ 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 '\>>> ', 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.
+
 
   background
 
@@ -876,7 +886,6 @@ except that the data it generates is copied to the end of the test-stdout file
 as well as to the named file.
 
 
-
   client [<options>] <ip address> <port> [<outgoing interface>]
 
 This command runs the auxiliary "client" program that simulates an SMTP client.
@@ -1047,10 +1056,13 @@ 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.
+    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 '\'.
 
 (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 intto the script
+    line is a filename; the content of the file is inserted into the script
     at this point.
 
 (7) Otherwise, the line is an input line line that is sent to the server. Any
index f61b016f96eae63df47bc4411d6af7c98e079659..a4d49aa79bd46eb09e8cd6358e5b6a932239a2c6 100755 (executable)
@@ -2792,8 +2792,9 @@ else { tests_exit(-1, "Command unrecognized in line $lineno: $_"); }
 
 
 # Run the command, with stdin connected to a pipe, and write the stdin data
-# to it, with appropriate substitutions. If a line ends with \NONL\, chop off
-# the terminating newline (and the \NONL\). If the command contains
+# to it, with appropriate substitutions. If a starts with '>>> ', process it
+# via Perl's string eval().
+# If the command contains
 # -DSERVER=server add "-server" to the command, where it will adjoin the name
 # for the stderr file. See comment above about the use of -DSERVER.
 
@@ -2807,7 +2808,8 @@ while (<SCRIPT>)
   $lineno++;
   last if /^\*{4}\s*$/;
   do_substitute($testno);
-  if (/^(.*)\\NONL\\\s*$/) { print CMD $1; } else { print CMD; }
+  s/^\\(>>>\s.*)/$1/ or s/^>>>\s(.*)\s*$/$1/ and $_ = eval "\"$1\"";
+  print CMD;
   }
 
 # For timeout tests, wait before closing the pipe; we expect a
index a8cf6863d8ee167d35b2df6c0723aa129dd007ed..e31e9809d5c43631bbbd20e656d4eaff2bcabb16 100644 (file)
@@ -78,7 +78,7 @@ exim -odi userx@test.ex <test-data
 ****
 exim -odi userx@test.ex
 Last line ending without a newline and with a partial match: 
-From\NONL\
+>>> From
 ****
 exim -odi filter-userx@test.ex
 Test message
@@ -91,11 +91,11 @@ From: is how headers start
 ****
 exim -odi filter-userx@test.ex
 Last line ending without a newline and with a partial match: 
-From\NONL\
+>>> From
 ****
 exim -odi userx@test.ex
 Last line ending without a newline and being a single dot:
-.\NONL\
+>>> .
 ****
 exim -odi mmdf-userx@test.ex
 Line consisting of four ^A characters
index 12f73c0b8e5c8e914019e29912205f2d3370ef40..512a60ea8fc2f8e88696c592ec02c900c74970bf 100644 (file)
@@ -61,7 +61,7 @@ exim -odi userx@test.ex <test-data
 ****
 exim -odi userx@test.ex
 Last line ending without a newline and with a partial match: 
-From\NONL\
+>>> From
 ****
 exim -odi filter-userx@test.ex
 Test message
@@ -74,11 +74,11 @@ From: is how headers start
 ****
 exim -odi filter-userx@test.ex
 Last line ending without a newline and with a partial match: 
-From\NONL\
+>>> From
 ****
 exim -odi userx@test.ex
 Last line ending without a newline and being a single dot:
-.\NONL\
+>>> .
 ****
 exim -odi mmdf-userx@test.ex
 Line consisting of four ^A characters
index 38e49edae56971b38a664c6dac86dee09fbd2be9..995f5cc13df59af2b2de8b94b56d01ba8e865ef1 100644 (file)
@@ -17,7 +17,7 @@ QUIT
 250 OK
 ****
 exim -odi abc@x.y.z
-Test message\NONL\
+>>> Test message
 ****
 server PORT_S
 220 Server ready
@@ -35,5 +35,5 @@ QUIT
 250 OK
 ****
 exim -odi abc@x.y.z
-Subject: Test message\NONL\
+>>> Subject: Test message
 ****
index 4503ae0c01b9419212bd4cc6f47cca9456878d9b..af7840470ec21cd0d15e7ef1ca7c03e05a2a33d2 100644 (file)
@@ -231,7 +231,7 @@ mail from:someone@some.domain
 rcpt to:CALLER@test.ex
 ??? 250
 bdat 87 last
->>> To: Susan@random.com\n
+\>>> To: Susan@random.com\n
 From: Sam@random.com
 Subject: This is a Bodyless test message
 
index f5a6fff9a7205811566dc15d7055b19415df6604..10c582a17ddbc4194f815b872d6e731f8fc263fa 100644 (file)
@@ -58,7 +58,7 @@ mail from:someone3@some.domain
 rcpt to:CALLER@test.ex
 ??? 250
 bdat 10
->>> To: Susan@
+\>>> To: Susan@
 ??? 250
 bdat 78 last
 random.com
@@ -103,7 +103,7 @@ mail from:someone3A@some.domain
 rcpt to:CALLER@test.ex
 ??? 250
 bdat 10
->>> To: Susan@
+\>>> To: Susan@
 ??? 250
 bdat 78 last
 random.com
index 41407e80b511e8f52faf9bdb45243427416fe4b0..a1ed5a43b299b7768a0eef693e00ec166211f403 100644 (file)
@@ -10,7 +10,7 @@ STARTTLS
 ??? 220
 EHLO rhu.barb
 ????250
->>> MAIL FROM:<>\r\nRCPT TO:test@example.com\r\n
+\>>> MAIL FROM:<>\r\nRCPT TO:test@example.com\r\n
 ??? 250 OK
 ??? 250 Accepted (rcpt via callout)
 QUIT
index 1eece11120925b250c592b79650cfe3d841721f5..154e056d85ff18959214c058c8f02d5ffe815949 100644 (file)
@@ -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