Repository navigation
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·182 lines (170 loc) · 5.39 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·182 lines (170 loc) · 5.39 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
APP_NAME=""
HOSTED=0
UNBLOCK=0
INJECTION_ARGUMENTS=()
CORE_ARGUMENTS=()
CORE_MODE=""
PORT=""
CORE_HOST="localhost"
CORE_HOST_SPECIFIED=0
usage() {
cat >&2 <<'EOF'
Usage:
./test.sh --app:simple [--unblock]
./test.sh --app:fct [--hosted] [--unblock]
./test.sh --app:rvmt [--unblock]
./test.sh --app:tui
./test.sh --app:core [/FCT|/RPT|/RVMT] [/Cli:<command>] [--remoteDT] [--remoteLocale] [--remoteFS] [--fakeClipboard] [--denyClipboard] [--unblock]
./test.sh --app:renderer [--corehost:<host>] [--port:<1-65535>] [--remoteDT] [--remoteLocale] [--remoteFS] [--denyClipboard] [--unblock]
EOF
}
for argument in "$@"; do
case "$argument" in
--app:simple)
APP_NAME="simple"
;;
--app:fct)
APP_NAME="fct"
;;
--app:tui)
APP_NAME="tui"
;;
--app:rvmt)
APP_NAME="rvmt"
;;
--app:core)
APP_NAME="core"
;;
/FCT|/RPT|/RVMT)
if [[ -n "$CORE_MODE" ]]; then echo "Choose one Core application." >&2; exit 1; fi
CORE_MODE="$argument"
;;
/Cli:*)
CORE_ARGUMENTS+=("$argument")
;;
--fakeClipboard)
CORE_ARGUMENTS+=(/fakeClipboard)
;;
--app:renderer)
APP_NAME="renderer"
;;
--hosted)
HOSTED=1
;;
--remoteDT|--remoteLocale|--remoteFS|--denyClipboard)
INJECTION_ARGUMENTS+=("/${argument#--}")
;;
--unblock)
UNBLOCK=1
;;
--corehost:*)
if [[ "$CORE_HOST_SPECIFIED" -eq 1 || -z "${argument#--corehost:}" ]]; then
echo "--corehost requires one nonempty destination host." >&2
exit 1
fi
CORE_HOST="${argument#--corehost:}"
CORE_HOST_SPECIFIED=1
;;
--port:*)
PORT="${argument#--port:}"
if [[ ! "$PORT" =~ ^[0-9]+$ || "${#PORT}" -gt 5 ]] || ((10#$PORT < 1 || 10#$PORT > 65535)); then
echo "Invalid port: $PORT" >&2
usage
exit 1
fi
;;
*)
echo "Unknown argument: $argument" >&2
usage
exit 1
;;
esac
done
case "$APP_NAME" in
simple)
if [[ "$HOSTED" -eq 1 ]]; then
echo "--hosted is only supported by --app:fct." >&2
exit 1
fi
APP="$SCRIPT_DIR/build/MacTest/bin/Test_HellWorld_Cpp.app/Contents/MacOS/Test_HellWorld_Cpp"
;;
fct)
APP="$SCRIPT_DIR/build/MacFullControlTest/bin/Test_FullControlTest.app/Contents/MacOS/Test_FullControlTest"
;;
tui)
if [[ "$HOSTED" -eq 1 || "$UNBLOCK" -eq 1 ]]; then
echo "--app:tui requires foreground terminal input; --hosted and --unblock are not supported." >&2
exit 1
fi
APP="$SCRIPT_DIR/build/MacTuiControlTest/bin/Test_TuiControlTest"
;;
rvmt)
if [[ "$HOSTED" -eq 1 ]]; then
echo "--hosted is only supported by --app:fct." >&2
exit 1
fi
APP="$SCRIPT_DIR/build/MacCppTestRvm/bin/Test_CppTest_Rvm.app/Contents/MacOS/Test_CppTest_Rvm"
;;
core)
if [[ "$HOSTED" -eq 1 ]]; then
echo "--hosted is only supported by --app:fct." >&2
exit 1
fi
APP="$SCRIPT_DIR/build/RemotingTest_Core/bin/RemotingTest_Core"
;;
renderer)
if [[ "$HOSTED" -eq 1 ]]; then
echo "--hosted is only supported by --app:fct." >&2
exit 1
fi
APP="$SCRIPT_DIR/build/RemotingTest_Rendering_macOS/bin/RemotingTest_Rendering_macOS.app/Contents/MacOS/RemotingTest_Rendering_macOS"
;;
*)
usage
exit 1
;;
esac
if [[ "$APP_NAME" != "core" && ( -n "$CORE_MODE" || ${#CORE_ARGUMENTS[@]} -gt 0 ) ]]; then
echo "Core application, /Cli and --fakeClipboard options require --app:core." >&2
exit 1
fi
if [[ "${#INJECTION_ARGUMENTS[@]}" -gt 0 && "$APP_NAME" != "renderer" && "$APP_NAME" != "core" ]]; then
echo "Remote injection options require --app:core or --app:renderer." >&2
exit 1
fi
if [[ "$CORE_HOST_SPECIFIED" -eq 1 && "$APP_NAME" != "renderer" ]]; then
echo "--corehost is only supported by --app:renderer." >&2
exit 1
fi
if [[ -n "$PORT" && "$APP_NAME" != "renderer" ]]; then
echo "--port is only supported by --app:renderer." >&2
exit 1
fi
if [[ ! -x "$APP" ]]; then
echo "Test application not found. Run ./build.sh first: $APP" >&2
exit 1
fi
arguments=()
case "$APP_NAME" in
core)
arguments=(/MiniHttp "${CORE_MODE:-/FCT}")
if (( ${#CORE_ARGUMENTS[@]} )); then arguments+=("${CORE_ARGUMENTS[@]}"); fi
;;
renderer)
arguments=(/MiniHttp "/corehost:$CORE_HOST")
if [[ -n "$PORT" ]]; then arguments+=("/port:$PORT"); fi
;;
rvmt) arguments=(/MiniHttp) ;;
fct) if [[ "$HOSTED" -eq 1 ]]; then arguments=(--hosted); fi ;;
esac
if (( ${#INJECTION_ARGUMENTS[@]} )); then arguments+=("${INJECTION_ARGUMENTS[@]}"); fi
# The conditional expansion also supports empty arrays in macOS Bash 3.2 with nounset.
if [[ "$UNBLOCK" -eq 1 ]]; then
"$APP" ${arguments[@]+"${arguments[@]}"} &
echo $!
else
exec "$APP" ${arguments[@]+"${arguments[@]}"}
fi