libldb: add ptest

* use external cmocka instead of bundled cmocka
* add run-ptest script

Ptest results:
$ ptest-runner libldb
START: ptest-runner
2023-10-12T11:49
BEGIN: /usr/lib/libldb/ptest
PASS: test_ldb_dn
PASS: test_ldb_qsort
DURATION: 0
END: /usr/lib/libldb/ptest
2023-10-12T11:49
STOP: ptest-runner
TOTAL: 1 FAIL: 0

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Yi Zhao 2023-10-12 19:56:14 +08:00 committed by Khem Raj
parent 287386a51f
commit 4a07ee78c5
3 changed files with 26 additions and 50 deletions

View File

@ -1,45 +0,0 @@
From a37eb0a46669592e32ed4e004abb2698ee4f90c5 Mon Sep 17 00:00:00 2001
From: Changqing Li <changqing.li@windriver.com>
Date: Wed, 25 Jul 2018 09:55:25 +0800
Subject: [PATCH] cmocka: fix musl libc conflicting types error
/third_party/cmocka/cmocka.h:126:28: error: conflicting types for 'uintptr_t'
typedef unsigned int uintptr_t;
^~~~~~~~~
use __DEFINED_uintptr_t in alltypes.h to check if uintptr already defined
Upstream-Status: Pending
Signed-off-by: Changqing Li <changqing.li@windriver.com>
---
third_party/cmocka/cmocka.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/third_party/cmocka/cmocka.h b/third_party/cmocka/cmocka.h
index e6861c8..238201d 100644
--- a/third_party/cmocka/cmocka.h
+++ b/third_party/cmocka/cmocka.h
@@ -111,7 +111,7 @@ typedef uintmax_t LargestIntegralType;
((LargestIntegralType)(value))
/* Smallest integral type capable of holding a pointer. */
-#if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED)
+#if !defined(__DEFINED_uintptr_t)
# if defined(_WIN32)
/* WIN32 is an ILP32 platform */
typedef unsigned int uintptr_t;
@@ -135,9 +135,8 @@ typedef uintmax_t LargestIntegralType;
# endif /* __WORDSIZE */
# endif /* _WIN32 */
-# define _UINTPTR_T
-# define _UINTPTR_T_DEFINED
-#endif /* !defined(_UINTPTR_T) || !defined(_UINTPTR_T_DEFINED) */
+# define __DEFINED_uintptr_t
+#endif /* !defined(__DEFINED_uintptr_t) */
/* Perform an unsigned cast to uintptr_t. */
#define cast_to_pointer_integral_type(value) \
--
2.25.1

View File

@ -0,0 +1,17 @@
#!/bin/sh
ptestdir=$(dirname "$(readlink -f "$0")")
cd "$ptestdir"/tests || exit
tests="test_ldb_dn test_ldb_qsort"
for f in $tests
do
if test -x ./"$f"; then
if ./"$f" > ./"$f".out 2> ./"$f".err; then
echo "PASS: $f"
else
echo "FAIL: $f"
fi
fi
done

View File

@ -3,7 +3,7 @@ HOMEPAGE = "https://ldb.samba.org"
SECTION = "libs"
LICENSE = "LGPL-3.0-or-later & LGPL-2.1-or-later & GPL-3.0-or-later"
DEPENDS += "libtdb libtalloc libtevent popt"
DEPENDS += "libtdb libtalloc libtevent popt cmocka"
RDEPENDS:pyldb += "python3"
export PYTHONHASHSEED="1"
@ -12,10 +12,9 @@ SRC_URI = "http://samba.org/ftp/ldb/ldb-${PV}.tar.gz \
file://0001-do-not-import-target-module-while-cross-compile.patch \
file://0002-ldb-Add-configure-options-for-packages.patch \
file://0003-Fix-pyext_PATTERN-for-cross-compilation.patch \
file://run-ptest \
"
SRC_URI:append:libc-musl = " file://cmocka-fix-musl-libc-conflicting-types-error.patch"
PACKAGECONFIG ??= "\
${@bb.utils.filter('DISTRO_FEATURES', 'acl', d)} \
${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)} \
@ -37,7 +36,7 @@ LIC_FILES_CHKSUM = "file://pyldb.h;endline=24;md5=dfbd238cecad76957f7f860fbe9ada
SRC_URI[sha256sum] = "26ee72d647854e662d99643eb2b2d341655abf31f4990838d6650fb5cf9209c8"
inherit pkgconfig waf-samba
inherit pkgconfig waf-samba ptest
S = "${WORKDIR}/ldb-${PV}"
@ -47,7 +46,7 @@ export WAF_NO_PREFORK="yes"
EXTRA_OECONF += "--disable-rpath \
--disable-rpath-install \
--bundled-libraries=cmocka \
--bundled-libraries=NONE \
--builtin-libraries=replace \
--with-modulesdir=${libdir}/ldb/modules \
--with-privatelibdir=${libdir}/ldb \
@ -81,3 +80,8 @@ do_configure:prepend() {
# For a clean rebuild
rm -fr bin/
}
do_install_ptest() {
install -d ${D}${PTEST_PATH}/tests
install -m 0755 ${B}/bin/test_ldb_* ${D}${PTEST_PATH}/tests/
}