aboutsummaryrefslogtreecommitdiff
path: root/src/tools/pgtest
blob: 080cf6ae761ef5b6ce4c7910594da8e27b11891f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh

# src/tools/pgtest [-n] [...]

# This runs a build/initdb/regression test suite
#
# This will start a temporary postmaster, so you have to
# have enough kernel resources to run two postmasters or
# stop your main postmaster before running this script.
#
# Use -n to prevent 'make clean'

MAKE="make"

[ ! -d src ] && echo "This must be run from the top of the PostgreSQL source tree" 1>&2 && exit 1

trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
mkdir /tmp/$$
TMP="/tmp/$$"

if [ "$1" != "-n" ]
then	CLEAN="Y"
else	CLEAN="N"
	shift
fi

rm -f tmp_install/log/install.log

# Run "make check" and store return code in $TMP/ret.
# Display output but also capture it in $TMP/0.
(
	if [ "$CLEAN" = 'Y' ]
	then	$MAKE "$@" clean 2>&1
		echo "$?" > "$TMP"/ret
	fi
	if [ "$(cat "$TMP"/ret)" -eq 0 ]
	then	$MAKE "$@" 2>&1 && $MAKE "$@" check 2>&1
		echo "$?" > "$TMP"/ret
	fi
) | tee "$TMP"/0

# Grab possible warnings from install.log
[ -e tmp_install/log/install.log ] && cat tmp_install/log/install.log >> "$TMP"/0

# If success, display warnings
if [ "$(cat "$TMP"/ret)" -eq 0 ]
then	cat "$TMP"/0 |
	# The following grep's have to be adjusted for your setup because
	# certain warnings are acceptable.
	grep -i warning |
	grep -v setproctitle |
	grep -v find_rule |
	grep -v yy_flex_realloc
fi

# return original make error code
exit "$(cat "$TMP"/ret)"