Skip to contentSkip to conversation

libssh: Add ptest

PATCH In review Virendra Thakur 3 participants 3 messages Feb 3, 2025 – Feb 4, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libssh: Add ptest

From: Virendra Thakur <[email protected]>

Enable ptest for libssh , this change is backported from upstream scarthgap.

Reference: https://git.openembedded.org/meta-openembedded/commit/?h=scarthgap&id=bf49bdea290ba8cf18f3fd6b47d1d71dfe499948

~ # ptest-runner libssh
START: ptest-runner
2025-01-28T14:28
BEGIN: /usr/lib/libssh/ptest
PASS: torture_buffer
PASS: torture_callbacks
PASS: torture_channel
PASS: torture_config
PASS: torture_crypto
PASS: torture_hashes
PASS: torture_init
PASS: torture_isipaddr
PASS: torture_keyfiles
PASS: torture_knownhosts_parsing
PASS: torture_list
PASS: torture_misc
PASS: torture_options
PASS: torture_packet
PASS: torture_packet_filter
PASS: torture_pki
PASS: torture_pki_ecdsa
PASS: torture_pki_ed25519
PASS: torture_pki_rsa
PASS: torture_rand
PASS: torture_threads_buffer
PASS: torture_threads_crypto
PASS: torture_threads_init
PASS: torture_threads_pki_rsa
DURATION: 119
END: /usr/lib/libssh/ptest
2025-01-28T14:29
STOP: ptest-runner
TOTAL: 1 FAIL: 0

---
 ....txt-do-not-search-ssh-sshd-commands.patch | 38 ++++++++++++++++
 .../recipes-support/libssh/libssh/run-ptest   | 45 +++++++++++++++++++
 .../recipes-support/libssh/libssh_0.8.9.bb    | 19 ++++++--
 3 files changed, 99 insertions(+), 3 deletions(-)
 create mode 100644 meta-oe/recipes-support/libssh/libssh/0001-tests-CMakeLists.txt-do-not-search-ssh-sshd-commands.patch
 create mode 100644 meta-oe/recipes-support/libssh/libssh/run-ptest
meta-oe/recipes-support/libssh/libssh/0001-tests-CMakeLists.txt-do-not-search-ssh-sshd-commands.patch new file +38 -0
new file mode 100644
index 0000000000..91355d0c88
@@ -0,0 +1,38 @@
+From d2525ba0bc7b11de12c54ea1a3d1eb862537136d Mon Sep 17 00:00:00 2001
+From: Yi Zhao <[email protected]>
+Date: Wed, 15 Mar 2023 16:51:58 +0800
+Subject: [PATCH] tests/CMakeLists.txt: do not search ssh/sshd commands on host
+
+It will search ssh/sshd commands on host when configure. Since they are
+not required by unittests, we can skip the search.
+
+Upstream-Status: Inappropriate [embedded specific]
+
+Signed-off-by: Yi Zhao <[email protected]>
+Signed-off-by: Virendra Thakur <[email protected]>
+---
+ tests/CMakeLists.txt | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index 22a36f37..aa32ca2e 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -48,6 +48,7 @@ set(TEST_TARGET_LIBRARIES
+
+ add_subdirectory(unittests)
+
++if (CLIENT_TESTING OR SERVER_TESTING)
+ if (CLIENT_TESTING)
+     find_package(socket_wrapper 1.1.5 REQUIRED)
+     find_package(nss_wrapper 1.1.2 REQUIRED)
+@@ -152,6 +153,7 @@ if (WITH_SERVER AND SERVER_TESTING)
+     add_subdirectory(pkd)
+ endif (WITH_SERVER AND SERVER_TESTING)
+
++endif ()
+ if (FUZZ_TESTING)
+     add_subdirectory(fuzz)
+ endif()
+-- 
+2.25.1
meta-oe/recipes-support/libssh/libssh/run-ptest new file +45 -0

45 lines not on this page · raw message

meta-oe/recipes-support/libssh/libssh_0.8.9.bb +16 -3
index 98910d3068..7d0fc2d32f 100644
@@ -18,17 +18,19 @@ SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable
            file://004_CVE-2023-6004.patch \
            file://005_CVE-2023-6004.patch \
            file://006_CVE-2023-6004.patch \
+           file://0001-tests-CMakeLists.txt-do-not-search-ssh-sshd-commands.patch \
+           file://run-ptest \
           "
 SRCREV = "04685a74df9ce1db1bc116a83a0da78b4f4fa1f8"
 
 S = "${WORKDIR}/git"
 
-inherit cmake
+inherit cmake ptest
 
-PACKAGECONFIG ??= "gcrypt"
+PACKAGECONFIG ??= "gcrypt ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}"
 PACKAGECONFIG[gssapi] = "-DWITH_GSSAPI=1, -DWITH_GSSAPI=0, krb5, "
 PACKAGECONFIG[gcrypt] = "-DWITH_GCRYPT=1, -DWITH_GCRYPT=0, libgcrypt, "
-
+PACKAGECONFIG[tests] = "-DUNIT_TESTING=1, -DUNIT_TESTING=0, cmocka"
 ARM_INSTRUCTION_SET:armv5 = "arm"
 
 EXTRA_OECMAKE = " \
@@ -44,6 +46,17 @@ do_configure:prepend () {
         || bbfatal "Failed to disable examples"
 }
 
