summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2016-10-31 13:15:02 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:20 +0000
commit4cd982566b10375925e616b176e988219d65b170 (patch)
tree5301e66b2d48ff232533ab4c4485c0aeed85d530 /meta
parent6ad52a82ea9129716f6fb0d2c50f51fc24ed171a (diff)
downloadpoky-4cd982566b10375925e616b176e988219d65b170.tar.gz
oeqa/runtime: Add case, context and loader classes for runtime testing
This adds OERuntimeTestCase, OERuntimeTestContext, and OERuntimeTestLoader to be used for runtime testing. As expected there are some changes in runtime context: - Adds the target to be used for runtime testing, the default is a SSH connection to the device under test running a OE image. - Runtime context requires image manifest because several tests are skipped if a package is missing or installed. - Several tests require the output of the ps command and it changes its output and arguments if busybox o procps is installed, so the case must use the correct ps command. [YOCTO #10234] (From OE-Core rev: f995f178de79d6d11422cd879d06371811f50651) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/runtime/case.py8
-rw-r--r--meta/lib/oeqa/runtime/context.py69
-rw-r--r--meta/lib/oeqa/runtime/loader.py16
3 files changed, 93 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/case.py b/meta/lib/oeqa/runtime/case.py
new file mode 100644
index 0000000000..43f1b2f425
--- /dev/null
+++ b/meta/lib/oeqa/runtime/case.py
@@ -0,0 +1,8 @@
1# Copyright (C) 2016 Intel Corporation
2# Released under the MIT license (see COPYING.MIT)
3
4from oeqa.core.case import OETestCase
5
6class OERuntimeTestCase(OETestCase):
7 # target instance set by OERuntimeTestLoader.
8 target = None
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
new file mode 100644
index 0000000000..496730ddbe
--- /dev/null
+++ b/meta/lib/oeqa/runtime/context.py
@@ -0,0 +1,69 @@
1# Copyright (C) 2016 Intel Corporation
2# Released under the MIT license (see COPYING.MIT)
3
4import os
5
6from oeqa.core.context import OETestContext, OETestContextExecutor
7from oeqa.core.target.ssh import OESSHTarget
8from oeqa.runtime.loader import OERuntimeTestLoader
9
10class OERuntimeTestContext(OETestContext):
11 loaderClass = OERuntimeTestLoader
12
13 def __init__(self, td, logger, target, packages_manifest):
14 super(OERuntimeTestContext, self).__init__(td, logger)
15 self.target = target
16 self.image_packages = self.readPackagesManifest(packages_manifest)
17 self._set_target_cmds()
18
19 def _set_target_cmds(self):
20 self.target_cmds = {}
21
22 self.target_cmds['ps'] = 'ps'
23 if 'procps' in self.image_packages:
24 self.target_cmds['ps'] = self.target_cmds['ps'] + ' -ef'
25
26 def readPackagesManifest(self, manifest):
27 if not os.path.exists(manifest):
28 raise OSError("Couldn't find manifest file: %s" % manifest)
29
30 image_packages = set()
31 with open(manifest, 'r') as f:
32 for line in f.readlines():
33 line = line.strip()
34 if line and not line.startswith("#"):
35 image_packages.add(line.split()[0])
36
37 return image_packages
38
39class OERuntimeTestContextExecutor(OETestContextExecutor):
40 _context_class = OERuntimeTestContext
41
42 name = 'runtime'
43 help = 'runtime test component'
44 description = 'executes runtime tests over targets'
45 default_cases = os.path.join(os.path.abspath(os.path.dirname(__file__)),
46 'cases')
47 default_target_ip = '192.168.7.2'
48
49 def register_commands(self, logger, subparsers):
50 super(OERuntimeTestContextExecutor, self).register_commands(logger, subparsers)
51 self.parser.add_argument('--target-ip', action='store',
52 default=self.default_target_ip,
53 help="IP address of device under test, default: %s" \
54 % self.default_target_ip)
55 self.parser.add_argument('--packages-manifest', action='store',
56 help="Package manifest of the image under test")
57
58 def _process_args(self, logger, args):
59 if not args.packages_manifest:
60 raise TypeError('Manifest file not provided')
61
62 super(OERuntimeTestContextExecutor, self)._process_args(logger, args)
63 target = OESSHTarget(args.target_ip)
64 self.tc_kwargs['init']['target'] = target
65
66 packages_manifest = os.path.join(os.getcwd(), args.packages_manifest)
67 self.tc_kwargs['init']['packages_manifest'] = packages_manifest
68
69_executor_class = OERuntimeTestContextExecutor
diff --git a/meta/lib/oeqa/runtime/loader.py b/meta/lib/oeqa/runtime/loader.py
new file mode 100644
index 0000000000..041ef976eb
--- /dev/null
+++ b/meta/lib/oeqa/runtime/loader.py
@@ -0,0 +1,16 @@
1# Copyright (C) 2016 Intel Corporation
2# Released under the MIT license (see COPYING.MIT)
3
4from oeqa.core.loader import OETestLoader
5from oeqa.runtime.case import OERuntimeTestCase
6
7class OERuntimeTestLoader(OETestLoader):
8 caseClass = OERuntimeTestCase
9
10 def _getTestCase(self, testCaseClass, tcName):
11 case = super(OERuntimeTestLoader, self)._getTestCase(testCaseClass, tcName)
12
13 # Adds custom attributes to the OERuntimeTestCase
14 setattr(case, 'target', self.tc.target)
15
16 return case