summaryrefslogtreecommitdiff
path: root/ci/test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ci/test.sh')
-rwxr-xr-xci/test.sh134
1 files changed, 112 insertions, 22 deletions
diff --git a/ci/test.sh b/ci/test.sh
index 0815522a9..c46cf0dc4 100755
--- a/ci/test.sh
+++ b/ci/test.sh
@@ -13,22 +13,52 @@ fi
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
BUILD_DIR=$(pwd)
+BUILD_PATH=${BUILD_PATH:=$PATH}
+CTEST=$(which ctest)
TMPDIR=${TMPDIR:-/tmp}
USER=${USER:-$(whoami)}
+HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX`
+export CLAR_HOMEDIR=${HOME}
+
SUCCESS=1
CONTINUE_ON_FAILURE=0
cleanup() {
echo "Cleaning up..."
- if [ ! -z "$GITDAEMON_PID" ]; then
- echo "Stopping git daemon..."
- kill $GITDAEMON_PID
+ if [ ! -z "$GIT_STANDARD_PID" ]; then
+ echo "Stopping git daemon (standard)..."
+ kill $GIT_STANDARD_PID
+ fi
+
+ if [ ! -z "$GIT_NAMESPACE_PID" ]; then
+ echo "Stopping git daemon (namespace)..."
+ kill $GIT_NAMESPACE_PID
+ fi
+
+ if [ ! -z "$GIT_SHA256_PID" ]; then
+ echo "Stopping git daemon (sha256)..."
+ kill $GIT_SHA256_PID
+ fi
+
+ if [ ! -z "$PROXY_BASIC_PID" ]; then
+ echo "Stopping proxy (Basic)..."
+ kill $PROXY_BASIC_PID
+ fi
+
+ if [ ! -z "$PROXY_NTLM_PID" ]; then
+ echo "Stopping proxy (NTLM)..."
+ kill $PROXY_NTLM_PID
+ fi
+
+ if [ ! -z "$HTTP_PID" ]; then
+ echo "Stopping HTTP server..."
+ kill $HTTP_PID
fi
if [ ! -z "$SSHD_DIR" -a -f "${SSHD_DIR}/pid" ]; then
- echo "Stopping SSH..."
+ echo "Stopping SSH server..."
kill $(cat "${SSHD_DIR}/pid")
fi
@@ -52,7 +82,11 @@ run_test() {
RETURN_CODE=0
- CLAR_SUMMARY="${BUILD_DIR}/results_${1}.xml" ctest -V -R "^${1}$" || RETURN_CODE=$? && true
+ (
+ export PATH="${BUILD_PATH}"
+ export CLAR_SUMMARY="${BUILD_DIR}/results_${1}.xml"
+ "${CTEST}" -V -R "^${1}$"
+ ) || RETURN_CODE=$? && true
if [ "$RETURN_CODE" -eq 0 ]; then
FAILED=0
@@ -73,48 +107,81 @@ run_test() {
fi
}
+indent() { sed "s/^/ /"; }
+
+cygfullpath() {
+ result=$(echo "${1}" | tr \; \\n | while read -r element; do
+ if [ "${last}" != "" ]; then echo -n ":"; fi
+ echo -n $(cygpath "${element}")
+ last="${element}"
+ done)
+ if [ "${result}" = "" ]; then exit 1; fi
+ echo "${result}"
+}
+
+if [[ "$(uname -s)" == MINGW* ]]; then
+ BUILD_PATH=$(cygfullpath "$BUILD_PATH")
+fi
+
+
# Configure the test environment; run them early so that we're certain
# that they're started by the time we need them.
+echo "CTest version:"
+env PATH="${BUILD_PATH}" "${CTEST}" --version | head -1 2>&1 | indent
+
+echo ""
+
echo "##############################################################################"
echo "## Configuring test environment"
echo "##############################################################################"
+echo ""
+
if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
- echo "Starting git daemon..."
- GITDAEMON_DIR=`mktemp -d ${TMPDIR}/gitdaemon.XXXXXXXX`
- git init --bare "${GITDAEMON_DIR}/test.git" >/dev/null
- git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null &
- GITDAEMON_PID=$!
- disown $GITDAEMON_PID
+ echo "Starting git daemon (standard)..."
+ GIT_STANDARD_DIR=`mktemp -d ${TMPDIR}/git_standard.XXXXXXXX`
+ git init --bare "${GIT_STANDARD_DIR}/test.git" >/dev/null
+ git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GIT_STANDARD_DIR}" "${GIT_STANDARD_DIR}" 2>/dev/null &
+ GIT_STANDARD_PID=$!
+
+ echo "Starting git daemon (namespace)..."
+ GIT_NAMESPACE_DIR=`mktemp -d ${TMPDIR}/git_namespace.XXXXXXXX`
+ cp -R "${SOURCE_DIR}/tests/resources/namespace.git" "${GIT_NAMESPACE_DIR}/namespace.git"
+ GIT_NAMESPACE="name1" git daemon --listen=localhost --port=9419 --export-all --enable=receive-pack --base-path="${GIT_NAMESPACE_DIR}" "${GIT_NAMESPACE_DIR}" &
+ GIT_NAMESPACE_PID=$!
+
+ echo "Starting git daemon (sha256)..."
+ GIT_SHA256_DIR=`mktemp -d ${TMPDIR}/git_sha256.XXXXXXXX`
+ cp -R "${SOURCE_DIR}/tests/resources/testrepo_256.git" "${GIT_SHA256_DIR}/testrepo_256.git"
+ git daemon --listen=localhost --port=9420 --export-all --enable=receive-pack --base-path="${GIT_SHA256_DIR}" "${GIT_SHA256_DIR}" &
+ GIT_SHA256_PID=$!
fi
if [ -z "$SKIP_PROXY_TESTS" ]; then
curl --location --silent --show-error https://github.com/ethomson/poxyproxy/releases/download/v0.7.0/poxyproxy-0.7.0.jar >poxyproxy.jar
- echo ""
echo "Starting HTTP proxy (Basic)..."
java -jar poxyproxy.jar --address 127.0.0.1 --port 8080 --credentials foo:bar --auth-type basic --quiet &
+ PROXY_BASIC_PID=$!
- echo ""
echo "Starting HTTP proxy (NTLM)..."
java -jar poxyproxy.jar --address 127.0.0.1 --port 8090 --credentials foo:bar --auth-type ntlm --quiet &
+ PROXY_NTLM_PID=$!
fi
if [ -z "$SKIP_NTLM_TESTS" -o -z "$SKIP_ONLINE_TESTS" ]; then
curl --location --silent --show-error https://github.com/ethomson/poxygit/releases/download/v0.5.1/poxygit-0.5.1.jar >poxygit.jar
- echo ""
echo "Starting HTTP server..."
- NTLM_DIR=`mktemp -d ${TMPDIR}/ntlm.XXXXXXXX`
- git init --bare "${NTLM_DIR}/test.git"
- java -jar poxygit.jar --address 127.0.0.1 --port 9000 --credentials foo:baz --quiet "${NTLM_DIR}" &
+ HTTP_DIR=`mktemp -d ${TMPDIR}/http.XXXXXXXX`
+ git init --bare "${HTTP_DIR}/test.git"
+ java -jar poxygit.jar --address 127.0.0.1 --port 9000 --credentials foo:baz --quiet "${HTTP_DIR}" &
+ HTTP_PID=$!
fi
if [ -z "$SKIP_SSH_TESTS" ]; then
- echo ""
- echo "Starting ssh daemon..."
- HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX`
+ echo "Starting SSH server..."
SSHD_DIR=`mktemp -d ${TMPDIR}/sshd.XXXXXXXX`
git init --bare "${SSHD_DIR}/test.git" >/dev/null
cat >"${SSHD_DIR}/sshd_config" <<-EOF
@@ -144,6 +211,11 @@ if [ -z "$SKIP_SSH_TESTS" ]; then
echo "[localhost]:2222 $algorithm $key" >>"${HOME}/.ssh/known_hosts"
done <"${SSHD_DIR}/id_rsa.pub"
+ # Append the github.com keys for the tests that don't override checks.
+ # We ask for ssh-rsa to test that the selection based off of known_hosts
+ # is working.
+ ssh-keyscan -t ssh-rsa github.com >>"${HOME}/.ssh/known_hosts"
+
# Get the fingerprint for localhost and remove the colons so we can
# parse it as a hex number. Older versions have a different output
# format.
@@ -214,12 +286,30 @@ fi
if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
echo ""
- echo "Running gitdaemon tests"
+ echo "Running gitdaemon (standard) tests"
echo ""
export GITTEST_REMOTE_URL="git://localhost/test.git"
run_test gitdaemon
unset GITTEST_REMOTE_URL
+
+ echo ""
+ echo "Running gitdaemon (namespace) tests"
+ echo ""
+
+ export GITTEST_REMOTE_URL="git://localhost:9419/namespace.git"
+ export GITTEST_REMOTE_BRANCH="four"
+ run_test gitdaemon_namespace
+ unset GITTEST_REMOTE_URL
+ unset GITTEST_REMOTE_BRANCH
+
+ echo ""
+ echo "Running gitdaemon (sha256) tests"
+ echo ""
+
+ export GITTEST_REMOTE_URL="git://localhost:9420/testrepo_256.git"
+ run_test gitdaemon_sha256
+ unset GITTEST_REMOTE_URL
fi
if [ -z "$SKIP_PROXY_TESTS" ]; then
@@ -343,7 +433,7 @@ if [ -z "$SKIP_FUZZERS" ]; then
echo "## Running fuzzers"
echo "##############################################################################"
- ctest -V -R 'fuzzer'
+ env PATH="${BUILD_PATH}" "${CTEST}" -V -R 'fuzzer'
fi
cleanup