Patch 0001 fixes this issue with vpath postgres builds: $ make -C src/test/regress install-tests /usr/bin/install: cannot create regular file 'PGPREFIX/lib/postgresql/regress/PGPREFIX/src/test/regress/expected/errors.out': No such file or directory make: *** [GNUmakefile:90: install-tests] Error 1
(where PGPREFIX is your --prefix) It also makes the install-tests target a toplevel target for convenience. Three related bonus patches are attached in case anyone thinks they're a good idea: - 0002 changes the install location of src/test/regress's install-tests output files (sql/, expected/ etc) to $(pkglibdir)/pgxs/src/test/regress so that PGXS resolves it as $(top_srcdir)/src/test/regress, same as for in-tree builds. Presently it installs in $(pkglibdir)/regress/ for some reason. This patch applies on top of 0001. It will affect packagers. - 0003 makes the toplevel install-tests target also install src/test/isolation test resources and the test modules. This patch applies on top of either 0001 or 0002, depending on whether you want to include 0002. - 0004 makes the dummy 'check' target in pgxs.mk optional for extensions that define the new PGXS variable NO_DUMMY_CHECK_TARGET . This lets extensions that want to define a 'check' target do so without having make complain at them about redefined targets. This patch is independent of the others and can apply on master directly. -- Craig Ringer http://www.2ndQuadrant.com/ 2ndQuadrant - PostgreSQL Solutions for the Enterprise
From 32792393d58540c4435e89df4e3b82d9800954c4 Mon Sep 17 00:00:00 2001 From: Craig Ringer <cr...@2ndquadrant.com> Date: Thu, 9 Apr 2020 12:29:21 +0800 Subject: [PATCH 1/4] Fix install-tests target for vpath builds The prefixing of $(srcdir) on test file names in src/test/regress's make install-tests target broke on vpath builds. Fix it so that the tests install properly. Add the install-tests target to the top-level Makefile too, so it's more easily found and used. --- GNUmakefile.in | 1 + src/test/regress/GNUmakefile | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/GNUmakefile.in b/GNUmakefile.in index ee636e3b50..bcbed94041 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -71,6 +71,7 @@ $(call recurse,check-world,src/test src/pl src/interfaces/ecpg contrib src/bin,c $(call recurse,checkprep, src/test src/pl src/interfaces/ecpg contrib src/bin) $(call recurse,installcheck-world,src/test src/pl src/interfaces/ecpg contrib src/bin,installcheck) +$(call recurse,install-tests,src/test/regress,install-tests) GNUmakefile: GNUmakefile.in $(top_builddir)/config.status ./config.status $@ diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile index 1a3164065f..2100850528 100644 --- a/src/test/regress/GNUmakefile +++ b/src/test/regress/GNUmakefile @@ -87,9 +87,9 @@ regress_data_files = \ install-tests: all install install-lib installdirs-tests $(MAKE) -C $(top_builddir)/contrib/spi install - for file in $(regress_data_files); do \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(pkglibdir)/regress/'$$file || exit; \ - done + $(foreach datafile,$(regress_data_files), \ + $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pkglibdir)/regress/$(subst $(srcdir),,$(datafile))'; \ + ) installdirs-tests: installdirs $(MKDIR_P) $(patsubst $(srcdir)/%/,'$(DESTDIR)$(pkglibdir)/regress/%',$(sort $(dir $(regress_data_files)))) -- 2.25.1
From 7724b734f321640a729d84599a3244084c769007 Mon Sep 17 00:00:00 2001 From: Craig Ringer <cr...@2ndquadrant.com> Date: Thu, 9 Apr 2020 12:53:51 +0800 Subject: [PATCH 3/4] Support the install-tests target for the rest of the test suite Install almost all the test suite when "make install-tests" is run, so it can be used by extensions that want to ensure that their behaviour doesn't break anything in PostgreSQL proper. As this is fairly advanced usage it's expected that extensions will provide their own Makefile support. PGXS does not attempt to do so. --- GNUmakefile.in | 2 +- src/test/Makefile | 2 ++ src/test/authentication/Makefile | 9 +++++++++ src/test/isolation/Makefile | 34 +++++++++++++++++++++++++------- src/test/kerberos/Makefile | 9 +++++++++ src/test/ldap/Makefile | 9 +++++++++ src/test/locale/Makefile | 4 ++++ src/test/modules/Makefile | 9 +++++++++ src/test/perl/Makefile | 6 ++++++ src/test/recovery/Makefile | 9 +++++++++ src/test/ssl/Makefile | 10 ++++++++++ src/test/subscription/Makefile | 9 +++++++++ 12 files changed, 104 insertions(+), 8 deletions(-) diff --git a/GNUmakefile.in b/GNUmakefile.in index bcbed94041..37cdfcb314 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -71,7 +71,7 @@ $(call recurse,check-world,src/test src/pl src/interfaces/ecpg contrib src/bin,c $(call recurse,checkprep, src/test src/pl src/interfaces/ecpg contrib src/bin) $(call recurse,installcheck-world,src/test src/pl src/interfaces/ecpg contrib src/bin,installcheck) -$(call recurse,install-tests,src/test/regress,install-tests) +$(call recurse,install-tests,src/test,install-tests) GNUmakefile: GNUmakefile.in $(top_builddir)/config.status ./config.status $@ diff --git a/src/test/Makefile b/src/test/Makefile index efb206aa75..b8df9428bc 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -48,5 +48,7 @@ installable_dirs := $(filter-out modules, $(SUBDIRS)) $(call recurse,$(recurse_alldirs_targets)) $(call recurse,installcheck, $(installable_dirs)) $(call recurse,install, $(installable_dirs)) +# The install-tests target visits all subdirs +$(call recurse,install-tests) $(recurse_always) diff --git a/src/test/authentication/Makefile b/src/test/authentication/Makefile index 124d1d0771..3ed3011a51 100644 --- a/src/test/authentication/Makefile +++ b/src/test/authentication/Makefile @@ -21,3 +21,12 @@ installcheck: clean distclean maintainer-clean: rm -rf tmp_check + +install-tests-dirs: + $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(subdir)/t' + +install-tests: install-tests-dirs + $(INSTALL_DATA) $(srcdir)/Makefile '$(DESTDIR)$(pgxsdir)/$(subdir)/Makefile' + $(foreach datafile,$(wildcard $(srcdir)/$(subdir)/t/*.pl), \ + $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pgxsdir)/$(subdir)/$(subst $(srcdir),,$(datafile))'; \ + ) diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile index da5e088bdd..34038de7f3 100644 --- a/src/test/isolation/Makefile +++ b/src/test/isolation/Makefile @@ -18,13 +18,6 @@ OBJS = \ all: isolationtester$(X) pg_isolation_regress$(X) -# Though we don't install these binaries, build them during installation -# (including temp-install). Otherwise, "make -j check-world" and "make -j -# installcheck-world" would spawn multiple, concurrent builds in this -# directory. Later builds would overwrite files while earlier builds are -# reading them, causing occasional failures. -install: | all - submake-regress: $(MAKE) -C $(top_builddir)/src/test/regress pg_regress.o @@ -67,3 +60,30 @@ installcheck-prepared-txns: all temp-install check-prepared-txns: all temp-install $(pg_isolation_regress_check) --schedule=$(srcdir)/isolation_schedule prepared-transactions + +installdirs: + $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(subdir)' + +# The isolation tester is useful for running tests on extensions so we install and ship it. +install: all installdirs + $(INSTALL_PROGRAM) pg_isolation_regress$(X) '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_isolation_regress$(X)' + +# PostgreSQL's own test data is not installed by default, but is available for +# install using the "install-tests" target in case extensions want to verify +# that their own changes don't break anything in PostgreSQL proper. + +isolation_data_files = \ + $(wildcard $(srcdir)/specs/*.spec) \ + $(wildcard $(srcdir)/expected/*.out) \ + $(wildcard $(srcdir)/data/*.data) \ + $(srcdir)/isolation_schedule + +installdirs-tests: installdirs + $(MKDIR_P) $(patsubst $(srcdir)/%/,'$(DESTDIR)$(pgxsdir)/$(subdir)/%',$(sort $(dir $(isolation_data_files)))) + +install-tests: all install installdirs-tests installdirs-tests + $(MAKE) -C $(top_builddir)/contrib/spi install + $(foreach datafile,$(isolation_data_files), \ + $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pgxsdir)/$(subdir)/$(subst $(srcdir),,$(datafile))'; \ + ) + $(INSTALL_DATA) Makefile '$(DESTDIR)$(pgxsdir)/$(subdir)/' diff --git a/src/test/kerberos/Makefile b/src/test/kerberos/Makefile index 04a0f746b5..fefd6aac51 100644 --- a/src/test/kerberos/Makefile +++ b/src/test/kerberos/Makefile @@ -23,3 +23,12 @@ installcheck: clean distclean maintainer-clean: rm -rf tmp_check + +install-tests-dirs: + $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(subdir)/t' + +install-tests: install-tests-dirs + $(INSTALL_DATA) $(srcdir)/Makefile '$(DESTDIR)$(pgxsdir)/$(subdir)/Makefile' + $(foreach datafile,$(wildcard $(srcdir)/$(subdir)/t/*.pl), \ + $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pgxsdir)/$(subdir)/$(subst $(srcdir),,$(datafile))'; \ + ) diff --git a/src/test/ldap/Makefile b/src/test/ldap/Makefile index 3e5afd9777..a8f2db286b 100644 --- a/src/test/ldap/Makefile +++ b/src/test/ldap/Makefile @@ -23,3 +23,12 @@ installcheck: clean distclean maintainer-clean: rm -rf tmp_check + +install-tests-dirs: + $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(subdir)/t' + +install-tests: install-tests-dirs + $(INSTALL_DATA) $(srcdir)/Makefile $(srcdir)/authdata.ldif '$(DESTDIR)$(pgxsdir)/$(subdir)/' + $(foreach datafile,$(wildcard $(srcdir)/$(subdir)/t/*.pl), \ + $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pgxsdir)/$(subdir)/$(subst $(srcdir),,$(datafile))'; \ + ) diff --git a/src/test/locale/Makefile b/src/test/locale/Makefile index 22a45b65f2..c07b958b5e 100644 --- a/src/test/locale/Makefile +++ b/src/test/locale/Makefile @@ -19,3 +19,7 @@ clean distclean maintainer-clean: # These behave like installcheck targets. check-%: all @$(MAKE) -C `echo $@ | sed 's/^check-//'` test + +# The locale tests can't really be run outside the source tree +# right now so don't install them. +install-tests: ; diff --git a/src/test/modules/Makefile b/src/test/modules/Makefile index 29de73c060..c11b06afb2 100644 --- a/src/test/modules/Makefile +++ b/src/test/modules/Makefile @@ -33,3 +33,12 @@ endif $(recurse) $(recurse_always) + +# Some of these modules are needed for the regress, isolation, or recovery +# (TAP) test suites, so install them when install-tests is requested. +# +# We should probably put them in a separate non-default path but right now we +# cannot do so due to the lack of any extension search path for extensions and +# control files. +# +$(call recurse,install-tests,$(SUBDIRS),install) diff --git a/src/test/perl/Makefile b/src/test/perl/Makefile index acdd160620..1063262365 100644 --- a/src/test/perl/Makefile +++ b/src/test/perl/Makefile @@ -30,4 +30,10 @@ uninstall: rm -f '$(DESTDIR)$(pgxsdir)/$(subdir)/RecursiveCopy.pm' rm -f '$(DESTDIR)$(pgxsdir)/$(subdir)/PostgresNode.pm' +else + +install: ; + endif + +install-tests: install diff --git a/src/test/recovery/Makefile b/src/test/recovery/Makefile index fa8e031526..fbe98bb27c 100644 --- a/src/test/recovery/Makefile +++ b/src/test/recovery/Makefile @@ -23,3 +23,12 @@ installcheck: clean distclean maintainer-clean: rm -rf tmp_check + +install-tests-dirs: + $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(subdir)/t' + +install-tests: install-tests-dirs + $(INSTALL_DATA) $(srcdir)/Makefile '$(DESTDIR)$(pgxsdir)/$(subdir)/' + $(foreach datafile,$(wildcard $(srcdir)/$(subdir)/t/*.pl), \ + $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pgxsdir)/$(subdir)/$(subst $(srcdir),,$(datafile))'; \ + ) diff --git a/src/test/ssl/Makefile b/src/test/ssl/Makefile index 06e37d5269..606957c431 100644 --- a/src/test/ssl/Makefile +++ b/src/test/ssl/Makefile @@ -161,3 +161,13 @@ check: installcheck: $(prove_installcheck) + +# Allow SSL tests to be run against an installed/packaged postgres too. +install-tests-dirs: + $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(subdir)/t' + +install-tests: install-tests-dirs + $(INSTALL_DATA) $(srcdir)/Makefile $(srcdir)/README $(wildcard $(srcdir)/*.config) '$(DESTDIR)$(pgxsdir)/$(subdir)/' + $(foreach datafile,$(wildcard $(srcdir)/$(subdir)/t/*.p[lm]), \ + $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pgxsdir)/$(subdir)/$(subst $(srcdir),,$(datafile))'; \ + ) diff --git a/src/test/subscription/Makefile b/src/test/subscription/Makefile index 3ac06aa3de..d691a28deb 100644 --- a/src/test/subscription/Makefile +++ b/src/test/subscription/Makefile @@ -25,3 +25,12 @@ installcheck: clean distclean maintainer-clean: rm -rf tmp_check + +install-tests-dirs: + $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(subdir)/t' + +install-tests: install-tests-dirs + $(INSTALL_DATA) $(srcdir)/Makefile $(srcdir)/README '$(DESTDIR)$(pgxsdir)/$(subdir)/' + $(foreach datafile,$(wildcard $(srcdir)/$(subdir)/t/*.pl), \ + $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pgxsdir)/$(subdir)/$(subst $(srcdir),,$(datafile))'; \ + ) -- 2.25.1
From d58e8adf008d77ab40aee8fd625591dc2925da72 Mon Sep 17 00:00:00 2001 From: Craig Ringer <cr...@2ndquadrant.com> Date: Thu, 9 Apr 2020 12:57:41 +0800 Subject: [PATCH 4/4] Make the dummy 'check' target in PGXS makefiles optional Allow extensions to provide their own 'check' target without getting warnings by defining the new special variable NO_DUMMY_CHECK_TARGET. This lets extensions avoid a spurious warning about overriding the existing target. --- src/makefiles/pgxs.mk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index 271e7eaba8..f6231d7701 100644 --- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -51,6 +51,10 @@ # ISOLATION_OPTS -- additional switches to pass to pg_isolation_regress # NO_INSTALLCHECK -- don't define an installcheck target, useful e.g. if # tests require special configuration, or don't use pg_regress +# NO_DUMMY_CHECK_TARGET -- don't define a dummy 'check' target that +# directs the user to installcheck. Useful if the extension can provide a +# useful "make check" that doesn't need to target an existing running +# PostgreSQL instance. # EXTRA_CLEAN -- extra files to remove in 'make clean' # PG_CPPFLAGS -- will be prepended to CPPFLAGS # PG_CFLAGS -- will be appended to CFLAGS @@ -429,9 +433,11 @@ endif # NO_INSTALLCHECK # Runs independently of any installation ifdef PGXS +ifndef NO_DUMMY_CHECK_TARGET check: @echo '"$(MAKE) check" is not supported.' @echo 'Do "$(MAKE) install", then "$(MAKE) installcheck" instead.' +endif else check: submake $(REGRESS_PREP) ifdef REGRESS -- 2.25.1
From 9cd66b28ec9c93386ac87c9f36c67a0bde4e6b10 Mon Sep 17 00:00:00 2001 From: Craig Ringer <cr...@2ndquadrant.com> Date: Thu, 23 Apr 2020 12:25:55 +0800 Subject: [PATCH 2/4] Move installed pg_regress test sources to $(pkglibdir)/pgxs/src/test/regress $(pkglibdir)/pgxs/ corresponds to the top_srcdir in a real source tree. It's supposed to be a thinned out top_srcdir that extensions etc can treat as if it's a real PostgreSQL srcdir when building and testing. When support for installing the pg_regress test sources themselves was added so we could create postgresqlNN-test packages, the test sources were installed in $(pkglibdir)/regress, outside the virtual srcdir. That's OK, it just means they aren't where you'd really expect them to be and cannot be found by Makefiles. Relocate the installed location to $(pkglibdir)/pgxs/src/test/regress so that they're in the same place relative to the installdir's fake $(top_srcdir) as they are in the real srcdir. Many packages already move them elsewhere; e.g. PGDG rpms install them in $(pkglibdir)/test/regress/ . So there is not a single expected location right now. Additionally we don't install a Makefile that "knows" where they are at present. So this change will mainly affect packaging. Doesn't install src/test/regress/GNUmakefile. It's easy enough to concoct your own pg_regress commandline to run the tests. --- src/test/regress/GNUmakefile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile index 2100850528..312e0f0baf 100644 --- a/src/test/regress/GNUmakefile +++ b/src/test/regress/GNUmakefile @@ -85,14 +85,25 @@ regress_data_files = \ $(wildcard $(srcdir)/data/*.data) \ $(srcdir)/parallel_schedule $(srcdir)/serial_schedule $(srcdir)/resultmap +# Install the sql, expected and data files, schedules, refint and autoinc +# contribs etc we actually need to run a "make installcheck" against an +# installed/packaged postgresql. +# +# Useful for extensions that want to run the Pg regression test suite with +# custom options to check that they don't break anything in PostgreSQL proper. +# +# Tests are installed in the PGXS tree so that they can be found at the +# expected relative paths in PGXS's faked-up thin source tree. +# install-tests: all install install-lib installdirs-tests $(MAKE) -C $(top_builddir)/contrib/spi install $(foreach datafile,$(regress_data_files), \ - $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pkglibdir)/regress/$(subst $(srcdir),,$(datafile))'; \ + $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pgxsdir)/$(subdir)/$(subst $(srcdir),,$(datafile))'; \ ) + installdirs-tests: installdirs - $(MKDIR_P) $(patsubst $(srcdir)/%/,'$(DESTDIR)$(pkglibdir)/regress/%',$(sort $(dir $(regress_data_files)))) + $(MKDIR_P) $(patsubst $(srcdir)/%/,'$(DESTDIR)$(pgxsdir)/$(subdir)/%',$(sort $(dir $(regress_data_files)))) # Get some extra C modules from contrib/spi -- 2.25.1