diff mbox series

[V1] kbd: Add ptest support

Message ID 1684136158-5950-1-git-send-email-qiutt@fujitsu.com
State New
Headers show
Series [V1] kbd: Add ptest support | expand

Commit Message

qiutt@fujitsu.com May 15, 2023, 7:35 a.m. UTC
From: Qiu Tingting <qiutt@fujitsu.com>

Add a ptest for kbd
- It is taking around 1s to execute with kvm, so added it to PTESTS_FAST
- It contains libkeymap unit tests(27 cases) and libkbdfile unit tests(13 cases)

Signed-off-by: Qiu Tingting <qiutt@fujitsu.com>
---
 meta/recipes-core/kbd/files/run-ptest | 18 +++++++
 meta/recipes-core/kbd/kbd_2.5.1.bb    | 72 ++++++++++++++++++++++++++-
 2 files changed, 89 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-core/kbd/files/run-ptest

Comments

Ross Burton May 15, 2023, 9:42 a.m. UTC | #1
On 15 May 2023, at 08:35, qiutt@fujitsu.com via lists.openembedded.org <qiutt=fujitsu.com@lists.openembedded.org> wrote:
> +# create atconfig
> +if [[ ! -f "atconfig" ]]; then
> +    echo 'abs_builddir="@PTEST_PATH@/tests/"' > atconfig
> +    echo 'abs_srcdir="@PTEST_PATH@/tests/"' >> atconfig
> +    echo 'abs_top_builddir="@PTEST_PATH@/"' >> atconfig
> +fi

You can generate this file when the package is built, surely.

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

Did you try to port the test suite away from bash?

Ross
qiutt@fujitsu.com May 16, 2023, 4:11 a.m. UTC | #2
Hiļ¼ŒRoss

> 
> 
>> +# create atconfig
>> +if [[ ! -f "atconfig" ]]; then
>> + echo 'abs_builddir="@PTEST_PATH@/tests/"' > atconfig
>> + echo 'abs_srcdir="@PTEST_PATH@/tests/"' >> atconfig
>> + echo 'abs_top_builddir="@PTEST_PATH@/"' >> atconfig
>> +fi
> 
> You can generate this file when the package is built, surely.
> 

When the package is built, this file is created, but the directory is not PTEST_PATH.
So, I create a new file for ptest.
Of course, there is no problem using the built file.
I will try to modify this patch.

> 
> 
>> +RDEPENDS:${PN}-ptest += "bash"
> 
> Did you try to port the test suite away from bash?

No, I didn't.
I will try to delete it.
qiutt@fujitsu.com May 18, 2023, 1:49 a.m. UTC | #3
Hi, Ross

Please review "[PATCH V2] kbd: Add ptest support".
Thanks.

Best regards,
Qiu Tingting
diff mbox series

Patch

diff --git a/meta/recipes-core/kbd/files/run-ptest b/meta/recipes-core/kbd/files/run-ptest
new file mode 100644
index 0000000000..cace13b8cb
--- /dev/null
+++ b/meta/recipes-core/kbd/files/run-ptest
@@ -0,0 +1,18 @@ 
+#!/bin/sh
+
+# Define test work dir
+WORKDIR=@PTEST_PATH@/tests/
+
+# Run test
+cd ${WORKDIR}
+
+# create atconfig
+if [[ ! -f "atconfig" ]]; then
+    echo 'abs_builddir="@PTEST_PATH@/tests/"' > atconfig
+    echo 'abs_srcdir="@PTEST_PATH@/tests/"' >> atconfig
+    echo 'abs_top_builddir="@PTEST_PATH@/"' >> atconfig
+fi
+
+./testsuite -k unittest | sed -e '/[0-9]:/s/://' \
+    -e '/ ok/s/^/PASS: /;/ FAILED/s/^/FAIL: /;/ skipped/s/^/SKIP: /' \
+    -e '/ ok/s/ ok.*//;/ skipped/s/ skipped.*//;/ FAILED/s/ FAILED.*//'
diff --git a/meta/recipes-core/kbd/kbd_2.5.1.bb b/meta/recipes-core/kbd/kbd_2.5.1.bb
index 7662b8f685..bed1ad7240 100644
--- a/meta/recipes-core/kbd/kbd_2.5.1.bb
+++ b/meta/recipes-core/kbd/kbd_2.5.1.bb
@@ -5,7 +5,7 @@  DESCRIPTION = "The kbd project contains tools for managing Linux console (Linux
 LICENSE = "GPL-2.0-or-later"
 LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
 
-inherit autotools gettext pkgconfig
+inherit autotools gettext pkgconfig ptest
 
 DEPENDS += "flex-native"
 
@@ -14,6 +14,7 @@  RPROVIDES:${PN} = "console-tools"
 RCONFLICTS:${PN} = "console-tools"
 
 SRC_URI = "${KERNELORG_MIRROR}/linux/utils/${BPN}/${BP}.tar.xz \
+           file://run-ptest \
            "
 
 SRC_URI[sha256sum] = "ccdf452387a6380973d2927363e9cbb939fa2068915a6f937ff9d24522024683"
@@ -45,3 +46,72 @@  ALTERNATIVE:${PN} = "chvt deallocvt fgconsole openvt showkey \
 ALTERNATIVE_PRIORITY = "100"
 
 BBCLASSEXTEND = "native"
