3 # This is based on git's t/lib-httpd.sh, which is
4 # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
7 if test -n "$DFE_TEST_SKIP_HTTPD"
9 echo "skipping test (undef DFE_TEST_SKIP_HTTPD to enable)"
13 LIB_HTTPD_PATH
=${LIB_HTTPD_PATH-'/usr/sbin/httpd'}
14 LIB_HTTPD_PORT
=${LIB_HTTPD_PORT-'8111'}
16 HTTPD_ROOT_PATH
="$PWD"/httpd
17 HTTPD_DOCUMENT_ROOT_PATH
=$HTTPD_ROOT_PATH/www
19 if ! test -x "$LIB_HTTPD_PATH"
21 echo "skipping test, no web server found at '$LIB_HTTPD_PATH'"
25 HTTPD_VERSION
=`$LIB_HTTPD_PATH -v | \
26 sed -n 's/^Server version: Apache\/\([0-9]*\)\..*$/\1/p; q'`
28 if test -n "$HTTPD_VERSION"
30 if test -z "$LIB_HTTPD_MODULE_PATH"
32 if ! test $HTTPD_VERSION -ge 2
34 echo "skipping test, at least Apache version 2 is required"
38 LIB_HTTPD_MODULE_PATH
='/usr/lib/apache'
41 error
"Could not identify web server at '$LIB_HTTPD_PATH'"
44 HTTPD_PARA
="-d $HTTPD_ROOT_PATH -f $HTTPD_ROOT_PATH/apache.conf"
47 mkdir
-p $HTTPD_DOCUMENT_ROOT_PATH
49 ln -s $LIB_HTTPD_MODULE_PATH $HTTPD_ROOT_PATH/modules
51 echo "PidFile httpd.pid" > $HTTPD_ROOT_PATH/apache.conf
52 echo "DocumentRoot www" >> $HTTPD_ROOT_PATH/apache.conf
53 echo "ErrorLog error.log" >> $HTTPD_ROOT_PATH/apache.conf
55 HTTPD_URL
=http
://127.0.0.1:$LIB_HTTPD_PORT
61 "$LIB_HTTPD_PATH" $HTTPD_PARA \
62 -c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start
66 "$LIB_HTTPD_PATH" $HTTPD_PARA -k stop