sqlite-parquet-vtable/tests/test-supported

43 lines
1.1 KiB
Plaintext
Raw Normal View History

2018-03-04 22:20:28 +00:00
#!/bin/bash
set -euo pipefail
# Verify that all the non-unsupported.*parquet files can be loaded and 'SELECT * FROM x LIMIT 1'ed
# without segfaulting.
load_supported() {
file=${1:?must provide file to load}
basename=$(basename "$file")
cat <<EOF
.echo on
.load build/linux/libparquet
2018-03-04 22:20:28 +00:00
.testcase $basename
.bail on
CREATE VIRTUAL TABLE test USING parquet('$file');
SELECT * FROM test LIMIT 1;
SELECT 123;
2018-07-06 00:03:30 +00:00
DROP TABLE test;
2018-03-04 22:20:28 +00:00
EOF
}
main() {
root=$(dirname "${BASH_SOURCE[0]}")/..
root=$(readlink -f "$root")
cd "$root"
supported_files=$(find ./parquet-generator/ -type f -name '*.parquet' -not -name 'unsupported*.parquet')
2018-03-04 22:20:28 +00:00
while read -r supported; do
echo "Testing: $supported"
2018-03-05 03:48:39 +00:00
if ! "$root"/sqlite/sqlite3 -init <(load_supported "$supported") < /dev/null > /dev/null 2> testcase-stderr.txt; then
2018-03-04 22:20:28 +00:00
echo "...FAILED; check testcase-{out,err}.txt" >&2
exit 1
fi
# We expect the 'SELECT 123' command to have been run
if ! grep -q 123 testcase-out.txt; then
echo "...FAILED; check testcase-{out,err}.txt" >&2
exit 1
fi
done < <(echo "$supported_files")
}
main "$@"