2023-08-20 05:50:16 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Get all the variables.
|
|
|
|
PROCESSES=$1
|
|
|
|
TRANCHES=$2
|
2024-08-22 02:13:07 +02:00
|
|
|
|
|
|
|
# Here we also shift 2 times and get the rest of our flags to pass on in $@.
|
|
|
|
shift 2
|
2023-08-20 05:50:16 +02:00
|
|
|
|
|
|
|
# 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
|
2024-08-22 02:13:07 +02:00
|
|
|
scripts/itest_part.sh $i $TRANCHES $@ &
|
2023-08-20 05:50:16 +02:00
|
|
|
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
|
2023-10-10 16:15:41 +02:00
|
|
|
# Only write the exit code of the first failing itest.
|
|
|
|
if [ $exit_code -eq 0 ]; then
|
2023-08-20 05:50:16 +02:00
|
|
|
exit_code=$current_exit_code
|
2023-10-10 16:15:41 +02:00
|
|
|
fi
|
2023-08-20 05:50:16 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Exit with the exit code of the first failing itest or 0.
|
|
|
|
exit $exit_code
|