On 03/20/2018 01:59 AM, Yeoh Ee Peng wrote:
+    def start_qemu_with_image(self, recipe, fstypes, cmd, targetlogger):
+        tinfoil = bb.tinfoil.Tinfoil()
+        tinfoil.prepare(config_only=False, quiet=True)
+        try:
+            tinfoil.logger.setLevel(logging.WARNING)
+            tinfoil.config_data.setVar("TEST_LOG_DIR", "${WORKDIR}/testimage")
+            tinfoil.config_data.setVar("TEST_QEMUBOOT_TIMEOUT", "1000")
+            # Tell QemuTarget() whether need find rootfs/kernel or not
+            #tinfoil.config_data.setVar("FIND_ROOTFS", '0')
+            recipedata = tinfoil.parse_recipe(recipe)
+            logdir = recipedata.getVar("TEST_LOG_DIR")
+            qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, 
fstypes)
+        finally:
+            # We need to shut down tinfoil early here in case we actually want
+            # to run tinfoil-using utilities with the running QEMU instance.
+            # Luckily QemuTarget doesn't need it after the constructor.
+            tinfoil.shutdown()
+        print('DEBUG: qemu.deploy')
+        qemu.deploy()
+        try:
+            print('DEBUG: qemu.start')
+            qemu.start(ssh=True, launch_cmd=cmd, discard_writes=True)
+        except bb.build.FuncFailed:
+            raise Exception('Failed to start QEMU - see the logs in %s' % 
logdir)
+
+        return qemu

Can you use runqemu from oeqa.utils.commands, instead of this custom hand-written invocation? There are plenty of examples in oe-selftests, e.g.:

                    with runqemu('core-image-minimal') as qemu:
# Make the test echo a string and search for that as
                        # run_serial()'s status code is useless.'
for filename in ("rootfs", "delayed-a", "delayed-b"): status, output = qemu.run_serial("test -f %s && echo found" % os.path.join(targettestdir, filename)) self.assertEqual(output, "found", "%s was not present on boot" % filename)


Alex
--
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to