summaryrefslogtreecommitdiff
path: root/meta/classes/imagetest-qemu.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/imagetest-qemu.bbclass')
-rw-r--r--meta/classes/imagetest-qemu.bbclass52
1 files changed, 46 insertions, 6 deletions
diff --git a/meta/classes/imagetest-qemu.bbclass b/meta/classes/imagetest-qemu.bbclass
index 4b3ddfc362..8301df8452 100644
--- a/meta/classes/imagetest-qemu.bbclass
+++ b/meta/classes/imagetest-qemu.bbclass
@@ -5,6 +5,9 @@ TEST_LOG ?= "${LOG_DIR}/qemuimagetests"
TEST_RESULT ?= "${TEST_DIR}/result"
TEST_TMP ?= "${TEST_DIR}/tmp"
TEST_SCEN ?= "sanity"
+TEST_STATUS ?= "${TEST_TMP}/status"
+TARGET_IPSAVE ?= "${TEST_TMP}/target_ip"
+TEST_SERIALIZE ?= "1"
python do_qemuimagetest() {
qemuimagetest_main(d)
@@ -34,10 +37,21 @@ def qemuimagetest_main(d):
machine = bb.data.getVar('MACHINE', d, 1)
pname = bb.data.getVar('PN', d, 1)
+ """function to save test cases running status"""
+ def teststatus(test, status, index, length):
+ test_status = bb.data.getVar('TEST_STATUS', d, 1)
+ if not os.path.exists(test_status):
+ raise bb.build.FuncFailed("No test status file existing under TEST_TMP")
+
+ f = open(test_status, "w")
+ f.write("\t%-15s%-15s%-15s%-15s\n" % ("Case", "Status", "Number", "Total"))
+ f.write("\t%-15s%-15s%-15s%-15s\n" % (case, status, index, length))
+ f.close()
+
"""funtion to run each case under scenario"""
def runtest(scen, case, fulltestpath):
resultpath = bb.data.getVar('TEST_RESULT', d, 1)
- testpath = bb.data.getVar('TEST_DIR', d, 1)
+ tmppath = bb.data.getVar('TEST_TMP', d, 1)
"""initialize log file for testcase"""
logpath = bb.data.getVar('TEST_LOG', d, 1)
@@ -45,20 +59,23 @@ def qemuimagetest_main(d):
caselog = os.path.join(logpath, "%s/log_%s.%s" % (scen, case, bb.data.getVar('DATETIME', d, 1)))
os.system("touch %s" % caselog)
-
"""export TEST_TMP, TEST_RESULT, DEPLOY_DIR and QEMUARCH"""
os.environ["PATH"] = bb.data.getVar("PATH", d, True)
- os.environ["TEST_TMP"] = testpath
+ os.environ["TEST_TMP"] = tmppath
os.environ["TEST_RESULT"] = resultpath
os.environ["DEPLOY_DIR"] = bb.data.getVar("DEPLOY_DIR", d, True)
os.environ["QEMUARCH"] = machine
os.environ["QEMUTARGET"] = pname
os.environ["DISPLAY"] = bb.data.getVar("DISPLAY", d, True)
os.environ["POKYBASE"] = bb.data.getVar("POKYBASE", d, True)
+ os.environ["TOPDIR"] = bb.data.getVar("TOPDIR", d, True)
+ os.environ["TEST_STATUS"] = bb.data.getVar("TEST_STATUS", d, True)
+ os.environ["TARGET_IPSAVE"] = bb.data.getVar("TARGET_IPSAVE", d, True)
+ os.environ["TEST_SERIALIZE"] = bb.data.getVar("TEST_SERIALIZE", d, True)
"""run Test Case"""
bb.note("Run %s test in scenario %s" % (case, scen))
- os.system("%s | tee -a %s" % (fulltestpath, caselog))
+ os.system("%s" % fulltestpath)
"""Generate testcase list in runtime"""
def generate_list(testlist):
@@ -96,6 +113,18 @@ def qemuimagetest_main(d):
list.append((item, casefile, fulltestcase))
return list
+ """Clean tmp folder for testing"""
+ def clean_tmp():
+ tmppath = bb.data.getVar('TEST_TMP', d, 1)
+
+ if os.path.isdir(tmppath):
+ for f in os.listdir(tmppath):
+ tmpfile = os.path.join(tmppath, f)
+ os.remove(tmpfile)
+
+ """Before running testing, clean temp folder first"""
+ clean_tmp()
+
"""check testcase folder and create test log folder"""
testpath = bb.data.getVar('TEST_DIR', d, 1)
bb.utils.mkdirhier(testpath)
@@ -105,7 +134,13 @@ def qemuimagetest_main(d):
tmppath = bb.data.getVar('TEST_TMP', d, 1)
bb.utils.mkdirhier(tmppath)
-
+
+ """initialize test status file"""
+ test_status = bb.data.getVar('TEST_STATUS', d, 1)
+ if os.path.exists(test_status):
+ os.remove(test_status)
+ os.system("touch %s" % test_status)
+
"""initialize result file"""
resultpath = bb.data.getVar('TEST_RESULT', d, 1)
bb.utils.mkdirhier(resultpath)
@@ -128,9 +163,11 @@ def qemuimagetest_main(d):
fulllist = generate_list(testlist)
"""Begin testing"""
- for test in fulllist:
+ for index,test in enumerate(fulllist):
(scen, case, fullpath) = test
+ teststatus(case, "running", index, (len(fulllist) - 1))
runtest(scen, case, fullpath)
+ teststatus(case, "finished", index, (len(fulllist) - 1))
"""Print Test Result"""
ret = 0
@@ -149,6 +186,9 @@ def qemuimagetest_main(d):
bb.note(line)
f.close()
+ """Clean temp files for testing"""
+ clean_tmp()
+
if ret != 0:
raise bb.build.FuncFailed("Some testcases fail, pls. check test result and test log!!!")