summaryrefslogtreecommitdiff
path: root/tests/prepare.sh
blob: 873fd80149c2613658c2f1f2ae15a1623c4f3441 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

set -e

if test "x${srcdir}" = "x"; then
	srcdir=.
fi

if test "x${top_builddir}" = "x"; then
	top_builddir=..
fi

echo "Testing in build directory: '${top_builddir}' and cwd: '$(pwd)'"

tmpdir="${top_builddir}/tests/tmp/lighttpd"

# create test-framework
rm -rf "${tmpdir}"
mkdir -p "${tmpdir}/servers/www.example.org/pages/"           \
         "${tmpdir}/servers/www.example.org/pages/dummydir/"  \
         "${tmpdir}/servers/www.example.org/pages/~test รค_/"  \
         "${tmpdir}/servers/www.example.org/pages/expire/"    \
         "${tmpdir}/servers/123.example.org/pages/"           \
         "${tmpdir}/servers/a.example.org/pages/a/"           \
         "${tmpdir}/servers/b.example.org/pages/b/"           \
         "${tmpdir}/logs/"                                    \
         "${tmpdir}/cache/"                                   \
         "${tmpdir}/cache/compress/"

# copy everything into the right places
cp "${srcdir}/docroot/"*.html \
   "${srcdir}/docroot/"*.pl \
   "${srcdir}/docroot/"*.fcgi \
   "${srcdir}/docroot/"*.txt \
   "${tmpdir}/servers/www.example.org/pages/"

# copy configs to alternate build root, if alternate build root is used
# (tests will fail to run from an alternate build root on platforms
#  on which cp -n is not supported, such as NetBSD and OpenBSD)
cp -n "${srcdir}/"*.conf \
      "${srcdir}/lighttpd.user" \
      "${srcdir}/lighttpd.htpasswd" \
      "${srcdir}/var-include-sub.conf" \
      "${top_builddir}/tests/" 2>/dev/null || true

# create some content
touch "${tmpdir}/servers/www.example.org/pages/image.jpg" \
      "${tmpdir}/servers/www.example.org/pages/image.JPG" \
      "${tmpdir}/servers/www.example.org/pages/Foo.txt" \
      "${tmpdir}/servers/www.example.org/pages/a" \
      "${tmpdir}/servers/www.example.org/pages/index.html~" \
      "${tmpdir}/servers/www.example.org/pages/expire/access.txt" \
      "${tmpdir}/servers/www.example.org/pages/expire/modification.txt"
echo "12345" > "${tmpdir}/servers/123.example.org/pages/12345.txt"
echo "12345" > "${tmpdir}/servers/123.example.org/pages/12345.html"
echo "12345" > "${tmpdir}/servers/123.example.org/pages/dummyfile.bla"
echo "12345" > "${tmpdir}/servers/123.example.org/pages/range.disabled"
cat - <<HERE > "${tmpdir}/servers/123.example.org/pages/100.txt"
123456789
123456789
123456789
123456789
123456789
123456789
123456789
123456789
123456789
abcdefghi
HERE

printf "%-40s" "preparing infrastructure"
[ -z "$MAKELEVEL" ] && echo

exit 0