[OE-core] [PATCH] oe-selftest: crosstap: add tests for crosstap script

Yeoh, Ee Peng ee.peng.yeoh at intel.com
Thu Mar 22 00:50:50 UTC 2018


Hi Alex,

From my understanding, oeqa.utils.commands.runqemu will start and stop qemu in a single call. 
For crosstap testcase, it require the steps below:
	- start qemu
	- call to crosstap to ssh into qemu to use systemtap
	- stop qemu

Therefore, crosstap testcase use the oeqa.targetcontrol.QemuTarget (used by runqemu) to first start qemu, perform call to crosstap, then stop qemu. 

Please let me know if there was any alternative way. 

Thank you very much for your inputs and help!

Thanks,
Ee Peng 

-----Original Message-----
From: Alexander Kanavin [mailto:alexander.kanavin at linux.intel.com] 
Sent: Wednesday, March 21, 2018 9:45 PM
To: Yeoh, Ee Peng <ee.peng.yeoh at intel.com>; openembedded-core at lists.openembedded.org
Subject: Re: [OE-core] [PATCH] oe-selftest: crosstap: add tests for crosstap script

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


More information about the Openembedded-core mailing list