The project has extensive runtime- and unittest suite - make use of it.

It takes around 10 seconds to run both suites.

Added two patches:
One is needed to convert python unittest output into automake output.

The other is required to be able to configure test data folder at
compile time - otherwise the tests are looking for the test-data
with absolute paths from the build machine.

Signed-off-by: Gyorgy Sarvari <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
(cherry picked from commit 35bc4860f18cd56a80ee29d492540acfcb620b59)

Adapted to Kirkstone. (It also required an extra patch to be able to
compile with the current googletest library)

Signed-off-by: Gyorgy Sarvari <[email protected]>
---
 ...1-Allow-test-data-path-configuration.patch | 30 ++++++++++++++++
 .../0001-Fix-build-with-gtest-1.11.patch      | 35 +++++++++++++++++++
 meta-oe/recipes-support/exiv2/exiv2/run-ptest |  6 ++++
 meta-oe/recipes-support/exiv2/exiv2_0.27.3.bb | 33 +++++++++++++++--
 4 files changed, 102 insertions(+), 2 deletions(-)
 create mode 100644 
meta-oe/recipes-support/exiv2/exiv2/0001-Allow-test-data-path-configuration.patch
 create mode 100644 
meta-oe/recipes-support/exiv2/exiv2/0001-Fix-build-with-gtest-1.11.patch
 create mode 100644 meta-oe/recipes-support/exiv2/exiv2/run-ptest

diff --git 
a/meta-oe/recipes-support/exiv2/exiv2/0001-Allow-test-data-path-configuration.patch
 
b/meta-oe/recipes-support/exiv2/exiv2/0001-Allow-test-data-path-configuration.patch
new file mode 100644
index 0000000000..9d6072a799
--- /dev/null
+++ 
b/meta-oe/recipes-support/exiv2/exiv2/0001-Allow-test-data-path-configuration.patch
@@ -0,0 +1,30 @@
+From 2483e51df6e02ad0ad5ae636767279fa230da44f Mon Sep 17 00:00:00 2001
+From: Gyorgy Sarvari <[email protected]>
+Date: Sun, 23 Nov 2025 11:52:24 +0100
+Subject: [PATCH] Allow test data path configuration
+
+The unittests expect to the executed in the source folder before/after build,
+and they expect the test data to be in the source folder. However for ptests
+these folders are not available.
+
+This patch allows the test data folders to be configuration during build time.
+
+Upstream-Status: Inappropriate [ptest-specific]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ unitTests/CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt
+index 51040c0e2..e2604d4a7 100644
+--- a/unitTests/CMakeLists.txt
++++ b/unitTests/CMakeLists.txt
+@@ -40,7 +40,7 @@ add_executable(unit_tests
+ target_compile_definitions(unit_tests
+   PRIVATE
+     exiv2lib_STATIC
+-    TESTDATA_PATH="${PROJECT_SOURCE_DIR}/test/data"
++    TESTDATA_PATH="${TEST_FOLDER}/test/data"
+ )
+ 
+ if (exiv2lib_COMPILE_DEFINITIONS)
diff --git 
a/meta-oe/recipes-support/exiv2/exiv2/0001-Fix-build-with-gtest-1.11.patch 
b/meta-oe/recipes-support/exiv2/exiv2/0001-Fix-build-with-gtest-1.11.patch
new file mode 100644
index 0000000000..fd4c88f062
--- /dev/null
+++ b/meta-oe/recipes-support/exiv2/exiv2/0001-Fix-build-with-gtest-1.11.patch
@@ -0,0 +1,35 @@
+From 14d482f9e2353e195149fff196e65cb3a6b46e25 Mon Sep 17 00:00:00 2001
+From: Gyorgy Sarvari <[email protected]>
+Date: Fri, 18 Jun 2021 18:53:46 +0200
+Subject: [PATCH] Fix build with gtest 1.11
+
+From: Antonio Rojas <[email protected]>
+
+INSTANTIATE_TYPED_TEST_CASE_P requires a non-empty prefix now
+
+Upstream-Status: Backport 
[https://github.com/Exiv2/exiv2/commit/c069e36605f05e8e58bf964e5ecbde04efb90a20]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ unitTests/test_slice.cpp | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/unitTests/test_slice.cpp b/unitTests/test_slice.cpp
+index bbc6785..ab51cda 100644
+--- a/unitTests/test_slice.cpp
++++ b/unitTests/test_slice.cpp
+@@ -422,12 +422,12 @@ REGISTER_TYPED_TEST_CASE_P(slice, atAccess, 
iteratorAccess, constructionFailsFro
+                            constMethodsPreserveConst);
+ 
+ typedef ::testing::Types<const std::vector<int>, std::vector<int>, int*, 
const int*> test_types_t;
+-INSTANTIATE_TYPED_TEST_CASE_P(, slice, test_types_t);
++INSTANTIATE_TYPED_TEST_CASE_P(slice, slice, test_types_t);
+ 
+ REGISTER_TYPED_TEST_CASE_P(mutableSlice, iterators, at);
+ typedef ::testing::Types<std::vector<int>, int*> mut_test_types_t;
+-INSTANTIATE_TYPED_TEST_CASE_P(, mutableSlice, mut_test_types_t);
++INSTANTIATE_TYPED_TEST_CASE_P(slice, mutableSlice, mut_test_types_t);
+ 
+ REGISTER_TYPED_TEST_CASE_P(dataBufSlice, successfulConstruction, 
failedConstruction);
+ typedef ::testing::Types<DataBuf&, const DataBuf&> data_buf_types_t;
+-INSTANTIATE_TYPED_TEST_CASE_P(, dataBufSlice, data_buf_types_t);
++INSTANTIATE_TYPED_TEST_CASE_P(slice, dataBufSlice, data_buf_types_t);
diff --git a/meta-oe/recipes-support/exiv2/exiv2/run-ptest 
b/meta-oe/recipes-support/exiv2/exiv2/run-ptest
new file mode 100644
index 0000000000..d7ed07d7c9
--- /dev/null
+++ b/meta-oe/recipes-support/exiv2/exiv2/run-ptest
@@ -0,0 +1,6 @@
+#!/bin/sh
+cd tests
+python3 ./runner.py -v 2>&1 | sed -e '/\.\.\. ok/ s/^/PASS: /g' -e '/\.\.\. 
[ERROR|FAIL]/ s/^/FAIL: /g' -e '/\.\.\. skipped/ s/^/SKIP: /g' -e 's/ \.\.\. 
ok//g' -e 's/ \.\.\. ERROR//g' -e 's/ \.\.\. FAIL//g' -e 's/ \.\.\. skipped//g'
+
+cd ..
+./build/bin/unit_tests --gtest_print_time=0 | sed -E  '/^\[ RUN/d ; s/\[       
OK \]/PASS: / ; s/\[ DISABLED \]/SKIP: / ; s/\[ FAILED \]/FAIL: /'
diff --git a/meta-oe/recipes-support/exiv2/exiv2_0.27.3.bb 
b/meta-oe/recipes-support/exiv2/exiv2_0.27.3.bb
index 1c1c05dfaa..0b70c3b235 100644
--- a/meta-oe/recipes-support/exiv2/exiv2_0.27.3.bb
+++ b/meta-oe/recipes-support/exiv2/exiv2_0.27.3.bb
@@ -2,10 +2,13 @@ SUMMARY = "Exif, Iptc and XMP metadata manipulation library 
and tools"
 LICENSE = "GPL-2.0-only"
 LIC_FILES_CHKSUM = "file://COPYING;md5=625f055f41728f84a8d7938acc35bdc2"
 
-DEPENDS = "zlib expat"
+DEPENDS = "zlib expat ${@bb.utils.contains('PTEST_ENABLED', '1', 'googletest', 
'', d)}"
 
 SRC_URI = 
"https://github.com/Exiv2/${BPN}/releases/download/v${PV}/${BP}-Source.tar.gz \
+           file://run-ptest \
+           file://0001-Allow-test-data-path-configuration.patch \
            
file://0001-Use-compiler-fcf-protection-only-if-compiler-arch-su.patch \
+           file://0001-Fix-build-with-gtest-1.11.patch \
            file://CVE-2021-29457.patch \
            file://CVE-2021-29458.patch \
            file://CVE-2021-29463.patch \
@@ -26,8 +29,34 @@ SRC_URI = 
"https://github.com/Exiv2/${BPN}/releases/download/v${PV}/${BP}-Source
 SRC_URI[sha256sum] = 
"a79f5613812aa21755d578a297874fb59a85101e793edc64ec2c6bd994e3e778"
 
 # Once patch is obsolete (project should be aware due to PRs), dos2unix can be 
removed either
-inherit dos2unix
+inherit dos2unix ptest
 
 S = "${WORKDIR}/${BPN}-${PV}-Source"
 
 inherit cmake gettext
+
+RDEPENDS:${PN}-ptest += " \
+    python3-html \
+    python3-lxml \
+    python3-multiprocessing \
+    python3-shell \
+    python3-unittest"
+
+EXTRA_OECMAKE = "\
+    ${@bb.utils.contains('PTEST_ENABLED', \
+    '1', \
+    '-DEXIV2_BUILD_SAMPLES=ON -DEXIV2_ENABLE_WEBREADY=ON 
-DEXIV2_BUILD_UNIT_TESTS=ON -DTEST_FOLDER=${PTEST_PATH}', \
+    '', \
+    d)} \
+"
+
+do_install_ptest(){
+    cp -r ${S}/tests ${D}${PTEST_PATH}/
+    cp -r ${S}/test ${D}${PTEST_PATH}/
+
+    install -d ${D}${PTEST_PATH}/build/bin
+    install ${B}/bin/* ${D}${PTEST_PATH}/build/bin
+
+    install -d ${D}${PTEST_PATH}/src
+    install ${S}/src/canonmn_int.cpp ${D}${PTEST_PATH}/src
+}
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#123493): 
https://lists.openembedded.org/g/openembedded-devel/message/123493
Mute This Topic: https://lists.openembedded.org/mt/117276144/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to