mirror of
https://git.yoctoproject.org/poky
synced 2026-09-20 03:49:32 +02:00
oeqa/utils/dump: Move get_host_dumper to OERuntimeTestContextExecutor class
To avoid getVar calls inside a utils module, also moves get_host_dumper import inside testexport isn't needed. [YOCTO #10231] (From OE-Core rev: f8beaf94e943a8b20d146be47a756af312ef107c) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
1247118870
commit
2d34b08533
@@ -163,7 +163,6 @@ def exportTests(d,tc):
|
|||||||
def testexport_main(d):
|
def testexport_main(d):
|
||||||
from oeqa.oetest import ExportTestContext
|
from oeqa.oetest import ExportTestContext
|
||||||
from oeqa.targetcontrol import get_target_controller
|
from oeqa.targetcontrol import get_target_controller
|
||||||
from oeqa.utils.dump import get_host_dumper
|
|
||||||
|
|
||||||
test_create_extract_dirs(d)
|
test_create_extract_dirs(d)
|
||||||
export_dir = d.getVar("TEST_EXPORT_DIR")
|
export_dir = d.getVar("TEST_EXPORT_DIR")
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ def testimage_main(d):
|
|||||||
import signal
|
import signal
|
||||||
from oeqa.oetest import ImageTestContext
|
from oeqa.oetest import ImageTestContext
|
||||||
from oeqa.targetcontrol import get_target_controller
|
from oeqa.targetcontrol import get_target_controller
|
||||||
from oeqa.utils.dump import get_host_dumper
|
|
||||||
from bb.utils import export_proxies
|
from bb.utils import export_proxies
|
||||||
|
from oeqa.utils.dump import HostDumper
|
||||||
|
|
||||||
pn = d.getVar("PN")
|
pn = d.getVar("PN")
|
||||||
bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR"))
|
bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR"))
|
||||||
@@ -139,7 +139,8 @@ def testimage_main(d):
|
|||||||
export_proxies(d)
|
export_proxies(d)
|
||||||
|
|
||||||
# we need the host dumper in test context
|
# we need the host dumper in test context
|
||||||
host_dumper = get_host_dumper(d)
|
host_dumper = HostDumper(d.getVar("testimage_dump_host", True),
|
||||||
|
d.getVar("TESTIMAGE_DUMP_DIR", True))
|
||||||
|
|
||||||
# the robot dance
|
# the robot dance
|
||||||
target = get_target_controller(d)
|
target = get_target_controller(d)
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import os
|
|||||||
|
|
||||||
from oeqa.core.context import OETestContext, OETestContextExecutor
|
from oeqa.core.context import OETestContext, OETestContextExecutor
|
||||||
from oeqa.core.target.ssh import OESSHTarget
|
from oeqa.core.target.ssh import OESSHTarget
|
||||||
|
from oeqa.utils.dump import HostDumper
|
||||||
|
|
||||||
from oeqa.runtime.loader import OERuntimeTestLoader
|
from oeqa.runtime.loader import OERuntimeTestLoader
|
||||||
|
|
||||||
class OERuntimeTestContext(OETestContext):
|
class OERuntimeTestContext(OETestContext):
|
||||||
@@ -12,10 +14,11 @@ class OERuntimeTestContext(OETestContext):
|
|||||||
runtime_files_dir = os.path.join(
|
runtime_files_dir = os.path.join(
|
||||||
os.path.dirname(os.path.abspath(__file__)), "files")
|
os.path.dirname(os.path.abspath(__file__)), "files")
|
||||||
|
|
||||||
def __init__(self, td, logger, target, image_packages):
|
def __init__(self, td, logger, target, host_dumper, image_packages):
|
||||||
super(OERuntimeTestContext, self).__init__(td, logger)
|
super(OERuntimeTestContext, self).__init__(td, logger)
|
||||||
self.target = target
|
self.target = target
|
||||||
self.image_packages = image_packages
|
self.image_packages = image_packages
|
||||||
|
self.host_dumper = host_dumper
|
||||||
self._set_target_cmds()
|
self._set_target_cmds()
|
||||||
|
|
||||||
def _set_target_cmds(self):
|
def _set_target_cmds(self):
|
||||||
@@ -39,6 +42,7 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
|
|||||||
default_target_type = 'simpleremote'
|
default_target_type = 'simpleremote'
|
||||||
default_server_ip = '192.168.7.1'
|
default_server_ip = '192.168.7.1'
|
||||||
default_target_ip = '192.168.7.2'
|
default_target_ip = '192.168.7.2'
|
||||||
|
default_host_dumper_dir = '/tmp/oe-saved-tests'
|
||||||
|
|
||||||
def register_commands(self, logger, subparsers):
|
def register_commands(self, logger, subparsers):
|
||||||
super(OERuntimeTestContextExecutor, self).register_commands(logger, subparsers)
|
super(OERuntimeTestContextExecutor, self).register_commands(logger, subparsers)
|
||||||
@@ -58,6 +62,11 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
|
|||||||
help="IP address of device under test, default: %s" \
|
help="IP address of device under test, default: %s" \
|
||||||
% self.default_server_ip)
|
% self.default_server_ip)
|
||||||
|
|
||||||
|
runtime_group.add_argument('--host-dumper-dir', action='store',
|
||||||
|
default=self.default_host_dumper_dir,
|
||||||
|
help="Directory where host status is dumped, if tests fails, default: %s" \
|
||||||
|
% self.default_host_dumper_dir)
|
||||||
|
|
||||||
runtime_group.add_argument('--packages-manifest', action='store',
|
runtime_group.add_argument('--packages-manifest', action='store',
|
||||||
help="Package manifest of the image under test")
|
help="Package manifest of the image under test")
|
||||||
|
|
||||||
@@ -90,6 +99,10 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
|
|||||||
|
|
||||||
return image_packages
|
return image_packages
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getHostDumper(cmds, directory):
|
||||||
|
return HostDumper(cmds, directory)
|
||||||
|
|
||||||
def _process_args(self, logger, args):
|
def _process_args(self, logger, args):
|
||||||
if not args.packages_manifest:
|
if not args.packages_manifest:
|
||||||
raise TypeError('Manifest file not provided')
|
raise TypeError('Manifest file not provided')
|
||||||
@@ -98,6 +111,9 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
|
|||||||
|
|
||||||
self.tc_kwargs['init']['target'] = \
|
self.tc_kwargs['init']['target'] = \
|
||||||
OERuntimeTestContextExecutor.getTarget(args.target_type)
|
OERuntimeTestContextExecutor.getTarget(args.target_type)
|
||||||
|
self.tc_kwargs['init']['host_dumper'] = \
|
||||||
|
OERuntimeTestContextExecutor.getHostDumper(None,
|
||||||
|
args.host_dumper_dir)
|
||||||
self.tc_kwargs['init']['image_packages'] = \
|
self.tc_kwargs['init']['image_packages'] = \
|
||||||
OERuntimeTestContextExecutor.readPackagesManifest(
|
OERuntimeTestContextExecutor.readPackagesManifest(
|
||||||
args.packages_manifest)
|
args.packages_manifest)
|
||||||
|
|||||||
@@ -5,12 +5,6 @@ import datetime
|
|||||||
import itertools
|
import itertools
|
||||||
from .commands import runCmd
|
from .commands import runCmd
|
||||||
|
|
||||||
def get_host_dumper(d):
|
|
||||||
cmds = d.getVar("testimage_dump_host")
|
|
||||||
parent_dir = d.getVar("TESTIMAGE_DUMP_DIR")
|
|
||||||
return HostDumper(cmds, parent_dir)
|
|
||||||
|
|
||||||
|
|
||||||
class BaseDumper(object):
|
class BaseDumper(object):
|
||||||
""" Base class to dump commands from host/target """
|
""" Base class to dump commands from host/target """
|
||||||
|
|
||||||
@@ -77,13 +71,12 @@ class HostDumper(BaseDumper):
|
|||||||
result = runCmd(cmd, ignore_status=True)
|
result = runCmd(cmd, ignore_status=True)
|
||||||
self._write_dump(cmd.split()[0], result.output)
|
self._write_dump(cmd.split()[0], result.output)
|
||||||
|
|
||||||
|
|
||||||
class TargetDumper(BaseDumper):
|
class TargetDumper(BaseDumper):
|
||||||
""" Class to get dumps from target, it only works with QemuRunner """
|
""" Class to get dumps from target, it only works with QemuRunner """
|
||||||
|
|
||||||
def __init__(self, cmds, parent_dir, qemurunner):
|
def __init__(self, cmds, parent_dir, runner):
|
||||||
super(TargetDumper, self).__init__(cmds, parent_dir)
|
super(TargetDumper, self).__init__(cmds, parent_dir)
|
||||||
self.runner = qemurunner
|
self.runner = runner
|
||||||
|
|
||||||
def dump_target(self, dump_dir=""):
|
def dump_target(self, dump_dir=""):
|
||||||
if dump_dir:
|
if dump_dir:
|
||||||
|
|||||||
Reference in New Issue
Block a user