summaryrefslogtreecommitdiffstats
path: root/meta/classes/testimage.bbclass
diff options
context:
space:
mode:
authorStefan Stanacar <stefanx.stanacar@intel.com>2013-09-23 07:58:11 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-09-24 17:24:12 +0100
commit95455bc3e2598a8b9045f76381c6091586ce683b (patch)
tree59e308df649d8fbcac3e7c8374676eaff2fe75d8 /meta/classes/testimage.bbclass
parent80203494aa4ac9a1c6b724f8ad7f50a533895138 (diff)
downloadpoky-95455bc3e2598a8b9045f76381c6091586ce683b.tar.gz
classes/testimage: add informational messages about tests and do some cleanup/formatting
Adds info about tests run even if they passed (in case of errors log will be printed anyway). Also some style change for qemu object. (From OE-Core rev: 4adcf960be9c7477e314788d42b80753c2aaf572) Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/testimage.bbclass')
-rw-r--r--meta/classes/testimage.bbclass40
1 files changed, 24 insertions, 16 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 9ecef68418..86bf22ef02 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -85,6 +85,7 @@ def testimage_main(d):
85 import oeqa.runtime 85 import oeqa.runtime
86 import re 86 import re
87 import shutil 87 import shutil
88 import time
88 from oeqa.oetest import runTests 89 from oeqa.oetest import runTests
89 from oeqa.utils.sshcontrol import SSHControl 90 from oeqa.utils.sshcontrol import SSHControl
90 from oeqa.utils.qemurunner import QemuRunner 91 from oeqa.utils.qemurunner import QemuRunner
@@ -114,21 +115,23 @@ def testimage_main(d):
114 #will handle fs type eventually, stick with ext3 for now 115 #will handle fs type eventually, stick with ext3 for now
115 #make a copy of the original rootfs and use that for tests 116 #make a copy of the original rootfs and use that for tests
116 origrootfs=os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME",True) + '.ext3') 117 origrootfs=os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME",True) + '.ext3')
117 rootfs=os.path.join(testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.ext3') 118 testrootfs=os.path.join(testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.ext3')
118 try: 119 try:
119 shutil.copyfile(origrootfs, rootfs) 120 shutil.copyfile(origrootfs, testrootfs)
120 except Exception as e: 121 except Exception as e:
121 bb.fatal("Error copying rootfs: %s" % e) 122 bb.fatal("Error copying rootfs: %s" % e)
122 123
123 qemu = QemuRunner(machine, rootfs)
124 qemu.tmpdir = d.getVar("TMPDIR", True)
125 qemu.deploy_dir_image = d.getVar("DEPLOY_DIR_IMAGE", True)
126 qemu.display = d.getVar("BB_ORIGENV", False).getVar("DISPLAY", True)
127 qemu.logfile = os.path.join(testdir, "qemu_boot_log.%s" % d.getVar('DATETIME', True))
128 try: 124 try:
129 qemu.boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT", True)) 125 boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT", True))
130 except ValueError: 126 except ValueError:
131 qemu.boottime = 500 127 boottime = 1000
128
129 qemu = QemuRunner(machine=machine, rootfs=testrootfs,
130 tmpdir = d.getVar("TMPDIR", True),
131 deploy_dir_image = d.getVar("DEPLOY_DIR_IMAGE", True),
132 display = d.getVar("BB_ORIGENV", False).getVar("DISPLAY", True),
133 logfile = os.path.join(testdir, "qemu_boot_log.%s" % d.getVar('DATETIME', True)),
134 boottime = boottime)
132 135
133 qemuloglink = os.path.join(testdir, "qemu_boot_log") 136 qemuloglink = os.path.join(testdir, "qemu_boot_log")
134 if os.path.islink(qemuloglink): 137 if os.path.islink(qemuloglink):
@@ -141,12 +144,12 @@ def testimage_main(d):
141 os.unlink(sshloglink) 144 os.unlink(sshloglink)
142 os.symlink(sshlog, sshloglink) 145 os.symlink(sshlog, sshloglink)
143 146
144
145 bb.note("DISPLAY value: %s" % qemu.display) 147 bb.note("DISPLAY value: %s" % qemu.display)
146 bb.note("rootfs file: %s" % rootfs) 148 bb.note("rootfs file: %s" % qemu.rootfs)
147 bb.note("Qemu log file: %s" % qemu.logfile) 149 bb.note("Qemu log file: %s" % qemu.logfile)
148 bb.note("SSH log file: %s" % sshlog) 150 bb.note("SSH log file: %s" % sshlog)
149 151
152 pn = d.getVar("PN", True)
150 #catch exceptions when loading or running tests (mostly our own errors) 153 #catch exceptions when loading or running tests (mostly our own errors)
151 try: 154 try:
152 if qemu.launch(): 155 if qemu.launch():
@@ -156,14 +159,19 @@ def testimage_main(d):
156 tc.qemu = qemu 159 tc.qemu = qemu
157 tc.target = SSHControl(host=qemu.ip,logfile=sshlog) 160 tc.target = SSHControl(host=qemu.ip,logfile=sshlog)
158 # run tests and get the results 161 # run tests and get the results
162 starttime = time.time()
159 result = runTests(tc) 163 result = runTests(tc)
160 164 stoptime = time.time()
161 if result.wasSuccessful(): 165 if result.wasSuccessful():
162 bb.note("All required tests passed") 166 bb.plain("%s - Ran %d test%s in %.3fs" % (pn, result.testsRun, result.testsRun != 1 and "s" or "", stoptime - starttime))
167 msg = "%s - OK - All required tests passed" % pn
168 skipped = len(result.skipped)
169 if skipped:
170 msg += " (skipped=%d)" % skipped
171 bb.plain(msg)
163 else: 172 else:
164 raise bb.build.FuncFailed("Some tests failed. You should check the task log and the ssh log. (ssh log is %s" % sshlog) 173 raise bb.build.FuncFailed("%s - FAILED - check the task log and the ssh log" % pn )
165
166 else: 174 else:
167 raise bb.build.FuncFailed("Failed to start qemu. You should check the task log and the qemu boot log (qemu log is %s)" % qemu.logfile) 175 raise bb.build.FuncFailed("%s - FAILED to start qemu - check the task log and the boot log" % pn)
168 finally: 176 finally:
169 qemu.kill() 177 qemu.kill()