|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -eux |
| 4 | + |
| 5 | +id |
| 6 | + |
| 7 | +# perform code analysis if necessary |
| 8 | +if [ $CHECK_CODE = "true" ]; then |
| 9 | + |
| 10 | + if [ "$CC" = "clang" ]; then |
| 11 | + scan-build --status-bugs make USE_PGXS=1 || status=$? |
| 12 | + exit $status |
| 13 | + |
| 14 | + elif [ "$CC" = "gcc" ]; then |
| 15 | + cppcheck --template "{file} ({line}): {severity} ({id}): {message}" \ |
| 16 | + --enable=warning,portability,performance \ |
| 17 | + --suppress=redundantAssignment \ |
| 18 | + --suppress=uselessAssignmentPtrArg \ |
| 19 | + --suppress=incorrectStringBooleanError \ |
| 20 | + --std=c89 src/*.c src/*.h 2> cppcheck.log |
| 21 | + |
| 22 | + if [ -s cppcheck.log ]; then |
| 23 | + cat cppcheck.log |
| 24 | + status=1 # error |
| 25 | + fi |
| 26 | + |
| 27 | + exit $status |
| 28 | + fi |
| 29 | + |
| 30 | + # don't forget to "make clean" |
| 31 | + make USE_PGXS=1 clean |
| 32 | +fi |
| 33 | + |
| 34 | +# initialize database |
| 35 | +initdb |
| 36 | + |
| 37 | +# build pg_pathman (using CFLAGS_SL for gcov) |
| 38 | +make USE_PGXS=1 CFLAGS_SL="$(pg_config --cflags_sl) -coverage" |
| 39 | +make USE_PGXS=1 install |
| 40 | + |
| 41 | +# check build |
| 42 | +status=$? |
| 43 | +if [ $status -ne 0 ]; then exit $status; fi |
| 44 | + |
| 45 | +# add pg_pathman to shared_preload_libraries and restart cluster 'test' |
| 46 | +echo "shared_preload_libraries = 'pg_pathman'" >> $PGDATA/postgresql.conf |
| 47 | +echo "port = 55435" >> $PGDATA/postgresql.conf |
| 48 | +pg_ctl start -l /tmp/postgres.log -w |
| 49 | + |
| 50 | +# run regression tests |
| 51 | +PGPORT=55435 make USE_PGXS=1 installcheck || status=$? |
| 52 | + |
| 53 | +# show diff if it exists |
| 54 | +if test -f regression.diffs; then cat regression.diffs; fi |
| 55 | + |
| 56 | +set +u |
| 57 | + |
| 58 | +# run python tests |
| 59 | +make USE_PGXS=1 python_tests || status=$? |
| 60 | +if [ $status -ne 0 ]; then exit $status; fi |
| 61 | + |
| 62 | +set -u |
| 63 | + |
| 64 | +# run mock tests (using CFLAGS_SL for gcov) |
| 65 | +make USE_PGXS=1 PG_CPPFLAGS="-coverage" cmocka_tests || status=$? |
| 66 | +if [ $status -ne 0 ]; then exit $status; fi |
| 67 | + |
| 68 | +# remove useless gcov files |
| 69 | +rm -f tests/cmocka/*.gcno |
| 70 | +rm -f tests/cmocka/*.gcda |
| 71 | + |
| 72 | +#generate *.gcov files |
| 73 | +gcov src/*.c src/compat/*.c src/include/*.h src/include/compat/*.h |
| 74 | + |
| 75 | +exit $status |
0 commit comments