+
+
+RDEPENDS:${PN}-ptest += "bash"
+
+do_compile_ptest() {
+    # update DATADIR in Makefile
+    sed -i 's,-DDATADIR=.*,-DDATADIR=\\\"${PTEST_PATH}/tests\\\" \\,g' ${B}/tests/libkeymap/Makefile
+    sed -i 's,-DDATADIR=.*,-DDATADIR=\\\"${PTEST_PATH}/tests\\\" \\,g' ${B}/tests/helpers/Makefile
+    sed -i 's,-DDATADIR=.*,-DDATADIR=\\\"${PTEST_PATH}/tests\\\" \\,g' ${B}/tests/libkbdfile/Makefile
+
+    # recompile tests
+    oe_runmake -C ${B}/tests/ clean
+    oe_runmake -C ${B}/tests/
+}
+
+do_install_ptest() {
+    # install files from build directory
+    install -d ${D}${PTEST_PATH}/tests/
+    install --mode=755 ${B}/tests/testsuite ${D}${PTEST_PATH}/tests/
+    install -d ${D}${PTEST_PATH}/tests/libkeymap/
+    find ${B}/tests/libkeymap/ -type f -not -name "*.o" -not -name "Makefile" \
+        -exec install --mode=755 {} ${D}${PTEST_PATH}/tests/libkeymap/ \;
+    install -d ${D}${PTEST_PATH}/tests/helpers/
+    find ${B}/tests/helpers/ -type f -not -name "*.o" -not -name "Makefile" \
+        -exec install --mode=755 {} ${D}${PTEST_PATH}/tests/helpers/ \;
+    install -d ${D}${PTEST_PATH}/tests/libkbdfile/
+    find ${B}/tests/libkbdfile/ -type f -not -name "*.o" -not -name "Makefile" \
+        -exec install --mode=755 {} ${D}${PTEST_PATH}/tests/libkbdfile/ \;
+    install -d ${D}${PTEST_PATH}/src/
+    install --mode=755 ${B}/src/loadkeys ${D}${PTEST_PATH}/src/
+
+    # install files from src/data directory
+    install -d ${D}${PTEST_PATH}/data/keymaps/i386/qwerty/
+    install ${S}/data/keymaps/i386/qwerty/defkeymap.map ${D}${PTEST_PATH}/data/keymaps/i386/qwerty/
+
+    # install files from src/tests/data directory
+    install -d ${D}${PTEST_PATH}/tests/data/
+    install -d ${D}${PTEST_PATH}/tests/data/libkeymap/
+    install ${S}/tests/data/libkeymap/* ${D}${PTEST_PATH}/tests/data/libkeymap/
+    install -d ${D}${PTEST_PATH}/tests/data/alt-is-meta/
+    install ${S}/tests/data/alt-is-meta/* ${D}${PTEST_PATH}/tests/data/alt-is-meta/
+    install -d ${D}${PTEST_PATH}/tests/data/bkeymap-2.0.4/
+    install ${S}/tests/data/bkeymap-2.0.4/* ${D}${PTEST_PATH}/tests/data/bkeymap-2.0.4/
+    install -d ${D}${PTEST_PATH}/tests/data/dumpkeys-mktable/
+    install ${S}/tests/data/dumpkeys-mktable/* ${D}${PTEST_PATH}/tests/data/dumpkeys-mktable/
+    install -d ${D}${PTEST_PATH}/tests/data/dumpkeys-fulltable/
+    install ${S}/tests/data/dumpkeys-fulltable/* ${D}${PTEST_PATH}/tests/data/dumpkeys-fulltable/
+    install -d ${D}${PTEST_PATH}/tests/data/findfile/test_1/consolefonts/
+    install ${S}/tests/data/findfile/test_1/consolefonts/* ${D}${PTEST_PATH}/tests/data/findfile/test_1/consolefonts/
+    install -d ${D}${PTEST_PATH}/tests/data/findfile/test_0/keymaps/include/
+    install ${S}/tests/data/findfile/test_0/keymaps/test0.map ${D}${PTEST_PATH}/tests/data/findfile/test_0/keymaps/
+    install ${S}/tests/data/findfile/test_0/keymaps/include/* ${D}${PTEST_PATH}/tests/data/findfile/test_0/keymaps/include/
+    install -d ${D}${PTEST_PATH}/tests/data/findfile/test_0/keymaps/i386/include/
+    install ${S}/tests/data/findfile/test_0/keymaps/i386/include/* ${D}${PTEST_PATH}/tests/data/findfile/test_0/keymaps/i386/include/
+    install -d ${D}${PTEST_PATH}/tests/data/findfile/test_0/keymaps/i386/qwerty/
+    install ${S}/tests/data/findfile/test_0/keymaps/i386/qwerty/* ${D}${PTEST_PATH}/tests/data/findfile/test_0/keymaps/i386/qwerty/
+    install -d ${D}${PTEST_PATH}/tests/data/findfile/test_0/keymaps/i386/qwertz/
+    install ${S}/tests/data/findfile/test_0/keymaps/i386/qwertz/* ${D}${PTEST_PATH}/tests/data/findfile/test_0/keymaps/i386/qwertz/
+    install -d ${D}${PTEST_PATH}/tests/data/keymaps/i386/qwerty/
+    install ${S}/tests/data/keymaps/i386/qwerty/* ${D}${PTEST_PATH}/tests/data/keymaps/i386/qwerty/
+    install -d ${D}${PTEST_PATH}/tests/data/keymaps/i386/include/
+    install ${S}/tests/data/keymaps/i386/include/* ${D}${PTEST_PATH}/tests/data/keymaps/i386/include/
+    install -d ${D}${PTEST_PATH}/tests/data/keymaps/include/
+    install ${S}/tests/data/keymaps/include/* ${D}${PTEST_PATH}/tests/data/keymaps/include/
+
+
+    # update PTEST_PATH in run-ptest
+    sed -i "s#@PTEST_PATH@#${PTEST_PATH}#g" ${D}${PTEST_PATH}/run-ptest
+}