summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-12-02 14:57:09 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:20 +0000
commit1247118870872f2e8fbbff031a4539c6cbe5a917 (patch)
tree77a08e91baa41254fbe1416c1ed2da711ef128e3
parent6c3ca00884a34fb732a4c4cf6a64ac64458645af (diff)
downloadpoky-1247118870872f2e8fbbff031a4539c6cbe5a917.tar.gz
oeqa/runtime/context: Move helper functions for process args to executor
(From OE-Core rev: 07ee2fa0008a50da87fd840aea5e8bb6051c68fa) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/runtime/context.py56
1 files changed, 36 insertions, 20 deletions
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
index e692bc0c60..ec378bb016 100644
--- a/meta/lib/oeqa/runtime/context.py
+++ b/meta/lib/oeqa/runtime/context.py
@@ -12,10 +12,10 @@ class OERuntimeTestContext(OETestContext):
12 runtime_files_dir = os.path.join( 12 runtime_files_dir = os.path.join(
13 os.path.dirname(os.path.abspath(__file__)), "files") 13 os.path.dirname(os.path.abspath(__file__)), "files")
14 14
15 def __init__(self, td, logger, target, packages_manifest): 15 def __init__(self, td, logger, target, image_packages):
16 super(OERuntimeTestContext, self).__init__(td, logger) 16 super(OERuntimeTestContext, self).__init__(td, logger)
17 self.target = target 17 self.target = target
18 self.image_packages = self.readPackagesManifest(packages_manifest) 18 self.image_packages = image_packages
19 self._set_target_cmds() 19 self._set_target_cmds()
20 20
21 def _set_target_cmds(self): 21 def _set_target_cmds(self):
@@ -25,19 +25,6 @@ class OERuntimeTestContext(OETestContext):
25 if 'procps' in self.image_packages: 25 if 'procps' in self.image_packages:
26 self.target_cmds['ps'] = self.target_cmds['ps'] + ' -ef' 26 self.target_cmds['ps'] = self.target_cmds['ps'] + ' -ef'
27 27
28 def readPackagesManifest(self, manifest):
29 if not os.path.exists(manifest):
30 raise OSError("Couldn't find manifest file: %s" % manifest)
31
32 image_packages = set()
33 with open(manifest, 'r') as f:
34 for line in f.readlines():
35 line = line.strip()
36 if line and not line.startswith("#"):
37 image_packages.add(line.split()[0])
38
39 return image_packages
40
41class OERuntimeTestContextExecutor(OETestContextExecutor): 28class OERuntimeTestContextExecutor(OETestContextExecutor):
42 _context_class = OERuntimeTestContext 29 _context_class = OERuntimeTestContext
43 30
@@ -74,16 +61,45 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
74 runtime_group.add_argument('--packages-manifest', action='store', 61 runtime_group.add_argument('--packages-manifest', action='store',
75 help="Package manifest of the image under test") 62 help="Package manifest of the image under test")
76 63
64
65 @staticmethod
66 def getTarget(target_type, target_ip, server_ip):
67 target = None
68
69 if target_type == 'simpleremote':
70 target = OESSHTarget(target_ip)
71 elif target_type == 'qemu':
72 raise NotImplementedError("target_type %s isn't implemented yet" % \
73 target_type)
74 else:
75 raise TypeError("target_type %s isn't supported" % target_type)
76
77 return target
78
79 @staticmethod
80 def readPackagesManifest(manifest):
81 if not os.path.exists(manifest):
82 raise OSError("Manifest file not exists: %s" % manifest)
83
84 image_packages = set()
85 with open(manifest, 'r') as f:
86 for line in f.readlines():
87 line = line.strip()
88 if line and not line.startswith("#"):
89 image_packages.add(line.split()[0])
90
91 return image_packages
92
77 def _process_args(self, logger, args): 93 def _process_args(self, logger, args):
78 if not args.packages_manifest: 94 if not args.packages_manifest:
79 raise TypeError('Manifest file not provided') 95 raise TypeError('Manifest file not provided')
80 96
81 super(OERuntimeTestContextExecutor, self)._process_args(logger, args) 97 super(OERuntimeTestContextExecutor, self)._process_args(logger, args)
82 target = OESSHTarget(args.target_ip)
83
84 self.tc_kwargs['init']['target'] = target
85 98
86 packages_manifest = os.path.join(os.getcwd(), args.packages_manifest) 99 self.tc_kwargs['init']['target'] = \
87 self.tc_kwargs['init']['packages_manifest'] = packages_manifest 100 OERuntimeTestContextExecutor.getTarget(args.target_type)
101 self.tc_kwargs['init']['image_packages'] = \
102 OERuntimeTestContextExecutor.readPackagesManifest(
103 args.packages_manifest)
88 104
89_executor_class = OERuntimeTestContextExecutor 105_executor_class = OERuntimeTestContextExecutor