From 0ee1026718693e39950f3939ebfb79e027a733c9 Mon Sep 17 00:00:00 2001 From: Filip Suba Date: Thu, 18 Jan 2024 13:08:38 +0100 Subject: [PATCH] Backport function tests from centos stream --- tests/functions_test/Makefile | 2 +- tests/functions_test/dmpd_library.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/functions_test/Makefile b/tests/functions_test/Makefile index d9e7f97..6b14a2f 100644 --- a/tests/functions_test/Makefile +++ b/tests/functions_test/Makefile @@ -72,4 +72,4 @@ $(METADATA): Makefile @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA) @echo "Requires: $(PACKAGE_NAME)" >> $(METADATA) - rhts-lint $(METADATA) \ No newline at end of file + rhts-lint $(METADATA) diff --git a/tests/functions_test/dmpd_library.py b/tests/functions_test/dmpd_library.py index c690a3d..1cf44df 100755 --- a/tests/functions_test/dmpd_library.py +++ b/tests/functions_test/dmpd_library.py @@ -16,6 +16,8 @@ """dmpd_library.py: Complete library providing functionality for device-mapper-persistent-data upstream test.""" +from __future__ import print_function + import platform from os.path import expanduser import re #regex @@ -25,7 +27,6 @@ import time import fileinput # TODO: Is this really necessary? Unlikely we will run into python2 in rawhide # again... -from __future__ import print_function def _print(string): @@ -55,7 +56,7 @@ def run(cmd, return_output=False, verbose=True, force_flush=False): date = "date \"+%Y-%m-%d %H:%M:%S\"" p = subprocess.Popen(date, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) stdout, stderr = p.communicate() - stdout = stdout.rstrip("\n") + stdout = stdout.decode('ascii', 'ignore').rstrip("\n") _print("INFO: [%s] Running: '%s'..." % (stdout, cmd)) #enabling shell=True, because was the only way I found to run command with '|' @@ -77,7 +78,7 @@ def run(cmd, return_output=False, verbose=True, force_flush=False): retcode = p.returncode - output = stdout + stderr + output = stdout.decode('ascii', 'ignore') + stderr.decode('ascii', 'ignore') #remove new line from last line output = output.rstrip()