Skip to content

Commit

Permalink
ci(nix): Setup a head build for the cross_compatibility integ test (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dougch authored Jul 26, 2024
1 parent a29e2ff commit 3c0dfee
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
52 changes: 37 additions & 15 deletions codebuild/bin/install_s2n_head.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
Expand All @@ -12,31 +12,53 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

set -ex
pushd "$(pwd)"
set -eu

usage() {
echo "install_s2n_head.sh build_dir"
exit 1
}

BUILD_DIR=$1
SRC_ROOT=${SRC_ROOT:-$(pwd)}

if [ "$#" -ne "1" ]; then
usage
fi

BUILD_DIR=$1
source codebuild/bin/jobs.sh
cd "$BUILD_DIR"

# Clone the most recent s2n commit
git clone --depth=1 https://github.com/aws/s2n-tls s2n_head
cmake ./s2n_head -Bbuild -DCMAKE_PREFIX_PATH="$LIBCRYPTO_ROOT" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=on -DBUILD_TESTING=on
cmake --build ./build -- -j $JOBS
clone(){
git clone --branch main --single-branch . "$SRC_ROOT"/s2n_head
}

# Copy new executables to bin directory
cp -f "$BUILD_DIR"/build/bin/s2nc "$BASE_S2N_DIR"/bin/s2nc_head
cp -f "$BUILD_DIR"/build/bin/s2nd "$BASE_S2N_DIR"/bin/s2nd_head
# CMake(nix) and Make are using different directory structures.
set +u
if [[ "$IN_NIX_SHELL" ]]; then
export DEST_DIR="$SRC_ROOT"/build/bin
export EXTRA_BUILD_FLAGS=""
else
export DEST_DIR="$SRC_ROOT"/bin
export EXTRA_BUILD_FLAGS="-DCMAKE_PREFIX_PATH=$LIBCRYPTO_ROOT"
fi
set -u

popd
# Cleanup any stale s2n_head clones.
if [[ -d "$SRC_ROOT/s2n_head" ]]; then
now=$(date +%s)
last_modified=$(stat -c %Y s2n_head)
days_old=$(( (now - last_modified) / 86400))
if ((days_old > 1 )); then
echo "s2n_head is $days_old days old, removing and cloning again."
rm -rf s2n_head
clone
else
echo "s2n_head already exists and is $days_old days old."
fi
else
clone
fi
cmake "$SRC_ROOT"/s2n_head -B"$BUILD_DIR" "$EXTRA_BUILD_FLAGS" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=on -DBUILD_TESTING=on
cmake --build "$BUILD_DIR" -- -j "$(nproc)"
cp -f "$BUILD_DIR"/bin/s2nc "$DEST_DIR"/s2nc_head
cp -f "$BUILD_DIR"/bin/s2nd "$DEST_DIR"/s2nd_head

exit 0
15 changes: 7 additions & 8 deletions nix/shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ libcrypto_alias libressl "${LIBRESSL_INSTALL_DIR}/bin/openssl"

function clean {
banner "Cleanup ./build"
rm -rf ./build
rm -rf ./build ./s2n_head
}

function configure {
Expand All @@ -47,6 +47,10 @@ function build {
banner "Running Build"
javac tests/integrationv2/bin/SSLSocketClient.java
cmake --build ./build -j $(nproc)
# Build s2n from HEAD
if [[ -z "${S2N_KTLS_TESTING_EXPECTED}" ]]; then
$SRC_ROOT/codebuild/bin/install_s2n_head.sh $(mktemp -d)
fi
}

function unit {
Expand All @@ -60,21 +64,16 @@ function unit {
function integ {
if [ "$1" == "help" ]; then
echo "The following tests are not supported:"
echo " - cross_compatibility"
echo " This test depends on s2nc_head and s2nd_head. To run"
echo " the test build s2n-tls from the main branch on github."
echo " Change the names of s2n[cd] to s2n[cd]_head and add those"
echo " binaries to \$PATH."
echo "- renegotiate_apache"
echo " This test requires apache to be running. See codebuild/bin/s2n_apache.sh"
echo " for more info."
return
fi
if [[ -z "$1" ]]; then
banner "Running all integ tests except cross_compatibility, renegotiate_apache."
banner "Running all integ tests except renegotiate_apache."
(cd $SRC_ROOT/build; ctest -L integrationv2 -E "(integrationv2_cross_compatibility|integrationv2_renegotiate_apache)" --verbose)
else
banner "Warning: cross_compatibility & renegotiate_apache are not supported in nix for various reasons integ help for more info."
banner "Warning: renegotiate_apache is not supported in nix for various reasons integ help for more info."
for test in $@; do
ctest --test-dir ./build -L integrationv2 --no-tests=error --output-on-failure -R "$test" --verbose
if [ "$?" -ne 0 ]; then
Expand Down

0 comments on commit 3c0dfee

Please sign in to comment.