diff options
Diffstat (limited to 'meta/classes/imagetest-qemu.bbclass')
| -rw-r--r-- | meta/classes/imagetest-qemu.bbclass | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/meta/classes/imagetest-qemu.bbclass b/meta/classes/imagetest-qemu.bbclass index bcae10d61d..28bb218272 100644 --- a/meta/classes/imagetest-qemu.bbclass +++ b/meta/classes/imagetest-qemu.bbclass | |||
| @@ -5,6 +5,7 @@ TEST_LOG ?= "${LOG_DIR}/qemuimagetests" | |||
| 5 | TEST_RESULT ?= "${TEST_DIR}/result" | 5 | TEST_RESULT ?= "${TEST_DIR}/result" |
| 6 | TEST_TMP ?= "${TEST_DIR}/tmp" | 6 | TEST_TMP ?= "${TEST_DIR}/tmp" |
| 7 | TEST_SCEN ?= "sanity" | 7 | TEST_SCEN ?= "sanity" |
| 8 | SHARE_IMAGE ?= "1" | ||
| 8 | 9 | ||
| 9 | python do_qemuimagetest() { | 10 | python do_qemuimagetest() { |
| 10 | qemuimagetest_main(d) | 11 | qemuimagetest_main(d) |
| @@ -37,7 +38,7 @@ def qemuimagetest_main(d): | |||
| 37 | """funtion to run each case under scenario""" | 38 | """funtion to run each case under scenario""" |
| 38 | def runtest(scen, case, fulltestpath): | 39 | def runtest(scen, case, fulltestpath): |
| 39 | resultpath = bb.data.getVar('TEST_RESULT', d, 1) | 40 | resultpath = bb.data.getVar('TEST_RESULT', d, 1) |
| 40 | testpath = bb.data.getVar('TEST_DIR', d, 1) | 41 | tmppath = bb.data.getVar('TEST_TMP', d, 1) |
| 41 | 42 | ||
| 42 | """initialize log file for testcase""" | 43 | """initialize log file for testcase""" |
| 43 | logpath = bb.data.getVar('TEST_LOG', d, 1) | 44 | logpath = bb.data.getVar('TEST_LOG', d, 1) |
| @@ -45,10 +46,9 @@ def qemuimagetest_main(d): | |||
| 45 | caselog = os.path.join(logpath, "%s/log_%s.%s" % (scen, case, bb.data.getVar('DATETIME', d, 1))) | 46 | caselog = os.path.join(logpath, "%s/log_%s.%s" % (scen, case, bb.data.getVar('DATETIME', d, 1))) |
| 46 | os.system("touch %s" % caselog) | 47 | os.system("touch %s" % caselog) |
| 47 | 48 | ||
| 48 | |||
| 49 | """export TEST_TMP, TEST_RESULT, DEPLOY_DIR and QEMUARCH""" | 49 | """export TEST_TMP, TEST_RESULT, DEPLOY_DIR and QEMUARCH""" |
| 50 | os.environ["PATH"] = bb.data.getVar("PATH", d, True) | 50 | os.environ["PATH"] = bb.data.getVar("PATH", d, True) |
| 51 | os.environ["TEST_TMP"] = testpath | 51 | os.environ["TEST_TMP"] = tmppath |
| 52 | os.environ["TEST_RESULT"] = resultpath | 52 | os.environ["TEST_RESULT"] = resultpath |
| 53 | os.environ["DEPLOY_DIR"] = bb.data.getVar("DEPLOY_DIR", d, True) | 53 | os.environ["DEPLOY_DIR"] = bb.data.getVar("DEPLOY_DIR", d, True) |
| 54 | os.environ["QEMUARCH"] = machine | 54 | os.environ["QEMUARCH"] = machine |
| @@ -56,6 +56,7 @@ def qemuimagetest_main(d): | |||
| 56 | os.environ["DISPLAY"] = bb.data.getVar("DISPLAY", d, True) | 56 | os.environ["DISPLAY"] = bb.data.getVar("DISPLAY", d, True) |
| 57 | os.environ["POKYBASE"] = bb.data.getVar("POKYBASE", d, True) | 57 | os.environ["POKYBASE"] = bb.data.getVar("POKYBASE", d, True) |
| 58 | os.environ["TOPDIR"] = bb.data.getVar("TOPDIR", d, True) | 58 | os.environ["TOPDIR"] = bb.data.getVar("TOPDIR", d, True) |
| 59 | os.environ["SHARE_IMAGE"] = bb.data.getVar("SHARE_IMAGE", d, True) | ||
| 59 | 60 | ||
| 60 | """run Test Case""" | 61 | """run Test Case""" |
| 61 | bb.note("Run %s test in scenario %s" % (case, scen)) | 62 | bb.note("Run %s test in scenario %s" % (case, scen)) |
| @@ -97,6 +98,18 @@ def qemuimagetest_main(d): | |||
| 97 | list.append((item, casefile, fulltestcase)) | 98 | list.append((item, casefile, fulltestcase)) |
| 98 | return list | 99 | return list |
| 99 | 100 | ||
| 101 | """Clean tmp folder for testing""" | ||
| 102 | def clean_tmp(): | ||
| 103 | tmppath = bb.data.getVar('TEST_TMP', d, 1) | ||
| 104 | |||
| 105 | if os.path.isdir(tmppath): | ||
| 106 | for f in os.listdir(tmppath): | ||
| 107 | tmpfile = os.path.join(tmppath, f) | ||
| 108 | os.remove(tmpfile) | ||
| 109 | |||
| 110 | """Before running testing, clean temp folder first""" | ||
| 111 | clean_tmp() | ||
| 112 | |||
| 100 | """check testcase folder and create test log folder""" | 113 | """check testcase folder and create test log folder""" |
| 101 | testpath = bb.data.getVar('TEST_DIR', d, 1) | 114 | testpath = bb.data.getVar('TEST_DIR', d, 1) |
| 102 | bb.utils.mkdirhier(testpath) | 115 | bb.utils.mkdirhier(testpath) |
| @@ -150,6 +163,9 @@ def qemuimagetest_main(d): | |||
| 150 | bb.note(line) | 163 | bb.note(line) |
| 151 | f.close() | 164 | f.close() |
| 152 | 165 | ||
| 166 | """Clean temp files for testing""" | ||
| 167 | clean_tmp() | ||
| 168 | |||
| 153 | if ret != 0: | 169 | if ret != 0: |
| 154 | raise bb.build.FuncFailed("Some testcases fail, pls. check test result and test log!!!") | 170 | raise bb.build.FuncFailed("Some testcases fail, pls. check test result and test log!!!") |
| 155 | 171 | ||
