diff options
Diffstat (limited to 't/lib-httpd.sh')
-rw-r--r-- | t/lib-httpd.sh | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index b43162ea2a..435a37465a 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -24,18 +24,36 @@ # LIB_HTTPD_MODULE_PATH web server modules path # LIB_HTTPD_PORT listening port # LIB_HTTPD_DAV enable DAV -# LIB_HTTPD_SVN enable SVN +# LIB_HTTPD_SVN enable SVN at given location (e.g. "svn") # LIB_HTTPD_SSL enable SSL # # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at> # -if test -z "$GIT_TEST_HTTPD" +if test -n "$NO_CURL" then - skip_all="Network testing disabled (define GIT_TEST_HTTPD to enable)" + skip_all='skipping test, git built without http support' test_done fi +if test -n "$NO_EXPAT" && test -n "$LIB_HTTPD_DAV" +then + skip_all='skipping test, git built without expat support' + test_done +fi + +test_tristate GIT_TEST_HTTPD +if test "$GIT_TEST_HTTPD" = false +then + skip_all="Network testing disabled (unset GIT_TEST_HTTPD to enable)" + test_done +fi + +if ! test_have_prereq NOT_ROOT; then + test_skip_or_die $GIT_TEST_HTTPD \ + "Cannot run httpd tests as root" +fi + HTTPD_PARA="" for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2' @@ -73,15 +91,15 @@ HTTPD_DOCUMENT_ROOT_PATH=$HTTPD_ROOT_PATH/www # hack to suppress apache PassEnv warnings GIT_VALGRIND=$GIT_VALGRIND; export GIT_VALGRIND GIT_VALGRIND_OPTIONS=$GIT_VALGRIND_OPTIONS; export GIT_VALGRIND_OPTIONS +GIT_TRACE=$GIT_TRACE; export GIT_TRACE if ! test -x "$LIB_HTTPD_PATH" then - skip_all="skipping test, no web server found at '$LIB_HTTPD_PATH'" - test_done + test_skip_or_die $GIT_TEST_HTTPD "no web server found at '$LIB_HTTPD_PATH'" fi -HTTPD_VERSION=`$LIB_HTTPD_PATH -v | \ - sed -n 's/^Server version: Apache\/\([0-9]*\)\..*$/\1/p; q'` +HTTPD_VERSION=$($LIB_HTTPD_PATH -v | \ + sed -n 's/^Server version: Apache\/\([0-9]*\)\..*$/\1/p; q') if test -n "$HTTPD_VERSION" then @@ -89,25 +107,31 @@ then then if ! test $HTTPD_VERSION -ge 2 then - skip_all="skipping test, at least Apache version 2 is required" - test_done + test_skip_or_die $GIT_TEST_HTTPD \ + "at least Apache version 2 is required" fi if ! test -d "$DEFAULT_HTTPD_MODULE_PATH" then - skip_all="Apache module directory not found. Skipping tests." - test_done + test_skip_or_die $GIT_TEST_HTTPD \ + "Apache module directory not found" fi LIB_HTTPD_MODULE_PATH="$DEFAULT_HTTPD_MODULE_PATH" fi else - error "Could not identify web server at '$LIB_HTTPD_PATH'" + test_skip_or_die $GIT_TEST_HTTPD \ + "Could not identify web server at '$LIB_HTTPD_PATH'" fi +install_script () { + write_script "$HTTPD_ROOT_PATH/$1" <"$TEST_PATH/$1" +} + prepare_httpd() { mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH" cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH" - cp "$TEST_PATH"/broken-smart-http.sh "$HTTPD_ROOT_PATH" + install_script broken-smart-http.sh + install_script error.sh ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules" @@ -131,15 +155,17 @@ prepare_httpd() { HTTPD_URL_USER=$HTTPD_PROTO://user%40host@$HTTPD_DEST HTTPD_URL_USER_PASS=$HTTPD_PROTO://user%40host:pass%40host@$HTTPD_DEST - if test -n "$LIB_HTTPD_DAV" -o -n "$LIB_HTTPD_SVN" + if test -n "$LIB_HTTPD_DAV" || test -n "$LIB_HTTPD_SVN" then HTTPD_PARA="$HTTPD_PARA -DDAV" if test -n "$LIB_HTTPD_SVN" then HTTPD_PARA="$HTTPD_PARA -DSVN" - rawsvnrepo="$HTTPD_ROOT_PATH/svnrepo" - svnrepo="http://127.0.0.1:$LIB_HTTPD_PORT/svn" + LIB_HTTPD_SVNPATH="$rawsvnrepo" + svnrepo="http://127.0.0.1:$LIB_HTTPD_PORT/" + svnrepo="$svnrepo$LIB_HTTPD_SVN" + export LIB_HTTPD_SVN LIB_HTTPD_SVNPATH fi fi } @@ -155,9 +181,9 @@ start_httpd() { >&3 2>&4 if test $? -ne 0 then - skip_all="skipping test, web server setup failed" trap 'die' EXIT - test_done + cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null + test_skip_or_die $GIT_TEST_HTTPD "web server setup failed" fi } |