-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathphd-run-with-args.sh
executable file
·101 lines (82 loc) · 2.05 KB
/
phd-run-with-args.sh
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
#!/bin/bash
# Unpacks and executes the PHD runner in the Buildomat environment, passing
# through to the runner any arguments that were passed to this script.
set -o errexit
set -o pipefail
set -o xtrace
indir="/input"
indir_suffix="phd-build/out/*.tar.gz"
phddir="$PWD/phd-test"
# Put artifacts on the runner's SSDs (the /work ramdisk is small by design, too
# small for images of any appreciable size).
pfexec zpool create -f phd-artifacts c1t1d0 c2t1d0
artifactdir="/phd-artifacts"
banner 'Inputs'
find $indir -ls
rm -rf "$phddir"
mkdir "$phddir"
for p in $indir/$indir_suffix; do
tar xzvf $p -C $phddir
for f in $(tar tf "$p"); do
chmod +x "$phddir/$f"
done
done
ls $phddir
banner 'Setup'
tmpdir="/tmp/propolis-phd"
if [ ! -d "$tmpdir" ]; then
mkdir $tmpdir
fi
banner 'Tests'
runner="$phddir/phd-runner"
artifacts="$phddir/artifacts.toml"
propolis="$phddir/propolis-server"
ls $runner
ls $artifacts
ls $propolis
args=(
$runner '--emit-bunyan' 'run'
'--propolis-server-cmd' $propolis
'--crucible-downstairs-commit' 'auto'
'--artifact-toml-path' $artifacts
'--tmp-directory' $tmpdir
'--artifact-directory' $artifactdir
'--parallelism' 2
$@
)
# Disable errexit so that we still upload logs on failure
set +e
(RUST_BACKTRACE=1 RUST_LOG="info,phd=debug" ptime -m pfexec "${args[@]}" | \
tee /tmp/phd-runner.log)
failcount=$?
set -e
# Disable errexit again because we may try collecting logs from runners that ran
# no tests (in which case *.log doesn't expand and tar will fail to find a file
# by that literal name)
set +e
tar -czvf /tmp/phd-tmp-files.tar.gz \
-C $tmpdir $tmpdir/*.log
for runnerdir in $tmpdir/runner-*; do
if [ -d "$runnerdir" ]; then
tar -rzvf /tmp/phd-tmp-files.tar.gz \
-C $runnerdir $runnerdir/*.log
fi
done
set -e
exitcode=0
if [ $failcount -eq 0 ]; then
echo
echo "ALL TESTS PASSED"
echo
else
echo
echo "SOME TESTS FAILED"
echo
exitcode=1
fi
if find /dev/vmm -mindepth 1 -maxdepth 1 | read ; then
echo "VMM handles leaked:"
find /dev/vmm -type c -exec basename {} \;
exitcode=2
fi
exit $exitcode