-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathrun-tests.sh
68 lines (48 loc) · 1.51 KB
/
run-tests.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
#!/bin/bash
# spell-checker:ignore nextest watchplus PIPESTATUS
echo "PATH: $PATH"
export PATH=$HOME/.cargo/bin:$PATH
export RUST_BACKTRACE=full
export CARGO_TERM_COLOR=always
export CARGO_INCREMENTAL=0
echo "PATH: $PATH"
run_with_retry() {
tries=$1
shift 1
for i in $(seq 1 $tries); do
echo "Try #$i of $tries: run $*"
"$@" && echo "Done in try#$i" && return 0
done
exit_code=$?
echo "Still failing after $tries. Code: $exit_code"
return $exit_code
}
run_tests_in_subprocess() (
# limit virtual memory to 3GB to avoid that OS kills sshd
ulimit -v $((1024 * 1024 * 3))
watchplus() {
# call: watchplus <interval> <command>
while true; do
"${@:2}"
sleep "$1"
done
}
kill_all_background_jobs() {
jobs -p | xargs -I{} kill -- {}
}
# observe (log) every 2 seconds the system resource usage to judge if we are at a limit
watchplus 2 df -h &
watchplus 2 free -hm &
nextest_params=(--profile ci --hide-progress-bar --features feat_os_unix_android)
# run tests
cd ~/coreutils && \
run_with_retry 3 timeout --preserve-status --verbose -k 1m 10m \
cargo nextest run --no-run "${nextest_params[@]}" &&
timeout --preserve-status --verbose -k 1m 60m \
cargo nextest run "${nextest_params[@]}"
result=$?
kill_all_background_jobs
return $result
)
# run sub-shell to be able to use ulimit without affecting the sshd
run_tests_in_subprocess