Skip to content

Commit

Permalink
integration/utils.py: Use runpy.run_path() to run xen-bugtool
Browse files Browse the repository at this point in the history
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
  • Loading branch information
bernhardkaindl committed Apr 4, 2024
1 parent e3815b0 commit f386ad8
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions tests/integration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import filecmp
import os
import runpy
import shutil
import sys
import tarfile
Expand All @@ -12,12 +13,6 @@

from lxml.etree import XMLSchema, parse # pytype: disable=import-error

# pyright: ignore[reportMissingImports]
if sys.version_info.major == 2: # pragma: no cover
from commands import getstatusoutput # type:ignore[import-not-found]
else:
from subprocess import getstatusoutput

BUGTOOL_OUTPUT_DIR = "/var/opt/xen/bug-report/"
BUGTOOL_DOM0_TEMPL = os.path.join(os.path.dirname(__file__), "dom0-template")

Expand Down Expand Up @@ -138,17 +133,18 @@ def run_bugtool_entry(bugtool_script, archive_type, test_entries):

os.environ["XENRT_BUGTOOL_BASENAME"] = test_entries

command = "python%s ./xen-bugtool -y --output=%s --entries=%s" % (
sys.version_info.major,
archive_type,
test_entries,
)
print("# " + command)
error_code, output = getstatusoutput(command)

print(output)
if error_code:
raise RuntimeError(output)
sys.argv = [
"xen-bugtool",
"-y",
"--output=%s" % archive_type,
"--entries=%s" % test_entries,
]
print(" ".join(sys.argv))
try:
runpy.run_path(bugtool_script, run_name="__main__")
except SystemExit as e:
if e.code: # pylint: disable=using-constant-test # pragma: no cover
raise

#
# Switch to the BUGTOOL_OUTPUT_DIR and extract the bugball in it.
Expand Down

0 comments on commit f386ad8

Please sign in to comment.