Debian Codegraph @

src/bin/pg_ctl/t/002_status.pl

raw
1
2 # Copyright (c) 2021-2025, PostgreSQL Global Development Group
3
4 use strict;
5 use warnings FATAL => 'all';
6
7 use PostgreSQL::Test::Cluster;
8 use PostgreSQL::Test::Utils;
9 use Test::More;
10
11 my $tempdir = PostgreSQL::Test::Utils::tempdir;
12
13 command_exit_is([ 'pg_ctl', 'status', '--pgdata' => "$tempdir/nonexistent" ],
14 4, 'pg_ctl status with nonexistent directory');
15
16 my $node = PostgreSQL::Test::Cluster->new('main');
17 $node->init;
18
19 command_exit_is([ 'pg_ctl', 'status', '--pgdata' => $node->data_dir ],
20 3, 'pg_ctl status with server not running');
21
22 system_or_bail(
23 'pg_ctl',
24 '--log' => "$tempdir/logfile",
25 '--pgdata' => $node->data_dir,
26 '--wait', 'start');
27 command_exit_is([ 'pg_ctl', 'status', '--pgdata' => $node->data_dir ],
28 0, 'pg_ctl status with server running');
29
30 system_or_bail 'pg_ctl', 'stop', '--pgdata' => $node->data_dir;
31
32 done_testing();