$dbhost,
$dbport;
$header =~ s/\s+$//;
+ $header =~ s/^ //;
my $perf = ($opt{showtime} and $db->{totaltime} and $action ne 'bloat') ? "time=$db->{totaltime}s" : '';
if ($db->{perf}) {
$db->{perf} =~ s/^ +//;
like ($result, qr{host:$host}, $t);
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid --warning option};
like ($cp->run('--warning=40'), qr{ERROR:.+must be a percentage}, $t);
}
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid warning option};
like ($cp->run('-w felz'), qr{^ERROR: Warning}, $t);
my $tname = 'cp_bloat_test';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid option};
like ($cp->run('-w=abc'), qr{must be a size or a percentage}, $t);
my $label = 'POSTGRES_CHECKPOINT';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called without warning or critical};
like ($cp->run(''), qr{Must provide a warning and/or critical}, $t);
like ($result, qr{ \| time=\d\.\d\ds\s$}, $t);
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid warning option};
like ($cp->run('-w felz'), qr{^ERROR: No warning}, $t);
like ($result, qr{host:$host}, $t);
$t = qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t = qq{$S handles 'string' type for non-match};
like ($cp->run(qq{--query="$good_query" --valtype=string --warning=abc}),
like ($cp->run('-w 0% -c 0%'), qr{^$label OK:}, $t);
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid warning option};
like ($cp->run('-w felz'), qr{^ERROR: Invalid 'warning' option: must be a percentage}, $t);
like ($cp->run('-w 0% -c 0%'), qr{^$label OK:}, $t);
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid warning option};
like ($cp->run('-w felz'), qr{^ERROR: Invalid 'warning' option: must be a percentage}, $t);
like ($cp->run('-w 10GB -c 20GB'), qr{^$label OK:}, $t);
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid warning option};
like ($cp->run('-w felz'), qr{^ERROR: Invalid size}, $t);
my $label = 'POSTGRES_FSM_PAGES';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid option};
like ($cp->run('--warning=40'), qr{ERROR:.+must be a percentage}, $t);
my $label = 'POSTGRES_FSM_RELATIONS';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid option};
like ($cp->run('--warning=40'), qr{ERROR:.+must be a percentage}, $t);
my $label = 'POSTGRES_LOCKS';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when invalid database used};
like ($cp->run('--dbname=foo'), qr{database "foo" does not exist}, $t);
my $label = 'POSTGRES_NEW_VERSION_BC';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
## No other tests for now
my $label = 'POSTGRES_NEW_VERSION_BOX';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
## No other tests for now
my $label = 'POSTGRES_NEW_VERSION_CP';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S returns warning for mismatched major version};
$cp->fake_self_version('1.2.3');
my $label = 'POSTGRES_NEW_VERSION_PG';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S returns unknown for bizarre Postgres version};
$cp->fake_version('7.8.12');
my $label = 'POSTGRES_NEW_VERSION_TNM';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
## No other tests for now
my $label = 'POSTGRES_PREPARED_TXNS';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
my $ver = $dbh->{pg_server_version};
if ($ver < 80100) {
$dbh2->commit();
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called without warning or critical};
like ($cp->run(''), qr{Must provide a warning and/or critical}, $t);
my $label = 'POSTGRES_SEQUENCE';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid option};
like ($cp->run('--warning=80'), qr{ERROR:.+must be a percentage}, $t);
my $label = 'POSTGRES_SLONY_STATUS';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with invalid warning};
like ($cp->run('-w foo'), qr{ERROR:.+'warning' must be a valid time}, $t);
my $label = 'POSTGRES_VERSION';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with MRTG but no option};
like ($cp->run('--output=mrtg'), qr{ERROR: Invalid mrtg}, $t);
my $label = 'POSTGRES_WAL_FILES';
$t=qq{$S fails when called with an invalid option};
-like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
+like ($cp->run('foobar=12'), qr{Usage:}, $t);
$t=qq{$S fails when called with an invalid option};
like ($cp->run('--warning=30%'), qr{ERROR:.+must be a positive integer}, $t);