rocksdb: Add ptest support

# ./run-ptest
PASS: agg_merge_test
PASS: cache_test
PASS: db_basic_test
PASS: env_basic_test
PASS: testutil_test

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Mingli Yu 2024-09-29 16:11:12 +08:00 committed by Khem Raj
parent d91297efee
commit c0095bd118
No known key found for this signature in database
GPG Key ID: BB053355919D3314
4 changed files with 74 additions and 2 deletions

View File

@ -55,6 +55,7 @@ PTESTS_SLOW_META_OE = "\
fftw \
libusb-compat \
rsyslog \
rocksdb \
mariadb \
poco \
re2 \

View File

@ -0,0 +1,42 @@
From 9abf6cd09c60f0be9a85c055dfdf43698f057f73 Mon Sep 17 00:00:00 2001
From: Mingli Yu <mingli.yu@windriver.com>
Date: Wed, 25 Sep 2024 13:47:37 +0800
Subject: [PATCH] CMakeLists.txt: Make the test discovery occur on target
Set DISCOVERY_MODE to PRE_TEST to delay test discovery until just
prior to test execution on the target to fix the build failure as
the default POST_BUILD behavior is not desirable in cross-compiling
env.
/build/tmp/work/core2-64-wrs-linux/rocksdb/9.0.0/build/env_basic_test: error while loading shared libraries: libgflags.so.2.2: cannot open shared object file: No such file or directory
CMake Error at /build/tmp/work/core2-64-wrs-linux/rocksdb/9.0.0/recipe-sysroot-native/usr/share/cmake-3.30/Modules/GoogleTestAddTests.cmake:112 (message):
Error running test executable.
Path: '/build/tmp/work/core2-64-wrs-linux/rocksdb/9.0.0/build/env_basic_test'
Working directory: '/build/tmp/work/core2-64-wrs-linux/rocksdb/9.0.0/build'
Result: 127
Output:
Upstream-Status: Inappropriate [oe specific]
Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 403ad1243..f34397798 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1502,7 +1502,7 @@ if(WITH_TESTS)
)
target_link_libraries(${exename}${ARTIFACT_SUFFIX} testutillib${ARTIFACT_SUFFIX} testharness gtest ${THIRDPARTY_LIBS} ${ROCKSDB_LIB})
if(NOT "${exename}" MATCHES "db_sanity_test")
- gtest_discover_tests(${exename} DISCOVERY_TIMEOUT 120)
+ gtest_discover_tests(${exename} DISCOVERY_TIMEOUT 120 DISCOVERY_MODE PRE_TEST)
add_dependencies(rocksdb_check ${exename}${ARTIFACT_SUFFIX})
endif()
endforeach(sourcefile ${TESTS})
--
2.34.1

View File

@ -0,0 +1,12 @@
#!/bin/sh
ptestdir=$(dirname "$(readlink -f "$0")")
cd "$ptestdir"/tests || exit
for test in *_test; do
if ./${test} >/dev/null 2>&1; then
echo "PASS: ${test}"
else
echo "FAIL: ${test}"
fi
done

View File

@ -18,6 +18,8 @@ SRC_URI = "git://github.com/facebook/${BPN}.git;branch=${SRCBRANCH};protocol=htt
file://0006-Implement-timer-for-arm-v6.patch \
file://0007-Fix-declaration-scope-of-LE_LOAD32-in-crc32c.patch \
file://static_library_as_option.patch \
file://0001-CMakeLists.txt-Make-the-test-discovery-occur-on-targ.patch \
file://run-ptest \
"
SRC_URI:append:riscv32 = " file://0001-replace-old-sync-with-new-atomic-builtin-equivalents.patch"
@ -27,7 +29,7 @@ SRC_URI:remove:toolchain-clang:riscv32 = "file://0001-replace-old-sync-with-new-
S = "${WORKDIR}/git"
inherit cmake
inherit cmake ptest
PACKAGECONFIG ??= "bzip2 zlib lz4 gflags"
PACKAGECONFIG[bzip2] = "-DWITH_BZ2=ON,-DWITH_BZ2=OFF,bzip2"
@ -40,7 +42,7 @@ PACKAGECONFIG[gflags] = "-DWITH_GFLAGS=ON,-DWITH_GFLAGS=OFF,gflags"
# Tools and tests currently don't compile on armv5 so we disable them
EXTRA_OECMAKE = "\
-DPORTABLE=ON \
-DWITH_TESTS=OFF \
-DWITH_TESTS=${@bb.utils.contains("DISTRO_FEATURES", "ptest", "ON", "OFF", d)} \
-DWITH_BENCHMARK_TOOLS=OFF \
-DWITH_TOOLS=OFF \
-DFAIL_ON_WARNINGS=OFF \
@ -54,6 +56,21 @@ do_install:append() {
sed -i "s#${RECIPE_SYSROOT}##g" ${D}${libdir}/cmake/rocksdb/RocksDBTargets.cmake
}
do_install_ptest() {
install -d ${D}${PTEST_PATH}/tests
# only cover the basic test as all the tests need to take about 6 hours
# time ./run-ptest
# real 356m32.956s
# user 252m32.004s
# sys 178m50.246s
install -m 0755 ${B}/env_basic_test ${D}${PTEST_PATH}/tests/
install -m 0755 ${B}/db_basic_test ${D}${PTEST_PATH}/tests/
install -m 0755 ${B}/agg_merge_test ${D}${PTEST_PATH}/tests/
install -m 0755 ${B}/testutil_test ${D}${PTEST_PATH}/tests/
install -m 0755 ${B}/cache_test ${D}${PTEST_PATH}/tests/
}
# Need toku_time_now() implemented for ppc/musl
# see utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h
COMPATIBLE_HOST:libc-musl:powerpc = "null"
COMPATIBLE_HOST:armv5 = 'null'