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

Alexander Kanavin alexander.kanavin at linux.intel.com
Thu Mar 22 11:38:26 UTC 2018


On 03/22/2018 02:50 AM, Yeoh, Ee Peng wrote:
>  From my understanding, oeqa.utils.commands.runqemu will start and stop qemu in a single call.

That's not the case at all. Please look at the example below again:

                     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)

It starts qemu, then does things (qemu.run_serial() ) with that running 
qemu instance. How and where qemu gets stopped is the 'magic' of 'with' 
statement.

The key part is that runqemu() has a @contextmanager decorator and 
contains this statement inside:

	yield qemu

which 'suspends' the runqemu() execution and resumes the caller 
function, passing it the qemu object. Once the 'with' block completes in 
the caller, the runqemu() function is allowed to resume and clean up the 
running qemu instance. It's definitely not a synchronous call/return 
thing. You can read all about it here:

https://docs.python.org/3/library/contextlib.html


> 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.

runqemu() was written for precisely this use case.


Alex



More information about the Openembedded-core mailing list