-
Notifications
You must be signed in to change notification settings - Fork 365
/
test.sh
executable file
·244 lines (196 loc) · 6.35 KB
/
test.sh
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
# Run all known IncludeOS tests.
#
# A lot of these tests require vmrunner and a network bridge.
# See https://github.com/includeos/vmrunner/pull/31
: "${QUICK_SMOKE:=}" # Define this to only do a ~1-5 min. smoke test.
: "${DRY_RUN:=}" # Define this to expand all steps without running any
: "${CCACHE_FLAG:=}" # Define as "--arg withCcache true" to enable ccache.
steps=0
fails=0
failed_tests=()
success(){
echo ""
if [[ $1 =~ ^[0-9]+$ ]]; then
echo -n "👷💬 Step $1 succeeded "
for ((i=1; i<=$1; i++)); do
echo -n "👏"
done
else
echo "👷💬 Step $1 succeeded ✅"
fi
echo ""
}
fail(){
echo ""
echo "👷⛔ Step $1 failed ($2)"
failed_tests+=("step $1: $2")
}
run(){
steps=$((steps + 1))
echo ""
echo "🚧 Step $steps) $2"
echo "⚙️ Running this command:"
# This will print the body of a bash function, but won't expand variables
# inside. It works well for bundling simple commands together and allows us to
# print them without wrapping them in qotes.
declare -f $1 | sed '1d;2d;$d' | sed 's/^[[:space:]]*//' # Print the function body
echo "-------------------------------------- 💣 --------------------------------------"
if [ ! $DRY_RUN ]
then
$1
fi
if [ $? -eq 0 ]; then
success $steps
else
echo "‼️ Error: Command failed with exit status $?"
fail $steps "$1"
fails=$((fails + 1))
return $?
fi
}
unittests(){
nix-build unittests.nix
}
build_chainloader(){
nix-build $CCACHE_FLAG chainloader.nix
}
build_example(){
nix-build $CCACHE_FLAG example.nix
}
multicore_subset(){
nix-shell --pure --arg smp true $CCACHE_FLAG --argstr unikernel ./test/kernel/integration/smp --run ./test.py
# The following tests are not using multiple CPU's, but have been equippedd with some anyway
# to make sure core functionality is not broken by missing locks etc. when waking up more cores.
nix-shell --pure --arg smp true $CCACHE_FLAG --argstr unikernel ./test/net/integration/udp --run ./test.py
nix-shell --pure --arg smp true $CCACHE_FLAG --argstr unikernel ./test/kernel/integration/paging --run ./test.py
}
smoke_tests(){
nix-shell --pure $CCACHE_FLAG --argstr unikernel ./test/net/integration/udp --run ./test.py
nix-shell --pure $CCACHE_FLAG --argstr unikernel ./test/net/integration/tcp --run ./test.py
nix-shell --pure $CCACHE_FLAG --argstr unikernel ./test/kernel/integration/paging --run ./test.py
nix-shell --pure $CCACHE_FLAG --argstr unikernel ./test/kernel/integration/smp --run ./test.py
}
run unittests "Build and run unit tests"
run build_chainloader "Build the 32-bit chainloader"
run build_example "Build the basic example"
run multicore_subset "Run selected tests with multicore enabled"
if [ "$QUICK_SMOKE" ]; then
run smoke_tests "Build and run a few key smoke tests"
if [ $fails -eq 0 ]; then
echo ""
echo "👷💬 A lot of things are working! 💪"
else
echo ""
echo "👷🧰 $fails / $steps steps failed. There's some work left to do. 🛠 "
echo ""
exit 1
fi
exit 0
fi
# Continuing from here will run all integration tests.
run_testsuite() {
local base_folder="$1"
shift
local exclusion_list=("$@")
steps=$((steps + 1))
substeps=1
subfails=0
echo ""
echo "====================================== 🚜 ======================================"
echo ""
echo "🚧 $steps) Running integration tests in $base_folder"
if [ ! ${#exclusion_list[@]} -eq 0 ]
then
echo "⚠️ With the following exceptions: "
for exclude in "${exclusion_list[@]}"; do
echo " - ✏️ Skipping $exclude"
done
fi
echo "--------------------------------------------------------------------------------"
for subfolder in "$base_folder"/*/; do
local skip=false
for exclude in "${exclusion_list[@]}"; do
if [[ "$subfolder" == *"$exclude"* ]]; then
skip=true
break
fi
done
if [ "$skip" = true ]; then
continue
fi
# The command to run, as string to be able to print the fully expanded command
cmd="nix-shell --pure $CCACHE_FLAG --argstr unikernel $subfolder --run ./test.py"
echo ""
echo "🚧 Step $steps.$substeps"
echo "📂 $subfolder"
echo "⚙️ Running this command:"
echo $cmd
echo "-------------------------------------- 💣 --------------------------------------"
if [ ! $DRY_RUN ]
then
$cmd
fi
if [ $? -eq 0 ]; then
success "$steps.$substeps"
else
fail "$steps.$substeps" "$cmd"
subfails=$((subfails + 1))
fi
substeps=$((substeps + 1))
done
if [ $subfails -eq 0 ]; then
success $steps
else
fail $steps
fails=$((fails + 1))
fi
}
#
# Kernel tests
#
exclusions=(
"LiveUpdate" # Missing includes
"context" # Outdated - references nonexisting OS::heap_end()
"fiber" # Crashes
"modules" # Requires 32-bit build, which our shell.nix is not set up for
)
run_testsuite "./test/kernel/integration" "${exclusions[@]}"
#
# C++ STL runtime tests
#
exclusions=(
)
run_testsuite "./test/stl/integration" "${exclusions[@]}"
#
# Networking tests
#
exclusions=(
"dhclient" # Times out because it requires DHCP server on the bridge.
"dhcpd" # Times out, requires certain routes to be set up. Seems easy.
"dhcpd_dhclient_linux" # We can't run userspace tests with this setup yet.
"gateway" # Requires NaCl which is currently not integrated
"http" # Linking fails, undefined ref to http_parser_parse_url, http_parser_execute
"microLB" # Missing dependencies: microLB, diskbuilder, os_add_os_library
"nat" # Times out after 3 / 6 tests seem to pass. Might be a legit bug here.
"router" # Times out, requies sudo and has complex network setup.
"router6" # Times out: iperf3: error - unable to connect to server
"vlan" # Times out. Looks similar to the nat test - maybe similar cause?
"websocket" # Linking fails, undefined ref to http_parser_parse_url, http_parser_execute
)
run_testsuite "./test/net/integration" "${exclusions[@]}"
echo -e "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
if [ $fails -eq 0 ]; then
echo ""
echo "🌈✨ Everything is awesome ✨"
echo ""
else
echo ""
echo "👷🧰 $fails / $steps steps failed. There's some work left to do. 🛠 "
echo ""
echo "Failed tests:"
for t in "${failed_tests[@]}"; do
echo "$t"
done
exit 1
fi