-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathtest-fake-ship.sh
More file actions
executable file
·220 lines (173 loc) · 5.34 KB
/
Copy pathtest-fake-ship.sh
File metadata and controls
executable file
·220 lines (173 loc) · 5.34 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
set -xeuo pipefail
urbit_binary=$GITHUB_WORKSPACE/$URBIT_BINARY
# stream all runtime output to the log as it accrues
#
# NB: the runtime must not inherit the CI log pipe on stdout: it puts
# the (shared) pipe in non-blocking mode, causing spurious write
# errors in subsequent commands
#
touch urbit-output
tail -F urbit-output >&2 &
tailproc=$!
cleanup () {
kill $(cat ./pier/.vere.lock) || true
# give tail a moment to flush before killing it
#
sleep 1
kill "$tailproc" 2>/dev/null || true
}
trap cleanup EXIT
if ! $urbit_binary --lite-boot --daemon --gc-abort ./pier >> urbit-output 2>&1; then
echo "ERROR: failed to boot fake ship" >&2
exit 1
fi
port=$(grep loopback ./pier/.http.ports | awk -F ' ' '{print $1}')
pierpid=$(cat ./pier/.vere.lock)
# fail immediately if the urbit process is no longer running
#
check_ship() {
if ! kill -0 "$pierpid" 2>/dev/null; then
echo "ERROR: urbit process exited unexpectedly" >&2
exit 1
fi
}
# NB: xargs chokes on quotes in the response; tolerate that (|| true),
# failing the pipeline only if curl itself fails
#
lensd() {
check_ship
curl -s \
--data "{\"source\":{\"dojo\":\"$1\"},\"sink\":{\"stdout\":null}}" \
"http://localhost:$port" | { xargs printf %s | sed 's/\\n/\n/g' || true; } || {
check_ship
echo "ERROR: lens request failed" >&2
exit 1
}
}
lensa() {
check_ship
curl -s \
--data "{\"source\":{\"dojo\":\"$2\"},\"sink\":{\"app\":\"$1\"}}" \
"http://localhost:$port" | { xargs printf %s | sed 's/\\n/\n/g' || true; } || {
check_ship
echo "ERROR: lens request failed" >&2
exit 1
}
}
# print the arvo version
#
lensd '+vats %base'
# measure initial memory usage
#
lensd '~& ~ ~& %init-mass-start ~'
lensa hood '+hood/mass'
lensd '~& ~ ~& %init-mass-end ~'
# run the unit tests
#
lensd '~& ~ ~& %test-unit-start ~'
lensd '-test %/tests ~'
lensd '~& ~ ~& %test-unit-end ~'
# use the :test app to build all agents, generators, and marks
#
lensa hood '+hood/start %test'
lensd '~& ~ ~& %test-agents-start ~'
lensa test '%agents'
lensd '~& ~ ~& %test-agents-end ~'
lensd '~& ~ ~& %test-generators-start ~'
lensa test '%generators'
lensd '~& ~ ~& %test-generators-end ~'
lensd '~& ~ ~& %test-marks-start ~'
lensa test '%marks'
lensd '~& ~ ~& %test-marks-end ~'
# measure memory usage post tests
#
lensd '~& ~ ~& %test-mass-start ~'
lensa hood '+hood/mass'
lensd '~& ~ ~& %test-mass-end ~'
# defragment the loom
#
lensd '~& ~ ~& %pack-start ~'
lensa hood '+hood/pack'
lensd '~& ~ ~& %pack-end ~'
# reclaim space within arvo
#
lensd '~& ~ ~& %trim-start ~'
lensa hood '+hood/trim'
lensd '~& ~ ~& %trim-end ~'
# measure memory usage pre |meld
#
lensd '~& ~ ~& %trim-mass-start ~'
lensa hood '+hood/mass'
lensd '~& ~ ~& %trim-mass-end ~'
# globally deduplicate
#
lensd '~& ~ ~& %meld-start ~'
lensa hood '+hood/meld'
lensd '~& ~ ~& %meld-end ~'
# measure memory usage post |meld
#
lensd '~& ~ ~& %meld-mass-start ~'
lensa hood '+hood/mass'
lensd '~& ~ ~& %meld-mass-end ~'
lensa hood '+hood/exit'
cleanup
# Collect output
cp urbit-output test-output-unit
cp urbit-output test-output-agents
cp urbit-output test-output-generators
cp urbit-output test-output-marks
if [[ $URBIT_BINARY == *"macos"* ]]; then
sed -i '' '0,/test-unit-start/d' test-output-unit
sed -i '' '/test-unit-end/,$d' test-output-unit
sed -i '' '0,/test-agents-start/d' test-output-agents
sed -i '' '/test-agents-end/,$d' test-output-agents
sed -i '' '0,/test-generators-start/d' test-output-generators
sed -i '' '/test-generators-end/,$d' test-output-generators
sed -i '' '0,/test-marks-start/d' test-output-marks
sed -i '' '/test-marks-end/,$d' test-output-marks
else
sed -i '0,/test-unit-start/d' test-output-unit
sed -i '/test-unit-end/,$d' test-output-unit
sed -i '0,/test-agents-start/d' test-output-agents
sed -i '/test-agents-end/,$d' test-output-agents
sed -i '0,/test-generators-start/d' test-output-generators
sed -i '/test-generators-end/,$d' test-output-generators
sed -i '0,/test-marks-start/d' test-output-marks
sed -i '/test-marks-end/,$d' test-output-marks
fi
OUTDIR="$(pwd)/test-fake-ship-output"
mkdir -p $OUTDIR
cp test-output-* $OUTDIR
set +x
hdr () {
echo =====$(sed 's/./=/g' <<< "$1")=====
echo ==== $1 ====
echo =====$(sed 's/./=/g' <<< "$1")=====
}
for f in $(find "$OUTDIR" -type f); do
hdr "$(basename $f)"
cat "$f" || true
done
fail=0
for f in $(find "$OUTDIR" -type f); do
if egrep "((FAILED|CRASHED)|warn:) " $f >/dev/null; then
if [[ $fail -eq 0 ]]; then
hdr "Test Failures"
fi
echo "ERROR Test failure in $(basename $f)"
fail=$((fail+1))
fi
done
# scan the full runtime output for fatal errors, which indicate a crash
# even if every test that managed to run reported success
#
if egrep "(unexpectedly shut down|serf error:|work exit: status|Assertion ')" urbit-output >/dev/null; then
hdr "Runtime Crash"
echo "ERROR fatal runtime error in urbit-output"
fail=$((fail+1))
fi
if [[ $fail -eq 0 ]]; then
hdr "Success"
fi
exit "$fail"