1
0
mirror of https://github.com/cldellow/sqlite-parquet-vtable.git synced 2025-09-12 22:29:58 +00:00

Add harness for low memory testing

This commit is contained in:
Colin Dellow
2018-03-24 11:27:06 -04:00
parent 599430b2f4
commit 6fa7bc3d0b
3 changed files with 48 additions and 3 deletions

41
tests/test-failmalloc Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
set -euo pipefail
# A harness that runs SQLite with the parquet extension in an environment where malloc randomly
# fails. "Success" is if the logs don't have any C++ exceptions that talk about std::bad_alloc
ensure_failmalloc() {
if [ ! -d libfailmalloc ]; then
git clone https://github.com/cldellow/libfailmalloc.git
fi
if [ ! -e libfailmalloc/.libs/libfailmalloc.so ]; then
cd libfailmalloc
./configure
make
fi
}
run_under_low_memory() {
start=$(date +%s%3N)
set +e
env LD_PRELOAD="$here"/libfailmalloc/.libs/libfailmalloc.so FAILMALLOC_PROBABILITY=0.00001 ./test-random &> results.bad_alloc
set -e
now=$(date +%s%3N)
echo "Bailed after $((now-start)) ms"
! grep std::bad_alloc results.bad_alloc
}
main() {
here=$(dirname "${BASH_SOURCE[0]}")
here=$(readlink -f "$here")
cd "$here"
ensure_failmalloc
# Sometimes we'll exit due to a Python memory issue, so try a few times.
for i in {0..10}; do
run_under_low_memory
done
}
main "$@"