summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/001_packages.t8
-rw-r--r--t/020_create_sql_remove.t13
-rw-r--r--t/027_jit.t44
3 files changed, 54 insertions, 11 deletions
diff --git a/t/001_packages.t b/t/001_packages.t
index 697e871..e205321 100644
--- a/t/001_packages.t
+++ b/t/001_packages.t
@@ -45,10 +45,12 @@ foreach my $v (@MAJORS) {
skip "No python2 support", 1 unless ($v <= 11 and $PgCommon::have_python2);
ok ((deb_installed "postgresql-plpython-$v$f"), "postgresql-plpython-$v$f installed");
}
- if ($v >= '9.1') {
+ SKIP: {
+ skip "no Python 3 package for version $v", 1 if ($v < '9.1');
+ my $pyver = `python3 --version 2>/dev/null`;
+ chomp $pyver;
+ skip "$pyver is too new for PL/Python3 on $v", 1 if ($v < 10 and $pyver and $pyver =~ /3\.1[2-9]/); # distutils removed in Python 3.12
ok ((deb_installed "postgresql-plpython3-$v$f"), "postgresql-plpython3-$v$f installed");
- } else {
- pass "no Python 3 package for version $v";
}
ok ((deb_installed "postgresql-plperl-$v$f"), "postgresql-plperl-$v$f installed");
ok ((deb_installed "postgresql-pltcl-$v$f"), "postgresql-pltcl-$v$f installed");
diff --git a/t/020_create_sql_remove.t b/t/020_create_sql_remove.t
index d208b99..aa2bcaa 100644
--- a/t/020_create_sql_remove.t
+++ b/t/020_create_sql_remove.t
@@ -292,19 +292,16 @@ tel|2
}
# Check PL/Python3 (untrusted)
- if ($v >= '9.1') {
+ SKIP: {
+ skip "Skipping PL/Python3 test for version $v...", 6 if ($v < 9.1);
+ my $pyver = `python3 --version 2>/dev/null`;
+ chomp $pyver;
+ skip "$pyver is too new for PL/Python3 on $v...", 6 if ($v < 10 and $pyver and $pyver =~ /3\.1[1-9]/); # distutils removed in Python 3.12
is_program_out 'postgres', create_extension($v, 'plpython3u'), 0, '', 'CREATE EXTENSION plpython3u succeeds for user postgres';
is_program_out 'postgres', 'psql nobodydb -qc "CREATE FUNCTION capitalize3(text) RETURNS text AS \'import sys; return args[0].capitalize() + sys.version[0]\' LANGUAGE plpython3u;"',
0, '', 'creating PL/Python3 function as user postgres succeeds';
is_program_out 'nobody', 'psql nobodydb -Atc "select capitalize3(\'foo\')"',
0, "Foo3\n", 'calling PL/Python function';
- } else {
- pass "Skipping PL/Python3 test for version $v...";
- pass '...';
- pass '...';
- pass '...';
- pass '...';
- pass '...';
}
# Check PL/Tcl (trusted/untrusted)
diff --git a/t/027_jit.t b/t/027_jit.t
new file mode 100644
index 0000000..4ed5ddb
--- /dev/null
+++ b/t/027_jit.t
@@ -0,0 +1,44 @@
+use strict;
+
+use lib 't';
+use TestLib;
+
+use Test::More;
+
+my $arch = `dpkg --print-architecture`;
+chomp $arch;
+if (grep { $_ eq $arch} qw(alpha hppa hurd-i386 ia64 kfreebsd-amd64 kfreebsd-i386 loong64 m68k powerpc riscv64 sh4 sparc64 x32)) {
+ ok 1, "No JIT tests on $arch";
+ done_testing();
+ exit;
+}
+
+foreach my $v (@MAJORS) {
+ if ($v < 11) {
+ ok 1, "No JIT support on $v";
+ next;
+ }
+ note "$v";
+
+ program_ok 'root', "pg_createcluster $v main --start", 0;
+
+ my $jit_default = $v == '11' ? 'off' : 'on';
+ like_program_out 'postgres', "psql -Xatc 'show jit'", 0, qr/$jit_default/, "JIT is $jit_default by default";
+ program_ok 'root', "pg_conftool $v main set jit on", 0, "Turn on JIT on PG11" if ($v == 11);
+ program_ok 'root', "pg_ctlcluster $v main reload", 0 if ($v == 11);
+
+ unlike_program_out 'postgres', "psql -c 'explain (analyze) select count(*) from pg_class'", 0, qr/JIT/,
+ "No JIT on cheap query";
+ program_ok 'root', "pg_conftool $v main set seq_page_cost 100000", 0;
+ program_ok 'root', "pg_conftool $v main set random_page_cost 100000", 0;
+ program_ok 'root', "pg_ctlcluster $v main reload", 0;
+ like_program_out 'postgres', "psql -c 'explain (analyze) select count(*) from pg_class'", 0, qr/Timing: Generation .* ms/,
+ "Expensive query is JITed";
+
+ program_ok 'root', "pg_dropcluster --stop $v main", 0;
+ check_clean;
+}
+
+done_testing();
+
+# vim: filetype=perl