-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathruntests_obsd.sh
More file actions
executable file
·117 lines (100 loc) · 2.59 KB
/
runtests_obsd.sh
File metadata and controls
executable file
·117 lines (100 loc) · 2.59 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
#set -x
#set -v
ulimit -S -c unlimited
CITRINE_MEMORY_LIMIT_MB=10
export CITRINE_MEMORY_LIMIT_MB
PLATFORMCODE="obsd"
export PLATFORMCODE
BUILD="${1:-build}"
if [[ $BUILD == "build" ]]; then
LDFLAGS='-shared'
ISO="en"
export ISO
gmake clean
EXTRACFLAGS="-D TEST"
gmake -f makefile.obsd clean
PACKAGE="server" NAME="server.so" gmake -f makefile.obsd plugin-clean
gmake -f makefile.obsd
PACKAGE="server" NAME="server.so" gmake -f makefile.obsd plugin
fi
setup1() {
i=$1
REQUEST_METHOD="POST" \
CONTENT_TYPE="application/x-www-form-urlencoded" \
CONTENT_LENGTH=20 \
QUERY_STRING="a=2&b=4&d[]=a&d[]=b&f[]=1&f[]=2" \
HTTP_COOKIE="xsid=abc123" \
FFITESTLIB="/usr/lib/libc.so.102.0" \
./xo ../../../tests/t-$i.ctr 1>/tmp/rs 2>/tmp/err < <(echo -n 'c=3&e[]=1&e[]=2&xx=1')
}
setup2() {
i=$1
BOUNDARY='------------------------abcdef1234567890'
BODY=$(printf -- '--%s\r\nContent-Disposition: form-data; name="c"\r\n\r\n2\r\n--%s\r\nContent-Disposition: form-data; name="file"; filename="hello.txt"\r\nContent-Type: text/plain\r\n\r\nhello file\r\n--%s--\r\n' "$BOUNDARY" "$BOUNDARY" "$BOUNDARY")
printf '%s' "$BODY" | \
CONTENT_TYPE="multipart/form-data; boundary=$BOUNDARY" \
CONTENT_LENGTH=${#BODY} \
REQUEST_METHOD=POST \
./xo ../../../tests/t-$i.ctr 1>/tmp/rs 2>/tmp/err
}
unittest() {
i=$1
mmode=$2
CITRINE_MEMORY_MODE=$mmode
export CITRINE_MEMORY_MODE
if [[ $i == "0635" ]]; then
setup2 $i
else
setup1 $i
fi
cat /tmp/rs /tmp/err > /tmp/out
if ! test -f ../../../tests/exp/en/test${i}en.exp; then
if ! touch ../../../tests/exp/en/test${i}en.exp; then
exit 1
fi
fi
skipcode=$(head -n1 ../../../tests/t-$1.ctr)
if [[ "$skipcode" == "#Linux" ]]; then
echo "SKIP Linux-only test"
return
fi
code="$(< ../../../tests/t-$i.ctr)"
observed="$(< /tmp/out)"
expected="$(< ../../../tests/exp/en/test${i}en.exp)"
sed '$ { /^$/d; }' ../../../tests/exp/en/test${i}en.exp > /tmp/out2
sed '$ { /^$/d; }' /tmp/out > /tmp/out3
diff="$(diff -bw /tmp/out3 /tmp/out2)"
if [[ $diff != "" ]]; then
echo "𐄂 test $i"
echo $skipcode
echo "expected:"
echo "|$expected|"
echo "observed:"
echo "|$observed|"
echo "diff:"
diff -bw ../../../tests/exp/en/test${i}en.exp /tmp/out
echo "code:"
echo $code
read -p "save new test result? (y/n)" answer
if [[ $answer == "y" ]]; then
cat /tmp/out > ../../../tests/exp/en/test${i}en.exp
echo "recorded."
else
exit 1
fi
else
echo "✓ test $i | $mmode"
fi
}
# select range
FROM=1
TIL=687
pushd build/OpenBSD/bin
for i in $(seq -f "%04g" $FROM $TIL);
do
unittest $i 1
unittest $i 4
unittest $i 0
done
popd