Enable easier ptest of perl modules
cover Enable easier ptest of perl modules
We need run-time testing in order to ensure recipe quality and automating this is easiest with ptest.
* Add a new ptest-perl.bbclass which:
- copies tests that almost all perl modules will have in t/ to PTEST_PATH
- uses a common run-ptest script (from meta-perl recipes)
- runs install_ptest_perl task after install_ptest
= checks that run-ptest is not already present
For many perl recipes, using this class will be as simple as:
"inherit ptest-perl"
To run the tests, follow the ptest instructions in the dev-manual [1] and then run "ptest-runner libfoo-perl" on target.
Tested on qemux86 with all oe-core lib*-perl recipes with no failures.
[1] http://www.yoctoproject.org/docs/current/dev-manual/dev-manual.html#testing-packages-with-ptest
The following changes since commit 8e4ece7bf0b09275a34ce8e7cc3e1e54a366c361:
glibc: Enable static PIE support when security_flags are enabled (2018-03-01 22:18:00 +0000)
are available in the Git repository at:
git://git.openembedded.org/openembedded-core-contrib timo/ptest-perl
http://cgit.openembedded.org//log/?h=timo/ptest-perl
Tim Orling (7):
meta/classes: add ptest-perl.bbclass
libtest-needs-perl: add 0.002005
liberror-perl: inherit ptest-perl
liburi-perl: inherit ptest-perl
libxml-parser-perl: inherit ptest-perl
libxml-perl: inherit ptest-perl
libxml-simple-perl: inherit ptest-perl
meta/classes/ptest-perl.bbclass | 30 ++++++++++++++++++++++ meta/files/ptest-perl/run-ptest | 16 ++++++++++++ .../recipes-devtools/perl/liberror-perl_0.17025.bb | 7 ++++- .../perl/libtest-needs-perl_0.002005.bb | 29 +++++++++++++++++++++ meta/recipes-devtools/perl/liburi-perl_1.73.bb | 10 +++++++- .../perl/libxml-parser-perl_2.44.bb | 11 +++++++- meta/recipes-devtools/perl/libxml-perl_0.08.bb | 2 +- .../perl/libxml-simple-perl_2.24.bb | 2 +- 8 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 meta/classes/ptest-perl.bbclass create mode 100644 meta/files/ptest-perl/run-ptest create mode 100644 meta/recipes-devtools/perl/libtest-needs-perl_0.002005.bb
Signature · 1 line
2.14.3
PATCH 1/7 meta/classes: add ptest-perl.bbclass
* Enable easier testing of perl modules
- Installs t/* to PTEST_PATH
- Uses common run-ptest script
--- meta/classes/ptest-perl.bbclass | 30 ++++++++++++++++++++++++++++++ meta/files/ptest-perl/run-ptest | 16 ++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 meta/classes/ptest-perl.bbclass create mode 100644 meta/files/ptest-perl/run-ptest
meta/classes/ptest-perl.bbclass new file +30 -0
@@ -0,0 +1,30 @@ +inherit ptest + +FILESEXTRAPATHS_prepend := "${COREBASE}/meta/files:" + +SRC_URI += "file://ptest-perl/run-ptest" + +do_install_ptest_perl() { + install -d ${D}${PTEST_PATH} + if [ ! -f ${D}${PTEST_PATH}/run-ptest ]; then + install -m 0755 ${WORKDIR}/ptest-perl/run-ptest ${D}${PTEST_PATH} + fi + cp -r ${B}/t ${D}${PTEST_PATH} + chown -R root:root ${D}${PTEST_PATH} +} + +FILES_${PN}-ptest_prepend = "${PTEST_PATH}/t/* ${PTEST_PATH}/run-ptest " + +RDEPENDS_${PN}-ptest_prepend = "perl " + +addtask install_ptest_perl after do_install_ptest_base before do_package + +python () { + if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d): + d.setVarFlag('do_install_ptest_perl', 'fakeroot', '1') + + # Remove all '*ptest_perl' tasks when ptest is not enabled + if not(d.getVar('PTEST_ENABLED') == "1"): + for i in ['do_install_ptest_perl']: + bb.build.deltask(i, d) +}
meta/files/ptest-perl/run-ptest new file +16 -0
@@ -0,0 +1,16 @@ +#!/bin/sh + +for case in `find t -type f -name '*.t'`; do + perl $case >$case.output 2>&1 + ret=$? + cat $case.output + if [ $ret -ne 0 ]; then + echo "FAIL: ${case%.t}" + elif grep -i 'SKIP' $case.output; then + echo "SKIP: ${case%.t}" + else + echo "PASS: ${case%.t}" + fi + + rm -f $case.output +done
Signature · 1 line
2.14.3
PATCH 2/7 libtest-needs-perl: add 0.002005
In reply to Tim OrlingSkip tests when modules not available
* Dependency for ptest of liburi-perl
--- .../perl/libtest-needs-perl_0.002005.bb | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 meta/recipes-devtools/perl/libtest-needs-perl_0.002005.bb
meta/recipes-devtools/perl/libtest-needs-perl_0.002005.bb new file +29 -0
@@ -0,0 +1,29 @@ +SUMMARY = "Skip tests when modules not available" +DESCRIPTION = "Skip test scripts if modules are not available. \ +The requested modules will be loaded, and optionally have their versions \ +checked. If the module is missing, the test script will be skipped. Modules \ +that are found but fail to compile will exit with an error rather than skip." + +HOMEPAGE = "https://metacpan.org/release/Test-Needs" +SECTION = "libs" +LICENSE = "Artistic-1.0 | GPL-1.0+" + +CPAN_NAME = "Test-Needs" +CPAN_AUTHOR = "HAARG" + +LIC_FILES_CHKSUM = "file://README;md5=3f3ccd21a0a48aa313db212cc3b1bc09;beginline=81;endline=82" + +DEPENDS += "perl" + +SRC_URI = "http://www.cpan.org/authors/id/H/HA/${CPAN_AUTHOR}/${CPAN_NAME}-${PV}.tar.gz" + +SRC_URI[md5sum] = "356634a56c99282e8059f290f5d534c8" +SRC_URI[sha256sum] = "5a4f33983586edacdbe00a3b429a9834190140190dab28d0f873c394eb7df399" + +S = "${WORKDIR}/${CPAN_NAME}-${PV}" + +inherit cpan ptest-perl + +RDEPENDS_${PN}-ptest += "perl-module-test-more" + +BBCLASSEXTEND = "native"
Signature · 1 line
2.14.3
Re: [PATCH 2/7] libtest-needs-perl: add 0.002005
Quoted 11 lines · Tim Orling
Skip tests when modules not available
* Dependency for ptest of liburi-perl
Signed-off-by Tim Orling <[email protected]>---
.../perl/libtest-needs-perl_0.002005.bb | 29
++++++++++++++++++++++1 file changed, 29 insertions(+)create mode 100644 meta/recipes-devtools/perl/libtest-needs- perl_0.002005.bb
Can you send a patch to fix:
https://autobuilder.yocto.io/builders/nightly-oe-
selftest/builds/878/steps/Running%20oe-selftest/logs/stdio
i.e.
oe-selftest -r distrodata.Distrodata.test_maintainers
please? (missing maintainers entry for libtest-needs-perl)
Cheers,
Richard
Re: [PATCH 2/7] libtest-needs-perl: add 0.002005
Quoted 18 lines · Richard Purdie
Quoted 11 lines · Tim Orling
Skip tests when modules not available
* Dependency for ptest of liburi-perl
Signed-off-by Tim Orling <[email protected]>--- .../perl/libtest-needs-perl_0.002005.bb | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 meta/recipes-devtools/perl/libtest-needs-perl_0.002005.bb
Can you send a patch to fix:
Quoted 9 lines
https://autobuilder.yocto.io/builders/nightly-oe-
selftest/builds/878/steps/Running%20oe-selftest/logs/stdioi.e.
oe-selftest -r distrodata.Distrodata.test_maintainers
please? (missing maintainers entry for libtest-needs-perl)
That’s what I get for submitting at 5 am. Details. Yes, I will send a patch to self-assign libtest-needs-perl and take over maintainership of all the libfoo-perl in oe-core (if there are no objections).
Quoted 8 lines
Cheers,
Richard
PATCH 3/7 liberror-perl: inherit ptest-perl
In reply to Tim Orling* Enable ptest by inheriting new ptest-perl.bbclass
--- meta/recipes-devtools/perl/liberror-perl_0.17025.bb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
meta/recipes-devtools/perl/liberror-perl_0.17025.bb +6 -1
@@ -18,11 +18,16 @@ SRC_URI[sha256sum] = "6c9f474ad3d4fe0cabff6b6be532cb1dd348245986d4a6b600ad921d5c S = "${WORKDIR}/Error-${PV}" -inherit cpan +inherit cpan ptest-perl do_compile() { export LIBC="$(find ${STAGING_DIR_TARGET}/${base_libdir}/ -name 'libc-*.so')" cpan_do_compile } +do_install_prepend() { + # test requires "-T" (taint) command line option + rm -rf ${B}/t/pod-coverage.t +} + BBCLASSEXTEND = "native"
Signature · 1 line
2.14.3
PATCH 4/7 liburi-perl: inherit ptest-perl
In reply to Tim Orling* Enable ptest by inheriting new ptest-perl.bbclass
* Remove t/cwd.t and t/file.t which require "-T" (taint) command line option as they will fail.
--- meta/recipes-devtools/perl/liburi-perl_1.73.bb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
meta/recipes-devtools/perl/liburi-perl_1.73.bb +9 -1
@@ -20,11 +20,19 @@ S = "${WORKDIR}/URI-${PV}" EXTRA_CPANFLAGS = "EXPATLIBPATH=${STAGING_LIBDIR} EXPATINCPATH=${STAGING_INCDIR}" -inherit cpan +inherit cpan ptest-perl do_compile() { export LIBC="$(find ${STAGING_DIR_TARGET}/${base_libdir}/ -name 'libc-*.so')" cpan_do_compile } +do_install_prepend() { + # these tests require "-T" (taint) command line option + rm -rf ${B}/t/cwd.t + rm -rf ${B}/t/file.t +} + +RDEPENDS_${PN}-ptest += "libtest-needs-perl" + BBCLASSEXTEND = "native"
Signature · 1 line
2.14.3
PATCH 5/7 libxml-parser-perl: inherit ptest-perl
In reply to Tim Orling* Enable ptest by inheriting new ptest-perl.bbclass
--- meta/recipes-devtools/perl/libxml-parser-perl_2.44.bb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
meta/recipes-devtools/perl/libxml-parser-perl_2.44.bb +10 -1
@@ -14,7 +14,7 @@ S = "${WORKDIR}/XML-Parser-${PV}" EXTRA_CPANFLAGS = "EXPATLIBPATH=${STAGING_LIBDIR} EXPATINCPATH=${STAGING_INCDIR} CC='${CC}' LD='${CCLD}' FULL_AR='${AR}'" -inherit cpan +inherit cpan ptest-perl # fix up sub MakeMaker project as arguments don't get propagated though # see https://rt.cpan.org/Public/Bug/Display.html?id=28632
@@ -34,4 +34,13 @@ do_compile_class-native() { cpan_do_compile } +do_install_ptest() { + sed -i -e "s:/usr/local/bin/perl:/usr/bin/perl:g" ${B}/samples/xmlstats + sed -i -e "s:/usr/local/bin/perl:/usr/bin/perl:g" ${B}/samples/xmlfilter + sed -i -e "s:/usr/local/bin/perl:/usr/bin/perl:g" ${B}/samples/xmlcomments + sed -i -e "s:/usr/local/bin/perl:/usr/bin/perl:g" ${B}/samples/canonical + cp -r ${B}/samples ${D}${PTEST_PATH} + chown -R root:root ${D}${PTEST_PATH}/samples +} + BBCLASSEXTEND="native nativesdk"
Signature · 1 line
2.14.3
PATCH 6/7 libxml-perl: inherit ptest-perl
In reply to Tim Orling* Enable ptest by inheriting new ptest-perl.bbclass
--- meta/recipes-devtools/perl/libxml-perl_0.08.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/perl/libxml-perl_0.08.bb +1 -1
@@ -19,7 +19,7 @@ SRC_URI[sha256sum] = "4571059b7b5d48b7ce52b01389e95d798bf5cf2020523c153ff27b4981 EXTRA_CPANFLAGS = "EXPATLIBPATH=${STAGING_LIBDIR} EXPATINCPATH=${STAGING_INCDIR}" -inherit cpan +inherit cpan ptest-perl do_compile() { export LIBC="$(find ${STAGING_DIR_TARGET}/${base_libdir}/ -name 'libc-*.so')"
Signature · 1 line
2.14.3
PATCH 7/7 libxml-simple-perl: inherit ptest-perl
In reply to Tim Orling* Enable ptest by inheriting new ptest-perl.bbclass
--- meta/recipes-devtools/perl/libxml-simple-perl_2.24.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/perl/libxml-simple-perl_2.24.bb +1 -1
@@ -19,6 +19,6 @@ S = "${WORKDIR}/XML-Simple-${PV}" EXTRA_PERLFLAGS = "-I ${PERLHOSTLIB}" -inherit cpan +inherit cpan ptest-perl BBCLASSEXTEND = "native"
Signature · 1 line
2.14.3