forked from lightningnetwork/lnd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitest_parallel.sh
More file actions
executable file
·39 lines (30 loc) · 924 Bytes
/
itest_parallel.sh
File metadata and controls
executable file
·39 lines (30 loc) · 924 Bytes
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
#!/bin/bash
# Get all the variables.
PROCESSES=$1
TRANCHES=$2
SHUFFLE_SEED=$3
# Here we also shift 3 times and get the rest of our flags to pass on in $@.
shift 3
# Create a variable to hold the final exit code.
exit_code=0
# Run commands using xargs in parallel and capture their PIDs
pids=()
for ((i=0; i<PROCESSES; i++)); do
scripts/itest_part.sh $i $TRANCHES $SHUFFLE_SEED $@ &
pids+=($!)
done
# Wait for the processes created by xargs to finish.
for pid in "${pids[@]}"; do
wait $pid
# Once finished, grab its exit code.
current_exit_code=$?
# Overwrite the exit code if current itest doesn't return 0.
if [ $current_exit_code -ne 0 ]; then
# Only write the exit code of the first failing itest.
if [ $exit_code -eq 0 ]; then
exit_code=$current_exit_code
fi
fi
done
# Exit with the exit code of the first failing itest or 0.
exit $exit_code