mirror of
https://github.com/Pithikos/C-Thread-Pool
synced 2024-11-24 22:39:56 +03:00
Split test_thread_free_multi into 2 separate funcs
This commit is contained in:
parent
1ff0984eea
commit
8f1bcb1aa4
@ -28,25 +28,30 @@ function test_thread_free { #threads
|
||||
}
|
||||
|
||||
|
||||
function _test_thread_free_multi { #threads
|
||||
output=$(valgrind --leak-check=full --track-origins=yes ./test "$1" 2>&1 > /dev/null)
|
||||
heap_usage=$(echo "$output" | grep "total heap usage")
|
||||
allocs=$(extract_num "[0-9]* allocs" "$heap_usage")
|
||||
frees=$(extract_num "[0-9]* frees" "$heap_usage")
|
||||
if (( "$allocs" == 0 )); then
|
||||
err "Allocated 0 times. Something is wrong.." "$output"
|
||||
exit 1
|
||||
fi
|
||||
if (( "$allocs" != "$frees" )); then
|
||||
err "Allocated $allocs times but freed only $frees" "$output"
|
||||
exit 1
|
||||
fi
|
||||
#echo "Allocs: $allocs Frees: $frees"
|
||||
}
|
||||
|
||||
|
||||
# This is the same with test_many_thread_allocs but multiplied
|
||||
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
|
||||
python -c "import sys; sys.stdout.write('$i/$2\r')"
|
||||
output=$(valgrind --leak-check=full --track-origins=yes ./test "$1" 2>&1 > /dev/null)
|
||||
heap_usage=$(echo "$output" | grep "total heap usage")
|
||||
allocs=$(extract_num "[0-9]* allocs" "$heap_usage")
|
||||
frees=$(extract_num "[0-9]* frees" "$heap_usage")
|
||||
if (( "$allocs" == 0 )); then
|
||||
err "Allocated 0 times. Something is wrong.." "$output"
|
||||
exit 1
|
||||
fi
|
||||
if (( "$allocs" != "$frees" )); then
|
||||
err "Allocated $allocs times but freed only $frees" "$output"
|
||||
exit 1
|
||||
fi
|
||||
#echo "Allocs: $allocs Frees: $frees"
|
||||
_test_thread_free_multi $1
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user