-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.sh
91 lines (70 loc) · 2.15 KB
/
test.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
tmpdir=${tmpdir-`pwd`/tmp}
pgbin=/usr/lib/postgresql/9.0/bin
make USE_PGXS=0 || exit 1
[ -f $tmpdir/postmaster.pid ] && PGDATA=$tmpdir $pgbin/pg_ctl stop -m immediate >/dev/null 2>&1
[ -d $tmpdir ] && rm -rf $tmpdir
mkdir $tmpdir
$pgbin/initdb -D $tmpdir
# make the current dir the $libdir
echo "dynamic_library_path='`pwd`'" >> $tmpdir/postgresql.conf
cat <<EOF >> $tmpdir/postgresql.conf
listen_addresses=''
fsync=no
shared_preload_libraries='\$libdir/auto_explain.so'
custom_variable_classes = 'auto_explain'
auto_explain.log_min_duration = '3s'
EOF
$pgbin/postgres -D $tmpdir -k $tmpdir 2>$tmpdir/server.err &
sleep 2;
export PGHOST=$tmpdir
SHAREDIR=$($pgbin/pg_config --sharedir)
if psql -v ON_ERROR_STOP postgres -c 'select 1' >/dev/null
then
which=currency
if [ -n "$2" ]
then
which="$2"
fi
case $1 in
# for later benchmarking of improvements...
'benchmark-sql')
echo "Running benchmark of pure-SQL CURRENCY datatype..."
$pgbin/psql -f sql/currency_in_sql.sql postgres
$pgbin/psql -f sql/benchmark_$which.sql postgres
;;
'benchmark')
echo "Running benchmark of custom CURRENCY datatype..."
$pgbin/psql -f sql/currency.sql postgres
$pgbin/psql -f sql/benchmark_$which.sql postgres
;;
*)
[ -z "$debug" ] && uninstall=uninstall
for test in setup tla currency $uninstall
do
$pgbin/psql -a postgres < sql/$test.sql > expected/$test.testout 2>&1
diff -F '^-- ' -u expected/$test.out expected/$test.testout && echo PASS: $test "($(wc -l expected/$test.out|cut -f1 -d\ ) lines)"
done
;;
esac
else
echo "---- pg server errors below----"
cat $tmpdir/server.err
echo "---- pg server errors above----"
debug=1
fi
if [ -n "$debug" ]
then
echo "to connect to your server:"
echo export PGHOST=$PGHOST
[ $(expr "$(which psql)" : "^$pgbin/psql") -eq 0 ] && echo export PATH=$pgbin:\$PATH
echo "psql postgres"
echo
echo "to stop the server:"
echo PGDATA=$tmpdir $pgbin/pg_ctl stop -m immediate
exit
else
export PGDATA=$tmpdir
$pgbin/pg_ctl stop -m immediate >/dev/null 2>&1
[ -d $tmpdir ] && rm -rf $tmpdir
fi