Blame SOURCES/0024-tests-Explicitly-decode-subprocess-output.patch

fc9b0e
From 3482dcfe74102da1e2d95d8adbc29940c06b1fef Mon Sep 17 00:00:00 2001
fc9b0e
Message-Id: <3482dcfe74102da1e2d95d8adbc29940c06b1fef.1566225007.git.aquini@redhat.com>
fc9b0e
In-Reply-To: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
fc9b0e
References: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
fc9b0e
From: David Gibson <david@gibson.dropbear.id.au>
fc9b0e
Date: Sat, 17 Aug 2019 20:59:48 +1000
fc9b0e
Subject: [RHEL7 PATCH 24/31] tests: Explicitly decode subprocess output
fc9b0e
fc9b0e
The output we get from subprocesses is logically a sequence of bytes, but
fc9b0e
we want to treat it as Python strings, which means decoding it into Unicode
fc9b0e
based on some encoding.
fc9b0e
fc9b0e
In Python2 we can get away with skipping that step, but in Python3 we won't
fc9b0e
be able to.  So, to get ready, add an explicit decode() step, using the
fc9b0e
system default encoding (probably UTF-8 in most cases).
fc9b0e
fc9b0e
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
fc9b0e
Signed-off-by: Eric B Munson <eric@munsonfam.org>
fc9b0e
Signed-off-by: Rafael Aquini <aquini@redhat.com>
fc9b0e
---
fc9b0e
 tests/run_tests.py | 10 ++++++----
fc9b0e
 1 file changed, 6 insertions(+), 4 deletions(-)
fc9b0e
fc9b0e
diff --git a/tests/run_tests.py b/tests/run_tests.py
fc9b0e
index e2025fe..79e0385 100755
fc9b0e
--- a/tests/run_tests.py
fc9b0e
+++ b/tests/run_tests.py
fc9b0e
@@ -48,7 +48,7 @@ def bash(cmd):
fc9b0e
     except KeyboardInterrupt:
fc9b0e
         # Abort and mark this a strange test result
fc9b0e
         return (127, "")
fc9b0e
-    out = p.stdout.read().strip()
fc9b0e
+    out = p.stdout.read().decode().strip()
fc9b0e
     return (rc, out)
fc9b0e
 
fc9b0e
 def snapshot_pool_state():
fc9b0e
@@ -80,7 +80,7 @@ def run_test_prog(bits, pagesize, cmd, **env):
fc9b0e
         return (None, "")
fc9b0e
     except OSError as e:
fc9b0e
         return (-e.errno, "")
fc9b0e
-    out = p.stdout.read().strip()
fc9b0e
+    out = p.stdout.read().decode().strip()
fc9b0e
 
fc9b0e
     if paranoid_pool_check:
fc9b0e
         afterpool = snapshot_pool_state()
fc9b0e
@@ -247,9 +247,11 @@ def get_pagesizes():
fc9b0e
     sizes = set()
fc9b0e
     out = ""
fc9b0e
     (rc, out) = bash("../obj/hugeadm --page-sizes")
fc9b0e
-    if rc != 0 or out == "": return sizes
fc9b0e
+    if rc != 0 or out == "":
fc9b0e
+        return sizes
fc9b0e
 
fc9b0e
-    for size in out.split("\n"): sizes.add(int(size))
fc9b0e
+    for size in out.split("\n"):
fc9b0e
+        sizes.add(int(size))
fc9b0e
     return sizes
fc9b0e
 
fc9b0e
 def get_wordsizes():
fc9b0e
-- 
fc9b0e
1.8.3.1
fc9b0e