Backport function tests from centos stream

This commit is contained in:
Filip Suba 2024-01-18 13:08:38 +01:00
parent d37efc8796
commit 0ee1026718
2 changed files with 5 additions and 4 deletions

View File

@ -72,4 +72,4 @@ $(METADATA): Makefile
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
rhts-lint $(METADATA)
rhts-lint $(METADATA)

View File

@ -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()