33# SPDX-License-Identifier: Apache-2.0
44
55# Build the current checkout, run its gateway on the host or in a disposable
6- # Nix test guest, and execute one named host-side E2E suite against that gateway.
6+ # Nix test guest, and execute host-side E2E tests against that gateway.
77
88set -Eeuo pipefail
99
@@ -20,13 +20,17 @@ usage() {
2020 cat << 'EOF '
2121Usage:
2222 e2e/run.sh [--vm DISTRO] [--with CONFIG ...] \
23- --gateway-config PATH -- suite NAME
23+ --gateway-config PATH [--features FEATURES] [-- suite NAME]
2424
2525Options:
2626 --vm DISTRO Run the gateway in a Nix test guest
2727 --with CONFIG Apply a Nix test-guest configuration; repeatable
28+ --host-cli-bin PATH Use a prebuilt host openshell CLI instead of building it
29+ --gateway-bin PATH Use a prebuilt openshell-gateway instead of building it
30+ --sandbox-bin PATH Use a prebuilt openshell-sandbox instead of building it
2831 --gateway-config PATH
2932 Fully resolved gateway TOML
33+ --features FEATURES Rust e2e feature set to enable (default: e2e)
3034 --suite NAME Rust suite at e2e/rust/tests/NAME.rs
3135 -h, --help Show this help
3236
@@ -92,6 +96,10 @@ catalog_has_entry() {
9296
9397vm=
9498gateway_config=
99+ gateway_bin=
100+ host_cli_bin=
101+ sandbox_bin=
102+ e2e_features=e2e
95103suite_name=
96104with_configurations=()
97105
@@ -107,11 +115,31 @@ while [ "$#" -gt 0 ]; do
107115 with_configurations+=(" $2 " )
108116 shift 2
109117 ;;
118+ --host-cli-bin)
119+ require_value " $1 " " $# " " ${2:- } "
120+ host_cli_bin=" $( resolve_file " $2 " ) " || die " --host-cli-bin does not name a file: $2 "
121+ shift 2
122+ ;;
123+ --gateway-bin)
124+ require_value " $1 " " $# " " ${2:- } "
125+ gateway_bin=" $( resolve_file " $2 " ) " || die " --gateway-bin does not name a file: $2 "
126+ shift 2
127+ ;;
128+ --sandbox-bin)
129+ require_value " $1 " " $# " " ${2:- } "
130+ sandbox_bin=" $( resolve_file " $2 " ) " || die " --sandbox-bin does not name a file: $2 "
131+ shift 2
132+ ;;
110133 --gateway-config)
111134 require_value " $1 " " $# " " ${2:- } "
112135 gateway_config=$2
113136 shift 2
114137 ;;
138+ --features)
139+ require_value " $1 " " $# " " ${2:- } "
140+ e2e_features=$2
141+ shift 2
142+ ;;
115143 --suite)
116144 require_value " $1 " " $# " " ${2:- } "
117145 suite_name=$2
130158if [ -z " ${gateway_config} " ]; then
131159 die " --gateway-config is required"
132160fi
133- if [ -z " ${suite_name} " ]; then
134- die " --suite is required"
135- fi
136161if ! command -v python3 > /dev/null 2>&1 ; then
137162 die " python3 is required"
138163fi
@@ -144,12 +169,17 @@ gateway_driver="$(python3 -c '
144169import sys, tomllib
145170print(tomllib.load(open(sys.argv[1], "rb"))["openshell"]["gateway"]["compute_drivers"][0])
146171' " ${gateway_config} " ) "
147- if [[ ! ${suite_name} =~ ^[a-z0-9][a-z0-9-] * $ ] ]; then
148- die " suite name must contain only lowercase letters, digits, and hyphens: ${suite_name} "
172+ if [ -z " ${e2e_features} " ]; then
173+ die " --features must not be empty "
149174fi
150- suite_path=" ${ROOT} /e2e/rust/tests/${suite_name} .rs"
151- if [ ! -f " ${suite_path} " ]; then
152- die " unknown suite: ${suite_name} "
175+ if [ -n " ${suite_name} " ]; then
176+ if [[ ! ${suite_name} =~ ^[a-z0-9][a-z0-9_-]* $ ]]; then
177+ die " suite name must contain only lowercase letters, digits, underscores, and hyphens: ${suite_name} "
178+ fi
179+ suite_path=" ${ROOT} /e2e/rust/tests/${suite_name} .rs"
180+ if [ ! -f " ${suite_path} " ]; then
181+ die " unknown suite: ${suite_name} "
182+ fi
153183fi
154184mode=host
155185if [ -n " ${vm} " ] || [ " ${# with_configurations[@]} " -gt 0 ]; then
@@ -230,49 +260,68 @@ target_dir="$(e2e_cargo_target_dir "${ROOT}" mise x -- cargo)"
230260
231261ensure_build_nofile_limit
232262
233- echo " ==> Building native host openshell CLI"
234- mise x -- cargo build " ${cargo_jobs[@]+" ${cargo_jobs[@]} " } " -p openshell-cli --bin openshell
235- host_cli_bin=" ${target_dir} /debug/openshell"
236-
237- echo " ==> Preparing ${linux_musl_target} build target"
238- mise x -- rustup target add " ${linux_musl_target} " > /dev/null
263+ if [ -n " ${host_cli_bin} " ]; then
264+ echo " ==> Using host openshell CLI: ${host_cli_bin} "
265+ else
266+ echo " ==> Building native host openshell CLI"
267+ mise x -- cargo build " ${cargo_jobs[@]+" ${cargo_jobs[@]} " } " -p openshell-cli --bin openshell
268+ host_cli_bin=" ${target_dir} /debug/openshell"
269+ fi
239270
240- echo " ==> Building Linux openshell-sandbox (${linux_musl_target} )"
241- mise x -- cargo zigbuild " ${cargo_jobs[@]+" ${cargo_jobs[@]} " } " \
242- --release \
243- --target " ${linux_musl_target} " \
244- -p openshell-sandbox \
245- --bin openshell-sandbox
246- linux_sandbox_bin=" ${target_dir} /${linux_musl_target} /release/openshell-sandbox"
271+ if [ -n " ${sandbox_bin} " ]; then
272+ echo " ==> Using Linux openshell-sandbox: ${sandbox_bin} "
273+ linux_sandbox_bin=" ${sandbox_bin} "
274+ else
275+ echo " ==> Preparing ${linux_musl_target} build target"
276+ mise x -- rustup target add " ${linux_musl_target} " > /dev/null
277+
278+ echo " ==> Building Linux openshell-sandbox (${linux_musl_target} )"
279+ mise x -- cargo zigbuild " ${cargo_jobs[@]+" ${cargo_jobs[@]} " } " \
280+ --release \
281+ --target " ${linux_musl_target} " \
282+ -p openshell-sandbox \
283+ --bin openshell-sandbox
284+ linux_sandbox_bin=" ${target_dir} /${linux_musl_target} /release/openshell-sandbox"
285+ fi
247286
248287host_gateway_bin=
249288guest_gateway_bin=
250289if [ " ${mode} " = host ]; then
251- echo " ==> Building native host openshell-gateway"
252- mise x -- cargo build " ${cargo_jobs[@]+" ${cargo_jobs[@]} " } " \
253- -p openshell-server \
254- --bin openshell-gateway \
255- --features bundled-z3
256- host_gateway_bin=" ${target_dir} /debug/openshell-gateway"
257- else
258- echo " ==> Preparing ${linux_gateway_rust_target} build target"
259- mise x -- rustup target add " ${linux_gateway_rust_target} " > /dev/null
260- echo " ==> Building Linux openshell-gateway (${linux_gateway_zig_target} )"
261- (
262- eval " $(
263- " ${ROOT} /tasks/scripts/setup-zig-cc-wrapper.sh" \
264- " ${linux_gateway_zig_target} " \
265- " ${linux_gateway_zig_target} " \
266- " ${target_dir} /zig-gnu-wrapper/e2e"
267- ) "
268- mise x -- cargo zigbuild " ${cargo_jobs[@]+" ${cargo_jobs[@]} " } " \
269- --release \
270- --target " ${linux_gateway_zig_target} " \
290+ if [ -n " ${gateway_bin} " ]; then
291+ echo " ==> Using host openshell-gateway: ${gateway_bin} "
292+ host_gateway_bin=" ${gateway_bin} "
293+ else
294+ echo " ==> Building native host openshell-gateway"
295+ mise x -- cargo build " ${cargo_jobs[@]+" ${cargo_jobs[@]} " } " \
271296 -p openshell-server \
272297 --bin openshell-gateway \
273298 --features bundled-z3
274- )
275- guest_gateway_bin=" ${target_dir} /${linux_gateway_rust_target} /release/openshell-gateway"
299+ host_gateway_bin=" ${target_dir} /debug/openshell-gateway"
300+ fi
301+ else
302+ if [ -n " ${gateway_bin} " ]; then
303+ echo " ==> Using Linux openshell-gateway: ${gateway_bin} "
304+ guest_gateway_bin=" ${gateway_bin} "
305+ else
306+ echo " ==> Preparing ${linux_gateway_rust_target} build target"
307+ mise x -- rustup target add " ${linux_gateway_rust_target} " > /dev/null
308+ echo " ==> Building Linux openshell-gateway (${linux_gateway_zig_target} )"
309+ (
310+ eval " $(
311+ " ${ROOT} /tasks/scripts/setup-zig-cc-wrapper.sh" \
312+ " ${linux_gateway_zig_target} " \
313+ " ${linux_gateway_zig_target} " \
314+ " ${target_dir} /zig-gnu-wrapper/e2e"
315+ ) "
316+ mise x -- cargo zigbuild " ${cargo_jobs[@]+" ${cargo_jobs[@]} " } " \
317+ --release \
318+ --target " ${linux_gateway_zig_target} " \
319+ -p openshell-server \
320+ --bin openshell-gateway \
321+ --features bundled-z3
322+ )
323+ guest_gateway_bin=" ${target_dir} /${linux_gateway_rust_target} /release/openshell-gateway"
324+ fi
276325fi
277326
278327expected_binaries=(" ${host_cli_bin} " " ${linux_sandbox_bin} " )
@@ -588,10 +637,17 @@ wait_for_gateway() {
588637
589638wait_for_gateway
590639
591- echo " ==> Running E2E suite: ${suite_name} "
640+ test_args=(
641+ cargo test
642+ --manifest-path e2e/rust/Cargo.toml
643+ --features " ${e2e_features} "
644+ )
645+ echo " ==> Running E2E features: ${e2e_features} "
646+ if [ -n " ${suite_name} " ]; then
647+ echo " ==> Running E2E suite: ${suite_name} "
648+ test_args+=(--test " ${suite_name} " )
649+ fi
650+ test_args+=(-- --nocapture)
651+
592652cd " ${ROOT} "
593- cargo test \
594- --manifest-path e2e/rust/Cargo.toml \
595- --features e2e \
596- --test " ${suite_name} " \
597- -- --nocapture
653+ " ${test_args[@]} "
0 commit comments