diff mbox series

[meta-oe,V3] xz: add ptest support

Message ID 1686189704-12596-1-git-send-email-duep.fnst@fujitsu.com
State New
Headers show
Series [meta-oe,V3] xz: add ptest support | expand

Commit Message

Erpei Du (Fujitsu) June 8, 2023, 2:01 a.m. UTC
From: duep <duep.fnst@fujitsu.com>

Add a ptest for xz
 - It is taking around 1s to execute with kvm, so added it to PTESTS_FAST
 - It contains 11 test files:
    test_bcj_exact_size test_block_header test_check test_filter_flags
    test_hardware test_index test_index_hash test_lzip_decoder
    test_memlimit test_stream_flags test_vli
 - Below is part of the run log:
    START: ptest-runner
    2023-06-01T01:57
    BEGIN:
    /usr/lib/xz/ptest
    === test_bcj_exact_size.c ===
    PASS: test_exact_size
    PASS: test_empty_block
    ---
    # TOTAL: 2
    # PASS:  2
    # SKIP:  0
    # FAIL:  0
    # ERROR: 0
    === END ===
    ...
    === test_vli.c ===
    PASS: test_lzma_vli_size
    PASS: test_lzma_vli_encode
    PASS: test_lzma_vli_decode
    ---
    # TOTAL: 3
    # PASS:  3
    # SKIP:  0
    # FAIL:  0
    # ERROR: 0
    === END ===
    DURATION: 0
    END: /usr/lib/xz/ptest
    2023-06-01T01:57
    STOP: ptest-runner
    TOTAL: 1 FAIL: 0
 - The tests under xz requires /bin/bash

Signed-off-by: duep <duep.fnst@fujitsu.com>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 meta/recipes-extended/xz/xz/run-ptest         |  5 ++++
 meta/recipes-extended/xz/xz_5.4.1.bb          | 23 +++++++++++++++++--
 3 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-extended/xz/xz/run-ptest
diff mbox series

Patch

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index d60ebb38fc..9aa68c75ea 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -70,6 +70,7 @@  PTESTS_FAST = "\
     sed \
     slang \
     wayland \
+    xz \
     zlib \
 "
 PTESTS_FAST:append:libc-glibc = " glibc-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..ebde965d5c
--- /dev/null
+++ b/meta/recipes-extended/xz/xz/run-ptest
@@ -0,0 +1,5 @@ 
+#!/bin/sh
+cd ./tests
+for i in `ls test*`; do
+	./$i
+done
diff --git a/meta/recipes-extended/xz/xz_5.4.1.bb b/meta/recipes-extended/xz/xz_5.4.1.bb
index 71bf4b540a..81fb3dc4c7 100644
--- a/meta/recipes-extended/xz/xz_5.4.1.bb
+++ b/meta/recipes-extended/xz/xz_5.4.1.bb
@@ -24,13 +24,14 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=97d554a32881fee0aa283d96e47cb24a \
                     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 \
+           file://run-ptest"
 SRC_URI[sha256sum] = "e4b0f81582efa155ccf27bb88275254a429d44968e488fc94b806f2a61cd3e22"
 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 +43,21 @@  ALTERNATIVE:${PN} = "xz xzcat unxz \
                      lzma lzcat unlzma"
 
 BBCLASSEXTEND = "native nativesdk"
+
+do_compile_ptest(){
+	oe_runmake -C ${B}/tests/ check TESTS=
+}
+
+do_install_ptest(){
+	install -d ${D}${PTEST_PATH}/tests/
+	find ${B}/tests/ -type f -not -name "*.o" -not -name "Makefile" \
+	  -exec install --mode=755 {} ${D}${PTEST_PATH}/tests/ \;
+
+	install -d ${D}${PTEST_PATH}/tests/.libs/
+	install --mode=755 ${B}/tests/.libs/* ${D}${PTEST_PATH}/tests/.libs/
+
+	install -d ${D}${PTEST_PATH}/tests/files/
+	install --mode=755 ${S}/tests/files/* ${D}${PTEST_PATH}/tests/files/
+}
+
+RDEPENDS:${PN}-ptest += "bash"