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

Yeoh, Ee Peng ee.peng.yeoh at intel.com
Fri Mar 23 01:32:56 UTC 2018


Hi Alex,

Thank you very much for your great sharing!
Yes, understood now, let me refactor this testcase to use runqemu instead. 

Thanks,
Ee Peng 

-----Original Message-----
From: Alexander Kanavin [mailto:alexander.kanavin at linux.intel.com] 
Sent: Thursday, March 22, 2018 7:38 PM
To: Yeoh, Ee Peng <ee.peng.yeoh at intel.com>; openembedded-core at lists.openembedded.org
Cc: Paul Eggleton <paul.eggleton at linux.intel.com>
Subject: Re: [OE-core] [PATCH] oe-selftest: crosstap: add tests for crosstap script

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