diff mbox series

xz: Add ptest support

Message ID 20240123080918.3391325-1-chi.xu@windriver.com
State Superseded, archived
Headers show
Series xz: Add ptest support | expand

Commit Message

Xu, Chi Jan. 23, 2024, 8:09 a.m. UTC
72 test cases in all and all test cases PASS.
Test results on qemux86-64:
root@qemux86-64:~# ptest-runner xz
START: ptest-runner
2024-01-23T07:37
BEGIN: /usr/lib/xz/ptest
=== test_block_header.c ===
PASS: test_lzma_block_header_size
PASS: test_lzma_block_header_encode
PASS: test_lzma_block_header_decode
---
=== END ===
PASS: create_compress_files
=== test_hardware.c ===
PASS: test_lzma_physmem
PASS: test_lzma_cputhreads
---
=== END ===
...
...
=== test_bcj_exact_size.c ===
PASS: test_exact_size
PASS: test_empty_block
---
=== END ===
DURATION: 1
END: /usr/lib/xz/ptest
2024-01-23T07:37
STOP: ptest-runner
TOTAL: 1 FAIL: 0

Signed-off-by: Xu, Chi <chi.xu@windriver.com>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 meta/recipes-extended/xz/xz/run-ptest         | 20 +++++++++++++++++++
 meta/recipes-extended/xz/xz_5.4.5.bb          | 18 +++++++++++++++--
 3 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-extended/xz/xz/run-ptest

Comments

Alexander Kanavin Jan. 23, 2024, 9:43 a.m. UTC | #1
On Tue, 23 Jan 2024 at 09:21, Chi Xu <chi.xu@eng.windriver.com> wrote:
> +tests=`find . -type f -executable | sed 's/\.\///g'`
> +
> +for i in ${tests}; do
> +    if [ $i == "create_compress_files" ]; then
> +        ./$i
> +        if [ $? -eq 0 ]; then
> +            echo "PASS: $i"
> +        else
> +            echo "FAIL: $i"
> +        fi
> +    else
> +        ./$i
> +    fi

This should be investigated a bit more. Why does create_compress_files
need to be special cased and other tests do not?

Alex
Xu, Chi Jan. 24, 2024, 1:38 a.m. UTC | #2
There are two types of cases in xz pkg: executables and POSIX shell scripts.
I only integrated executables in V1 patch.
There are two script cases "test_compress.sh" and "test_scripts.sh", create_compress_files is a test tool which will be called by "test_compress.sh". 
I will install both types of case and send V2.

Thanks,
Chi

> -----Original Message-----
> From: Alexander Kanavin <alex.kanavin@gmail.com>
> Sent: Tuesday, January 23, 2024 5:43 PM
> To: Xu, Chi <Chi.Xu@windriver.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH] xz: Add ptest support
> 
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and
> know the content is safe.
> 
> On Tue, 23 Jan 2024 at 09:21, Chi Xu <chi.xu@eng.windriver.com> wrote:
> > +tests=`find . -type f -executable | sed 's/\.\///g'`
> > +
> > +for i in ${tests}; do
> > +    if [ $i == "create_compress_files" ]; then
> > +        ./$i
> > +        if [ $? -eq 0 ]; then
> > +            echo "PASS: $i"
> > +        else
> > +            echo "FAIL: $i"
> > +        fi
> > +    else
> > +        ./$i
> > +    fi
> 
> This should be investigated a bit more. Why does create_compress_files need
> to be special cased and other tests do not?
> 
> Alex
diff mbox series

Patch

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index ef6f471e7b..21b84d311a 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -78,6 +78,7 @@  PTESTS_FAST = "\
     slang \
     wayland \
     zlib \
+    xz \
     libexif \
 "
 PTESTS_FAST:append:libc-glibc = " glibc-y2038-tests"
diff --git a/meta/recipes-extended/xz/xz/run-ptest b/meta/recipes-extended/xz/xz/run-ptest
new file mode 100644
index 0000000000..64aaf38638
--- /dev/null
+++ b/meta/recipes-extended/xz/xz/run-ptest
@@ -0,0 +1,20 @@ 
+#!/bin/bash
+
+ptestdir=$(dirname "$(readlink -f "$0")")
+cd "$ptestdir"/tests || exit
+
+tests=`find . -type f -executable | sed 's/\.\///g'`
+
+for i in ${tests}; do
+    if [ $i == "create_compress_files" ]; then
+        ./$i
+        if [ $? -eq 0 ]; then
+            echo "PASS: $i"
+        else
+            echo "FAIL: $i"
+        fi
+    else
+        ./$i
+    fi
+done
+
diff --git a/meta/recipes-extended/xz/xz_5.4.5.bb b/meta/recipes-extended/xz/xz_5.4.5.bb
index 09eade8be0..e7a873af96 100644
--- a/meta/recipes-extended/xz/xz_5.4.5.bb
+++ b/meta/recipes-extended/xz/xz_5.4.5.bb
@@ -24,13 +24,15 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=c8ea84ebe7b93cce676b54355dc6b2c0 \
                     file://lib/getopt.c;endline=23;md5=2069b0ee710572c03bb3114e4532cd84 \
                     "
 
-SRC_URI = "https://tukaani.org/xz/xz-${PV}.tar.gz"
+SRC_URI = "https://tukaani.org/xz/xz-${PV}.tar.gz \
+           ${@bb.utils.contains('PTEST_ENABLED', '1', 'file://run-ptest', '', d)} \
+          "
 SRC_URI[sha256sum] = "135c90b934aee8fbc0d467de87a05cb70d627da36abe518c357a873709e5b7d6"
 UPSTREAM_CHECK_REGEX = "xz-(?P<pver>\d+(\.\d+)+)\.tar"
 
 CACHED_CONFIGUREVARS += "gl_cv_posix_shell=/bin/sh"
 
-inherit autotools gettext
+inherit autotools gettext ptest
 
 PACKAGES =+ "liblzma"
 
@@ -42,3 +44,15 @@  ALTERNATIVE:${PN} = "xz xzcat unxz \
                      lzma lzcat unlzma"
 
 BBCLASSEXTEND = "native nativesdk"
+
+RDEPENDS:${PN}-ptest += "bash"
+
+do_compile_ptest() {
+        oe_runmake check TESTS=
+}
+
+do_install_ptest () {
+        install -d ${D}/${PTEST_PATH}/tests
+        find ${B}/tests/.libs -type f -executable -exec cp {} ${D}${PTEST_PATH}/tests \;
+        cp -r ${S}/tests/files ${D}${PTEST_PATH}/tests
+}