Commit 0ee440d3 authored by Martin Pitt's avatar Martin Pitt

factorize version in 030_create_errors.t

parent a393e69e
......@@ -11,25 +11,27 @@ use Test::More tests => 9;
use lib '/usr/share/postgresql-common';
use PgCommon;
my $version = '7.4';
my $socketdir = '/tmp/postgresql-testsuite/';
mkdir $socketdir or die "mkdir: $!";
chown scalar (getpwnam 'postgres'), 0, $socketdir or die "chown: $!";
# create cluster
ok ((system "pg_createcluster --socketdir '$socketdir' 7.4 main >/dev/null") == 0,
ok ((system "pg_createcluster --socketdir '$socketdir' $version main >/dev/null") == 0,
"pg_createcluster --socketdir");
# chown cluster to an invalid user to test error
(system 'chown -R 99 /var/lib/postgresql/7.4/main') == 0 or die "chown failed: $!";
is ((system 'pg_ctlcluster -s 7.4 main start 2>/dev/null'), 256,
(system "chown -R 99 /var/lib/postgresql/$version/main") == 0 or die "chown failed: $!";
is ((system "pg_ctlcluster -s $version main start 2>/dev/null"), 256,
'pg_ctlcluster fails on invalid cluster owner uid');
(system 'chown -R postgres:99 /var/lib/postgresql/7.4/main') == 0 or die "chown failed: $!";
is ((system 'pg_ctlcluster -s 7.4 main start 2>/dev/null'), 256,
(system "chown -R postgres:99 /var/lib/postgresql/$version/main") == 0 or die "chown failed: $!";
is ((system "pg_ctlcluster -s $version main start 2>/dev/null"), 256,
'pg_ctlcluster as root fails on invalid cluster owner gid');
is ((exec_as 'postgres', 'pg_ctlcluster 7.4 main start'), 1,
is ((exec_as 'postgres', "pg_ctlcluster $version main start"), 1,
'pg_ctlcluster as postgres fails on invalid cluster owner gid');
(system 'chown -R postgres:postgres /var/lib/postgresql/7.4/main') == 0 or die "chown failed: $!";
is ((system 'pg_ctlcluster -s 7.4 main start'), 0,
(system "chown -R postgres:postgres /var/lib/postgresql/$version/main") == 0 or die "chown failed: $!";
is ((system "pg_ctlcluster -s $version main start"), 0,
'pg_ctlcluster succeeds on valid cluster owner uid/gid');
# check socket
......@@ -37,7 +39,7 @@ ok_dir '/var/run/postgresql', [], 'No sockets in /var/run/postgresql';
ok_dir $socketdir, ['.s.PGSQL.5432', '.s.PGSQL.5432.lock'], "Socket is in $socketdir";
# remove cluster and directory
ok ((system "pg_dropcluster 7.4 main --stop-server") == 0,
ok ((system "pg_dropcluster $version main --stop-server") == 0,
'pg_dropcluster');
ok_dir $socketdir, [], 'No sockets any more';
rmdir $socketdir or die "rmdir: $!";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment