diff mbox series

[meta-oe] cli11: add ptest support

Message ID 20251017120510.2439753-1-skandigraun@gmail.com
State Under Review
Headers show
Series [meta-oe] cli11: add ptest support | expand

Commit Message

Gyorgy Sarvari Oct. 17, 2025, 12:05 p.m. UTC
The tests take single digit seconds to execute.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 .../include/ptest-packagelists-meta-oe.inc    |  1 +
 .../remove_tmpdir_from_test_binary.patch      | 33 +++++++++++++++++++
 meta-oe/recipes-support/cli11/cli11/run-ptest |  5 +++
 meta-oe/recipes-support/cli11/cli11_2.5.0.bb  | 19 +++++++++--
 4 files changed, 56 insertions(+), 2 deletions(-)
 create mode 100644 meta-oe/recipes-support/cli11/cli11/remove_tmpdir_from_test_binary.patch
 create mode 100644 meta-oe/recipes-support/cli11/cli11/run-ptest
diff mbox series

Patch

diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
index 18324ff0d3..825747d522 100644
--- a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
+++ b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
@@ -8,6 +8,7 @@ 
 # ptests which take less than ~30s each
 PTESTS_FAST_META_OE = "\
     asio \
+    cli11 \
     cmocka \
     cunit \
     duktape \
diff --git a/meta-oe/recipes-support/cli11/cli11/remove_tmpdir_from_test_binary.patch b/meta-oe/recipes-support/cli11/cli11/remove_tmpdir_from_test_binary.patch
new file mode 100644
index 0000000000..22c3e5211f
--- /dev/null
+++ b/meta-oe/recipes-support/cli11/cli11/remove_tmpdir_from_test_binary.patch
@@ -0,0 +1,33 @@ 
+Remove tmpdir from apptest binary
+
+This binary is used in the ptest package. It executes another helper binary
+for the test, which is identified by its absolute path, as it was determined during
+build. To avoid the QA error (and to find the helper binary during test excution),
+use pwd command files.
+
+Upstream-Status: Inappropriate [oe-specific]
+Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
+
+
+diff --git a/tests/AppTest.cpp b/tests/AppTest.cpp
+index 29aff27c..ddb8238b 100644
+--- a/tests/AppTest.cpp
++++ b/tests/AppTest.cpp
+@@ -2819,7 +2819,7 @@ TEST_CASE("C20_compile", "simple") {
+ 
+ // #845
+ TEST_CASE("Ensure UTF-8", "[app]") {
+-    const char *commandline = CLI11_ENSURE_UTF8_EXE " 1234 false \"hello world\"";
++    const char *commandline = "$(pwd)/ensure_utf8 1234 false \"hello world\"";
+     int retval = std::system(commandline);
+ 
+     if(retval == -1) {
+@@ -2837,7 +2837,7 @@ TEST_CASE("Ensure UTF-8", "[app]") {
+ 
+ // #845
+ TEST_CASE("Ensure UTF-8 called twice", "[app]") {
+-    const char *commandline = CLI11_ENSURE_UTF8_TWICE_EXE " 1234 false \"hello world\"";
++    const char *commandline = "$(pwd)/ensure_utf8_twice 1234 false \"hello world\"";
+     int retval = std::system(commandline);
+ 
+     if(retval == -1) {
diff --git a/meta-oe/recipes-support/cli11/cli11/run-ptest b/meta-oe/recipes-support/cli11/cli11/run-ptest
new file mode 100644
index 0000000000..ef37d44783
--- /dev/null
+++ b/meta-oe/recipes-support/cli11/cli11/run-ptest
@@ -0,0 +1,5 @@ 
+#!/bin/sh
+cd tests
+for t in `ls ./*Test`; do
+	./$t && echo PASS: $t || echo FAIL: $t
+done
diff --git a/meta-oe/recipes-support/cli11/cli11_2.5.0.bb b/meta-oe/recipes-support/cli11/cli11_2.5.0.bb
index f6c9ac8f69..980932165b 100644
--- a/meta-oe/recipes-support/cli11/cli11_2.5.0.bb
+++ b/meta-oe/recipes-support/cli11/cli11_2.5.0.bb
@@ -6,12 +6,27 @@  LIC_FILES_CHKSUM = "file://LICENSE;md5=b8bdde6bda8508bef68a39f3e0d7e939"
 
 DEPENDS = "catch2"
 
-SRC_URI = "gitsm://github.com/CLIUtils/CLI11;branch=main;protocol=https"
+SRC_URI = "gitsm://github.com/CLIUtils/CLI11;branch=main;protocol=https \
+           file://remove_tmpdir_from_test_binary.patch \
+           file://run-ptest"
 SRCREV = "4160d259d961cd393fd8d67590a8c7d210207348"
 
-inherit cmake
+inherit cmake ptest
 
 # cli11 is a header only C++ library, so the main package will be empty.
 RDEPENDS:${PN}-dev = ""
+RDEPENDS:${PN}-ptest = ""
+
+do_install_ptest(){
+	# double tests is not a typo. The inner empty tests folder is
+	# used by one the tests.
+	install -d ${D}${PTEST_PATH}/tests/tests
+	for t in `ls ${B}/tests/*Test`; do
+		install $t ${D}${PTEST_PATH}/tests/
+	done
+	install ${B}/tests/ensure_utf8 ${D}${PTEST_PATH}/tests/
+	install ${B}/tests/ensure_utf8_twice ${D}${PTEST_PATH}/tests/
+	install ${B}/tests/link_test_2 ${D}${PTEST_PATH}/tests/
+}
 
 BBCLASSEXTEND = "native nativesdk"