Skip to contentSkip to conversation

exiv2: add ptest support

PATCH Gyorgy Sarvari 1 participant 1 message Jan 31 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Quick note: While running YP compatibility check, it turned out that this patch tries to pull in python3-lxml recipe from meta-python, breaking YP compatibility - this change is now dropped because of that. It will rather live as a bbappend in my meta-oe-test layer.

Quoted 182 lines · Gyorgy Sarvari via lists.openembedded.org

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.

(cherry picked from commit 35bc4860f18cd56a80ee29d492540acfcb620b59)

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

---
 ...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
meta-oe/recipes-support/exiv2/exiv2/0001-Allow-test-data-path-configuration.patch new file +30 -0
new file mode 100644
index 0000000000..9d6072a799
@@ -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)
meta-oe/recipes-support/exiv2/exiv2/0001-Fix-build-with-gtest-1.11.patch new file +35 -0
new file mode 100644
index 0000000000..fd4c88f062
@@ -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);
meta-oe/recipes-support/exiv2/exiv2/run-ptest new file +6 -0
new file mode 100644
index 0000000000..d7ed07d7c9
@@ -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: /'
meta-oe/recipes-support/exiv2/exiv2_0.27.3.bb +31 -3
index 1c1c05dfaa..0b70c3b235 100644
@@ -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/6084445
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-