run.sh - geomyidae-tests - geomyidae tests
HTML git clone git://bitreich.org/geomyidae-tests/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae-tests/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
run.sh (1501B)
---
1 #!/bin/sh
2 bin="$(pwd)/../geomyidae/geomyidae"
3 host="127.0.0.1"
4 port="7070"
5 base="$(pwd)"
6 user="$(stat -c '%U' Makefile)" # stat -f on OpenBSD
7 group="$(stat -c '%G' Makefile)"
8
9 tls=0
10 chroot=0
11 counter=0
12 run_tests() {
13 while read -r line; do
14 printf '%s\r\n' "$line" | nc "$host" "$port"
15
16 f="results/${counter}.txt"
17 if test -f "$f"; then
18 echo "" >> "$f"
19 echo "request path was: $line, tls=$tls, chroot=$chroot" >> "$f"
20 counter=$((counter + 1))
21 fi
22 done < tests
23 }
24
25 uid=$(id -u)
26 if test "$uid" != "0"; then
27 echo "needs to be run as root to be able to chroot the daemon, etc" >&2
28 exit 1
29 fi
30
31 # setup and clean previous tests
32 rm -rf results
33 mkdir -p results
34 chown "$user:$group" results
35 rm -f test_counter.txt
36 # subdirectory
37 mkdir -p deepah
38 chown "$user:$group" deepah
39 cd deepah || exit 1
40 # remove previous symlinks.
41 # recreate symlinks.
42 test -e test.cgi || ln -sf ../test.cgi test.cgi
43 test -e results || ln -sf ../results results
44 test -e test_counter.txt || ln -sf ../test_counter.txt test_counter.txt
45 cd ../ || exit 1
46
47 "$bin" -4 -d -b "$base" -p "$port" -o "$port" -h "$host" -u "$user" -g "$group" &
48 pid=$!
49 #echo "PID is: $pid" >&2
50 run_tests
51 kill "$pid"
52
53 chroot=1
54 "$bin" -4 -c -d -b "$base" -p "$port" -o "$port" -h "$host" -u "$user" -g "$group" &
55 pid=$!
56 #echo "PID is: $pid" >&2
57 run_tests
58 kill "$pid"
59
60 # TOOD: test TLS in chroot and non-chroot also.
61 #tls=1
62 #chroot=0
63 #start geomyidae
64 #run_tests
65 #kill geomyidae
66
67 #tls=1
68 #chroot=1
69 #start geomyidae
70 #run_tests
71 #kill geomyidae
72
73 echo "done"