5 if [ -n "$SKIP_TESTS" ]; then
9 # Windows doesn't run the NTLM tests properly (yet)
10 if [[ "$(uname -s)" == MINGW
* ]]; then
14 SOURCE_DIR
=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
16 TMPDIR
=${TMPDIR:-/tmp}
17 USER
=${USER:-$(whoami)}
25 if [ ! -z "$GITDAEMON_PID" ]; then
26 echo "Stopping git daemon..."
30 if [ ! -z "$SSHD_DIR" -a -f "${SSHD_DIR}/pid" ]; then
31 echo "Stopping SSH..."
32 kill $
(cat "${SSHD_DIR}/pid")
39 if [[ "$GITTEST_FLAKY_RETRY" > 0 ]]; then
40 ATTEMPTS_REMAIN
=$GITTEST_FLAKY_RETRY
46 while [[ "$ATTEMPTS_REMAIN" > 0 ]]; do
47 if [ "$FAILED" -eq 1 ]; then
49 echo "Re-running flaky ${1} tests..."
55 CLAR_SUMMARY
="${BUILD_DIR}/results_${1}.xml" ctest -V -R "^${1}$" || RETURN_CODE
=$?
&& true
57 if [ "$RETURN_CODE" -eq 0 ]; then
62 echo "Test exited with code: $RETURN_CODE"
63 ATTEMPTS_REMAIN
="$(($ATTEMPTS_REMAIN-1))"
67 if [ "$FAILED" -ne 0 ]; then
68 if [ "$CONTINUE_ON_FAILURE" -ne 1 ]; then
76 # Configure the test environment; run them early so that we're certain
77 # that they're started by the time we need them.
79 echo "##############################################################################"
80 echo "## Configuring test environment"
81 echo "##############################################################################"
83 if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
84 echo "Starting git daemon..."
85 GITDAEMON_DIR
=`mktemp -d ${TMPDIR}/gitdaemon.XXXXXXXX`
86 git init
--bare "${GITDAEMON_DIR}/test.git"
87 git daemon
--listen=localhost
--export-all --enable=receive-pack
--base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev
/null
&
92 if [ -z "$SKIP_PROXY_TESTS" ]; then
93 curl
--location --silent --show-error https
://github.com
/ethomson
/poxyproxy
/releases
/download
/v0.7
.0/poxyproxy-0.7
.0.jar
>poxyproxy.jar
96 echo "Starting HTTP proxy (Basic)..."
97 java
-jar poxyproxy.jar
--address 127.0.0.1 --port 8080 --credentials foo
:bar
--auth-type basic
--quiet &
100 echo "Starting HTTP proxy (NTLM)..."
101 java
-jar poxyproxy.jar
--address 127.0.0.1 --port 8090 --credentials foo
:bar
--auth-type ntlm
--quiet &
104 if [ -z "$SKIP_NTLM_TESTS" ]; then
105 curl
--location --silent --show-error https
://github.com
/ethomson
/poxygit
/releases
/download
/v0.4
.0/poxygit-0.4
.0.jar
>poxygit.jar
108 echo "Starting HTTP server..."
109 NTLM_DIR
=`mktemp -d ${TMPDIR}/ntlm.XXXXXXXX`
110 git init
--bare "${NTLM_DIR}/test.git"
111 java
-jar poxygit.jar
--address 127.0.0.1 --port 9000 --credentials foo
:baz
--quiet "${NTLM_DIR}" &
114 if [ -z "$SKIP_SSH_TESTS" ]; then
115 echo "Starting ssh daemon..."
116 HOME
=`mktemp -d ${TMPDIR}/home.XXXXXXXX`
117 SSHD_DIR
=`mktemp -d ${TMPDIR}/sshd.XXXXXXXX`
118 git init
--bare "${SSHD_DIR}/test.git"
119 cat >"${SSHD_DIR}/sshd_config" <<-EOF
121 ListenAddress 0.0.0.0
123 HostKey ${SSHD_DIR}/id_rsa
124 PidFile ${SSHD_DIR}/pid
125 AuthorizedKeysFile ${HOME}/.ssh/authorized_keys
127 RSAAuthentication yes
128 PasswordAuthentication yes
129 PubkeyAuthentication yes
130 ChallengeResponseAuthentication no
132 # Required here as sshd will simply close connection otherwise
135 ssh-keygen
-t rsa
-f "${SSHD_DIR}/id_rsa" -N "" -q
136 /usr
/sbin
/sshd
-f "${SSHD_DIR}/sshd_config" -E "${SSHD_DIR}/log"
140 ssh-keygen
-t rsa
-f "${HOME}/.ssh/id_rsa" -N "" -q
141 cat "${HOME}/.ssh/id_rsa.pub" >>"${HOME}/.ssh/authorized_keys"
142 while read algorithm key comment
; do
143 echo "[localhost]:2222 $algorithm $key" >>"${HOME}/.ssh/known_hosts"
144 done <"${SSHD_DIR}/id_rsa.pub"
146 # Get the fingerprint for localhost and remove the colons so we can
147 # parse it as a hex number. Older versions have a different output
149 if [[ $
(ssh -V 2>&1) == OpenSSH_6
* ]]; then
150 SSH_FINGERPRINT
=$
(ssh-keygen
-F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l |
tail -n 1 | cut
-d ' ' -f 2 |
tr -d ':')
152 SSH_FINGERPRINT
=$
(ssh-keygen
-E md5
-F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l |
tail -n 1 | cut
-d ' ' -f 3 | cut
-d : -f2- |
tr -d :)
156 # Run the tests that do not require network connectivity.
158 if [ -z "$SKIP_OFFLINE_TESTS" ]; then
160 echo "##############################################################################"
161 echo "## Running (offline) tests"
162 echo "##############################################################################"
167 if [ -n "$RUN_INVASIVE_TESTS" ]; then
169 echo "Running invasive tests"
172 export GITTEST_INVASIVE_FS_SIZE
=1
173 export GITTEST_INVASIVE_MEMORY
=1
174 export GITTEST_INVASIVE_SPEED
=1
176 unset GITTEST_INVASIVE_FS_SIZE
177 unset GITTEST_INVASIVE_MEMORY
178 unset GITTEST_INVASIVE_SPEED
181 if [ -z "$SKIP_ONLINE_TESTS" ]; then
182 # Run the online tests. The "online" test suite only includes the
183 # default online tests that do not require additional configuration.
184 # The "proxy" and "ssh" test suites require further setup.
187 echo "##############################################################################"
188 echo "## Running (online) tests"
189 echo "##############################################################################"
191 export GITTEST_FLAKY_RETRY
=5
193 unset GITTEST_FLAKY_RETRY
195 # Run the online tests that immutably change global state separately
196 # to avoid polluting the test environment.
198 echo "##############################################################################"
199 echo "## Running (online_customcert) tests"
200 echo "##############################################################################"
201 run_test online_customcert
204 if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
206 echo "Running gitdaemon tests"
209 export GITTEST_REMOTE_URL
="git://localhost/test.git"
211 unset GITTEST_REMOTE_URL
214 if [ -z "$SKIP_PROXY_TESTS" ]; then
216 echo "Running proxy tests (Basic authentication)"
219 export GITTEST_REMOTE_PROXY_HOST
="localhost:8080"
220 export GITTEST_REMOTE_PROXY_USER
="foo"
221 export GITTEST_REMOTE_PROXY_PASS
="bar"
223 unset GITTEST_REMOTE_PROXY_HOST
224 unset GITTEST_REMOTE_PROXY_USER
225 unset GITTEST_REMOTE_PROXY_PASS
228 echo "Running proxy tests (NTLM authentication)"
231 export GITTEST_REMOTE_PROXY_HOST
="localhost:8090"
232 export GITTEST_REMOTE_PROXY_USER
="foo"
233 export GITTEST_REMOTE_PROXY_PASS
="bar"
234 export GITTEST_FLAKY_RETRY
=5
236 unset GITTEST_FLAKY_RETRY
237 unset GITTEST_REMOTE_PROXY_HOST
238 unset GITTEST_REMOTE_PROXY_USER
239 unset GITTEST_REMOTE_PROXY_PASS
242 if [ -z "$SKIP_NTLM_TESTS" ]; then
244 echo "Running NTLM tests (IIS emulation)"
247 export GITTEST_REMOTE_URL
="http://localhost:9000/ntlm/test.git"
248 export GITTEST_REMOTE_USER
="foo"
249 export GITTEST_REMOTE_PASS
="baz"
250 run_test auth_clone_and_push
251 unset GITTEST_REMOTE_URL
252 unset GITTEST_REMOTE_USER
253 unset GITTEST_REMOTE_PASS
256 echo "Running NTLM tests (Apache emulation)"
259 export GITTEST_REMOTE_URL
="http://localhost:9000/broken-ntlm/test.git"
260 export GITTEST_REMOTE_USER
="foo"
261 export GITTEST_REMOTE_PASS
="baz"
262 run_test auth_clone_and_push
263 unset GITTEST_REMOTE_URL
264 unset GITTEST_REMOTE_USER
265 unset GITTEST_REMOTE_PASS
268 if [ -z "$SKIP_NEGOTIATE_TESTS" -a -n "$GITTEST_NEGOTIATE_PASSWORD" ]; then
270 echo "Running SPNEGO tests"
273 if [ "$(uname -s)" = "Darwin" ]; then
274 KINIT_FLAGS
="--password-file=STDIN"
277 echo $GITTEST_NEGOTIATE_PASSWORD | kinit
$KINIT_FLAGS test@LIBGIT2.ORG
280 export GITTEST_REMOTE_URL
="https://test.libgit2.org/kerberos/empty.git"
281 export GITTEST_REMOTE_DEFAULT
="true"
283 unset GITTEST_REMOTE_URL
284 unset GITTEST_REMOTE_DEFAULT
287 echo "Running SPNEGO tests (expect/continue)"
290 export GITTEST_REMOTE_URL
="https://test.libgit2.org/kerberos/empty.git"
291 export GITTEST_REMOTE_DEFAULT
="true"
292 export GITTEST_REMOTE_EXPECTCONTINUE
="true"
294 unset GITTEST_REMOTE_URL
295 unset GITTEST_REMOTE_DEFAULT
296 unset GITTEST_REMOTE_EXPECTCONTINUE
301 if [ -z "$SKIP_SSH_TESTS" ]; then
303 echo "Running ssh tests"
306 export GITTEST_REMOTE_URL
="ssh://localhost:2222/$SSHD_DIR/test.git"
307 export GITTEST_REMOTE_USER
=$USER
308 export GITTEST_REMOTE_SSH_KEY
="${HOME}/.ssh/id_rsa"
309 export GITTEST_REMOTE_SSH_PUBKEY
="${HOME}/.ssh/id_rsa.pub"
310 export GITTEST_REMOTE_SSH_PASSPHRASE
=""
311 export GITTEST_REMOTE_SSH_FINGERPRINT
="${SSH_FINGERPRINT}"
313 unset GITTEST_REMOTE_URL
314 unset GITTEST_REMOTE_USER
315 unset GITTEST_REMOTE_SSH_KEY
316 unset GITTEST_REMOTE_SSH_PUBKEY
317 unset GITTEST_REMOTE_SSH_PASSPHRASE
318 unset GITTEST_REMOTE_SSH_FINGERPRINT
321 if [ -z "$SKIP_FUZZERS" ]; then
323 echo "##############################################################################"
324 echo "## Running fuzzers"
325 echo "##############################################################################"
332 if [ "$SUCCESS" -ne 1 ]; then
333 echo "Some tests failed."