diff --git a/meta-oe/recipes-support/libssh/libssh/0001-tests-CMakeLists.txt-do-not-search-ssh-sshd-commands.patch b/meta-oe/recipes-support/libssh/libssh/0001-tests-CMakeLists.txt-do-not-search-ssh-sshd-commands.patch new file mode 100644 index 0000000000..91355d0c88 --- /dev/null +++ b/meta-oe/recipes-support/libssh/libssh/0001-tests-CMakeLists.txt-do-not-search-ssh-sshd-commands.patch @@ -0,0 +1,38 @@ +From d2525ba0bc7b11de12c54ea1a3d1eb862537136d Mon Sep 17 00:00:00 2001 +From: Yi Zhao +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 +Signed-off-by: Virendra Thakur +--- + 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 diff --git a/meta-oe/recipes-support/libssh/libssh/run-ptest b/meta-oe/recipes-support/libssh/libssh/run-ptest new file mode 100644 index 0000000000..4ab3e5d141 --- /dev/null +++ b/meta-oe/recipes-support/libssh/libssh/run-ptest @@ -0,0 +1,45 @@ +#!/bin/sh + +# Valid tests to run +tests="torture_buffer \ + torture_callbacks \ + torture_channel \ + torture_config \ + torture_crypto \ + torture_hashes \ + torture_init \ + torture_isipaddr \ + torture_keyfiles \ + torture_knownhosts_parsing \ + torture_list \ + torture_misc \ + torture_options \ + torture_packet \ + torture_packet_filter \ + torture_pki \ + torture_pki_ecdsa \ + torture_pki_ed25519 \ + torture_pki_rsa \ + torture_rand \ + torture_threads_buffer \ + torture_threads_crypto \ + torture_threads_init \ + torture_threads_pki_rsa \ + " + +ptestdir=$(dirname "$(readlink -f "$0")") +cd "$ptestdir"/tests || exit + +# Run specified tests +for f in $tests +do + if test -e ./"$f"; then + if ./"$f" > ./"$f".out 2> ./"$f".err; then + echo "PASS: $f" + else + echo "FAIL: $f" + fi + else + echo "SKIP: $f" + fi +done diff --git a/meta-oe/recipes-support/libssh/libssh_0.8.9.bb b/meta-oe/recipes-support/libssh/libssh_0.8.9.bb index 98910d3068..7d0fc2d32f 100644 --- a/meta-oe/recipes-support/libssh/libssh_0.8.9.bb +++ b/meta-oe/recipes-support/libssh/libssh_0.8.9.bb @@ -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"