From 4673fa0c9be3a35ea2614b88215e972b656778f2 Mon Sep 17 00:00:00 2001 From: Justin W Smith Date: Wed, 26 Feb 2025 14:27:56 +0000 Subject: [PATCH] Integration test for libssh2 --- .github/workflows/integrations.yml | 12 ++++ .../ci/integration/run_libssh2_integration.sh | 63 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 tests/ci/integration/run_libssh2_integration.sh diff --git a/.github/workflows/integrations.yml b/.github/workflows/integrations.yml index d04758e939..85130a248f 100644 --- a/.github/workflows/integrations.yml +++ b/.github/workflows/integrations.yml @@ -10,6 +10,18 @@ concurrency: env: CC: gcc jobs: + libssh2: + if: github.repository_owner == 'aws' + runs-on: ubuntu-latest + steps: + - name: Install OS Dependencies + run: | + sudo apt-get update -o Acquire::Languages=none -o Acquire::Translation=none + sudo apt-get -y --no-install-recommends install cmake gcc ninja-build golang make + - uses: actions/checkout@v4 + - name: Run libssh2 integration tests + run: | + ./tests/ci/integration/run_libssh2_integration.sh python-main: if: github.repository_owner == 'aws' runs-on: ubuntu-latest diff --git a/tests/ci/integration/run_libssh2_integration.sh b/tests/ci/integration/run_libssh2_integration.sh new file mode 100755 index 0000000000..576b162215 --- /dev/null +++ b/tests/ci/integration/run_libssh2_integration.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 OR ISC + +set -exu + +source tests/ci/common_posix_setup.sh + +# Set up environment. + +# SYS_ROOT +# | +# - SRC_ROOT(aws-lc) +# | +# - SCRATCH_FOLDER +# | +# - libssh2 +# - LIBSSH2_BUILD_FOLDER +# - LIBSSH2_INSTALL_FOLDER +# - AWS_LC_BUILD_FOLDER +# - AWS_LC_INSTALL_FOLDER + +# Assumes script is executed from the root of aws-lc directory +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +SCRATCH_FOLDER=${SYS_ROOT}/"LIBSSH2_SCRATCH" +LIBSSH2_SRC_FOLDER="${SCRATCH_FOLDER}/libssh2" +LIBSSH2_PATCH_FOLDER="${SCRIPT_DIR}"/libssh2_patch +LIBSSH2_BUILD_FOLDER="${SCRATCH_FOLDER}/libssh2-build" +LIBSSH2_INSTALL_FOLDER="${SCRATCH_FOLDER}/libssh2-install" +AWS_LC_BUILD_FOLDER="${SCRATCH_FOLDER}/aws-lc-build" +AWS_LC_INSTALL_FOLDER="${SCRATCH_FOLDER}/aws-lc-install" + +mkdir -p "${SCRATCH_FOLDER}" +rm -rf "${SCRATCH_FOLDER:?}"/* + +function libssh2_build() { + cmake "${LIBSSH2_SRC_FOLDER}" -B "${LIBSSH2_BUILD_FOLDER}" -DCRYPTO_BACKEND=OpenSSL -DBUILD_TESTS=1 -DCMAKE_INSTALL_PREFIX="${LIBSSH2_INSTALL_FOLDER}" -DOPENSSL_ROOT_DIR="${AWS_LC_INSTALL_FOLDER}" -DENABLE_WERROR=ON -DENABLE_DEBUG_LOGGING=ON + cmake --build "${LIBSSH2_BUILD_FOLDER}" --target install + ldd "${LIBSSH2_INSTALL_FOLDER}/lib/libssh2.so" | grep "${AWS_LC_INSTALL_FOLDER}" | grep "libcrypto.so" || exit 1 +} + +function libssh2_run_tests() { + pushd "${LIBSSH2_BUILD_FOLDER}" + ctest -VV --output-on-failure + popd +} + +pushd "${SCRATCH_FOLDER}" + +# Get latest libssh2 version. +git clone /~https://github.com/libssh2/libssh2.git "${LIBSSH2_SRC_FOLDER}" +mkdir -p "${AWS_LC_BUILD_FOLDER}" "${AWS_LC_INSTALL_FOLDER}" "${LIBSSH2_BUILD_FOLDER}" "${LIBSSH2_INSTALL_FOLDER}" +ls + +aws_lc_build "$SRC_ROOT" "$AWS_LC_BUILD_FOLDER" "$AWS_LC_INSTALL_FOLDER" -DBUILD_TESTING=OFF -DBUILD_TOOL=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=1 +aws_lc_build "$SRC_ROOT" "$AWS_LC_BUILD_FOLDER" "$AWS_LC_INSTALL_FOLDER" -DBUILD_TESTING=OFF -DBUILD_TOOL=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=0 +export LD_LIBRARY_PATH="${AWS_LC_INSTALL_FOLDER}/lib/:${AWS_LC_INSTALL_FOLDER}/lib64/:${LD_LIBRARY_PATH:-}" + +libssh2_build +libssh2_run_tests + +popd +