6
6
# * cmocka-based tests
7
7
# Copyright (c) 2017, Postgres Professional
8
8
9
- set -eux
9
+ set -ux
10
10
11
11
echo CHECK_CODE=$CHECK_CODE
12
+ echo PG_VERSION=$( pg_config --version)
12
13
13
14
status=0
14
15
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
+
15
22
# perform code analysis if necessary
16
23
if [ " $CHECK_CODE " = " clang" ]; then
17
24
scan-build --status-bugs make USE_PGXS=1 || status=$?
18
25
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
36
26
fi
37
27
38
28
# we need testgres for pathman tests
@@ -42,28 +32,20 @@ source env/bin/activate
42
32
pip install testgres
43
33
pip freeze | grep testgres
44
34
45
- # don't forget to "make clean"
46
- make USE_PGXS=1 clean
47
-
48
35
# initialize database
49
36
initdb
50
37
51
38
# build pg_pathman (using PG_CPPFLAGS and SHLIB_LINK for gcov)
39
+ set -e
40
+ make USE_PGXS=1 clean
52
41
make USE_PGXS=1 PG_CPPFLAGS=" -coverage" SHLIB_LINK=" -coverage"
53
42
make USE_PGXS=1 install
54
-
55
- # check build
56
- status=$?
57
- if [ $status -ne 0 ]; then exit $status ; fi
43
+ set +e
58
44
59
45
# add pg_pathman to shared_preload_libraries and restart cluster 'test'
60
46
echo " shared_preload_libraries = 'pg_pathman'" >> $PGDATA /postgresql.conf
61
47
echo " 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
67
49
68
50
# run regression tests
69
51
export PG_REGRESS_DIFF_OPTS=" -w -U3" # for alpine's diff (BusyBox)
@@ -72,18 +54,22 @@ PGPORT=55435 make USE_PGXS=1 installcheck || status=$?
72
54
# show diff if it exists
73
55
if test -f regression.diffs; then cat regression.diffs; fi
74
56
75
- set +u
57
+ # list cores and exit if we failed
58
+ ls " $CORE_DIR "
59
+ if [ $status -ne 0 ]; then exit $status ; fi
76
60
77
61
# run python tests
62
+ set +u
78
63
make USE_PGXS=1 python_tests || status=$?
79
- if [ $status -ne 0 ]; then exit $status ; fi
80
-
81
64
set -u
82
65
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 "
85
68
if [ $status -ne 0 ]; then exit $status ; fi
86
69
70
+ # run cmocka tests (using CFLAGS_SL for gcov)
71
+ make USE_PGXS=1 PG_CPPFLAGS=" -coverage" cmocka_tests || exit $?
72
+
87
73
# remove useless gcov files
88
74
rm -f tests/cmocka/* .gcno
89
75
rm -f tests/cmocka/* .gcda
@@ -92,6 +78,8 @@ rm -f tests/cmocka/*.gcda
92
78
gcov src/* .c src/compat/* .c src/include/* .h src/include/compat/* .h
93
79
94
80
# send coverage stats to Coveralls
81
+ set +u
95
82
bash <( curl -s https://codecov.io/bash)
83
+ set -u
96
84
97
85
exit $status
0 commit comments