new file mode 100644
@@ -0,0 +1,30 @@
+From 2483e51df6e02ad0ad5ae636767279fa230da44f Mon Sep 17 00:00:00 2001
+From: Gyorgy Sarvari <skandigraun@gmail.com>
+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 <skandigraun@gmail.com>
+---
+ 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)
new file mode 100644
@@ -0,0 +1,35 @@
+From 14d482f9e2353e195149fff196e65cb3a6b46e25 Mon Sep 17 00:00:00 2001
+From: Gyorgy Sarvari <skandigraun@gmail.com>
+Date: Fri, 18 Jun 2021 18:53:46 +0200
+Subject: [PATCH] Fix build with gtest 1.11
+
+From: Antonio Rojas <arojas@archlinux.org>
+
+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 <skandigraun@gmail.com>
+---
+ 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);
new file mode 100644
@@ -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: /'
@@ -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
+}