66# * cmocka-based tests
77# Copyright (c) 2017, Postgres Professional
88
9- set -eux
9+ set -ux
1010
1111echo CHECK_CODE=$CHECK_CODE
12+ echo PG_VERSION=$( pg_config --version)
1213
1314status=0
1415
16+ # change relevant core dump settings
17+ CORE_DIR=/tmp/cores
18+ ulimit -c unlimited -S
19+ mkdir " $CORE_DIR "
20+ echo " $CORE_DIR /%e-%s-%p.core" | sudo tee /proc/sys/kernel/core_pattern
21+
1522# perform code analysis if necessary
1623if [ " $CHECK_CODE " = " clang" ]; then
1724 scan-build --status-bugs make USE_PGXS=1 || status=$?
1825 exit $status
19-
20- elif [ " $CHECK_CODE " = " cppcheck" ]; then
21- cppcheck \
22- --template " {file} ({line}): {severity} ({id}): {message}" \
23- --enable=warning,portability,performance \
24- --suppress=redundantAssignment \
25- --suppress=uselessAssignmentPtrArg \
26- --suppress=literalWithCharPtrCompare \
27- --suppress=incorrectStringBooleanError \
28- --std=c89 src/* .c src/include/* .h 2> cppcheck.log
29-
30- if [ -s cppcheck.log ]; then
31- cat cppcheck.log
32- status=1 # error
33- fi
34-
35- exit $status
3626fi
3727
3828# we need testgres for pathman tests
@@ -42,28 +32,20 @@ source env/bin/activate
4232pip install testgres
4333pip freeze | grep testgres
4434
45- # don't forget to "make clean"
46- make USE_PGXS=1 clean
47-
4835# initialize database
4936initdb
5037
5138# build pg_pathman (using PG_CPPFLAGS and SHLIB_LINK for gcov)
39+ set -e
40+ make USE_PGXS=1 clean
5241make USE_PGXS=1 PG_CPPFLAGS=" -coverage" SHLIB_LINK=" -coverage"
5342make USE_PGXS=1 install
54-
55- # check build
56- status=$?
57- if [ $status -ne 0 ]; then exit $status ; fi
43+ set +e
5844
5945# add pg_pathman to shared_preload_libraries and restart cluster 'test'
6046echo " shared_preload_libraries = 'pg_pathman'" >> $PGDATA /postgresql.conf
6147echo " port = 55435" >> $PGDATA /postgresql.conf
62- pg_ctl start -l /tmp/postgres.log -w
63-
64- # check startup
65- status=$?
66- if [ $status -ne 0 ]; then cat /tmp/postgres.log; fi
48+ pg_ctl start -l /tmp/postgres.log -w || cat /tmp/postgres.log
6749
6850# run regression tests
6951export PG_REGRESS_DIFF_OPTS=" -w -U3" # for alpine's diff (BusyBox)
@@ -72,18 +54,22 @@ PGPORT=55435 make USE_PGXS=1 installcheck || status=$?
7254# show diff if it exists
7355if test -f regression.diffs; then cat regression.diffs; fi
7456
75- set +u
57+ # list cores and exit if we failed
58+ ls " $CORE_DIR "
59+ if [ $status -ne 0 ]; then exit $status ; fi
7660
7761# run python tests
62+ set +u
7863make USE_PGXS=1 python_tests || status=$?
79- if [ $status -ne 0 ]; then exit $status ; fi
80-
8164set -u
8265
83- # run cmocka tests (using CFLAGS_SL for gcov)
84- make USE_PGXS=1 PG_CPPFLAGS= " -coverage " cmocka_tests || status= $?
66+ # list cores and exit if we failed
67+ ls " $CORE_DIR "
8568if [ $status -ne 0 ]; then exit $status ; fi
8669
70+ # run cmocka tests (using CFLAGS_SL for gcov)
71+ make USE_PGXS=1 PG_CPPFLAGS=" -coverage" cmocka_tests || exit $?
72+
8773# remove useless gcov files
8874rm -f tests/cmocka/* .gcno
8975rm -f tests/cmocka/* .gcda
@@ -92,6 +78,8 @@ rm -f tests/cmocka/*.gcda
9278gcov src/* .c src/compat/* .c src/include/* .h src/include/compat/* .h
9379
9480# send coverage stats to Coveralls
81+ set +u
9582bash <( curl -s https://codecov.io/bash)
83+ set -u
9684
9785exit $status
0 commit comments