source: mod_gnutls/test/proxy_backend.bash @ cdc6e4a

debian/masterdebian/stretch-backportsupstream
Last change on this file since cdc6e4a was cdc6e4a, checked in by Thomas Klute <thomas2.klute@…>, 2 years ago

Choose flock or PID wait based on availability, not file parameter presence

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#!/bin/bash
2
3set -e
4. ${srcdir}/common.bash
5
6if [ -z "${BACKEND_HOST}" ]; then
7    export BACKEND_HOST="localhost"
8fi
9if [ -z "${BACKEND_PORT}" ]; then
10    export BACKEND_PORT="9934"
11fi
12: ${BACKEND_PID:="backend.pid"}
13: ${srcdir:="."}
14: ${APACHE2:="apache2"}
15: ${TEST_LOCK_WAIT:="30"}
16
17function backend_apache
18{
19    # needed for start and stop
20    dir="${1}"
21    conf="${2}"
22    action="${3}"
23    # needed only for start
24    lockfile="${4}"
25
26    TEST_NAME="$(basename "${dir}")"
27    (
28        export TEST_NAME
29        export TEST_PORT="${BACKEND_PORT}"
30        export srcdir="$(realpath ${srcdir})"
31        local flock_cmd=""
32        case ${action} in
33            start)
34                if [ -n "${USE_TEST_NAMESPACE}" ]; then
35                    echo "Using namespaces to isolate tests, no need for" \
36                         "locking."
37                elif [ -n "${FLOCK}" ]; then
38                    flock_cmd="${FLOCK} -w ${TEST_LOCK_WAIT} ${lockfile}"
39                else
40                    echo "Locking disabled, using wait based on proxy PID file."
41                    wait_pid_gone "${BACKEND_PID}"
42                fi
43                ${flock_cmd} \
44                    ${APACHE2} -f "$(realpath ${testdir}/${conf})" -k start || return 1
45                ;;
46            stop)
47                ${APACHE2} -f "$(realpath ${testdir}/${conf})" -k stop || return 1
48                ;;
49            *)
50                echo "${FUNCNAME[0]}: Invalid action \"${action}\"." >&2
51                exit 1
52                ;;
53        esac
54    )
55}
Note: See TracBrowser for help on using the repository browser.