meson.bbclass: add support for running the meson tests at build time
PATCH 1/2 meson.bbclass: add support for running the meson tests at build time
The generic exe_wrapper introcuced in 40349dc5 can be used to run the meson tests when build the receipe. This patch add the meson_test task on the meson bbclass that adds this possibility.
The exe_wrapper will run using the qemu usermode and because of that it has some limitations, one big limitation that causes many test to fail is that it don't support the fork system call. So don't expect the same results when it runs natively on target.
Running the tests at build time is upstream way for testing but is not possible in OE as we always croos-compile. This can be useful in some integration processes and for debuging and it adds the possibility to run the test in an interactive way using the devtool build for example.
There are two variable for that:
MESON_QEMU_WRAPPER_TEST_ENABLED: this enables the test when it's "1"
EXTRA_OEMESON_TEST: this is used to add extra args
Some results when using this patch in the bigest meson project on OE-core are the folloing:
cat <<'EOF' >>conf/local.conf MESON_QEMU_WRAPPER_TEST_ENABLED:pn-systemd-boot = "1" EOF
bitbake -c do_meson_test -v systemd-boot
Ok: 821 Expected Fail: 0 Fail: 95 Unexpected Pass: 0 Skipped: 33 Timeout: 0
cat <<'EOF' >>conf/local.conf
MESON_QEMU_WRAPPER_TEST_ENABLED:pn-glib-2.0 = "1"
EOF
bitbake -c do_meson_test -v glib-2.0
Ok: 197 Expected Fail: 0 Fail: 76 Unexpected Pass: 0 Skipped: 0 Timeout: 2
cat <<'EOF' >>conf/local.conf MESON_QEMU_WRAPPER_TEST_ENABLED:pn-gstreamer1.0 = "1" EOF
bitbake -c do_meson_test -v gstreamer1.0
Ok: 95 Expected Fail: 0 Fail: 10 Unexpected Pass: 0 Skipped: 1 Timeout: 0
--- meta/classes/meson.bbclass | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
meta/classes/meson.bbclass +16 -0
@@ -179,3 +179,19 @@ meson_do_install() { } EXPORT_FUNCTIONS do_configure do_compile do_install + +EXTRA_OEMESON_TEST ?= "" + +do_meson_test() { + bbwarn "don't expect the same results when it runs natively as it will run in qemu usermode (that has its own limitations)" + meson test -C ${B} ${EXTRA_OEMESON_TEST} +} +do_meson_test[vardeps] += "EXTRA_OEMESON_TEST" + +MESON_QEMU_WRAPPER_RUNTEST = "" +MESON_QEMU_WRAPPER_RUNTEST:class-target = "${@d.getVar('MESON_QEMU_WRAPPER_TEST_ENABLED') == '1' and d.getVar('EXEWRAPPER_ENABLED') == 'True'}" + +python() { + if d.getVar('MESON_QEMU_WRAPPER_RUNTEST') == 'True': + bb.build.addtask('meson_test', None, 'do_compile', d) +}
Signature · 1 line
2.35.1
PATCH 2/2 meson.bbclass: add exe_wrapper helper
When we use the exe_wrapper to run the tests we need a way to circumvent the limitations of qemu usermode. So for example we can skip the tests we know will fail. The ideia of this help script is to handle such cases before the qemu usermode was launched.
--- meta/classes/meson.bbclass | 6 ++++++ 1 file changed, 6 insertions(+)
meta/classes/meson.bbclass +6 -0
@@ -114,6 +114,8 @@ cpp_link_args = ${@meson_array('BUILD_LDFLAGS', d)} EOF } +MESON_QEMU_WRAPPER_HELPER ?= "" + do_write_config:append:class-target() { # Write out a qemu wrapper that will be used as exe_wrapper so that meson # can run target helper binaries through that.
@@ -127,10 +129,14 @@ export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy # meson sets this wrongly (only to libs in build-dir), qemu_wrapper_cmdline() and GIR_EXTRA_LIBS_PATH take care of it properly unset LD_LIBRARY_PATH +# import any customization provided in the helper +test -f "${MESON_QEMU_WRAPPER_HELPER}" && . ${MESON_QEMU_WRAPPER_HELPER} + $qemu_binary "\$@" EOF chmod +x ${WORKDIR}/meson-qemuwrapper } +do_write_config:class-target[vardeps] += "MESON_QEMU_WRAPPER_HELPER" # Tell externalsrc that changes to this file require a reconfigure CONFIGURE_FILES = "meson.build"
Signature · 1 line
2.35.1