commit:     a6b83f082a08073c99ad5e8b0a8564fb30083816
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 20 22:36:53 2018 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Thu Sep 20 22:37:15 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a6b83f08

app-admin/rsyslog: fix omprog-output-capture-mt test when using Py3

Package-Manager: Portage-2.3.49, Repoman-2.3.10

 ...-8.38.0-fix-omprog-output-capture-mt-test.patch | 66 ++++++++++++++++++++++
 app-admin/rsyslog/rsyslog-8.38.0.ebuild            |  2 +-
 2 files changed, 67 insertions(+), 1 deletion(-)

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
index 00000000000..c78e0e502d4
--- /dev/null
+++ 
b/app-admin/rsyslog/files/rsyslog-8.38.0-fix-omprog-output-capture-mt-test.patch
@@ -0,0 +1,66 @@
+From 0b0a1262f2b401ea16b7d0b36d8254c500cb9d8e Mon Sep 17 00:00:00 2001
+From: Joan Sala <[email protected]>
+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()

diff --git a/app-admin/rsyslog/rsyslog-8.38.0.ebuild 
b/app-admin/rsyslog/rsyslog-8.38.0.ebuild
index 6df02d0bab4..c8801a0aef2 100644
--- a/app-admin/rsyslog/rsyslog-8.38.0.ebuild
+++ b/app-admin/rsyslog/rsyslog-8.38.0.ebuild
@@ -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"

Reply via email to