Bug 12841

Summary: Additional layer extending test breaks bitbake -c testimage
Product: [QA/Testing] Runtime Testing Reporter: Paul Eggleton <bluelightning>
Component: generalAssignee: Apoorv <apoorv.sangal>
Status: RESOLVED MOVED QA Contact:
Severity: normal    
Priority: Medium CC: ee.peng.yeoh, ross.burton
Version: 5.99   
Target Milestone: 2.7   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Paul Eggleton 2018-07-03 03:19:40 UTC
If you add meta-security-smack to your configuration (inside the https://github.com/intel/meta-intel-iot-security repository) then add INHERIT += "testimage" to local.conf and then run bitbake -c testimage on a previously built image, you will get:

--------- snip ---------
ERROR: core-image-minimal-1.0-r0 do_testimage: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_testimage(d)
     0003:
File: '/data/poky/meta/classes/testimage.bbclass', lineno: 125, function: do_testimage
     0121:    netstat -an
     0122:}
     0123:
     0124:python do_testimage() {
 *** 0125:    testimage_main(d)
     0126:}
     0127:
     0128:addtask testimage
     0129:do_testimage[nostamp] = "1"
File: '/data/poky/meta/classes/testimage.bbclass', lineno: 148, function: testimage_main
     0144:    import logging
     0145:
     0146:    from bb.utils import export_proxies
     0147:    from oeqa.core.utils.misc import updateTestData
 *** 0148:    from oeqa.runtime.context import OERuntimeTestContext
     0149:    from oeqa.runtime.context import OERuntimeTestContextExecutor
     0150:    from oeqa.core.target.qemu import supported_fstypes
     0151:    from oeqa.core.utils.test import getSuiteCases
     0152:    from oeqa.utils import make_logger_bitbake_compatible
Exception: ImportError: No module named 'oeqa.runtime.context'

ERROR: core-image-minimal-1.0-r0 do_testimage: Function failed: do_testimage
ERROR: Logfile of failure stored in: /data/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_testimage.83960
ERROR: Task (/data/poky/meta/recipes-core/images/core-image-minimal.bb:do_testimage) failed with exit code '1'
--------- snip ---------

The issue is related to the fact that meta-security-smack is adding a few custom runtime tests. Interestingly, if you run the following within the poky repo then the issue goes away:

touch meta/lib/oeqa/__init__.py

It seems to me we probably ought to have this file there in OE-Core - I don't think meta-security-smack is doing something specific to trigger this that it shouldn't although I'm not 100% sure.
Comment 1 Apoorv 2018-09-25 14:08:05 UTC
this is due to changes made in commit id d9b3ee8b38f877c1723e48f1aa311c28102786fb. This would need further analaysis.
Comment 2 Apoorv 2018-09-26 14:26:46 UTC
QemuTarget is used to start a qemu instance (as it's currently done in testimage.bbclass).
SimpleRemoteTarget is meant for a remote machine (by setting TEST_TARGET_IP) that's already up and running with network and ssh. It allows to select one implementation or another by setting TEST_TARGET (currently to: "qemu" and "simpleremote").

Earlier,in poky (old version), when input (TAEST_TARGET = "simpleremote") is provided through local.conf file, then corresponding controller class implemention "SimpleRemoteTarget" got called. 
The "SimpleRemoteTarget" is class implemention for input "simpleremote".

poky commit id: 17e3dc2cb5e7c060647a29a508d43a622ba53b80

+def get_target_controller(d):
+    if d.getVar("TEST_TARGET", True) == "qemu":
+        return QemuTarget(d)
+    elif d.getVar("TEST_TARGET", True) == "simpleremote":
+        return SimpleRemoteTarget(d)
+    else:
+        bb.fatal("Please set a valid TEST_TARGET")

Now, in latest poky release, this class "SimpleRemoteTarget" implemention has been replaced by class "OESSHTarget" (meta/lib/oeqa/core/target/ssh.py:class OESSHTarget(OETarget):)

file name : poky/meta/lib/oeqa/runtime/context.py

if target_type == 'simpleremote':
    target = OESSHTarget(logger, target_ip, server_ip, **kwargs)
elif target_type == 'qemu':
    target = OEQemuTarget(logger, target_ip, server_ip, **kwargs)
else:

This class "SimpleRemoteTarget"  is present in file ./meta/lib/oeqa/targetcontrol.py but its instance/object is not being created anywhere.

Based on the analysis, class "SimpleRemoteTarget" is obsolete now. So, we need to update the document.
Comment 3 Apoorv 2018-09-27 02:53:58 UTC
apologies..please discard my comment2, it was for bug id 12842.
Comment 4 Ross Burton 2019-06-06 15:17:31 UTC
I believe the problem here is that meta-security-smack ships a __init__.py in its oeqa tree:

https://github.com/intel/meta-intel-iot-security/blob/master/meta-security-smack/lib/oeqa/runtime/__init__.py

This file should be deleted.

Moved to https://github.com/intel/meta-intel-iot-security/pull/142.