diff mbox series

jq: add ptest

Message ID 20220915151146.29844-1-zheng.qiu@windriver.com
State New
Headers show
Series jq: add ptest | expand

Commit Message

Zheng Qiu Sept. 15, 2022, 3:11 p.m. UTC
Add run-ptest to explicitly call 7 tests provided by jq.
In run-ptest, add a soft link to jq in ptest directory to avoid to
having patch the jq setup script, then remove the soft link before
exiting.

Signed-off-by: Zheng Qiu <zheng.qiu@windriver.com>
Signed-off-by: Randy MacLeod <randy.macleod@windriver.com>
---
 meta-oe/recipes-devtools/jq/jq/run-ptest | 48 ++++++++++++++++++++++++
 meta-oe/recipes-devtools/jq/jq_git.bb    | 12 +++++-
 2 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-devtools/jq/jq/run-ptest

Comments

Ross Burton Sept. 15, 2022, 4:44 p.m. UTC | #1
On 15 Sep 2022, at 16:11, Qiu, Zheng via lists.openembedded.org <Zheng.Qiu=windriver.com@lists.openembedded.org> wrote:
> +cd /usr/lib/jq/ptest

Typically ptests assume they’ve been cd’d into here already.  Also, if libdir is changed, this path is wrong.

> +ln -sf /usr/bin/jq .

Much easier to just ship this symlink instead of generating it.

> +./tests/optionaltest
> +if [ $? -eq 0 ]; then
> +  echo 'PASS: optionaltest'
> +else
> +  echo 'FAIL: optionaltest'
> +fi

Do this as a loop to avoid repeating the same script.

> +RDEPENDS:${PN}-ptest += " valgrind"

Not sure this is useful for us: we want t to use ptest for integration testing, not development regression testing.

> +do_install_ptest() {
> +    cp -rf ${B}/tests ${D}${PTEST_PATH}
> +    cp -rf ${B}/.libs ${D}${PTEST_PATH}
> +    # libjq.so.* is packaged in the main jq component, so remove it from ptest
> +    rm -f ${D}${PTEST_PATH}/.libs/libjq.so.*
> +}

You’ll find it easier to patch the makefile to install the binaries. instead of assuming knowledge of how libtool has built the binaries.  If you’re lucky, upstream will take a patch to add an install-the-tests option.

Ross
Zheng Qiu Sept. 15, 2022, 8:04 p.m. UTC | #2
On 15 Sep 2022, at 12:45, Ross Burton via lists.openembedded.org wrote:
>On 15 Sep 2022, at 16:11, Qiu, Zheng via lists.openembedded.org <Zheng.Qiu=windriver.com@lists.openembedded.org> wrote:
>> +cd /usr/lib/jq/ptest
>
>Typically ptests assume they’ve been cd’d into here already.  Also, if libdir is changed, this path is wrong.

OK.

>
>> +ln -sf /usr/bin/jq .
>
>Much easier to just ship this symlink instead of generating it.

Seems sensible.

>
>> +./tests/optionaltest
>> +if [ $? -eq 0 ]; then
>> +  echo 'PASS: optionaltest'
>> +else
>> +  echo 'FAIL: optionaltest'
>> +fi
>
>Do this as a loop to avoid repeating the same script.

Sure.

>
>> +RDEPENDS:${PN}-ptest += " valgrind"
>
>Not sure this is useful for us: we want t to use ptest for integration testing, not development regression testing.

That seems to be true in general since there are few ptest that are depend on valgrind.
Randy and I talked about this, and in the case of running ptest after running fixing CVEs, valgrind could be useful.
Perhaps we should introduce a new DISTRO_FEATURES that enables valgrind and other memory check tools.
For now I will drop the valgrind dependency and I confirmed all tests still pass and still do useful checks.

We created an enhancement request, to track the idea:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=14914

>
>> +do_install_ptest() {
>> +    cp -rf ${B}/tests ${D}${PTEST_PATH}
>> +    cp -rf ${B}/.libs ${D}${PTEST_PATH}
>> +    # libjq.so.* is packaged in the main jq component, so remove it from ptest
>> +    rm -f ${D}${PTEST_PATH}/.libs/libjq.so.*
>> +}
>
>You’ll find it easier to patch the makefile to install the binaries. instead of assuming knowledge of how libtool 
> has built the binaries.  If you’re lucky, upstream will take a patch to add an install-the-tests option.

