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
#!/usr/bin/env bash
#
# Wrapper for the `simple_http_server_is_remotely_accessible` integration
# test in `tests/integration_test.rs`. The test spawns `innisfree up`, which
# needs CAP_NET_ADMIN to bring up the userspace wireguard TUN. Rather than
# running the entire test suite as root, this wrapper builds the binary and
# applies the capabilities once via sudo, then invokes `cargo test` as the
# regular user.
#
# Set DIGITALOCEAN_API_TOKEN before running. Extra args are forwarded to
# `cargo test` after the `--ignored` separator (e.g. `--nocapture` is on by
# default; pass `--test-threads=1` to add more).
if [; then
fi
if ! ; then
fi
# Compile the test artifacts — including the `innisfree` bin in its test-
# time feature configuration — without running them. `cargo test` adds
# dev-dependencies to the dependency graph, which can change the feature
# unification of upstream crates (notably `tokio`, which we union with
# `process` + `time` for the integration test). That changes the bin's
# build inputs, so a plain `cargo build` followed by `cargo test` would
# rebuild and replace the binary, dropping the file capabilities below.
# `--no-run` produces the exact same artifacts `cargo test` will use, so
# the subsequent setcap survives.