summaryrefslogtreecommitdiffstats
path: root/src/test/modules/libpq_pipeline/t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:46:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:46:48 +0000
commit311bcfc6b3acdd6fd152798c7f287ddf74fa2a98 (patch)
tree0ec307299b1dada3701e42f4ca6eda57d708261e /src/test/modules/libpq_pipeline/t
parentInitial commit. (diff)
downloadpostgresql-15-upstream.tar.xz
postgresql-15-upstream.zip
Adding upstream version 15.4.upstream/15.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/modules/libpq_pipeline/t')
-rw-r--r--src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
new file mode 100644
index 0000000..0821329
--- /dev/null
+++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
@@ -0,0 +1,78 @@
+
+# Copyright (c) 2021-2022, PostgreSQL Global Development Group
+
+use strict;
+use warnings;
+
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More;
+
+my $node = PostgreSQL::Test::Cluster->new('main');
+$node->init;
+$node->start;
+
+my $numrows = 700;
+
+my ($out, $err) = run_command([ 'libpq_pipeline', 'tests' ]);
+die "oops: $err" unless $err eq '';
+my @tests = split(/\s+/, $out);
+
+mkdir "$PostgreSQL::Test::Utils::tmp_check/traces";
+
+for my $testname (@tests)
+{
+ my @extraargs = ('-r', $numrows);
+ my $cmptrace = grep(/^$testname$/,
+ qw(simple_pipeline nosync multi_pipelines prepared singlerow
+ pipeline_abort pipeline_idle transaction
+ disallowed_in_pipeline)) > 0;
+
+ # For a bunch of tests, generate a libpq trace file too.
+ my $traceout =
+ "$PostgreSQL::Test::Utils::tmp_check/traces/$testname.trace";
+ if ($cmptrace)
+ {
+ push @extraargs, "-t", $traceout;
+ }
+
+ # Execute the test
+ $node->command_ok(
+ [
+ 'libpq_pipeline', @extraargs,
+ $testname, $node->connstr('postgres')
+ ],
+ "libpq_pipeline $testname");
+
+ # Compare the trace, if requested
+ if ($cmptrace)
+ {
+ my $expected;
+ my $result;
+
+ $expected = slurp_file_eval("traces/$testname.trace");
+ next unless $expected ne "";
+ $result = slurp_file_eval($traceout);
+ next unless $result ne "";
+
+ is($result, $expected, "$testname trace match");
+ }
+}
+
+$node->stop('fast');
+
+done_testing();
+
+sub slurp_file_eval
+{
+ my $filepath = shift;
+ my $contents;
+
+ eval { $contents = slurp_file($filepath); };
+ if ($@)
+ {
+ fail "reading $filepath: $@";
+ return "";
+ }
+ return $contents;
+}