True, but this is my first commit and what we have works. ;-)

I've looked at what I think is a good example of what you are talking about: 
recipes-support/xmlsec1/xmlsec1_1.2.34.bb
do_install_ptest () {
    oe_runmake -C ${S}/examples DESTDIR=${D}${PTEST_PATH} ${PTEST_EXTRA_ARGS} install-ptest
}
Randy and I will commit to working on this as a follow up patch, since meta-oe doesn't have a bug tracker.

>
>Ross
>
>
diff mbox series

Patch

diff --git a/meta-oe/recipes-devtools/jq/jq/run-ptest b/meta-oe/recipes-devtools/jq/jq/run-ptest
new file mode 100644
index 000000000..791179936
--- /dev/null
+++ b/meta-oe/recipes-devtools/jq/jq/run-ptest
@@ -0,0 +1,48 @@ 
+#!/bin/sh
+
+cd /usr/lib/jq/ptest
+ln -sf /usr/bin/jq .
+./tests/optionaltest
+if [ $? -eq 0 ]; then
+  echo 'PASS: optionaltest'
+else
+  echo 'FAIL: optionaltest'
+fi
+./tests/mantest
+if [ $? -eq 0 ]; then
+  echo 'PASS: mantest'
+else
+  echo 'FAIL: mantest'
+fi
+./tests/jqtest
+if [ $? -eq 0 ]; then
+  echo 'PASS: jqtest'
+else
+  echo 'FAIL: jqtest'
+fi
+./tests/onigtest
+if [ $? -eq 0 ]; then
+  echo 'PASS: onigtest'
+else
+  echo 'FAIL: onigtest'
+fi
+./tests/shtest
+if [ $? -eq 0 ]; then
+  echo 'PASS: shtest'
+else
+  echo 'FAIL: shtest'
+fi
+./tests/utf8test
+if [ $? -eq 0 ]; then
+  echo 'PASS: utf8test'
+else
+  echo 'FAIL: utf8test'
+fi
+./tests/base64test
+if [ $? -eq 0 ]; then
+  echo 'PASS: base64test'
+else
+  echo 'FAIL: base64test'
+fi
+
+rm /usr/lib/jq/ptest/jq
diff --git a/meta-oe/recipes-devtools/jq/jq_git.bb b/meta-oe/recipes-devtools/jq/jq_git.bb
index f69b435e5..3e4f60348 100644
--- a/meta-oe/recipes-devtools/jq/jq_git.bb
+++ b/meta-oe/recipes-devtools/jq/jq_git.bb
@@ -12,11 +12,12 @@  PV = "1.6+git${SRCPV}"
 SRC_URI = "git://github.com/stedolan/jq;protocol=https;branch=master \
     file://0001-configure-Pass-_XOPEN_SOURCE-when-checking-for-strpt.patch \
     file://0002-builtin-Replace-_BSD_SOURCE-with-_DEFAULT_SOURCE.patch \
+    file://run-ptest \
     "
 SRCREV = "cff5336ec71b6fee396a95bb0e4bea365e0cd1e8"
 S = "${WORKDIR}/git"
 
-inherit autotools-brokensep
+inherit autotools-brokensep ptest
 
 PACKAGECONFIG ?= "oniguruma"
 
@@ -27,5 +28,14 @@  PACKAGECONFIG[oniguruma] = "--with-oniguruma,--without-oniguruma,onig"
 EXTRA_OECONF += " \
     --disable-valgrind \
 "
+RDEPENDS:${PN}-ptest += " valgrind"
+
+do_install_ptest() {
+    cp -rf ${B}/tests ${D}${PTEST_PATH}
+    cp -rf ${B}/.libs ${D}${PTEST_PATH}
+    # libjq.so.* is packaged in the main jq component, so remove it from ptest
+    rm -f ${D}${PTEST_PATH}/.libs/libjq.so.*
+}
+
 
 BBCLASSEXTEND = "native"