app-admin/rsyslog: fix omprog-output-capture-mt test when using Py3
authorThomas Deutschmann <whissi@gentoo.org>
Thu, 20 Sep 2018 22:36:53 +0000 (00:36 +0200)
committerThomas Deutschmann <whissi@gentoo.org>
Thu, 20 Sep 2018 22:37:15 +0000 (00:37 +0200)
Package-Manager: Portage-2.3.49, Repoman-2.3.10

app-admin/rsyslog/files/rsyslog-8.38.0-fix-omprog-output-capture-mt-test.patch [new file with mode: 0644]
app-admin/rsyslog/rsyslog-8.38.0.ebuild

diff --git a/app-admin/rsyslog/files/rsyslog-8.38.0-fix-omprog-output-capture-mt-test.patch b/app-admin/rsyslog/files/rsyslog-8.38.0-fix-omprog-output-capture-mt-test.patch
new file mode 100644 (file)
index 0000000..c78e0e5
--- /dev/null
@@ -0,0 +1,66 @@
+From 0b0a1262f2b401ea16b7d0b36d8254c500cb9d8e Mon Sep 17 00:00:00 2001
+From: Joan Sala <jsiwrk@gmail.com>
+Date: Thu, 20 Sep 2018 22:37:58 +0200
+Subject: [PATCH] testbench: fix incompatibility of one omprog test with
+ Python3
+
+Python3 writes to stderr immediately, and this caused the
+captured output to differ with respect to Python2. Simplified
+the test to do a single write to stderr. Also a cast to int
+was needed when calculating 'numRepeats'.
+
+closes #3030
+---
+ tests/omprog-output-capture-mt.sh               |  2 +-
+ .../testsuites/omprog-output-capture-mt-bin.py  | 17 +++++++----------
+ 2 files changed, 8 insertions(+), 11 deletions(-)
+
+diff --git a/tests/omprog-output-capture-mt.sh b/tests/omprog-output-capture-mt.sh
+index 50f5c6354..080fabd2a 100755
+--- a/tests/omprog-output-capture-mt.sh
++++ b/tests/omprog-output-capture-mt.sh
+@@ -24,7 +24,7 @@ else
+     LINE_LENGTH=511   # 512 minus 1 byte (for the newline char)
+ fi
+-export command_line="/usr/bin/stdbuf -oL -eL $srcdir/testsuites/omprog-output-capture-mt-bin.py $LINE_LENGTH"
++export command_line="/usr/bin/stdbuf -oL $srcdir/testsuites/omprog-output-capture-mt-bin.py $LINE_LENGTH"
+ check_command_available stdbuf
+ generate_conf
+diff --git a/tests/testsuites/omprog-output-capture-mt-bin.py b/tests/testsuites/omprog-output-capture-mt-bin.py
+index 6c81da24b..03097f37b 100755
+--- a/tests/testsuites/omprog-output-capture-mt-bin.py
++++ b/tests/testsuites/omprog-output-capture-mt-bin.py
+@@ -10,7 +10,7 @@
+ logLine = sys.stdin.readline()
+ while logLine:
+     logLine = logLine.strip()
+-    numRepeats = lineLength / len(logLine)
++    numRepeats = int(lineLength / len(logLine))
+     lineToStdout = (linePrefix + "[stdout] " + logLine*numRepeats)[:lineLength]
+     lineToStderr = (linePrefix + "[stderr] " + logLine*numRepeats)[:lineLength]
+@@ -22,16 +22,13 @@
+     # size of the block buffer is generally greater than PIPE_BUF).
+     sys.stdout.write(lineToStdout + "\n")
+-    # Write to stderr using two writes. Since stderr is unbuffered, each write will be written
+-    # immediately to the pipe, and this will cause intermingled lines in the output file.
+-    # However, we avoid this by executing this script with 'stdbuf -eL', which forces line
+-    # buffering for stderr. We could alternatively do a single write.
+-    sys.stderr.write(lineToStderr)
+-    sys.stderr.write("\n")
++    # Write to stderr using a single write. Since stderr is unbuffered, each write will be
++    # written immediately (and atomically) to the pipe.
++    sys.stderr.write(lineToStderr + "\n")
+-    # Note: In future versions of Python3, stderr will possibly be line buffered (see
+-    # https://bugs.python.org/issue13601).
+-    # Note: When writing to stderr using the Python logging module, it seems that line
++    # Note (FTR): In future versions of Python3, stderr will possibly be line buffered (see
++    # https://bugs.python.org/issue13601). The previous write will also be atomic in this case.
++    # Note (FTR): When writing to stderr using the Python logging module, it seems that line
+     # buffering is also used (although this could depend on the Python version).
+     logLine = sys.stdin.readline()
index 6df02d0bab47ef4ad7a922885ed6cd97b0ef427f..c8801a0aef2bf7c1a98c9555f5354eb7a0455241 100644 (file)
@@ -23,7 +23,7 @@ else
                doc? ( https://www.rsyslog.com/files/download/${PN}/${PN}-doc-${PV}.tar.gz )
        "
 
-       PATCHES=()
+       PATCHES=( "${FILESDIR}"/${P}-fix-omprog-output-capture-mt-test.patch )
 fi
 
 LICENSE="GPL-3 LGPL-3 Apache-2.0"