Changeset 300ae82 in mod_gnutls for test/runtests


Ignore:
Timestamp:
Apr 16, 2018, 8:42:39 PM (3 years ago)
Author:
Daniel Kahn Gillmor <dkg@…>
Branches:
debian/master, debian/stretch-backports
Children:
8982265
Parents:
639ce77 (diff), f5342b1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge tag 'upstream/0.8.3' into debian/master

Upstream version 0.8.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/runtests

    r639ce77 r300ae82  
    77set -e
    88. ${srcdir}/common.bash
     9. ${srcdir}/apache_service.bash
    910netns_reexec ${@}
    1011
     
    1718    testid=${srcdir}/tests/"$(printf "%02d" "$testid")"_*
    1819fi
     20testdir="$(realpath ${testid})"
    1921
    2022BADVARS=0
    21 for v in APACHE2 TEST_HOST TEST_PORT TEST_QUERY_DELAY TEST_MSVA_WAIT \
     23for v in APACHE2 TEST_HOST TEST_PORT TEST_QUERY_TIMEOUT TEST_SERVICE_WAIT \
    2224                 MSVA_PORT; do
    2325    if [ ! -v "$v" ]; then
     
    3436function pinpoint_error()
    3537{
    36     echo "${1} failed at line ${2}!" >&2
    37 }
    38 trap 'pinpoint_error ${BASH_SOURCE} ${LINENO}' ERR
     38    echo "Command \"${BASH_COMMAND}\" failed. Call trace:" >&2
     39    local stack=0
     40    while caller $((stack++)) >&2; do true; done
     41}
     42trap 'pinpoint_error' ERR
    3943
    4044function stop_msva()
     
    8993        if [ -n "${pid}" ] && ps -p "${pid}"; then
    9094            kill "${pid}"
     95        else
     96            echo "No running process with PID ${pid} (${pidfile})."
    9197        fi
    9298        rm "${pidfile}"
     
    96102function apache_down_err() {
    97103    printf "FAILURE: %s\n" "$TEST_NAME"
    98     ${APACHE2} -f "${t}/apache.conf" -k stop || true
     104    ${APACHE2} -f "${testdir}/apache.conf" -k stop || true
    99105    if [ -e output ]; then
    100106        printf "\ngnutls-cli outputs:\n"
    101107        diff_output_filter_headers "output" "$output" || true
     108    fi
     109
     110    if [ -r "${testdir}/backend.conf" ]; then
     111        apache_service "${testdir}" "backend.conf" stop || true
     112    fi
     113
     114    if [ -r "${testdir}/ocsp.conf" ]; then
     115        apache_service "${testdir}" "ocsp.conf" stop || true
    102116    fi
    103117
     
    123137
    124138    printf "TESTING: initial MSVA verification\n"
    125     # set to 0 if MSVA is up
    126     ret=1
    127139    export MONKEYSPHERE_VALIDATION_AGENT_SOCKET="http://127.0.0.1:$MSVA_PORT"
    128140
    129     # convert TEST_MSVA_WAIT to seconds because that's what "sleep" expects
    130     TEST_MSVA_SLEEP="$((${TEST_MSVA_WAIT} / 1000)).$((${TEST_MSVA_WAIT} % 1000))"
    131     # wait at most TEST_MSVA_MAX_WAIT milliseconds for MSVA to get ready
    132     waited=0
    133     until [ ${ret} -eq 0 ] \
    134               || [ ${waited} -ge ${TEST_MSVA_MAX_WAIT} ]; do
    135         if msva-query-agent https "$(cat client.uid)" x509pem client < client/x509.pem
    136         then
    137             ret=0
    138         else
    139             echo "MSVA not ready yet"
    140         fi
    141         sleep "${TEST_MSVA_SLEEP}"
    142         waited=$((${waited} + ${TEST_MSVA_WAIT}))
    143     done
    144 
     141    msva_test_cmd="msva-query-agent https \"$(cat client.uid)\" x509pem client < client/x509.pem"
    145142    # check if MSVA is up, fail if not
    146     if [ ${ret} -eq 0 ]; then
     143    if wait_ready "${msva_test_cmd}"; then
    147144        printf "\nSUCCESS: initial MSVA verification\n"
    148145    else
     
    152149fi
    153150
    154 TEST_PID="apache2.pid"
    155151# configure locking for the Apache process
    156152if [ -n "${USE_TEST_NAMESPACE}" ]; then
    157153    echo "Using namespaces to isolate tests, no need for locking."
    158154    flock_cmd=""
    159 elif [ -n "${TEST_LOCK}" ]; then
     155elif [ -n "${FLOCK}" ]; then
    160156    flock_cmd="${FLOCK} -w ${TEST_LOCK_WAIT} $(realpath ${TEST_LOCK})"
    161157else
    162158    echo "Locking disabled, using wait based on Apache PID file."
    163     wait_pid_gone "${TEST_PID}"
     159    wait_pid_gone "${TEST_LOCK}"
    164160    flock_cmd=""
    165161fi
    166162
    167 t="$(realpath ${testid})"
    168163export srcdir="$(realpath ${srcdir})"
    169 export TEST_NAME="$(basename "$t")"
     164export TEST_NAME="$(basename "${testdir}")"
    170165output="outputs/${TEST_NAME}.output"
    171166rm -f "$output"
    172167
    173 if [ -e ${t}/fail.* ]; then
     168if [ -e ${testdir}/fail.* ]; then
    174169    EXPECTED_FAILURE="$(printf " (expected: %s)" fail.*)"
    175170else
     
    179174trap apache_down_err EXIT
    180175if [ -n "${USE_MSVA}" ]; then
    181     MONKEYSPHERE_VALIDATION_AGENT_SOCKET="http://127.0.0.1:$MSVA_PORT" \
    182                                         ${flock_cmd} \
    183                                         ${APACHE2} -f "${t}/apache.conf" -k start \
    184         || [ -e "${t}/fail.server" ]
    185 else
    186     ${flock_cmd} \
    187         ${APACHE2} -f "${t}/apache.conf" -k start \
    188         || [ -e "${t}/fail.server" ]
     176    export MONKEYSPHERE_VALIDATION_AGENT_SOCKET="http://127.0.0.1:$MSVA_PORT"
     177fi
     178
     179# If VERBOSE is enabled, log the HTTPD build configuration
     180if [ -n "${VERBOSE}" ]; then
     181    ${APACHE2} -f "${srcdir}/base_apache.conf" -V
     182fi
     183
     184# Start OCSP responder, if configured
     185if [ -r "${testdir}/ocsp.conf" ]; then
     186    apache_service "${testdir}" "ocsp.conf" start "${OCSP_LOCK}"
     187    CHECK_OCSP_SERVER="true"
     188    if [ -n "${VERBOSE}" ]; then
     189        echo "OCSP index for the test CA:"
     190        cat authority/ocsp_index.txt
     191    fi
     192fi
     193
     194# Start proxy backend server, if configured
     195if [ -r "${testdir}/backend.conf" ]; then
     196    apache_service "${testdir}" "backend.conf" start "${BACKEND_LOCK}"
     197fi
     198
     199if ! ${flock_cmd} ${APACHE2} -f "${testdir}/apache.conf" -k start; then
     200    if [ -e "${testdir}/fail.server" ]; then
     201        echo "Apache HTTPD failed to start as expected."
     202        exit 0
     203    else
     204        echo "Apache HTTPD unexpectedly failed to start."
     205        exit 1
     206    fi
    189207fi
    190208
     
    195213    fi
    196214    echo "---- Testing OCSP server ----"
    197     ocsptool --ask --nonce --load-issuer authority/x509.pem --load-cert server/x509.pem ${store_ocsp}
     215    wait_ready "ocsptool --ask --nonce --load-issuer authority/x509.pem --load-cert server/x509.pem ${store_ocsp}"
    198216    echo "---- OCSP test done ----"
    199217fi
     
    212230# end with CRLF as required by RFC 7230, Section 3.1.1 regardless of
    213231# the line ends in the input file.
    214 if (sed -r "s/__HOSTNAME__/${TEST_HOST}/;s/\r?$/\r/" <${t}/input && \
    215            run_with_pidfile "${sleep_pidfile}" sleep "${TEST_QUERY_DELAY}" &) | \
    216        gnutls-cli -p "${TEST_PORT}" $(cat ${t}/gnutls-cli.args) "${TEST_HOST}" \
     232if (sed -r "s/__HOSTNAME__/${TEST_HOST}/;s/\r?$/\r/" <${testdir}/input && \
     233           run_with_pidfile "${sleep_pidfile}" sleep "${TEST_QUERY_TIMEOUT}" &) | \
     234       gnutls-cli -p "${TEST_PORT}" $(cat ${testdir}/gnutls-cli.args) "${TEST_HOST}" \
    217235       | tee "$output" && test "${PIPESTATUS[1]}" -eq 0;
    218236then
    219     if [ -e ${t}/fail* ]; then
    220         printf "%s should have failed but succeeded\n" "$(basename "$t")" >&2
     237    if [ -e ${testdir}/fail* ]; then
     238        printf "%s should have failed but succeeded\n" "$(basename "$testdir")" >&2
    221239        exit 1
    222240    fi
    223241else
    224     if [ ! -e ${t}/fail* ]; then
    225         printf "%s should have succeeded but failed\n" "$(basename "$t")" >&2
     242    if [ ! -e ${testdir}/fail* ]; then
     243        printf "%s should have succeeded but failed\n" "$(basename "$testdir")" >&2
    226244        exit 1
    227245    fi
     
    231249unset sleep_pidfile
    232250
    233 if [ -e ${t}/output ] ; then
    234     diff_output_filter_headers "${t}/output" "$output" >&2
     251if [ -e ${testdir}/output ] ; then
     252    diff_output_filter_headers "${testdir}/output" "$output" >&2
    235253fi
    236254if [ -n "${USE_MSVA}" ]; then
     
    239257    trap - EXIT
    240258fi
    241 ${APACHE2} -f "${t}/apache.conf" -k stop || [ -e ${t}/fail.server ]
     259${APACHE2} -f "${testdir}/apache.conf" -k stop || [ -e ${testdir}/fail.server ]
    242260printf "SUCCESS: %s\n" "$TEST_NAME"
     261
     262if [ -r "${testdir}/backend.conf" ]; then
     263    apache_service "${testdir}" "backend.conf" stop || true
     264fi
     265
     266if [ -r "${testdir}/ocsp.conf" ]; then
     267    apache_service "${testdir}" "ocsp.conf" stop || true
     268fi
    243269
    244270if [ -n "${USE_MSVA}" ]; then
Note: See TracChangeset for help on using the changeset viewer.