mirror of
https://github.com/Pithikos/C-Thread-Pool
synced 2024-11-21 21:21:23 +03:00
Run memleak tests in parallel where possible
This commit is contained in:
parent
230dd7e643
commit
4f4082e817
@ -35,11 +35,11 @@ function _test_thread_free_multi { #threads
|
||||
frees=$(extract_num "[0-9]* frees" "$heap_usage")
|
||||
if (( "$allocs" == 0 )); then
|
||||
err "Allocated 0 times. Something is wrong.." "$output"
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
if (( "$allocs" != "$frees" )); then
|
||||
err "Allocated $allocs times but freed only $frees" "$output"
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
#echo "Allocs: $allocs Frees: $frees"
|
||||
}
|
||||
@ -49,9 +49,26 @@ function _test_thread_free_multi { #threads
|
||||
function test_thread_free_multi { #threads #times
|
||||
echo "Testing multiple threads creation and destruction in pool(threads=$1 times=$2)"
|
||||
compile src/no_work.c
|
||||
for ((i = 1; i <= $2; i++)); do
|
||||
pids=()
|
||||
|
||||
# Run tests in p
|
||||
for (( i = 1; i <= "$2"; i++ )); do
|
||||
|
||||
# Run test in background
|
||||
python -c "import sys; sys.stdout.write('$i/$2\r')"
|
||||
_test_thread_free_multi $1
|
||||
_test_thread_free_multi "$1" &
|
||||
pids+=($!)
|
||||
|
||||
# Wait for 10 background jobs to finish
|
||||
if (( "$i" % 10 == 0 )); then
|
||||
for pid in ${pids[@]}; do
|
||||
wait $pid
|
||||
if (( $? != 0 )); then
|
||||
err "Test failed" "Test failed"
|
||||
fi
|
||||
done
|
||||
pids=()
|
||||
fi
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user