+do_compile:prepend () {
+    if [ ${PTEST_ENABLED} = "1" ]; then
+        sed -i -e 's|${B}|${PTEST_PATH}|g' ${B}/config.h
+    fi
+}
+
+do_install_ptest () {
+    install -d ${D}${PTEST_PATH}/tests
+    cp -f ${B}/tests/unittests/torture_* ${D}${PTEST_PATH}/tests/
+}
+
 TOOLCHAIN = "gcc"
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.34.1
#1 lore raw

virendra thakur via lists.openembedded.org schrieb am Mo 03. Feb, 13:26 (+0530):

Quoted 10 lines
meta-oe/recipes-support/libssh/libssh_0.8.9.bb +2 -0
index 98910d3068..7d0fc2d32f 100644
@@ -18,17 +18,19 @@ SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable
            file://004_CVE-2023-6004.patch \
            file://005_CVE-2023-6004.patch \
            file://006_CVE-2023-6004.patch \
+           file://0001-tests-CMakeLists.txt-do-not-search-ssh-sshd-commands.patch \
+           file://run-ptest \

meta-oe/recipes-support/libssh/libssh_0.8.9.bb SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable · line 30

Quoted 10 lines
meta-oe/recipes-support/libssh/libssh_0.8.9.bb +2 -2
           "
 SRCREV = "04685a74df9ce1db1bc116a83a0da78b4f4fa1f8"
 
 S = "${WORKDIR}/git"
 
-inherit cmake
+inherit cmake ptest
 
-PACKAGECONFIG ??= "gcrypt"
+PACKAGECONFIG ??= "gcrypt ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}"

Would oe.utils.vartrue() be better?

Regards Jörg

Signature · 8 lines
MCSE = Minesweeper Consultant & Solitaire Expert

Navimatix GmbH           T: 03641 - 327 99 0
Tatzendpromenade 2       F: 03641 - 526 306
07745 Jena               www.navimatix.de

Geschäftsführer: Steffen Späthe, Jan Rommeley
Registergericht: Amtsgericht Jena, HRB 501480
#2 lore raw

@Jörg Sommer<mailto:[email protected]>

This change is already present in scarthgap branch, i am just backporting it from the scarthgap to kirkstone.

bb.utils.contains is better option as we are expecting a return based on presence of ptest enable.

[cid:75e3c0ba-b9c0-49f2-a84c-8f7a86e2ae47]<https://outlook.office.com/bookwithme/user/[email protected]?anonymous&ep=bwmEmailSignature> Book time to meet with me<https://outlook.office.com/bookwithme/user/[email protected]?anonymous&ep=bwmEmailSignature>
________________________________
From: Jörg Sommer <[email protected]>
Sent: Monday, February 3, 2025 10:17 PM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Virendra Kumar Thakur <[email protected]>
Subject: Re: [oe] [meta-oe][kirkstone][PATCH] libssh: Add ptest

Caution: This email originated from outside of the KPIT. Do not click links or open attachments unless you recognize the sender and know the content is safe.

virendra thakur via lists.openembedded.org schrieb am Mo 03. Feb, 13:26 (+0530):

Quoted 10 lines
meta-oe/recipes-support/libssh/libssh_0.8.9.bb +2 -0
index 98910d3068..7d0fc2d32f 100644
@@ -18,17 +18,19 @@ SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable
            file://004_CVE-2023-6004.patch \
            file://005_CVE-2023-6004.patch \
            file://006_CVE-2023-6004.patch \
+           file://0001-tests-CMakeLists.txt-do-not-search-ssh-sshd-commands.patch \
+           file://run-ptest \

meta-oe/recipes-support/libssh/libssh_0.8.9.bb SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable · line 30

Quoted 10 lines
meta-oe/recipes-support/libssh/libssh_0.8.9.bb +2 -2
           "
 SRCREV = "04685a74df9ce1db1bc116a83a0da78b4f4fa1f8"
 
 S = "${WORKDIR}/git"
 
-inherit cmake
+inherit cmake ptest
 
-PACKAGECONFIG ??= "gcrypt"
+PACKAGECONFIG ??= "gcrypt ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}"

Would oe.utils.vartrue() be better?

Regards Jörg

--
MCSE = Minesweeper Consultant & Solitaire Expert

Navimatix GmbH T: 03641 - 327 99 0
Tatzendpromenade 2 F: 03641 - 526 306
07745 Jena https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.navimatix.de%2F&data=05%7C02%7CVirendra.Thakur%40kpit.com%7C56eadaaaddd3470f2eb908dd4472860f%7C3539451eb46e4a26a242ff61502855c7%7C0%7C0%7C638741980907356124%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=2jFgh%2BF8v67We4q4YApHdbHoydo4l2HYjy0SWcUP4ko%3D&reserved=0<http://www.navimatix.de/>

Geschäftsführer: Steffen Späthe, Jan Rommeley
Registergericht: Amtsgericht Jena, HRB 501480
This message contains information that may be privileged or confidential and is the property of the KPIT Technologies Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Technologies Ltd. does not accept any liability for virus infected mails.