Refactor PG_TEST_EXTRA logic in autoconf build
authorAndres Freund <andres@anarazel.de>
Tue, 20 Sep 2022 18:09:30 +0000 (11:09 -0700)
committerAndres Freund <andres@anarazel.de>
Tue, 20 Sep 2022 18:24:16 +0000 (11:24 -0700)
To avoid duplicating the PG_TEST_EXTRA logic in Makefiles into the upcoming
meson based build definition, move the checks into the the tests
themselves. That also has the advantage of making skipped tests visible.

Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/7dae5979-c6c0-cec5-7a36-76a85aa8053d@enterprisedb.com

src/test/Makefile
src/test/kerberos/t/001_auth.pl
src/test/ldap/t/001_auth.pl
src/test/ssl/t/001_ssltests.pl
src/test/ssl/t/002_scram.pl
src/test/ssl/t/003_sslinfo.pl

index 69ef074d75ecfef9f829654ce3149a255f3584e4..dbd3192874d3375c520ce08a72458b0d98741868 100644 (file)
@@ -17,25 +17,20 @@ SUBDIRS = perl regress isolation modules authentication recovery subscription
 ifeq ($(with_icu),yes)
 SUBDIRS += icu
 endif
-
-# Test suites that are not safe by default but can be run if selected
-# by the user via the whitespace-separated list in variable
-# PG_TEST_EXTRA:
 ifeq ($(with_gssapi),yes)
-ifneq (,$(filter kerberos,$(PG_TEST_EXTRA)))
 SUBDIRS += kerberos
 endif
-endif
 ifeq ($(with_ldap),yes)
-ifneq (,$(filter ldap,$(PG_TEST_EXTRA)))
 SUBDIRS += ldap
 endif
-endif
 ifeq ($(with_ssl),openssl)
-ifneq (,$(filter ssl,$(PG_TEST_EXTRA)))
 SUBDIRS += ssl
 endif
-endif
+
+# Test suites that are not safe by default but can be run if selected
+# by the user via the whitespace-separated list in variable PG_TEST_EXTRA.
+# Export PG_TEST_EXTRA to check it in individual tap tests.
+export PG_TEST_EXTRA
 
 # We don't build or execute these by default, but we do want "make
 # clean" etc to recurse into them.  (We must filter out those that we
index 62e0542639309e2a1ecb5091627450a3750469de..47169a1d1eb4a9f19f9c1e241bfb9ece96505954 100644 (file)
@@ -25,6 +25,10 @@ if ($ENV{with_gssapi} ne 'yes')
 {
    plan skip_all => 'GSSAPI/Kerberos not supported by this build';
 }
+elsif ($ENV{PG_TEST_EXTRA} !~ /\bkerberos\b/)
+{
+   plan skip_all => 'Potentially unsafe test GSSAPI/Kerberos not enabled in PG_TEST_EXTRA';
+}
 
 my ($krb5_bin_dir, $krb5_sbin_dir);
 
index 86dff8bd1f3b5ac27665d6f4f74ca37d1cae5519..2f064f6944069aadfea7058f11763f87f9d9d2c5 100644 (file)
@@ -16,6 +16,10 @@ if ($ENV{with_ldap} ne 'yes')
 {
    plan skip_all => 'LDAP not supported by this build';
 }
+elsif ($ENV{PG_TEST_EXTRA} !~ /\bldap\b/)
+{
+   plan skip_all => 'Potentially unsafe test LDAP not enabled in PG_TEST_EXTRA';
+}
 elsif ($^O eq 'darwin' && -d '/usr/local/opt/openldap')
 {
    # typical paths for Homebrew
index efab2ac194c24bd610e7458b97b5160a5c534cdc..c77bc9ef500a000fa75d6514af00d54ac4af40da 100644 (file)
@@ -17,6 +17,10 @@ if ($ENV{with_ssl} ne 'openssl')
 {
    plan skip_all => 'OpenSSL not supported by this build';
 }
+elsif ($ENV{PG_TEST_EXTRA} !~ /ssl/)
+{
+   plan skip_all => 'Potentially unsafe test SSL not enabled in PG_TEST_EXTRA';
+}
 
 my $ssl_server = SSL::Server->new();
 
index 588f47a39b990dd271074c09eb6f54d53eecc060..deaa4aa086581aed1d098f455146e09aea3dd578 100644 (file)
@@ -20,6 +20,10 @@ if ($ENV{with_ssl} ne 'openssl')
 {
    plan skip_all => 'OpenSSL not supported by this build';
 }
+elsif ($ENV{PG_TEST_EXTRA} !~ /\bssl\b/)
+{
+   plan skip_all => 'Potentially unsafe test SSL not enabled in PG_TEST_EXTRA';
+}
 
 my $ssl_server = SSL::Server->new();
 
index 87fb18a31e00f1cb2d7fb778dad383e415ea3a0e..eb0a733a8421f4136c77f19c339de83075837239 100644 (file)
@@ -18,6 +18,10 @@ if ($ENV{with_ssl} ne 'openssl')
 {
    plan skip_all => 'OpenSSL not supported by this build';
 }
+elsif ($ENV{PG_TEST_EXTRA} !~ /\bssl\b/)
+{
+   plan skip_all => 'Potentially unsafe test SSL not enabled in PG_TEST_EXTRA';
+}
 
 #### Some configuration
 my $ssl_server = SSL::Server->new();