|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | +# SPDX-License-Identifier: Apache-2.0 OR ISC |
| 4 | + |
| 5 | +set -exu |
| 6 | + |
| 7 | +source tests/ci/common_posix_setup.sh |
| 8 | + |
| 9 | +# Set up environment. |
| 10 | + |
| 11 | +# SYS_ROOT |
| 12 | +# | |
| 13 | +# - SRC_ROOT(aws-lc) |
| 14 | +# | |
| 15 | +# - SCRATCH_FOLDER |
| 16 | +# | |
| 17 | +# - httpd |
| 18 | +# - httpd-install |
| 19 | +# - aws-lc-build |
| 20 | +# - aws-lc-install |
| 21 | + |
| 22 | +# Assumes script is executed from the root of aws-lc directory |
| 23 | +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 24 | +HTTPD_PATCH_FOLDER="${SCRIPT_DIR}/httpd_patch" |
| 25 | + |
| 26 | +SCRATCH_FOLDER=${SYS_ROOT}/"SCRATCH-httpd-integ" |
| 27 | +HTTPD_SRC_FOLDER="${SCRATCH_FOLDER}/httpd" |
| 28 | +HTTPD_INSTALL_FOLDER="${SCRATCH_FOLDER}/httpd-install" |
| 29 | +AWS_LC_BUILD_FOLDER="${SCRATCH_FOLDER}/aws-lc-build" |
| 30 | +AWS_LC_INSTALL_FOLDER="${SCRATCH_FOLDER}/aws-lc-install" |
| 31 | + |
| 32 | +if [ $# -eq 0 ]; then |
| 33 | + # Use tag "2.4.65" if none specified |
| 34 | + HTTPD_TAGS=("2.4.65") |
| 35 | +else |
| 36 | + HTTPD_TAGS=("$@") |
| 37 | +fi |
| 38 | + |
| 39 | +mkdir -p ${SCRATCH_FOLDER} |
| 40 | +rm -rf "${SCRATCH_FOLDER:?}"/* |
| 41 | +cd ${SCRATCH_FOLDER} |
| 42 | + |
| 43 | +# Dependencies: Ubuntu |
| 44 | +if [ "$(id -u)" -eq 0 ]; then |
| 45 | + apt update |
| 46 | + apt install -y libpcre2-dev libnghttp2-dev nghttp2-client zlib1g-dev libtool-bin libxml2-dev pebble python3-venv |
| 47 | +fi |
| 48 | + |
| 49 | +function run_httpd_test() { |
| 50 | + local HTTPD_TAG=$1 |
| 51 | + echo "Running httpd integration test for tag: ${HTTPD_TAG}" |
| 52 | + |
| 53 | + # Clean up previous build |
| 54 | + rm -rf "${HTTPD_SRC_FOLDER:?}" "${HTTPD_INSTALL_FOLDER:?}" |
| 55 | + mkdir -p "${HTTPD_INSTALL_FOLDER}" |
| 56 | + |
| 57 | + # Clone httpd and APR |
| 58 | + git clone https://github.com/apache/httpd.git "${HTTPD_SRC_FOLDER}" --depth 1 |
| 59 | + cd "${HTTPD_SRC_FOLDER}" |
| 60 | + git fetch --tags origin |
| 61 | + git checkout -b branch-for-${HTTPD_TAG} ${HTTPD_TAG} |
| 62 | + git clone https://github.com/apache/apr.git srclib/apr --depth 1 |
| 63 | + |
| 64 | + # Build httpd from source |
| 65 | + pushd "${HTTPD_SRC_FOLDER}" |
| 66 | + httpd_patch |
| 67 | + httpd_build |
| 68 | + |
| 69 | + # Ensure httpd is linked to AWS-LC |
| 70 | + nm --defined-only "${HTTPD_INSTALL_FOLDER}/bin/httpd" | grep -q awslc_version_string |
| 71 | + |
| 72 | + # Setup Python environment and run tests |
| 73 | + setup_python_env |
| 74 | + httpd_run_tests |
| 75 | + popd |
| 76 | + |
| 77 | + cd ${SCRATCH_FOLDER} |
| 78 | +} |
| 79 | + |
| 80 | +function httpd_patch() { |
| 81 | + # if the directory exists |
| 82 | + if [ -d "${HTTPD_PATCH_FOLDER}/${HTTPD_TAG}" ]; then |
| 83 | + patch -p1 --quiet -i "${HTTPD_PATCH_FOLDER}/${HTTPD_TAG}"/* |
| 84 | + else |
| 85 | + echo "No patches found for httpd tag: '${HTTPD_TAG}'" |
| 86 | + fi |
| 87 | +} |
| 88 | + |
| 89 | +function httpd_build() { |
| 90 | + ./buildconf |
| 91 | + ./configure \ |
| 92 | + "CFLAGS=-I/usr/include/libxml2" \ |
| 93 | + --prefix="${HTTPD_INSTALL_FOLDER}" \ |
| 94 | + --with-included-apr \ |
| 95 | + --with-ssl="${AWS_LC_INSTALL_FOLDER}" \ |
| 96 | + --enable-mpms-shared="all" \ |
| 97 | + --enable-mods-shared="most" \ |
| 98 | + --with-libxml2=/usr \ |
| 99 | + --enable-mods-static="access_compat actions alias asis authn_core authz_core autoindex cgi deflate dir env expires filter headers include log_config mime negotiation proxy proxy_http proxy_http2 remoteip rewrite setenvif slotmem_shm ssl status unixd version" |
| 100 | + make -j "$NUM_CPU_THREADS" |
| 101 | + make install |
| 102 | +} |
| 103 | + |
| 104 | +function setup_python_env() { |
| 105 | + python3 -m venv venv |
| 106 | + source venv/bin/activate |
| 107 | + python3 -m pip install --upgrade pip |
| 108 | + python3 -m pip install pyopenssl websockets pytest filelock python-multipart |
| 109 | +} |
| 110 | + |
| 111 | +function httpd_run_tests() { |
| 112 | + source venv/bin/activate |
| 113 | + # Disabled tests: |
| 114 | + # * Tests relating to TLS renegotiation -- This feature is disabled by default in AWS-LC. |
| 115 | + # * Tests relating to mod_md -- not built |
| 116 | + # * "test_h2_106_02" had intermittent failures |
| 117 | + # -- The test ignores exit status 55 (CURL_SEND_ERROR), but fails when it's 56 (CURL_RECV_ERROR). It should ignore both. |
| 118 | + # There seems to be a subtle behavioral difference here between OpenSSL and AWS-LC. |
| 119 | + python3 -m pytest test -k "not TestSslRenegotiation and not test_md_ and not test_h2_106_02" |
| 120 | +} |
| 121 | + |
| 122 | +# Static build for AWS-LC |
| 123 | +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 |
| 124 | + |
| 125 | +# Run tests for each tag |
| 126 | +for HTTPD_TAG in "${HTTPD_TAGS[@]}"; do |
| 127 | + run_httpd_test "$HTTPD_TAG" |
| 128 | +done |
0 commit comments