meta-openembedded/meta-oe/recipes-extended/7zip/bit7z/0001-Allow-running-tests-on-target-when-cross-compiling.patch
Peter Marko 36b1e2b140
bit7z: add ptest support
Main problem with ptest for this component is that it uses cmake's
FetchContent and CPM to get dependencies.
This adds lot of ugly code to the recipe including conditional patch.

Second big problem is that tests need BIT7Z_DISABLE_USE_STD_FILESYSTEM
which uses test library. This means that when building with ptests, the
code is significantly different than when building without it.
But in production case we don't want to use testing library...
This is known at upstream and will be fixed eventually as github CI is
failing on this too when submitting unrelated patches upstream.

Other considerations:
* created patch for new cmake option to pass path to test data on target
* created patch for new cmake option to pass path to lib7zip on target
* skipped test which consumes too much RAM (it passes if machine has
  plenty of RAM)
* testdata contains files for other architectures, so INSANE_SKIP is
  needed for ptest package
* created patch for tests failing with musl

Tests usually take 9s on my build machine so added them to fast ptests.
However since the dependency 7zip recipe does not build on 64-bit
architectures, I could not add it to PTESTS_FAST_META_OE.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2025-04-07 12:21:23 -07:00

46 lines
2.1 KiB
Diff

From 9f0eed91d32ec2f310bd5c23af187f888394fcb4 Mon Sep 17 00:00:00 2001
From: Peter Marko <peter.marko@siemens.com>
Date: Wed, 2 Apr 2025 09:33:03 +0200
Subject: [PATCH] Allow running tests on target when cross-compiling
When bit7z is Cross-compiled, target device does not contain
source/build directory anymore and thus path to test data is different.
Make it possible to pass the new path to cmake.
Upstream-Status: Submitted [https://github.com/rikyoz/bit7z/pull/289]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
tests/CMakeLists.txt | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 60da280..dbdff1f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -49,6 +49,11 @@ add_executable( ${TESTS_TARGET_PUBLIC} ${SOURCE_FILES} ${PUBLIC_API_SOURCE_FILES
if( BIT7Z_TESTS_FILESYSTEM )
set( BIT7Z_TESTS_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/data )
+ if( NOT BIT7Z_TESTS_DATA_DIR_TARGET )
+ set( BIT7Z_TESTS_DATA_DIR_TARGET ${BIT7Z_TESTS_DATA_DIR} )
+ else()
+ message( STATUS "Custom test data dir on target: ${BIT7Z_TESTS_DATA_DIR_TARGET}" )
+ endif()
include( FetchContent )
FetchContent_Declare( bit7z-test-data
@@ -61,11 +66,11 @@ if( BIT7Z_TESTS_FILESYSTEM )
message( STATUS "Tests data directory: ${BIT7Z_TESTS_DATA_DIR}" )
target_compile_definitions( ${TESTS_TARGET} PRIVATE
BIT7Z_TESTS_FILESYSTEM
- BIT7Z_TESTS_DATA_DIR="${BIT7Z_TESTS_DATA_DIR}" )
+ BIT7Z_TESTS_DATA_DIR="${BIT7Z_TESTS_DATA_DIR_TARGET}" )
target_compile_definitions( ${TESTS_TARGET_PUBLIC} PRIVATE
BIT7Z_TESTS_PUBLIC_API_ONLY
BIT7Z_TESTS_FILESYSTEM
- BIT7Z_TESTS_DATA_DIR="${BIT7Z_TESTS_DATA_DIR}" )
+ BIT7Z_TESTS_DATA_DIR="${BIT7Z_TESTS_DATA_DIR_TARGET}" )
if( NOT EXISTS ${BIT7Z_TESTS_DATA_DIR}/test_filesystem/empty )
file( MAKE_DIRECTORY ${BIT7Z_TESTS_DATA_DIR}/test_filesystem/empty )
endif()