-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·69 lines (60 loc) · 1.61 KB
/
Copy pathrun_tests.sh
File metadata and controls
executable file
·69 lines (60 loc) · 1.61 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
#!/bin/bash
#
# jq(1) may be in a different place on OmniOS or Helios systems:
#
export PATH=$PATH:/opt/ooce/bin
if ! command -v jq >/dev/null; then
printf 'ERROR: need jq(1) installed\n' >&2
exit 1
fi
#
# Build the tests first to make sure root doesn't have to create a bunch of
# files in target/. There are some hoops we then need to jump through to
# record the names of all the test binaries.
#
if ! j=$(cargo build --locked --workspace --tests \
--message-format json-render-diagnostics); then
printf 'ERROR: failed to build tests\n' >&2
exit 1
fi
#
# Parse the JSON into an array of test binary names.
#
if ! t=$(jq -r -s 'map(
select(.reason == "compiler-artifact") |
select(.target.test) |
select(.executable) |
.executable
) | flatten | .[]' <<< "$j"); then
printf 'ERROR: failed to parse JSON for test binaries\n' >&2
exit 1
fi
if ! readarray -t tests <<< "$t"; then
exit 1
fi
if (( ${#tests[@]} == 0 )); then
printf 'ERROR: no test binaries?\n' >&2
exit 1
fi
printf 'found %d test binaries\n' "${#tests[@]}" >&2
#
# Set up simnets for this test, and be sure to try to tear them down no matter
# why we end up exiting:
#
trap 'pfexec dladm delete-simnet sim0; pfexec dladm delete-simnet sim1' EXIT
if ! pfexec dladm create-simnet sim0 ||
! pfexec dladm create-simnet sim1 ||
! pfexec dladm modify-simnet -p sim0 sim1; then
printf 'ERROR: simnet setup failure\n' >&2
exit 1
fi
e=0
for (( i = 0; i < ${#tests[@]}; i++ )); do
tbin="${tests[$i]}"
printf 'EXEC: %s\n' "$tbin" >&2
if ! pfexec "$tbin" --nocapture; then
printf 'FAILURE (%s)\n' "$tbin" >&2
e=1
fi
done
exit $e