Tests: Smoke-test that the module is returning data
parent
8d47b33509
commit
3789187861
|
@ -0,0 +1,3 @@
|
||||||
|
#! /bin/bash
|
||||||
|
nginx_start
|
||||||
|
grep 'Index of' <( fetch )
|
|
@ -0,0 +1,6 @@
|
||||||
|
#! /bin/bash
|
||||||
|
nginx_start
|
||||||
|
content=$(fetch --with-headers)
|
||||||
|
grep 'Index of /' <<< "${content}" # It is an index
|
||||||
|
grep '\<table\>' <<< "${content}" # It contains a table
|
||||||
|
grep '^ Content-Type:[[:space:]]*text/html' <<< "${content}"
|
|
@ -0,0 +1,25 @@
|
||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
location / {
|
||||||
|
root html;
|
||||||
|
index index.html index.htm;
|
||||||
|
}
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html {
|
||||||
|
root html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
66
t/preamble
66
t/preamble
|
@ -6,6 +6,72 @@
|
||||||
# Distributed under terms of the MIT license.
|
# Distributed under terms of the MIT license.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
function nginx_conf_generate () {
|
||||||
|
if ${DYNAMIC} ; then
|
||||||
|
echo 'load_module modules/ngx_http_fancyindex_module.so;'
|
||||||
|
fi
|
||||||
|
cat <<-EOF
|
||||||
|
worker_processes 1;
|
||||||
|
events { worker_connections 1024; }
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
server {
|
||||||
|
server_name localhost;
|
||||||
|
listen 127.0.0.1:8888;
|
||||||
|
root ${TESTDIR};
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html { root html; }
|
||||||
|
location / {
|
||||||
|
index index.html;
|
||||||
|
fancyindex on;
|
||||||
|
$*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly NGINX_CONF="${PREFIX}/conf/nginx.conf"
|
||||||
|
readonly NGINX_PID="${PREFIX}/logs/nginx.pid"
|
||||||
|
rm -f "${NGINX_CONF}" "${NGINX_PID}"
|
||||||
|
mkdir -p "${PREFIX}/logs"
|
||||||
|
|
||||||
|
function nginx () {
|
||||||
|
"${PREFIX}/sbin/nginx" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
function nginx_conf () {
|
||||||
|
nginx_conf_generate "$@" > "${NGINX_CONF}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function nginx_is_running () {
|
||||||
|
[[ -r ${NGINX_PID} ]] && kill -0 $(< "${NGINX_PID}")
|
||||||
|
}
|
||||||
|
|
||||||
|
function nginx_stop () {
|
||||||
|
if nginx_is_running ; then nginx -s stop ; fi
|
||||||
|
rm -f "${NGINX_PID}"
|
||||||
|
}
|
||||||
|
trap nginx_stop EXIT
|
||||||
|
|
||||||
|
function nginx_start () {
|
||||||
|
if [[ $# -gt 0 || ! -r ${NGINX_CONF} ]] ; then nginx_conf "$@" ; fi
|
||||||
|
nginx_stop # Ensure that it is not running.
|
||||||
|
nginx
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetch () {
|
||||||
|
local -a opts=( -q )
|
||||||
|
if [[ $1 = --with-headers ]] ; then
|
||||||
|
opts+=( -S )
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
wget "${opts[@]}" -O- "http://localhost:8888${1:-/}" 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
function fail () {
|
function fail () {
|
||||||
printf "(FF) "
|
printf "(FF) "
|
||||||
printf "$@"
|
printf "$@"
|
||||||
|
|
13
t/run
13
t/run
|
@ -6,10 +6,16 @@ if [[ $# -lt 1 || $# -gt 2 ]] ; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
readonly T=$(dirname "$0")
|
# Obtain the absolute path to the tests directory
|
||||||
|
pushd "$(dirname "$0")" &> /dev/null
|
||||||
|
readonly T=$(pwd)
|
||||||
|
popd &> /dev/null
|
||||||
export T
|
export T
|
||||||
|
|
||||||
readonly prefix=$1
|
# Same for the nginx prefix directory
|
||||||
|
pushd "$1" &> /dev/null
|
||||||
|
readonly prefix=$(pwd)
|
||||||
|
popd &> /dev/null
|
||||||
|
|
||||||
dynamic=false
|
dynamic=false
|
||||||
if [[ $# -gt 1 && $2 -eq 1 ]] ; then
|
if [[ $# -gt 1 && $2 -eq 1 ]] ; then
|
||||||
|
@ -28,8 +34,9 @@ for t in "$T"/*.test ; do
|
||||||
outfile="${name}.out"
|
outfile="${name}.out"
|
||||||
shfile="${name}.sh"
|
shfile="${name}.sh"
|
||||||
cat > "${shfile}" <<-EOF
|
cat > "${shfile}" <<-EOF
|
||||||
readonly PREFIX='${prefix}'
|
|
||||||
readonly DYNAMIC=${dynamic}
|
readonly DYNAMIC=${dynamic}
|
||||||
|
readonly TESTDIR='$T'
|
||||||
|
readonly PREFIX='${prefix}'
|
||||||
$(< "$T/preamble")
|
$(< "$T/preamble")
|
||||||
$(< "$t")
|
$(< "$t")
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in New Issue