kbd:Add ptest support
PATCH v5 1/1 kbd:Add ptest support
From: Qiu Tingting <[email protected]>
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)
- Below is parts of the run log:
START: ptest-runner
2023-10-10T06:30
BEGIN: /usr/lib/kbd/ptest
## --------------------- ##
## kbd 2.6.3 test suite. ##
## --------------------- ##
libkeymap unit tests
PASS: test 01
PASS: test 02
...
libkbdfile unit tests
PASS: test 01
PASS: test 02
...
36 tests were successful.
4 tests were skipped.
DURATION: 1
END: /usr/lib/kbd/ptest
2023-10-10T06:30
STOP: ptest-runner
TOTAL: 1 FAIL: 0
--- .../distro/include/ptest-packagelists.inc | 1 + meta/recipes-core/kbd/kbd/run-ptest | 10 ++++ meta/recipes-core/kbd/kbd_2.6.3.bb | 46 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 meta/recipes-core/kbd/kbd/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -27,6 +27,7 @@ PTESTS_FAST = "\ gzip \ json-c \ json-glib \ + kbd \ libconvert-asn1-perl \ liberror-perl \ libgpg-error\
meta/recipes-core/kbd/kbd/run-ptest new file +10 -0
@@ -0,0 +1,10 @@ +#!/bin/sh + +# Define test work dir +WORKDIR=@PTEST_PATH@/tests/ + +# Run test +cd ${WORKDIR} +./atconfig ./testsuite +./testsuite -c +./testsuite --am-fmt -k unittest
meta/recipes-core/kbd/kbd_2.6.3.bb +46 -0
52 lines not on this page · raw message
Signature · 1 line
2.25.1
meta/recipes-core/kbd/kbd_2.6.3.bb do_install:append () { · line 57
Quoted 10 lines · On Mon, 23 Oct 2023 at 04:53, [email protected] <[email protected]> wrote:
meta/recipes-core/kbd/kbd_2.6.3.bb +10
-0+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/ +}
I'd like to better understand why DATADIR needs to be reset at build time, with this not-that-elegant bit of code (particularly make clean should really be avoided). Can you show where and how DATADIR is used? Can we set it at runtime, for example via environment variable?
Alex
Hi, Alex
As you said, it is not-that-elegant bit of code.
But DATADIR is used as a part of CPPFLAGS for compiling c files in tests, such as libkeymap/libkeymap-test01.c, libkbdfile/libkbdfile-test13.c and others. sample:
Quoted 4 lines
libkeymap/libkeymap-test01.c: f =fopen( *DATADIR* "/data/libkeymap/charset-keymap0.map", "r"); libkeymap/libkeymap-test09.c: setenv("LOADKEYS_INCLUDE_PATH", DATADIR "/data/libkeymap", 1);
libkeymap/ Makefile: (before reset)
Review
Quoted 9 lines
AM_CPPFLAGS= \
$(CODE_COVERAGE_CPPFLAGS) \(quoted diff) +0
-5-I$(top_srcdir)/src/libcommon \ -I$(top_srcdir)/src/libkbdfile \ -I$(top_srcdir)/src/libkeymap \ -DDATADIR=\"$(realpath $(top_srcdir))/tests\" \ -DBUILDDIR=\"$(realpath $(builddir))\"
Best Regards,
Qiu Tingting
Quoted 9 lines · On Tue, 24 Oct 2023 at 06:12, [email protected] <[email protected]> wrote:
Hi,Alex
As you said, it is not-that-elegant bit of code.
But DATADIR is used as a part of CPPFLAGS for compiling c files in tests, such aslibkeymap/libkeymap-test01.c,libkbdfile/libkbdfile-test13.cand others. sample:
libkeymap/libkeymap-test01.c: f =fopen(DATADIR "/data/libkeymap/charset-keymap0.map", "r");libkeymap/libkeymap-test09.c:setenv("LOADKEYS_INCLUDE_PATH", DATADIR "/data/libkeymap", 1);
I see, thanks. I would suggest that Makefile.am is patched with a dedicated patch that sets DATADIR to ptest directory on target (you can mark it Inappropriate), so that the change is robust (sed expressions are prone to silent regressions, and), and happens before actual build, so no 'make clean' is needed.
Alex
Hi, Alex
I'm afraid DATADIR should be an absolute path.
Tried to make a ptest.patch with relative path, but failed.
As we know the ptest directory is not a fixed path, so making a patch may be not suitable. For no 'make clean', we can modify the Makefile.am in do_patch().
Any ideas?
Best Regards,
Qiu Tingting
Quoted 29 lines
-----Original Message-----
From: Alexander Kanavin <[email protected]>
Sent: Tuesday, October 24, 2023 4:51 PM
To: Qiu, Tingting/仇 婷婷 <[email protected]>
Cc: [email protected]
Subject: Re: [OE-core] [PATCH V5] kbd:Add ptest supportQuoted 6 lines · On Tue, 24 Oct 2023 at 06:12, [email protected] <[email protected]> wrote:
Hi,Alex
As you said, it is not-that-elegant bit of code.
But DATADIR is used as a part of CPPFLAGS for compiling c files in tests, such aslibkeymap/libkeymap-test01.c,libkbdfile/libkbdfile-test13.cand others.
Quoted 3 lines
sample:
libkeymap/libkeymap-test01.c: f = fopen(DATADIR"/data/libkeymap/charset-keymap0.map", "r");
libkeymap/libkeymap-test09.c: setenv("LOADKEYS_INCLUDE_PATH",
DATADIR "/data/libkeymap", 1);I see, thanks. I would suggest that Makefile.am is patched with a dedicated patch that sets DATADIR to ptest directory on target (you can mark it Inappropriate), so that the change is robust (sed expressions are prone to silent regressions, and), and happens before actual build, so no 'make clean' is needed.
Alex
Hello Qiu,
I think the easiest is to adjust the code so that it first obtains the datadir from some environment variable, and if that is not set, falls back to the hardcoded default. Then run-ptest can set the variable. Such a patch can even be proposed upstream.
Alex
Quoted 40 lines · Tingting Qiu (Fujitsu)
Hi, Alex
I'm afraid DATADIR should be an absolute path.
Tried to make a ptest.patch with relative path, but failed.
As we know the ptest directory is not a fixed path, so making a patch may be not suitable. For no 'make clean', we can modify the Makefile.am indo_patch().
Any ideas?Best Regards,
Qiu TingtingQuoted 29 lines
-----Original Message-----
From: Alexander Kanavin <[email protected]>
Sent: Tuesday, October 24, 2023 4:51 PM
To: Qiu, Tingting/仇 婷婷 <[email protected]>
Cc: [email protected]
Subject: Re: [OE-core] [PATCH V5] kbd:Add ptest supportQuoted 6 lines · On Tue, 24 Oct 2023 at 06:12, [email protected] <[email protected]> wrote:
Hi,Alex
As you said, it is not-that-elegant bit of code.
But DATADIR is used as a part of CPPFLAGS for compiling c files in tests, such aslibkeymap/libkeymap-test01.c,libkbdfile/libkbdfile-test13.cand others.
Quoted 3 lines
sample:
libkeymap/libkeymap-test01.c: f = fopen(DATADIR"/data/libkeymap/charset-keymap0.map", "r");
libkeymap/libkeymap-test09.c: setenv("LOADKEYS_INCLUDE_PATH",
DATADIR "/data/libkeymap", 1);I see, thanks. I would suggest that Makefile.am is patched with a dedicated patch that sets DATADIR to ptest directory on target (you can mark it Inappropriate), so that the change is robust (sed expressions are prone to silent regressions, and), and happens before actual build, so no 'make clean' is needed.
Alex