summaryrefslogtreecommitdiffstats
path: root/meta/classes/testimage.bbclass
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-01-28 09:46:25 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 16:06:22 +0000
commit3d1d30b0a38b338aa9e17566c2d8a0298e031edb (patch)
treef15ab8103fb93714eca41d03ebfdc1b13d0a6db8 /meta/classes/testimage.bbclass
parent8b5ee367a630027d478aed265ee79a7230e91673 (diff)
downloadpoky-3d1d30b0a38b338aa9e17566c2d8a0298e031edb.tar.gz
testimage: Modularize helper functions for get test lists.
Test lists functions can be used in other parts so modularize it and move to oeqa/oetest.py library. Testimage class was updated to meet the new sign of the functions. (From OE-Core rev: c9f771533af70e7ccb1e7064e58926cfaee7367a) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/testimage.bbclass')
-rw-r--r--meta/classes/testimage.bbclass78
1 files changed, 4 insertions, 74 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 3986340f46..3fe27a27db 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -106,74 +106,6 @@ do_testsdk[nostamp] = "1"
106do_testsdk[depends] += "${TESTIMAGEDEPENDS}" 106do_testsdk[depends] += "${TESTIMAGEDEPENDS}"
107do_testsdk[lockfiles] += "${TESTIMAGELOCK}" 107do_testsdk[lockfiles] += "${TESTIMAGELOCK}"
108 108
109# get testcase list from specified file
110# if path is a relative path, then relative to build/conf/
111def read_testlist(d, fpath):
112 if not os.path.isabs(fpath):
113 builddir = d.getVar("TOPDIR", True)
114 fpath = os.path.join(builddir, "conf", fpath)
115 if not os.path.exists(fpath):
116 bb.fatal("No such manifest file: ", fpath)
117 tcs = []
118 for line in open(fpath).readlines():
119 line = line.strip()
120 if line and not line.startswith("#"):
121 tcs.append(line)
122 return " ".join(tcs)
123
124def get_tests_list(d, type="runtime"):
125 testsuites = []
126 testslist = []
127 manifests = d.getVar("TEST_SUITES_MANIFEST", True)
128 if manifests is not None:
129 manifests = manifests.split()
130 for manifest in manifests:
131 testsuites.extend(read_testlist(d, manifest).split())
132 else:
133 testsuites = d.getVar("TEST_SUITES", True).split()
134 if type == "sdk":
135 testsuites = (d.getVar("TEST_SUITES_SDK", True) or "auto").split()
136 bbpath = d.getVar("BBPATH", True).split(':')
137
138 # This relies on lib/ under each directory in BBPATH being added to sys.path
139 # (as done by default in base.bbclass)
140 for testname in testsuites:
141 if testname != "auto":
142 if testname.startswith("oeqa."):
143 testslist.append(testname)
144 continue
145 found = False
146 for p in bbpath:
147 if os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname + '.py')):
148 testslist.append("oeqa." + type + "." + testname)
149 found = True
150 break
151 elif os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname.split(".")[0] + '.py')):
152 testslist.append("oeqa." + type + "." + testname)
153 found = True
154 break
155 if not found:
156 bb.fatal('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname)
157
158 if "auto" in testsuites:
159 def add_auto_list(path):
160 if not os.path.exists(os.path.join(path, '__init__.py')):
161 bb.fatal('Tests directory %s exists but is missing __init__.py' % path)
162 files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_')])
163 for f in files:
164 module = 'oeqa.' + type + '.' + f[:-3]
165 if module not in testslist:
166 testslist.append(module)
167
168 for p in bbpath:
169 testpath = os.path.join(p, 'lib', 'oeqa', type)
170 bb.debug(2, 'Searching for tests in %s' % testpath)
171 if os.path.exists(testpath):
172 add_auto_list(testpath)
173
174 return testslist
175
176
177def exportTests(d,tc): 109def exportTests(d,tc):
178 import json 110 import json
179 import shutil 111 import shutil
@@ -272,7 +204,7 @@ def testimage_main(d):
272 import oeqa.runtime 204 import oeqa.runtime
273 import time 205 import time
274 import signal 206 import signal
275 from oeqa.oetest import loadTests, runTests 207 from oeqa.oetest import loadTests, runTests, get_test_suites, get_tests_list
276 from oeqa.targetcontrol import get_target_controller 208 from oeqa.targetcontrol import get_target_controller
277 from oeqa.utils.dump import get_host_dumper 209 from oeqa.utils.dump import get_host_dumper
278 210
@@ -286,7 +218,7 @@ def testimage_main(d):
286 # tests in TEST_SUITES become required tests 218 # tests in TEST_SUITES become required tests
287 # they won't be skipped even if they aren't suitable for a image (like xorg for minimal) 219 # they won't be skipped even if they aren't suitable for a image (like xorg for minimal)
288 # testslist is what we'll actually pass to the unittest loader 220 # testslist is what we'll actually pass to the unittest loader
289 testslist = get_tests_list(d) 221 testslist = get_tests_list(get_test_suites(d), d.getVar("BBPATH", True).split(':'))
290 testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"] 222 testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"]
291 223
292 tagexp = d.getVar("TEST_SUITES_TAGS", True) 224 tagexp = d.getVar("TEST_SUITES_TAGS", True)
@@ -368,7 +300,6 @@ def testimage_main(d):
368 300
369testimage_main[vardepsexclude] =+ "BB_ORIGENV" 301testimage_main[vardepsexclude] =+ "BB_ORIGENV"
370 302
371
372def testsdk_main(d): 303def testsdk_main(d):
373 import unittest 304 import unittest
374 import os 305 import os
@@ -377,7 +308,7 @@ def testsdk_main(d):
377 import oeqa.sdk 308 import oeqa.sdk
378 import time 309 import time
379 import subprocess 310 import subprocess
380 from oeqa.oetest import loadTests, runTests 311 from oeqa.oetest import loadTests, runTests, get_test_suites, get_tests_list
381 312
382 pn = d.getVar("PN", True) 313 pn = d.getVar("PN", True)
383 bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True)) 314 bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True))
@@ -385,7 +316,7 @@ def testsdk_main(d):
385 # tests in TEST_SUITES become required tests 316 # tests in TEST_SUITES become required tests
386 # they won't be skipped even if they aren't suitable. 317 # they won't be skipped even if they aren't suitable.
387 # testslist is what we'll actually pass to the unittest loader 318 # testslist is what we'll actually pass to the unittest loader
388 testslist = get_tests_list(d, "sdk") 319 testslist = get_tests_list(get_test_suites(d, "sdk"), d.getVar("BBPATH", True).split(':'), "sdk")
389 testsrequired = [t for t in (d.getVar("TEST_SUITES_SDK", True) or "auto").split() if t != "auto"] 320 testsrequired = [t for t in (d.getVar("TEST_SUITES_SDK", True) or "auto").split() if t != "auto"]
390 321
391 tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") 322 tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh")
@@ -457,4 +388,3 @@ def testsdk_main(d):
457 bb.utils.remove(sdktestdir, True) 388 bb.utils.remove(sdktestdir, True)
458 389
459testsdk_main[vardepsexclude] =+ "BB_ORIGENV" 390testsdk_main[vardepsexclude] =+ "BB_ORIGENV"
460