| 1 |
# Copyright (c) 2023-2025, PostgreSQL Global Development Group |
| 2 |
use strict; |
| 3 |
use warnings FATAL => 'all'; |
| 4 |
use Config; |
| 5 |
use PostgreSQL::Test::Utils; |
| 6 |
use PostgreSQL::Test::Cluster; |
| 7 |
use Test::More; |
| 8 |
|
| 9 |
my $node = PostgreSQL::Test::Cluster->new('node'); |
| 10 |
|
| 11 |
$node->init(); |
| 12 |
$node->start(); |
| 13 |
|
| 14 |
$node->safe_psql('postgres', |
| 15 |
q(CREATE DATABASE db_sql_ascii ENCODING "sql_ascii" TEMPLATE template0;)); |
| 16 |
|
| 17 |
my $cmd = |
| 18 |
[ 'test_escape', '--conninfo', $node->connstr . " dbname=db_sql_ascii" ]; |
| 19 |
|
| 20 |
# There currently is no good other way to transport test results from a C |
| 21 |
# program that requires just the node being set-up... |
| 22 |
my ($stderr, $stdout); |
| 23 |
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr; |
| 24 |
|
| 25 |
is($result, 1, "test_escape returns 0"); |
| 26 |
is($stderr, '', "test_escape stderr is empty"); |
| 27 |
|
| 28 |
foreach my $line (split('\n', $stdout)) |
| 29 |
{ |
| 30 |
if ($line =~ m/^ok \d+ ?(.*)/) |
| 31 |
{ |
| 32 |
ok(1, $1); |
| 33 |
} |
| 34 |
|
| 35 |
elsif ($line =~ m/^not ok \d+ ?(.*)/) |
| 36 |
{ |
| 37 |
ok(0, $1); |
| 38 |
} |
| 39 |
|
| 40 |
elsif ($line =~ m/^# ?(.*)/) |
| 41 |
{ |
| 42 |
note $1; |
| 43 |
} |
| 44 |
elsif ($line =~ m/^\d+..\d+$/) |
| 45 |
{ |
| 46 |
} |
| 47 |
else |
| 48 |
{ |
| 49 |
BAIL_OUT("no unmapped lines, got $line"); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
done_testing(); |