From ff18115ae9dc2f2e54f5feb8cd9c493bd963a641 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 3 Mar 2018 08:52:21 -0500 Subject: [PATCH] Prevent LDAP and SSL tests from running without support in build Add checks in each test file that the build supports the feature, otherwise skip all the tests. Before, if someone were to (accidentally) invoke these tests without build support, they would fail in confusing ways. based on patch from Michael Paquier --- src/test/ldap/Makefile | 2 ++ src/test/ldap/t/001_auth.pl | 11 ++++++++++- src/test/ssl/Makefile | 2 ++ src/test/ssl/t/001_ssltests.pl | 11 ++++++++++- src/test/ssl/t/002_scram.pl | 11 ++++++++++- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/test/ldap/Makefile b/src/test/ldap/Makefile index fef5742b82..74fef48650 100644 --- a/src/test/ldap/Makefile +++ b/src/test/ldap/Makefile @@ -13,6 +13,8 @@ subdir = src/test/ldap top_builddir = ../../.. include $(top_builddir)/src/Makefile.global +export with_ldap + check: $(prove_check) diff --git a/src/test/ldap/t/001_auth.pl b/src/test/ldap/t/001_auth.pl index a83d96ae91..3a71e05353 100644 --- a/src/test/ldap/t/001_auth.pl +++ b/src/test/ldap/t/001_auth.pl @@ -2,7 +2,16 @@ use strict; use warnings; use TestLib; use PostgresNode; -use Test::More tests => 19; +use Test::More; + +if ($ENV{with_ldap} eq 'yes') +{ + plan tests => 19; +} +else +{ + plan skip_all => 'LDAP not supported by this build'; +} my ($slapd, $ldap_bin_dir, $ldap_schema_dir); diff --git a/src/test/ssl/Makefile b/src/test/ssl/Makefile index 4e9095529a..5cd2c5a404 100644 --- a/src/test/ssl/Makefile +++ b/src/test/ssl/Makefile @@ -13,6 +13,8 @@ subdir = src/test/ssl top_builddir = ../../.. include $(top_builddir)/src/Makefile.global +export with_openssl + CERTIFICATES := server_ca server-cn-and-alt-names \ server-cn-only server-single-alt-name server-multiple-alt-names \ server-no-names server-revoked server-ss \ diff --git a/src/test/ssl/t/001_ssltests.pl b/src/test/ssl/t/001_ssltests.pl index 4b097a69bf..34df5e9dbb 100644 --- a/src/test/ssl/t/001_ssltests.pl +++ b/src/test/ssl/t/001_ssltests.pl @@ -2,10 +2,19 @@ use strict; use warnings; use PostgresNode; use TestLib; -use Test::More tests => 62; +use Test::More; use ServerSetup; use File::Copy; +if ($ENV{with_openssl} eq 'yes') +{ + plan tests => 62; +} +else +{ + plan skip_all => 'SSL not supported by this build'; +} + #### Some configuration # This is the hostname used to connect to the server. This cannot be a diff --git a/src/test/ssl/t/002_scram.pl b/src/test/ssl/t/002_scram.pl index 9460763a65..7c6be7a219 100644 --- a/src/test/ssl/t/002_scram.pl +++ b/src/test/ssl/t/002_scram.pl @@ -4,10 +4,19 @@ use strict; use warnings; use PostgresNode; use TestLib; -use Test::More tests => 6; +use Test::More; use ServerSetup; use File::Copy; +if ($ENV{with_openssl} eq 'yes') +{ + plan tests => 6; +} +else +{ + plan skip_all => 'SSL not supported by this build'; +} + # This is the hostname used to connect to the server. my $SERVERHOSTADDR = '127.0.0.1'; -- 2.40.0