Add ptest support by wrapping existing tests for libxpm. The tests use GLib for various checks: * Read and parse input files * Write images, read them back, and compare the results * Parse RGB color names and check for the correct values
As such, add glib-2.0 as a build dependency (only if ptest is enabled). Also add libxpm to ptest-packagelists.inc. Test execution takes <3s on my machine, so add it to PTESTS_FAST. [YOCTO #16330] Signed-off-by: Enoch Ng <[email protected]> --- .../distro/include/ptest-packagelists.inc | 1 + .../xorg-lib/libxpm/run-ptest | 48 +++++++++++++++++++ .../xorg-lib/libxpm_3.5.19.bb | 22 ++++++++- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-graphics/xorg-lib/libxpm/run-ptest diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc index 2badb56c48..08bf8e48ee 100644 --- a/meta/conf/distro/include/ptest-packagelists.inc +++ b/meta/conf/distro/include/ptest-packagelists.inc @@ -58,6 +58,7 @@ PTESTS_FAST = "\ libxml-simple-perl \ libxml2 \ libxmlb \ + libxpm \ libxslt \ libyaml \ logrotate \ diff --git a/meta/recipes-graphics/xorg-lib/libxpm/run-ptest b/meta/recipes-graphics/xorg-lib/libxpm/run-ptest new file mode 100644 index 0000000000..0ba4e788d3 --- /dev/null +++ b/meta/recipes-graphics/xorg-lib/libxpm/run-ptest @@ -0,0 +1,48 @@ +#!/bin/sh + +TESTS="XpmCreate XpmMisc XpmRead XpmWrite rgb" + +for test in $TESTS; do + if [ ! -x "./$test" ]; then + echo "SKIP: $test" + continue + fi + + ./"$test" | \ + while IFS= read -r line; do + case "$line" in + "ok "*) + # output: "ok <num> <path>" or "ok <num> # SKIP <reason>" + tmp="${line#ok }" + testname="${tmp#* }" + case "$line" in + *"# SKIP"*) + testname="${testname%% \# SKIP*}" + echo "SKIP: ${test}/${testname}" + ;; + *) + echo "PASS: ${test}/${testname}" + ;; + esac + ;; + "not ok "*) + # output: "not ok <num> <testpath>" + tmp="${line#not ok }" + testname="${tmp#* }" + case "$line" in + *"# SKIP"*) + testname="${testname%% \# SKIP*}" + echo "SKIP: ${test}/${testname}" + ;; + *"# TODO"*) + testname="${testname%% \# TODO*}" + echo "FAIL: ${test}/${testname}" + ;; + *) + echo "FAIL: ${test}/${testname}" + ;; + esac + ;; + esac + done +done diff --git a/meta/recipes-graphics/xorg-lib/libxpm_3.5.19.bb b/meta/recipes-graphics/xorg-lib/libxpm_3.5.19.bb index 32e052fd42..9ba96b39a0 100644 --- a/meta/recipes-graphics/xorg-lib/libxpm_3.5.19.bb +++ b/meta/recipes-graphics/xorg-lib/libxpm_3.5.19.bb @@ -1,7 +1,7 @@ require xorg-lib-common.inc # libxpm requires xgettext to build -inherit gettext +inherit gettext ptest SUMMARY = "Xpm: X Pixmap extension library" @@ -13,15 +13,35 @@ protocol." LICENSE = "MIT" LIC_FILES_CHKSUM = "file://COPYING;md5=903942ebc9d807dfb68540f40bae5aff" DEPENDS += "libxext libsm libxt gettext-native" +DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'glib-2.0', '', d)}" PE = "1" XORG_PN = "libXpm" EXTRA_OECONF += "--disable-open-zfile" +EXTRA_OECONF += "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '--enable-unit-tests', '--disable-unit-tests', d)}" PACKAGES =+ "sxpm cxpm" FILES:cxpm = "${bindir}/cxpm" FILES:sxpm = "${bindir}/sxpm" +SRC_URI += " file://run-ptest" + SRC_URI[sha256sum] = "ad3576d689221a39dc728f0e0dc02ca7bb6a0d724c9a77fd1bfa1e9af83be900" +TEST_TARGETS = "XpmCreate XpmMisc XpmRead XpmWrite rgb" + +do_compile_ptest() { + oe_runmake -C ${B}/test ${TEST_TARGETS} +} + +do_install_ptest() { + for test_bin in ${TEST_TARGETS}; do + ${B}/libtool --mode=install install ${B}/test/${test_bin} ${D}${PTEST_PATH}/ + done + + cp -r ${S}/test/pixmaps ${D}${PTEST_PATH}/ + + install -m 0644 ${S}/test/rgb.txt ${D}${PTEST_PATH}/ +} + BBCLASSEXTEND = "native"
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#240853): https://lists.openembedded.org/g/openembedded-core/message/240853 Mute This Topic: https://lists.openembedded.org/mt/120254877/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
