Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9ba3a4f

Browse files
committed
add support for valgrind
1 parent493aa8d commit9ba3a4f

File tree

2 files changed

+65
-23
lines changed

2 files changed

+65
-23
lines changed

‎mk_dockerfile.sh‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
set -eu
2-
sed -e's/${PG_VERSION}/'${PG_VERSION}/g -e's/${LEVEL}/'${LEVEL}/g Dockerfile.tmpl> Dockerfile
1+
if [-z${PG_VERSION+x} ];then
2+
echo PG_VERSION is not set!
3+
exit 1
4+
fi
5+
6+
if [-z${LEVEL+x} ];then
7+
LEVEL=scan-build
8+
fi
9+
10+
echo PG_VERSION=${PG_VERSION}
11+
echo LEVEL=${LEVEL}
12+
13+
sed \
14+
-e's/${PG_VERSION}/'${PG_VERSION}/g \
15+
-e's/${LEVEL}/'${LEVEL}/g \
16+
Dockerfile.tmpl> Dockerfile

‎run_tests.sh‎

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env bash
22

3+
#
34
# Copyright (c) 2018, Postgres Professional
4-
5-
6-
# provide a decent default level
7-
if [-z${LEVEL+x} ];then
8-
LEVEL=scan-build
9-
fi
5+
#
6+
# supported levels:
7+
#* standard
8+
#* scan-build
9+
#* hardcore
10+
#* nightmare
11+
#
1012

1113
set -ux
12-
1314
status=0
1415

1516

@@ -31,41 +32,41 @@ if [ "$LEVEL" = "scan-build" ]; then
3132
fi
3233

3334
# build with cassert + valgrind support
34-
if ["$LEVEL"="hardcore" ];then
35+
if ["$LEVEL"="hardcore" ]|| ["$LEVEL"="nightmare" ];then
3536

3637
set -e
3738

38-
CUSTOM_PG_PATH=$PWD/pg_bin
39+
CUSTOM_PG_BIN=$PWD/pg_bin
40+
CUSTOM_PG_SRC=$PWD/postgresql
3941

4042
# here PG_VERSION is provided by postgres:X-alpine docker image
4143
wget -O postgresql.tar.bz2"https://ftp.postgresql.org/pub/source/v$PG_VERSION/postgresql-$PG_VERSION.tar.bz2"
4244
echo"$PG_SHA256 *postgresql.tar.bz2"| sha256sum -c -
4345

44-
mkdirpostgresql
46+
mkdir$CUSTOM_PG_SRC
4547

4648
tar \
4749
--extract \
4850
--file postgresql.tar.bz2 \
49-
--directorypostgresql \
51+
--directory$CUSTOM_PG_SRC \
5052
--strip-components 1
5153

52-
cdpostgresql
54+
cd$CUSTOM_PG_SRC
5355

5456
# enable Valgrind support
5557
sed -i.bak"s/\/* #define USE_VALGRIND *\//#define USE_VALGRIND/g" src/include/pg_config_manual.h
5658

5759
# enable additional options
58-
eval ./configure \
59-
--with-gnu-ld \
60+
./configure \
6061
--enable-debug \
6162
--enable-cassert \
62-
--prefix=$CUSTOM_PG_PATH
63+
--prefix=$CUSTOM_PG_BIN
6364

64-
# TODO: -j$(nproc)
65-
make -s -j1&& make install
65+
make -s -j$(nproc)&& make -s install
6666

6767
# override default PostgreSQL instance
68-
export PATH=$CUSTOM_PG_PATH/bin:$PATH
68+
export PATH=$CUSTOM_PG_BIN/bin:$PATH
69+
export LD_LIBRARY_PATH=$CUSTOM_PG_BIN/lib
6970

7071
# show pg_config path (just in case)
7172
which pg_config
@@ -82,16 +83,43 @@ make USE_PGXS=1 install
8283
# initialize database
8384
initdb -D$PGDATA
8485

86+
# set appropriate port
87+
export PGPORT=55435
88+
echo"port =$PGPORT">>$PGDATA/postgresql.conf
89+
8590
# restart cluster 'test'
86-
echo"port = 55435">>$PGDATA/postgresql.conf
87-
pg_ctl start -l /tmp/postgres.log -w|| status=$?
91+
if ["$LEVEL"="nightmare" ];then
92+
ls$CUSTOM_PG_BIN/bin
93+
94+
valgrind \
95+
--leak-check=no \
96+
--time-stamp=yes \
97+
--trace-children=yes \
98+
--gen-suppressions=all \
99+
--suppressions=$CUSTOM_PG_SRC/src/tools/valgrind.supp \
100+
--log-file=/tmp/valgrind-%p.log \
101+
postgres -l /tmp/postgres.log -w|| status=$?
102+
else
103+
pg_ctl start -l /tmp/postgres.log -w|| status=$?
104+
fi
88105

89106
# something's wrong, exit now!
90107
if [$status-ne 0 ];then cat /tmp/postgres.log;exit 1;fi
91108

92109
# run regression tests
93110
export PG_REGRESS_DIFF_OPTS="-w -U3"# for alpine's diff (BusyBox)
94-
PGPORT=55435 make USE_PGXS=1 installcheck|| status=$?
111+
make USE_PGXS=1 installcheck|| status=$?
112+
113+
# show Valgrind logs if necessary
114+
if ["$LEVEL"="nightmare" ];then
115+
forfin$(find /tmp -name valgrind-*.log);do
116+
if grep -q'Command: [^ ]*/postgres'$f&& grep -q'ERROR SUMMARY: [1-9]'$f;then
117+
echo"========= Contents of$f"
118+
cat$f
119+
status=1
120+
fi
121+
done
122+
fi
95123

96124
# show diff if it exists
97125
iftest -f regression.diffs;then cat regression.diffs;fi

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp