]> granicus.if.org Git - postgresql/blobdiff - src/test/regress/GNUmakefile
Enforce our convention about max number of parallel regression tests.
[postgresql] / src / test / regress / GNUmakefile
index 43d29cd8f929dd997ca3457c29338fe8608c30d7..56cd2020787c14c5f524ed13b0718ba13c9471cd 100644 (file)
@@ -1,26 +1,32 @@
 #-------------------------------------------------------------------------
 #
 # GNUmakefile--
-#    Makefile for regress (the regression tests)
+#    Makefile for src/test/regress (the regression tests)
 #
-# Copyright (c) 1994, Regents of the University of California
+# Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
 #
-#
-# IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.26 2000/10/07 20:23:03 petere Exp $
+# src/test/regress/GNUmakefile
 #
 #-------------------------------------------------------------------------
 
+PGFILEDESC = "pg_regress - test driver"
+PGAPPICON = win32
+
 subdir = src/test/regress
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-contribdir := $(top_builddir)/contrib
-
-CFLAGS+= -I$(libpq_srcdir) $(CFLAGS_SL)
-
-LDADD+= $(libpq)
+# maximum simultaneous connections for parallel tests
+MAXCONNOPT =
+ifdef MAX_CONNECTIONS
+MAXCONNOPT += --max-connections=$(MAX_CONNECTIONS)
+endif
 
+# stuff to pass into build of pg_regress
+EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \
+       '-DSHELLPROG="$(SHELL)"' \
+       '-DDLSUFFIX="$(DLSUFFIX)"'
 
 ##
 ## Prepare for tests
@@ -28,144 +34,138 @@ LDADD+= $(libpq)
 
 # Build regression test driver
 
-all: pg_regress
+all: pg_regress$(X)
 
-pg_regress: pg_regress.sh GNUmakefile
-       sed -e 's,@bindir@,$(bindir),g' \
-           -e 's,@libdir@,$(libdir),g' \
-           -e 's,@datadir@,$(datadir),g' \
-           -e 's/@VERSION@/$(VERSION)/g' \
-           -e 's/@host_tuple@/$(host_tuple)/g' \
-           -e 's,@GMAKE@,$(MAKE),g' \
-         $< >$@
-       chmod a+x $@
+pg_regress$(X): pg_regress.o pg_regress_main.o $(WIN32RES) | submake-libpgport
+       $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
 
+# dependencies ensure that path changes propagate
+pg_regress.o: pg_regress.c $(top_builddir)/src/port/pg_config_paths.h
+pg_regress.o: override CPPFLAGS += -I$(top_builddir)/src/port $(EXTRADEFS)
 
-# Build dynamically-loaded object file for CREATE FUNCTION ... LANGUAGE 'C'.
+$(top_builddir)/src/port/pg_config_paths.h: $(top_builddir)/src/Makefile.global
+       $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
 
-DLOBJS := regress$(DLSUFFIX)
-# This is for some platforms
-ifdef EXPSUFF
-DLOBJS += regress$(EXPSUFF)
-endif
+install: all installdirs
+       $(INSTALL_PROGRAM) pg_regress$(X) '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)'
+
+installdirs:
+       $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(subdir)'
+
+uninstall:
+       rm -f '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)'
+
+
+# Build dynamically-loaded object file for CREATE FUNCTION ... LANGUAGE C.
+
+NAME = regress
+OBJS = $(WIN32RES) regress.o
 
-all: $(DLOBJS)
+include $(top_srcdir)/src/Makefile.shlib
 
+all: all-lib
 
-# Build test input and expected files
+$(OBJS): | submake-generated-headers
 
-file_list := copy create_function_1 create_function_2 misc constraints
-input_files  := $(foreach file, $(file_list), sql/$(file).sql)
-output_files := $(foreach file, $(file_list), expected/$(file).out)
+# Test input and expected files.  These are created by pg_regress itself, so we
+# don't have a rule to create them.  We do need rules to clean them however.
+input_files = $(patsubst $(srcdir)/input/%.source,sql/%.sql, $(wildcard $(srcdir)/input/*.source))
+output_files := $(patsubst $(srcdir)/output/%.source,expected/%.out, $(wildcard $(srcdir)/output/*.source))
 
-all: $(input_files) $(output_files)
 
-sql/%.sql: input/%.source
-       pwd=`pwd` && sed "s,_OBJWD_,$$pwd,g;s/_DLSUFFIX_/$(DLSUFFIX)/g" $(srcdir)/$< >$@
+# not installed by default
 
-expected/%.out: output/%.source
-       pwd=`pwd` && sed "s,_OBJWD_,$$pwd,g;s/_DLSUFFIX_/$(DLSUFFIX)/g" $(srcdir)/$< >$@
+regress_data_files = \
+       $(filter-out $(addprefix $(srcdir)/,$(output_files)),$(wildcard $(srcdir)/expected/*.out)) \
+       $(wildcard $(srcdir)/input/*.source) \
+       $(wildcard $(srcdir)/output/*.source) \
+       $(filter-out $(addprefix $(srcdir)/,$(input_files)),$(wildcard $(srcdir)/sql/*.sql)) \
+       $(wildcard $(srcdir)/data/*.data) \
+       $(srcdir)/parallel_schedule $(srcdir)/serial_schedule $(srcdir)/resultmap
 
+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
 
-# And finally some extra C modules...
+installdirs-tests: installdirs
+       $(MKDIR_P)  $(patsubst $(srcdir)/%/,'$(DESTDIR)$(pkglibdir)/regress/%',$(sort $(dir $(regress_data_files))))
 
-all: all-spi
 
-.PHONY: all-spi
-all-spi:
-       $(MAKE) -C $(contribdir)/spi REFINT_VERBOSE=1 refint$(DLSUFFIX) autoinc$(DLSUFFIX)
+# Get some extra C modules from contrib/spi
+
+all: refint$(DLSUFFIX) autoinc$(DLSUFFIX)
+
+refint$(DLSUFFIX): $(top_builddir)/contrib/spi/refint$(DLSUFFIX)
+       cp $< $@
+
+autoinc$(DLSUFFIX): $(top_builddir)/contrib/spi/autoinc$(DLSUFFIX)
+       cp $< $@
+
+$(top_builddir)/contrib/spi/refint$(DLSUFFIX): | submake-contrib-spi ;
+
+$(top_builddir)/contrib/spi/autoinc$(DLSUFFIX): | submake-contrib-spi ;
+
+submake-contrib-spi: | submake-libpgport submake-generated-headers
+       $(MAKE) -C $(top_builddir)/contrib/spi
+
+.PHONY: submake-contrib-spi
+
+# Tablespace setup
+
+.PHONY: tablespace-setup
+tablespace-setup:
+       rm -rf ./testtablespace
+       mkdir ./testtablespace
 
 
 ##
 ## Run tests
 ##
 
-check: all
-       $(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --schedule=parallel_schedule --multibyte=$(MULTIBYTE)
+REGRESS_OPTS = --dlpath=. --max-concurrent-tests=20 $(EXTRA_REGRESS_OPTS)
 
-installcheck: all
-       $(SHELL) ./pg_regress --schedule=serial_schedule --multibyte=$(MULTIBYTE)
+check: all tablespace-setup
+       $(pg_regress_check) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS)
 
+check-tests: all tablespace-setup
+       $(pg_regress_check) $(REGRESS_OPTS) $(MAXCONNOPT) $(TESTS) $(EXTRA_TESTS)
 
-# old interfaces follow...
+installcheck: all tablespace-setup
+       $(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/serial_schedule $(EXTRA_TESTS)
 
-#
-# huge extra tests run in target bigtest
-#
-EXTRA_TESTS    = numeric_big
+installcheck-parallel: all tablespace-setup
+       $(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS)
 
-#
-# run the tests
-#
-runtest: all
-ifneq ($(PORTNAME), win)
-       MULTIBYTE=$(MULTIBYTE);export MULTIBYTE; \
-       $(SHELL) ./regress.sh $(host_tuple) 2>&1 | tee regress.out
-else
-       MULTIBYTE=$(MULTIBYTE);export MULTIBYTE; \
-       ./regress.sh $(host_tuple) 2>&1 | tee regress.out
-endif
-       @echo "ACTUAL RESULTS OF REGRESSION TEST ARE NOW IN FILE regress.out"
-       @echo ""
-       @echo "To run the optional big test(s) too, type 'make bigtest'"
-       @echo "These big tests can take over an hour to complete"
-       @echo "These actually are: $(EXTRA_TESTS)"
+installcheck-tests: all tablespace-setup
+       $(pg_regress_installcheck) $(REGRESS_OPTS) $(TESTS) $(EXTRA_TESTS)
 
-#
-# run the test including the huge extra tests
-#
-bigtest: all
-ifneq ($(PORTNAME), win)
-       MULTIBYTE=$(MULTIBYTE);export MULTIBYTE; \
-       $(SHELL) ./regress.sh $(host_tuple) $(EXTRA_TESTS) 2>&1 | tee regress.out
-else
-       MULTIBYTE=$(MULTIBYTE);export MULTIBYTE; \
-       ./regress.sh $(host_tuple) $(EXTRA_TESTS) 2>&1 | tee regress.out
-endif
-       @echo "ACTUAL RESULTS OF REGRESSION TEST ARE NOW IN FILE regress.out"
+standbycheck: all
+       $(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/standby_schedule --use-existing
 
-#
-# run the parallel test suite
-#
-runcheck: all
-ifneq ($(PORTNAME), win)
-       MULTIBYTE=$(MULTIBYTE);export MULTIBYTE; \
-       $(SHELL) ./run_check.sh $(host_tuple)
-else
-       MULTIBYTE=$(MULTIBYTE);export MULTIBYTE; \
-       ./run_check.sh $(host_tuple)
-endif
-       @echo "ACTUAL RESULTS OF REGRESSION TEST ARE NOW IN FILES run_check.out"
-       @echo "AND regress.out"
-       @echo ""
-       @echo "To run the optional big test(s) too, type 'make bigcheck'"
-       @echo "These big tests can take over an hour to complete"
-       @echo "These actually are: $(EXTRA_TESTS)"
+# old interfaces follow...
 
-#
-# run the test including the huge extra tests
-#
-bigcheck: all
-ifneq ($(PORTNAME), win)
-       MULTIBYTE=$(MULTIBYTE);export MULTIBYTE; \
-       $(SHELL) ./run_check.sh $(host_tuple) $(EXTRA_TESTS)
-else
-       MULTIBYTE=$(MULTIBYTE);export MULTIBYTE; \
-       ./run_check.sh $(host_tuple) $(EXTRA_TESTS)
-endif
-       @echo "ACTUAL RESULTS OF REGRESSION TEST ARE NOW IN FILES run_check.out"
-       @echo "AND regress.out"
+runcheck: check
+runtest: installcheck
+runtest-parallel: installcheck-parallel
 
+bigtest: all tablespace-setup
+       $(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/serial_schedule numeric_big
 
-# clean up
+bigcheck: all tablespace-setup
+       $(pg_regress_check) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) numeric_big
 
-clean distclean maintainer-clean:
+
+##
+## Clean up
+##
+
+clean distclean maintainer-clean: clean-lib
 # things built by `all' target
-       $(MAKE) -C $(contribdir)/spi clean
-       rm -f $(output_files) $(input_files) $(DLOBJS) regress.o pg_regress
+       rm -f $(OBJS) refint$(DLSUFFIX) autoinc$(DLSUFFIX)
+       rm -f pg_regress_main.o pg_regress.o pg_regress$(X)
 # things created by various check targets
-       rm -rf results tmp_check log
-       rm -f regression.diffs regression.out regress.out run_check.out
-ifeq ($(PORTNAME), win)
-       rm -f regress.def
-endif
+       rm -f $(output_files) $(input_files)
+       rm -rf testtablespace
+       rm -rf $(pg_regress_clean_files)