sdktest.bbclass does not find custom sdk tests
Hi,
I'm currently trying to create some tests for my sdk, using sdktest.bbclass, but i'm having issues with bitbake locating my tests. In my layer, i have this setup:
├── meta-custom
...
│ ├── conf │ │ └── layer.conf │ ├── lib │ │ └── oeqa │ │ ├── controllers │ │ │ └── __init__.py │ │ └── sdk │ │ ├── cases │ │ │ ├── mytest.py │ │ ├── __init__.py
...
In the __init__.py files i have added:
from pkgutil import extend_path__path__ = extend_path ( __path__ , __name__ )
And in layer.conf:
addpylib ${ LAYERDIR } / lib oeqa
And in my image i have:
inherit testsdk
mytest.py is quite simple:
from oeqa. sdk. case import OESDKTestCase
class CustomTestSuite ( OESDKTestCase ):
def test_failure ( self ):
self. _run ( " false " )
def test_success ( self ):
self. _run ( " true " )
But when i run bitbake custom-image -c testsdk after bitbake custom-image -c populate_sdk, the following is only run:
SDK testing environment: armv8a-poky-linux GalculatorTest class: SDK don't support gtk+3 No python3-maturin package in the SDK No python3-maturin package in the SDK RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain RESULTS: RESULTS - assimp.BuildAssimp.test_assimp: PASSED (89.13s) RESULTS - buildcpio.BuildCpioTest.test_cpio: PASSED (23.24s) RESULTS - buildepoxy.EpoxyTest.test_epoxy: PASSED (11.51s) RESULTS - buildlzip.BuildLzipTest.test_lzip: PASSED (1.31s) RESULTS - gcc.GccCompileTest.test_gcc_compile: PASSED (0.07s) RESULTS - gcc.GccCompileTest.test_gpp2_compile: PASSED (0.07s) RESULTS - gcc.GccCompileTest.test_gpp_compile: PASSED (0.17s) RESULTS - gcc.GccCompileTest.test_make: PASSED (0.08s) RESULTS - perl.PerlTest.test_perl: PASSED (0.02s) RESULTS - python.Python3Test.test_python3: PASSED (0.03s) RESULTS - buildgalculator.GalculatorTest.test_galculator: SKIPPED (0.00s) RESULTS - maturin.MaturinDevelopTest.test_maturin_develop: SKIPPED (0.00s) RESULTS - maturin.MaturinTest.test_maturin_list_python: SKIPPED (0.00s) RESULTS - rust.RustCompileTest.test_cargo_build: SKIPPED (0.00s) RESULTS - rust.RustHostCompileTest.test_cargo_build: SKIPPED (0.00s)
SUMMARY: custom-image sdk - Ran 15 tests in 125.628s custom-image sdk - OK - All required tests passed (successes=10, skipped=5, failures=0, errors=0) NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded.
Where i would expect:
mytest.CustomTestSuite.test_failure: FAILURE (or ERROR) mytest.CustomTestSuite.test_success: PASSED
Any help or pointers is appreciated :)
Quoted 61 lines · On 4/11/25 08:52, kasper.sloth99 via lists.yoctoproject.org wrote:
Hi,
I'm currently trying to create some tests for my sdk, using sdktest.bbclass, but i'm having issues with bitbake locating my tests. In my layer, i have this setup:
├── meta-custom
...│ ├── conf │ │ └── layer.conf │ ├── lib │ │ └── oeqa │ │ ├── controllers │ │ │ └── __init__.py │ │ └── sdk │ │ ├── cases │ │ │ ├── mytest.py │ │ ├── __init__.py...
In the
__init__.pyfiles i have added:frompkgutilimportextend_path__path__=extend_path(__path__,__name__)
And in layer.conf:
addpylib${LAYERDIR}/liboeqa
And in my image i have:
inherittestsdkmytest.pyis quite simple:
fromoeqa.sdk.caseimportOESDKTestCase classCustomTestSuite(OESDKTestCase):deftest_failure(self):self._run("false")deftest_success(self):self._run("true")
But when i run bitbake custom-image -c testsdk after bitbake custom-image -cpopulate_sdk, the following is only run:|SDK testing environment: armv8a-poky-linux ||GalculatorTest class: SDK don't support gtk+3 ||No python3-maturin package in the SDK ||No python3-maturin package in the SDK ||RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain ||RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain ||RESULTS: ||RESULTS - assimp.BuildAssimp.test_assimp: PASSED (89.13s) ||RESULTS - buildcpio.BuildCpioTest.test_cpio: PASSED (23.24s) ||RESULTS - buildepoxy.EpoxyTest.test_epoxy: PASSED (11.51s) ||RESULTS - buildlzip.BuildLzipTest.test_lzip: PASSED (1.31s) ||RESULTS - gcc.GccCompileTest.test_gcc_compile: PASSED (0.07s) ||RESULTS - gcc.GccCompileTest.test_gpp2_compile: PASSED (0.07s) ||RESULTS - gcc.GccCompileTest.test_gpp_compile: PASSED (0.17s) ||RESULTS - gcc.GccCompileTest.test_make: PASSED (0.08s) ||RESULTS - perl.PerlTest.test_perl: PASSED (0.02s) ||RESULTS - python.Python3Test.test_python3: PASSED (0.03s) ||RESULTS - buildgalculator.GalculatorTest.test_galculator: SKIPPED (0.00s) ||RESULTS - maturin.MaturinDevelopTest.test_maturin_develop: SKIPPED (0.00s) ||RESULTS - maturin.MaturinTest.test_maturin_list_python: SKIPPED (0.00s) ||RESULTS - rust.RustCompileTest.test_cargo_build: SKIPPED (0.00s) ||RESULTS - rust.RustHostCompileTest.test_cargo_build: SKIPPED (0.00s)| |SUMMARY: ||custom-image sdk - Ran 15 tests in 125.628s ||custom-image
Quoted 9 lines
sdk - OK - All required tests passed (successes=10, skipped=5, failures=0, errors=0) ||NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded.|
Where i would expect:
mytest.CustomTestSuite.test_failure: FAILURE (or ERROR) mytest.CustomTestSuite.test_success: PASSED
Any help or pointers is appreciated :)
Until you get better answers, here is one, which might not be the most optimal...
This is what seems to be happening:
1. testsdk.bbclass[1] runs the class from TESTSDK_CLASS_NAME to run the tests.
2. The default class pulls[2] the tests from OESDKTestContextExecutor
3. Which in turn loads testcases only from the current folder[3]
This seems to be different from the self-test mechanism, which collects the tests from all layers[4].
At least for me, that function looks too big to monkeypatch it in a way that I would understand half a day later. (It's a matter of taste also I guess, I don't want to discourage anyone)
The maybe-better-than-nothing-until-someone-else-replies workaround:
1. In your layer, instead of calling the module oeqa, rename it to myqa (or whatever)
2. From oe-core, lib/oeqa/sdk folder copy testsdk.py and context.py to lib/myqa/sdk folder in your layer
3. In your layer edit testsdk.py, edit the import at the top to load myqa module instead of oeqa
4. To run your tests set 'TESTSDK_CLASS_NAME = "myqa.sdk.testsdk.TestSDK"' in your preferred way. To run the original tests, don't touch that variable.
[1]:
https://git.openembedded.org/openembedded-core/tree/meta/classes-recipe/testsdk.bbclass#n17
[2]:
https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/sdk/testsdk.py#n117
[3]:
https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/sdk/context.py#n61
[4]:
https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/selftest/context.py#n242
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 100 lines · Gyorgy Sarvari via lists.yoctoproject.org
Quoted 61 lines · On 4/11/25 08:52, kasper.sloth99 via lists.yoctoproject.org wrote:
Hi,
I'm currently trying to create some tests for my sdk, using sdktest.bbclass, but i'm having issues with bitbake locating my tests. In my layer, i have this setup:
├── meta-custom
...│ ├── conf │ │ └── layer.conf │ ├── lib │ │ └── oeqa │ │ ├── controllers │ │ │ └── __init__.py │ │ └── sdk │ │ ├── cases │ │ │ ├── mytest.py │ │ ├── __init__.py...
In the
__init__.pyfiles i have added:frompkgutilimportextend_path__path__=extend_path(__path__,__name__)
And in layer.conf:
addpylib${LAYERDIR}/liboeqa
And in my image i have:
inherittestsdkmytest.pyis quite simple:
fromoeqa.sdk.caseimportOESDKTestCase classCustomTestSuite(OESDKTestCase):deftest_failure(self):self._run("false")deftest_success(self):self._run("true")
But when i run bitbake custom-image -c testsdk after bitbake custom-image -cpopulate_sdk, the following is only run:|SDK testing environment: armv8a-poky-linux ||GalculatorTest class: SDK don't support gtk+3 ||No python3-maturin package in the SDK ||No python3-maturin package in the SDK ||RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain ||RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain ||RESULTS: ||RESULTS - assimp.BuildAssimp.test_assimp: PASSED (89.13s) ||RESULTS - buildcpio.BuildCpioTest.test_cpio: PASSED (23.24s) ||RESULTS - buildepoxy.EpoxyTest.test_epoxy: PASSED (11.51s) ||RESULTS - buildlzip.BuildLzipTest.test_lzip: PASSED (1.31s) ||RESULTS - gcc.GccCompileTest.test_gcc_compile: PASSED (0.07s) ||RESULTS - gcc.GccCompileTest.test_gpp2_compile: PASSED (0.07s) ||RESULTS - gcc.GccCompileTest.test_gpp_compile: PASSED (0.17s) ||RESULTS - gcc.GccCompileTest.test_make: PASSED (0.08s) ||RESULTS - perl.PerlTest.test_perl: PASSED (0.02s) ||RESULTS - python.Python3Test.test_python3: PASSED (0.03s) ||RESULTS - buildgalculator.GalculatorTest.test_galculator: SKIPPED (0.00s) ||RESULTS - maturin.MaturinDevelopTest.test_maturin_develop: SKIPPED (0.00s) ||RESULTS - maturin.MaturinTest.test_maturin_list_python: SKIPPED (0.00s) ||RESULTS - rust.RustCompileTest.test_cargo_build: SKIPPED (0.00s) ||RESULTS - rust.RustHostCompileTest.test_cargo_build: SKIPPED (0.00s)| |SUMMARY: ||custom-image sdk - Ran 15 tests in 125.628s ||custom-imageQuoted 9 lines
sdk - OK - All required tests passed (successes=10, skipped=5, failures=0, errors=0) ||NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded.|
Where i would expect:
mytest.CustomTestSuite.test_failure: FAILURE (or ERROR) mytest.CustomTestSuite.test_success: PASSED
Any help or pointers is appreciated :)Until you get better answers, here is one, which might not be the most optimal...
This is what seems to be happening:
1. testsdk.bbclass[1] runs the class fromTESTSDK_CLASS_NAMEto run the tests.
2. The default class pulls[2] the tests from OESDKTestContextExecutor
3. Which in turn loads testcases only from the current folder[3]This seems to be different from the self-test mechanism, which collects the tests from all layers[4].
At least for me, that function looks too big to monkeypatch it in a way that I would understand half a day later. (It's a matter of taste also I guess, I don't want to discourage anyone)
The maybe-better-than-nothing-until-someone-else-replies workaround:
1. In your layer, instead of calling the module oeqa, rename it to myqa (or whatever)
2. From oe-core,lib/oeqa/sdkfolder copytestsdk.pyandcontext.pytolib/myqa/sdkfolder in your layer
3. In your layer edittestsdk.py, edit the import at the top to load myqa module instead of oeqa
4. To run your tests set 'TESTSDK_CLASS_NAME= "myqa.sdk.testsdk.TestSDK"' in your preferred way. To run the original tests, don't touch that variable.
Quoted 8 lines
[1]:
https://git.openembedded.org/openembedded-core/tree/meta/classes-recipe/testsdk.bbclass#n17
[2]:
https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/sdk/testsdk.py#n117
[3]:
https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/sdk/context.py#n61
[4]:
https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/selftest/context.py#n242
After having some sleep, the problem is still the same, but I realized that it can be solved much easier.
Forget what I wrote in my previous email, and add the following to your image recipe[1]:
```
def import_and_run(name, d):
from oeqa.sdk.context import OESDKTestContextExecutor
test_cases = []
bbpath = d.getVar('BBPATH')
for layer in bbpath.split(":"):
cases = os.path.join(layer, 'lib', 'oeqa', 'sdk', 'cases')
if os.path.isdir(cases):
test_cases.append(cases)
OESDKTestContextExecutor.default_cases = test_cases
import importlib
class_name = d.getVar(name)
if class_name:
module, cls = class_name.rsplit('.', 1)
m = importlib.import_module(module)
c = getattr(m, cls)()
c.run(d)
else:
bb.warn('No tests were run because %s did not define a class' %
name)
```This is a bit extended version of the "import_and_run" function defined in the testsdk.bbclass, that first patches OESDKTestContextExecutor to collect tests from all layers.
I believe this should execute all tests from all layers in one go, without the messy tinkering I mentioned.
One thing: I haven't tested IMAGE_INHERIT specifically, but I believe that it won't work with this. You need to add "inherit testsdk" in your image recipe, and put this function *after* the inherit line.
Results on my end:
RESULTS - mytest.CustomTestSuite.test_success: PASSED (0.00s) RESULTS - autotools.AutotoolsTest.test_cpio: PASSED (18.34s) RESULTS - cmake.CMakeTest.test_assimp: PASSED (144.55s) RESULTS - gcc.GccCompileTest.test_gcc_compile: PASSED (0.06s) RESULTS - gcc.GccCompileTest.test_gpp2_compile: PASSED (0.06s) RESULTS - gcc.GccCompileTest.test_gpp_compile: PASSED (0.20s) RESULTS - gcc.GccCompileTest.test_make: PASSED (0.06s)
RESULTS - makefile.MakefileTest.test_lzip: PASSED (1.34s) RESULTS - meson.MesonTest.test_epoxy: PASSED (11.65s)
RESULTS - perl.PerlTest.test_perl: PASSED (0.01s)
RESULTS - python.Python3Test.test_python3: PASSED (0.02s) RESULTS - gtk3.GTK3Test.test_galculator: SKIPPED (0.00s) RESULTS - kmod.KernelModuleTest.test_cryptodev: SKIPPED (0.00s) RESULTS - maturin.MaturinDevelopTest.test_maturin_develop: SKIPPED (0.00s) RESULTS - maturin.MaturinTest.test_maturin_list_python: SKIPPED (0.00s) RESULTS - rust.RustCompileTest.test_cargo_build: SKIPPED (0.00s) RESULTS - rust.RustHostCompileTest.test_cargo_build: SKIPPED (0.00s) RESULTS - mytest.CustomTestSuite.test_failure: ERROR (0.01s)
[1]: In case indentation would be broken in the email:
https://gist.github.com/OldManYellsAtCloud/86fe110a3d1bdb26a28a724dd3ff6c52
Quoted 8 lines · Gyorgy Sarvari via lists.yoctoproject.org
After having some sleep, the problem is still the same, but I realized that it can be solved much easier.
Forget what I wrote in my previous email, and add the following to your image recipe[1]:
Whilst that works, I consider this a bug in testsdk. If someone could file a bug (or send a patch!) to unify the test case lookup then that would be great.
Ross
Quoted 9 lines · Ross Burton
Quoted 6 lines · Gyorgy Sarvari via lists.yoctoproject.org
After having some sleep, the problem is still the same, but I realized that it can be solved much easier.
Forget what I wrote in my previous email, and add the following to your image recipe[1]:Whilst that works, I consider this a bug in testsdk. If someone could file a bug (or send a patch!) to unify the test case lookup then that would be great.
Ross
Yeah, it occurred to me also, just wasn't sure how well it would be received considering that it took quite some time for someone to want it.
But with you altogether, that's 2 (at least). Will try to send a patch in the afternoon.
It would be nice with a patch. Will you backport it to scarthgap?
Kasper
Quoted 19 lines
Den 15. apr. 2025 kl. 12.26 skrev Gyorgy Sarvari <[email protected]>:
Quoted 9 lines · Ross Burton
Quoted 6 lines
Quoted 1 line · Gyorgy Sarvari via lists.yoctoproject.org
After having some sleep, the problem is still the same, but I realized that it can be solved much easier.
Forget what I wrote in my previous email, and add the following to your image recipe[1]:Whilst that works, I consider this a bug in testsdk. If someone could file a bug (or send a patch!) to unify the test case lookup then that would be great.
Ross
Yeah, it occurred to me also, just wasn't sure how well it would be received considering that it took quite some time for someone to want it.
But with you altogether, that's 2 (at least). Will try to send a patch in the afternoon.