blob: 22f1d5451a58714ee0a5b75c051fa8940e30fd64 (
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
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
|
#!/bin/bash
set -euo pipefail
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
TESTER_DIR=${SCRIPT_DIR}/tester
DATA_DIR=${TESTER_DIR}/data
MP3_DIR=${SCRIPT_DIR}/../mp3
# Set automatically
arch="`uname -m`"
platform=
verbose=true
fail_fast=false
bin_dir=$(realpath ${SCRIPT_DIR}/..)
__check_platform()
{
if test -z "$platform" -a \( "$arch" = "arm64" -o "$arch" = "aarch64" \); then
platform=linux/arm64
elif test -z "$platform"; then
platform=linux/amd64
fi
}
do_help() {
echo "$0 --bin-dir . server"
}
check_exists() {
bin="$1"
if [[ ! -e ${bin} ]]; then
echo "Binary ${bin} not found! Exiting"
exit 1
fi
}
run_tester() {
tester_name=$1
shift
case $platform in
linux/amd64)
tester_path=${TESTER_DIR}/
;;
linux/arm64)
tester_path=${TESTER_DIR}/arm64
;;
*)
echo "Unsupported platform ${platform}"
exit 1
esac
vflag=""
if $verbose; then
vflag="-test.v"
fi
failflag=""
if $fail_fast; then
failflag="-test.failfast"
fi
export BIN_DIR=${bin_dir}
export MP3_DIR=$MP3_DIR
export DATA_DIR=$DATA_DIR
${tester_path}/${tester_name} $vflag $failflag $@
}
do_server() {
check_exists "${bin_dir}/snowcast_server"
run_tester server_tester $@
}
do_control() {
check_exists "${bin_dir}/snowcast_server"
run_tester server_tester $@
}
do_milestone() {
do_control -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)"
do_server -test.v -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)"
}
do_all() {
do_server $@
do_control $@
}
main() {
POSITIONAL=()
while [[ $# -gt 0 ]]; do
key=$1
case $key in
--fail-fast|-f)
shift
fail_fast=true
;;
--quiet|-q)
shift
verbose=false
;;
-a|--arm|--arm64|--aarch64)
shift
if [[ ( "${arch}" == "arm64" ) || ( "${arch}" == "aarch64" ) ]]; then
platform=linux/arm64
else
echo "$0 --arm only works on arm64 hosts (platform is ${arch})" 1>&2
exit 1
fi
;;
-x|--x86-64)
shift
platform=linux/amd64
;;
--bin-dir)
bin_dir="$2"
shift
shift
;;
--help)
shift
do_help
exit 0
;;
*)
POSITIONAL+=("$1")
shift
esac
done
set -- "${POSITIONAL[@]}"
__check_platform
# Default subcommand
if [[ $# == 0 ]]; then
do_all
exit 0
fi
# Subcommands
case $1 in
help)
do_help
exit 0
;;
server)
shift
do_server $@
;;
control)
shift
do_control $@
;;
milestone)
shift
do_milestone $@
;;
all)
shift
do_all $@
;;
*)
echo "Unrecognized command $1"
exit 1
;;
esac
}
main $@
|