Re: [yocto] Writing custom hardware tests
Gyorgy Sarvari <[email protected]>
| Newsgroups | org.yoctoproject.lists.yocto |
|---|---|
| Message-ID | <[email protected]> |
On 10/1/25 18:09, Rusty Howell via lists.yoctoproject.org wrote:
> Hi all,
>
> I am trying to write some automated hardware tests for my device. I'm
> following the instructions
> in https://docs.yoctoproject.org/5.0.12/test-manual/runtime-testing.html#performing-automated-runtime-testing
>
> In local.conf I have the following:
>
> DISTRO_FEATURES:append = " ptest"
> EXTRA_IMAGE_FEATURES += "ptest-pkgs"
> TEST_SERIALCONTROL_CMD = "microcom -s 115200 -p /dev/ttyUSB0"
> IMAGE_CLASSES += "testimage"
> #INHERIT += "testexport"
> TEST_TARGET = "MyTarget"
>
> In my layer I have a custom target
> meta-my-layer/lib/oeqa/controllers/mytarget.py (copied from
> meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py and modified for
> MyTarget class)
>
> When I run bitbake -c testimage my-image I get this error
>
> 0182: @staticmethod
> 0183: def _loadControllerFromModule(target, modulename):
> Exception: AttributeError: Unable to load MyTarget from available
> modules: ['oeqa.controllers.controllerimage',
> 'oeqa.controllers.testtargetloader', 'oeqa.controllers.fvp']
>
> If I add addpylib${LAYERDIR}/lib oeqa to my layer.conf (like other
> layers have) I get this new error
>
> File:
> '/workspaces/my-distro/sources/poky/meta/classes-recipe/testimage.bbclass',
> lineno: 181, function: testimage_main
> 0177: import logging
> 0178: import shutil
> 0179:
> 0180: from bb.utils import export_proxies
> *** 0181: from oeqa.runtime.context import OERuntimeTestContext
> 0182: from oeqa.runtime.context import
> OERuntimeTestContextExecutor
> 0183: from oeqa.core.target.qemu import supported_fstypes
> 0184: from oeqa.core.utils.test import getSuiteCases
> 0185: from oeqa.utils import make_logger_bitbake_compatible
> Exception: ModuleNotFoundError: No module named 'oeqa.runtime.context'
>
> Any help is appreciated.
>
I believe unfortunately that this part has been without too much
attention lately. addpylib directive is not needed for this.
There are two things:
1. For runtime tests controllers are searched in PATH[1], instead of
BBPATH - that's why it can't find your test controller. You can work
around by adding this to your image recipe:
python __anonymous () {
import sys
sys.path.append("<start_of_path>/meta-my-layer/lib")
}
(Alternatively you can also extend path with d.getVar("BBPATH").split(":"))
It's may not be nice, but it gets you to the next step for now.
2. Some time ago there was some refactoring[2] done in the testimage
bbclass (instead of passing "d" to init the controller a bunch of kwargs
are sent), however these example hw controllers were not refactored
apparently from meta-yocto-bsp layer. You could try to adapt the grub
example (and its ancestor) to the new format or, if other classes are
also usable for you, you could give them a try too (SSHTarget for example).
[1]:
https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/runtime/context.py#n161
[2]:
https://git.yoctoproject.org/poky/commit/meta/classes/testimage.bbclass?id=3857e5c91da678d7bdc07712a1df9daa14354986
(search for "robot dance")