Commit feae7856 authored by Peter Eisentraut's avatar Peter Eisentraut

Allow pg_regress to be run outside the build tree. Look for input files

in both input and output dir, to handle vpath builds more simply.
parent dad4cb62
# PGXS: PostgreSQL extensions makefile # PGXS: PostgreSQL extensions makefile
# $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.12 2008/04/07 14:15:58 petere Exp $ # $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.13 2008/10/01 22:38:56 petere Exp $
# This file contains generic rules to build many kinds of simple # This file contains generic rules to build many kinds of simple
# extension modules. You only need to set a few variables and include # extension modules. You only need to set a few variables and include
...@@ -232,23 +232,6 @@ endif ...@@ -232,23 +232,6 @@ endif
# where to find psql for running the tests # where to find psql for running the tests
PSQLDIR = $(bindir) PSQLDIR = $(bindir)
# When doing a VPATH build, must copy over the test .sql and .out
# files so that the driver script can find them. We have to use an
# absolute path for the targets, because otherwise make will try to
# locate the missing files using VPATH, and will find them in
# $(srcdir), but the point here is that we want to copy them from
# $(srcdir) to the build directory.
ifdef VPATH
abs_builddir := $(shell pwd)
test_files_src := $(wildcard $(srcdir)/sql/*.sql) $(wildcard $(srcdir)/expected/*.out) $(wildcard $(srcdir)/data/*.data)
test_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(test_files_src))
all: $(test_files_build)
$(test_files_build): $(abs_builddir)/%: $(srcdir)/%
ln -s $< $@
endif # VPATH
.PHONY: submake .PHONY: submake
submake: submake:
ifndef PGXS ifndef PGXS
......
# Makefile for PL/Perl # Makefile for PL/Perl
# $PostgreSQL: pgsql/src/pl/plperl/GNUmakefile,v 1.34 2008/04/07 14:15:58 petere Exp $ # $PostgreSQL: pgsql/src/pl/plperl/GNUmakefile,v 1.35 2008/10/01 22:38:56 petere Exp $
subdir = src/pl/plperl subdir = src/pl/plperl
top_builddir = ../../.. top_builddir = ../../..
...@@ -50,27 +50,6 @@ all: all-lib ...@@ -50,27 +50,6 @@ all: all-lib
SPI.c: SPI.xs SPI.c: SPI.xs
$(PERL) $(perl_privlibexp)/ExtUtils/xsubpp -typemap $(perl_privlibexp)/ExtUtils/typemap $< >$@ $(PERL) $(perl_privlibexp)/ExtUtils/xsubpp -typemap $(perl_privlibexp)/ExtUtils/typemap $< >$@
# When doing a VPATH build, copy over the .sql and .out files so that the
# test script can find them. See comments in src/test/regress/GNUmakefile.
ifdef VPATH
ifneq ($(PORTNAME),win32)
abs_srcdir := $(shell cd $(srcdir) && pwd)
abs_builddir := $(shell pwd)
else
abs_srcdir := $(shell cd $(srcdir) && pwd -W)
abs_builddir := $(shell pwd -W)
endif
test_files_src := $(wildcard $(srcdir)/sql/*.sql) $(wildcard $(srcdir)/expected/*.out)
test_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(test_files_src))
all: $(test_files_build)
$(test_files_build): $(abs_builddir)/%: $(srcdir)/%
ln -s $< $@
endif
install: all installdirs install-lib install: all installdirs install-lib
installdirs: installdirs-lib installdirs: installdirs-lib
......
# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.29 2008/04/07 14:15:58 petere Exp $ # $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.30 2008/10/01 22:38:56 petere Exp $
subdir = src/pl/plpython subdir = src/pl/plpython
top_builddir = ../../.. top_builddir = ../../..
...@@ -66,27 +66,6 @@ include $(top_srcdir)/src/Makefile.shlib ...@@ -66,27 +66,6 @@ include $(top_srcdir)/src/Makefile.shlib
all: all-lib all: all-lib
# When doing a VPATH build, copy over the .sql and .out files so that the
# test script can find them. See comments in src/test/regress/GNUmakefile.
ifdef VPATH
ifneq ($(PORTNAME),win32)
abs_srcdir := $(shell cd $(srcdir) && pwd)
abs_builddir := $(shell pwd)
else
abs_srcdir := $(shell cd $(srcdir) && pwd -W)
abs_builddir := $(shell pwd -W)
endif
test_files_src := $(wildcard $(srcdir)/sql/*.sql) $(wildcard $(srcdir)/expected/*.out)
test_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(test_files_src))
all: $(test_files_build)
$(test_files_build): $(abs_builddir)/%: $(srcdir)/%
ln -s $< $@
endif
install: all installdirs install-lib install: all installdirs install-lib
installdirs: installdirs-lib installdirs: installdirs-lib
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# Makefile for the pltcl shared object # Makefile for the pltcl shared object
# #
# $PostgreSQL: pgsql/src/pl/tcl/Makefile,v 1.51 2008/04/07 14:15:58 petere Exp $ # $PostgreSQL: pgsql/src/pl/tcl/Makefile,v 1.52 2008/10/01 22:38:56 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -49,27 +49,6 @@ ifeq ($(TCL_SHARED_BUILD), 1) ...@@ -49,27 +49,6 @@ ifeq ($(TCL_SHARED_BUILD), 1)
all: all-lib all: all-lib
$(MAKE) -C modules $@ $(MAKE) -C modules $@
# When doing a VPATH build, copy over the .sql and .out files so that the
# test script can find them. See comments in src/test/regress/GNUmakefile.
ifdef VPATH
ifneq ($(PORTNAME),win32)
abs_srcdir := $(shell cd $(srcdir) && pwd)
abs_builddir := $(shell pwd)
else
abs_srcdir := $(shell cd $(srcdir) && pwd -W)
abs_builddir := $(shell pwd -W)
endif
test_files_src := $(wildcard $(srcdir)/sql/*.sql) $(wildcard $(srcdir)/expected/*.out)
test_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(test_files_src))
all: $(test_files_build)
$(test_files_build): $(abs_builddir)/%: $(srcdir)/%
ln -s $< $@
endif
install: all installdirs install-lib install: all installdirs install-lib
$(MAKE) -C modules $@ $(MAKE) -C modules $@
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.74 2008/05/30 00:04:32 tgl Exp $ # $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.75 2008/10/01 22:38:57 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -65,9 +65,12 @@ pg_regress.o: pg_regress.c $(top_builddir)/src/port/pg_config_paths.h ...@@ -65,9 +65,12 @@ pg_regress.o: pg_regress.c $(top_builddir)/src/port/pg_config_paths.h
$(top_builddir)/src/port/pg_config_paths.h: $(top_builddir)/src/Makefile.global $(top_builddir)/src/port/pg_config_paths.h: $(top_builddir)/src/Makefile.global
$(MAKE) -C $(top_builddir)/src/port pg_config_paths.h $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
install: pg_regress$(X) install: all installdirs
$(INSTALL_PROGRAM) pg_regress$(X) '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)' $(INSTALL_PROGRAM) pg_regress$(X) '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)'
installdirs:
$(mkinstalldirs) '$(DESTDIR)$(pgxsdir)/$(subdir)'
uninstall: uninstall:
rm -f '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)' rm -f '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)'
...@@ -83,34 +86,28 @@ all: all-lib ...@@ -83,34 +86,28 @@ all: all-lib
# Test input and expected files. These are created by pg_regress itself, so we # 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. # don't have a rule to create them. We do need rules to clean them however.
ifile_list := $(subst .source,, $(notdir $(wildcard $(top_srcdir)/$(subdir)/input/*.source))) input_files = $(patsubst $(srcdir)/input/%.source,sql/%.sql, $(wildcard $(srcdir)/input/*.source))
input_files := $(foreach file, $(ifile_list), sql/$(file).sql) output_files := $(patsubst $(srcdir)/output/%.source,expected/%.out, $(wildcard $(srcdir)/output/*.source))
ofile_list := $(subst .source,, $(notdir $(wildcard $(top_srcdir)/$(subdir)/output/*.source)))
output_files := $(foreach file, $(ofile_list), expected/$(file).out)
ifneq ($(PORTNAME),win32)
abs_srcdir := $(shell cd $(srcdir) && pwd)
abs_builddir := $(shell pwd)
else
abs_srcdir := $(shell cd $(srcdir) && pwd -W)
abs_builddir := $(shell pwd -W)
endif
# When doing a VPATH build, copy over the remaining .sql and .out
# files so that the driver script can find them. We have to use an
# absolute path for the targets, because otherwise make will try to
# locate the missing files using VPATH, and will find them in
# $(srcdir), but the point here is that we want to copy them from
# $(srcdir) to the build directory.
ifdef VPATH # not installed by default
remaining_files_src := $(wildcard $(srcdir)/sql/*.sql) $(wildcard $(srcdir)/expected/*.out) $(srcdir)/resultmap
remaining_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(remaining_files_src))
all: $(remaining_files_build) regress_data_files = \
$(remaining_files_build): $(abs_builddir)/%: $(srcdir)/% $(filter-out $(addprefix $(srcdir)/,$(output_files)),$(wildcard $(srcdir)/expected/*.out)) \
ln -s $< $@ $(wildcard $(srcdir)/input/*.source) \
endif $(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; \
done
installdirs-tests: installdirs
$(mkinstalldirs) $(patsubst $(srcdir)/%/,'$(DESTDIR)$(pkglibdir)/regress/%',$(sort $(dir $(regress_data_files))))
# Get some extra C modules from contrib/spi... # Get some extra C modules from contrib/spi...
...@@ -144,14 +141,16 @@ tablespace-setup: ...@@ -144,14 +141,16 @@ tablespace-setup:
## Run tests ## Run tests
## ##
pg_regress_call = ./pg_regress --inputdir=$(srcdir) --dlpath=. --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE)
check: all check: all
./pg_regress --temp-install=./tmp_check --top-builddir=$(top_builddir) --srcdir=$(abs_srcdir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE) $(TEMP_CONF) $(pg_regress_call) --temp-install=./tmp_check --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(TEMP_CONF)
installcheck: all installcheck: all
./pg_regress --psqldir=$(PSQLDIR) --schedule=$(srcdir)/serial_schedule --srcdir=$(abs_srcdir) --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) $(pg_regress_call) --psqldir=$(PSQLDIR) --schedule=$(srcdir)/serial_schedule
installcheck-parallel: all installcheck-parallel: all
./pg_regress --psqldir=$(PSQLDIR) --schedule=$(srcdir)/parallel_schedule --srcdir=$(abs_srcdir) --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE) $(pg_regress_call) --psqldir=$(PSQLDIR) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT)
# old interfaces follow... # old interfaces follow...
...@@ -161,10 +160,10 @@ runtest: installcheck ...@@ -161,10 +160,10 @@ runtest: installcheck
runtest-parallel: installcheck-parallel runtest-parallel: installcheck-parallel
bigtest: all bigtest: all
./pg_regress --psqldir=$(PSQLDIR) --schedule=$(srcdir)/serial_schedule --srcdir=$(abs_srcdir) --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) numeric_big $(pg_regress_call) --psqldir=$(PSQLDIR) --schedule=$(srcdir)/serial_schedule numeric_big
bigcheck: all bigcheck: all
./pg_regress --temp-install=./tmp_check --top-builddir=$(top_builddir) --srcdir=$(abs_srcdir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE) numeric_big $(pg_regress_call) --temp-install=./tmp_check --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) numeric_big
## ##
...@@ -173,15 +172,9 @@ bigcheck: all ...@@ -173,15 +172,9 @@ bigcheck: all
clean distclean maintainer-clean: clean-lib clean distclean maintainer-clean: clean-lib
# things built by `all' target # things built by `all' target
rm -f $(OBJS) refint$(DLSUFFIX) autoinc$(DLSUFFIX) rm -f $(OBJS) refint$(DLSUFFIX) autoinc$(DLSUFFIX) pg_regress_main.o pg_regress.o pg_regress$(X)
rm -f $(output_files) $(input_files) pg_regress_main.o pg_regress.o pg_regress$(X)
# things created by various check targets # things created by various check targets
rm -f $(output_files) $(input_files)
rm -rf testtablespace rm -rf testtablespace
rm -rf results tmp_check log rm -rf results tmp_check log
rm -f regression.diffs regression.out regress.out run_check.out rm -f regression.diffs regression.out regress.out run_check.out
ifeq ($(PORTNAME), cygwin)
rm -f regress.def
endif
ifdef VPATH
rm -f $(remaining_files_build)
endif
...@@ -4,52 +4,52 @@ ...@@ -4,52 +4,52 @@
CREATE FUNCTION widget_in(cstring) CREATE FUNCTION widget_in(cstring)
RETURNS widget RETURNS widget
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT; LANGUAGE C STRICT;
CREATE FUNCTION widget_out(widget) CREATE FUNCTION widget_out(widget)
RETURNS cstring RETURNS cstring
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT; LANGUAGE C STRICT;
CREATE FUNCTION int44in(cstring) CREATE FUNCTION int44in(cstring)
RETURNS city_budget RETURNS city_budget
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT; LANGUAGE C STRICT;
CREATE FUNCTION int44out(city_budget) CREATE FUNCTION int44out(city_budget)
RETURNS cstring RETURNS cstring
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT; LANGUAGE C STRICT;
CREATE FUNCTION check_primary_key () CREATE FUNCTION check_primary_key ()
RETURNS trigger RETURNS trigger
AS '@abs_builddir@/refint@DLSUFFIX@' AS '@libdir@/refint@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION check_foreign_key () CREATE FUNCTION check_foreign_key ()
RETURNS trigger RETURNS trigger
AS '@abs_builddir@/refint@DLSUFFIX@' AS '@libdir@/refint@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION autoinc () CREATE FUNCTION autoinc ()
RETURNS trigger RETURNS trigger
AS '@abs_builddir@/autoinc@DLSUFFIX@' AS '@libdir@/autoinc@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION funny_dup17 () CREATE FUNCTION funny_dup17 ()
RETURNS trigger RETURNS trigger
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION ttdummy () CREATE FUNCTION ttdummy ()
RETURNS trigger RETURNS trigger
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION set_ttdummy (int4) CREATE FUNCTION set_ttdummy (int4)
RETURNS int4 RETURNS int4
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT; LANGUAGE C STRICT;
-- Things that shouldn't work: -- Things that shouldn't work:
...@@ -73,7 +73,7 @@ CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C ...@@ -73,7 +73,7 @@ CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
AS 'nosuchfile'; AS 'nosuchfile';
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
AS '@abs_builddir@/regress@DLSUFFIX@', 'nosuchsymbol'; AS '@libdir@/regress@DLSUFFIX@', 'nosuchsymbol';
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal
AS 'nosuch'; AS 'nosuch';
...@@ -36,36 +36,36 @@ CREATE FUNCTION user_relns() ...@@ -36,36 +36,36 @@ CREATE FUNCTION user_relns()
CREATE FUNCTION pt_in_widget(point, widget) CREATE FUNCTION pt_in_widget(point, widget)
RETURNS bool RETURNS bool
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION overpaid(emp) CREATE FUNCTION overpaid(emp)
RETURNS bool RETURNS bool
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION boxarea(box) CREATE FUNCTION boxarea(box)
RETURNS float8 RETURNS float8
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION interpt_pp(path, path) CREATE FUNCTION interpt_pp(path, path)
RETURNS point RETURNS point
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION reverse_name(name) CREATE FUNCTION reverse_name(name)
RETURNS name RETURNS name
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION oldstyle_length(int4, text) CREATE FUNCTION oldstyle_length(int4, text)
RETURNS int4 RETURNS int4
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
-- --
-- Function dynamic loading -- Function dynamic loading
-- --
LOAD '@abs_builddir@/regress@DLSUFFIX@'; LOAD '@libdir@/regress@DLSUFFIX@';
...@@ -3,49 +3,49 @@ ...@@ -3,49 +3,49 @@
-- --
CREATE FUNCTION widget_in(cstring) CREATE FUNCTION widget_in(cstring)
RETURNS widget RETURNS widget
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT; LANGUAGE C STRICT;
NOTICE: type "widget" is not yet defined NOTICE: type "widget" is not yet defined
DETAIL: Creating a shell type definition. DETAIL: Creating a shell type definition.
CREATE FUNCTION widget_out(widget) CREATE FUNCTION widget_out(widget)
RETURNS cstring RETURNS cstring
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT; LANGUAGE C STRICT;
NOTICE: argument type widget is only a shell NOTICE: argument type widget is only a shell
CREATE FUNCTION int44in(cstring) CREATE FUNCTION int44in(cstring)
RETURNS city_budget RETURNS city_budget
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT; LANGUAGE C STRICT;
NOTICE: type "city_budget" is not yet defined NOTICE: type "city_budget" is not yet defined
DETAIL: Creating a shell type definition. DETAIL: Creating a shell type definition.
CREATE FUNCTION int44out(city_budget) CREATE FUNCTION int44out(city_budget)
RETURNS cstring RETURNS cstring
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT; LANGUAGE C STRICT;
NOTICE: argument type city_budget is only a shell NOTICE: argument type city_budget is only a shell
CREATE FUNCTION check_primary_key () CREATE FUNCTION check_primary_key ()
RETURNS trigger RETURNS trigger
AS '@abs_builddir@/refint@DLSUFFIX@' AS '@libdir@/refint@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION check_foreign_key () CREATE FUNCTION check_foreign_key ()
RETURNS trigger RETURNS trigger
AS '@abs_builddir@/refint@DLSUFFIX@' AS '@libdir@/refint@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION autoinc () CREATE FUNCTION autoinc ()
RETURNS trigger RETURNS trigger
AS '@abs_builddir@/autoinc@DLSUFFIX@' AS '@libdir@/autoinc@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION funny_dup17 () CREATE FUNCTION funny_dup17 ()
RETURNS trigger RETURNS trigger
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION ttdummy () CREATE FUNCTION ttdummy ()
RETURNS trigger RETURNS trigger
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION set_ttdummy (int4) CREATE FUNCTION set_ttdummy (int4)
RETURNS int4 RETURNS int4
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT; LANGUAGE C STRICT;
-- Things that shouldn't work: -- Things that shouldn't work:
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
...@@ -75,8 +75,8 @@ CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C ...@@ -75,8 +75,8 @@ CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
AS 'nosuchfile'; AS 'nosuchfile';
ERROR: could not access file "nosuchfile": No such file or directory ERROR: could not access file "nosuchfile": No such file or directory
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
AS '@abs_builddir@/regress@DLSUFFIX@', 'nosuchsymbol'; AS '@libdir@/regress@DLSUFFIX@', 'nosuchsymbol';
ERROR: could not find function "nosuchsymbol" in file "@abs_builddir@/regress@DLSUFFIX@" ERROR: could not find function "nosuchsymbol" in file "@libdir@/regress@DLSUFFIX@"
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal
AS 'nosuch'; AS 'nosuch';
ERROR: there is no built-in function named "nosuch" ERROR: there is no built-in function named "nosuch"
...@@ -29,29 +29,29 @@ CREATE FUNCTION user_relns() ...@@ -29,29 +29,29 @@ CREATE FUNCTION user_relns()
LANGUAGE SQL; LANGUAGE SQL;
CREATE FUNCTION pt_in_widget(point, widget) CREATE FUNCTION pt_in_widget(point, widget)
RETURNS bool RETURNS bool
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION overpaid(emp) CREATE FUNCTION overpaid(emp)
RETURNS bool RETURNS bool
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION boxarea(box) CREATE FUNCTION boxarea(box)
RETURNS float8 RETURNS float8
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION interpt_pp(path, path) CREATE FUNCTION interpt_pp(path, path)
RETURNS point RETURNS point
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION reverse_name(name) CREATE FUNCTION reverse_name(name)
RETURNS name RETURNS name
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION oldstyle_length(int4, text) CREATE FUNCTION oldstyle_length(int4, text)
RETURNS int4 RETURNS int4
AS '@abs_builddir@/regress@DLSUFFIX@' AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C; LANGUAGE C;
-- --
-- Function dynamic loading -- Function dynamic loading
-- --
LOAD '@abs_builddir@/regress@DLSUFFIX@'; LOAD '@libdir@/regress@DLSUFFIX@';
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.47 2008/08/05 05:16:08 tgl Exp $ * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.48 2008/10/01 22:38:57 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -47,6 +47,10 @@ typedef struct _resultmap ...@@ -47,6 +47,10 @@ typedef struct _resultmap
* out where "make install" will put stuff under the temp_install directory. * out where "make install" will put stuff under the temp_install directory.
* In non-temp_install mode, the only thing we need is the location of psql, * In non-temp_install mode, the only thing we need is the location of psql,
* which we expect to find in psqldir, or in the PATH if psqldir isn't given. * which we expect to find in psqldir, or in the PATH if psqldir isn't given.
*
* XXX Because pg_regress is not installed in bindir, we can't support
* this for relocatable trees as it is. --psqldir would need to be
* specified in those cases.
*/ */
char *bindir = PGBINDIR; char *bindir = PGBINDIR;
char *libdir = LIBDIR; char *libdir = LIBDIR;
...@@ -70,7 +74,7 @@ _stringlist *dblist = NULL; ...@@ -70,7 +74,7 @@ _stringlist *dblist = NULL;
bool debug = false; bool debug = false;
char *inputdir = "."; char *inputdir = ".";
char *outputdir = "."; char *outputdir = ".";
char *psqldir = NULL; char *psqldir = PGBINDIR;
static _stringlist *loadlanguage = NULL; static _stringlist *loadlanguage = NULL;
static int max_connections = 0; static int max_connections = 0;
static char *encoding = NULL; static char *encoding = NULL;
...@@ -83,8 +87,8 @@ static int temp_port = 65432; ...@@ -83,8 +87,8 @@ static int temp_port = 65432;
static bool nolocale = false; static bool nolocale = false;
static char *hostname = NULL; static char *hostname = NULL;
static int port = -1; static int port = -1;
static char *dlpath = PKGLIBDIR;
static char *user = NULL; static char *user = NULL;
static char *srcdir = NULL;
static _stringlist *extraroles = NULL; static _stringlist *extraroles = NULL;
/* internal variables */ /* internal variables */
...@@ -391,10 +395,8 @@ replace_string(char *string, char *replace, char *replacement) ...@@ -391,10 +395,8 @@ replace_string(char *string, char *replace, char *replacement)
* the given suffix. * the given suffix.
*/ */
static void static void
convert_sourcefiles_in(char *source, char *dest, char *suffix) convert_sourcefiles_in(char *source_subdir, char *dest_subdir, char *suffix)
{ {
char abs_srcdir[MAXPGPATH];
char abs_builddir[MAXPGPATH];
char testtablespace[MAXPGPATH]; char testtablespace[MAXPGPATH];
char indir[MAXPGPATH]; char indir[MAXPGPATH];
struct stat st; struct stat st;
...@@ -403,27 +405,7 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix) ...@@ -403,27 +405,7 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix)
char **names; char **names;
int count = 0; int count = 0;
#ifdef WIN32 snprintf(indir, MAXPGPATH, "%s/%s", inputdir, source_subdir);
char *c;
#endif
if (!getcwd(abs_builddir, sizeof(abs_builddir)))
{
fprintf(stderr, _("%s: could not get current directory: %s\n"),
progname, strerror(errno));
exit_nicely(2);
}
/*
* in a VPATH build, use the provided source directory; otherwise, use the
* current directory.
*/
if (srcdir)
strlcpy(abs_srcdir, srcdir, MAXPGPATH);
else
strlcpy(abs_srcdir, abs_builddir, MAXPGPATH);
snprintf(indir, MAXPGPATH, "%s/%s", abs_srcdir, source);
/* Check that indir actually exists and is a directory */ /* Check that indir actually exists and is a directory */
ret = stat(indir, &st); ret = stat(indir, &st);
...@@ -441,17 +423,7 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix) ...@@ -441,17 +423,7 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix)
/* Error logged in pgfnames */ /* Error logged in pgfnames */
exit_nicely(2); exit_nicely(2);
#ifdef WIN32 snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir);
/* in Win32, replace backslashes with forward slashes */
for (c = abs_builddir; *c; c++)
if (*c == '\\')
*c = '/';
for (c = abs_srcdir; *c; c++)
if (*c == '\\')
*c = '/';
#endif
snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", abs_builddir);
#ifdef WIN32 #ifdef WIN32
/* /*
...@@ -490,7 +462,7 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix) ...@@ -490,7 +462,7 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix)
/* build the full actual paths to open */ /* build the full actual paths to open */
snprintf(prefix, strlen(*name) - 6, "%s", *name); snprintf(prefix, strlen(*name) - 6, "%s", *name);
snprintf(srcfile, MAXPGPATH, "%s/%s", indir, *name); snprintf(srcfile, MAXPGPATH, "%s/%s", indir, *name);
snprintf(destfile, MAXPGPATH, "%s/%s.%s", dest, prefix, suffix); snprintf(destfile, MAXPGPATH, "%s/%s.%s", dest_subdir, prefix, suffix);
infile = fopen(srcfile, "r"); infile = fopen(srcfile, "r");
if (!infile) if (!infile)
...@@ -508,9 +480,10 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix) ...@@ -508,9 +480,10 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix)
} }
while (fgets(line, sizeof(line), infile)) while (fgets(line, sizeof(line), infile))
{ {
replace_string(line, "@abs_srcdir@", abs_srcdir); replace_string(line, "@abs_srcdir@", inputdir);
replace_string(line, "@abs_builddir@", abs_builddir); replace_string(line, "@abs_builddir@", outputdir);
replace_string(line, "@testtablespace@", testtablespace); replace_string(line, "@testtablespace@", testtablespace);
replace_string(line, "@libdir@", dlpath);
replace_string(line, "@DLSUFFIX@", DLSUFFIX); replace_string(line, "@DLSUFFIX@", DLSUFFIX);
fputs(line, outfile); fputs(line, outfile);
} }
...@@ -520,7 +493,7 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix) ...@@ -520,7 +493,7 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix)
/* /*
* If we didn't process any files, complain because it probably means * If we didn't process any files, complain because it probably means
* somebody neglected to pass the needed --srcdir argument. * somebody neglected to pass the needed --inputdir argument.
*/ */
if (count <= 0) if (count <= 0)
{ {
...@@ -1087,7 +1060,7 @@ file_line_count(const char *file) ...@@ -1087,7 +1060,7 @@ file_line_count(const char *file)
return l; return l;
} }
static bool bool
file_exists(const char *file) file_exists(const char *file)
{ {
FILE *f = fopen(file, "r"); FILE *f = fopen(file, "r");
...@@ -1792,6 +1765,34 @@ create_role(const char *rolename, const _stringlist * granted_dbs) ...@@ -1792,6 +1765,34 @@ create_role(const char *rolename, const _stringlist * granted_dbs)
} }
} }
static char *
make_absolute_path(const char *in)
{
char *result;
if (is_absolute_path(in))
result = strdup(in);
else
{
static char cwdbuf[MAXPGPATH];
if (!cwdbuf[0])
{
if (!getcwd(cwdbuf, sizeof(cwdbuf)))
{
fprintf(stderr, _("could not get current working directory: %s\n"), strerror(errno));
exit_nicely(2);
}
}
result = malloc(strlen(cwdbuf) + strlen(in) + 2);
sprintf(result, "%s/%s", cwdbuf, in);
}
canonicalize_path(result);
return result;
}
static void static void
help(void) help(void)
{ {
...@@ -1812,7 +1813,7 @@ help(void) ...@@ -1812,7 +1813,7 @@ help(void)
printf(_(" --outputdir=DIR place output files in DIR (default \".\")\n")); printf(_(" --outputdir=DIR place output files in DIR (default \".\")\n"));
printf(_(" --schedule=FILE use test ordering schedule from FILE\n")); printf(_(" --schedule=FILE use test ordering schedule from FILE\n"));
printf(_(" (can be used multiple times to concatenate)\n")); printf(_(" (can be used multiple times to concatenate)\n"));
printf(_(" --srcdir=DIR absolute path to source directory (for VPATH builds)\n")); printf(_(" --dlpath=DIR look for dynamic libraries in DIR\n"));
printf(_(" --temp-install=DIR create a temporary installation in DIR\n")); printf(_(" --temp-install=DIR create a temporary installation in DIR\n"));
printf(_("\n")); printf(_("\n"));
printf(_("Options for \"temp-install\" mode:\n")); printf(_("Options for \"temp-install\" mode:\n"));
...@@ -1861,7 +1862,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc ...@@ -1861,7 +1862,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
{"port", required_argument, NULL, 14}, {"port", required_argument, NULL, 14},
{"user", required_argument, NULL, 15}, {"user", required_argument, NULL, 15},
{"psqldir", required_argument, NULL, 16}, {"psqldir", required_argument, NULL, 16},
{"srcdir", required_argument, NULL, 17}, {"dlpath", required_argument, NULL, 17},
{"create-role", required_argument, NULL, 18}, {"create-role", required_argument, NULL, 18},
{"temp-config", required_argument, NULL, 19}, {"temp-config", required_argument, NULL, 19},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
...@@ -1922,22 +1923,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc ...@@ -1922,22 +1923,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
add_stringlist_item(&schedulelist, optarg); add_stringlist_item(&schedulelist, optarg);
break; break;
case 9: case 9:
/* temp_install must be absolute path */ temp_install = make_absolute_path(optarg);
if (is_absolute_path(optarg))
temp_install = strdup(optarg);
else
{
char cwdbuf[MAXPGPATH];
if (!getcwd(cwdbuf, sizeof(cwdbuf)))
{
fprintf(stderr, _("could not get current working directory: %s\n"), strerror(errno));
exit_nicely(2);
}
temp_install = malloc(strlen(cwdbuf) + strlen(optarg) + 2);
sprintf(temp_install, "%s/%s", cwdbuf, optarg);
}
canonicalize_path(temp_install);
break; break;
case 10: case 10:
nolocale = true; nolocale = true;
...@@ -1969,7 +1955,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc ...@@ -1969,7 +1955,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
psqldir = strdup(optarg); psqldir = strdup(optarg);
break; break;
case 17: case 17:
srcdir = strdup(optarg); dlpath = strdup(optarg);
break; break;
case 18: case 18:
split_to_stringlist(strdup(optarg), ", ", &extraroles); split_to_stringlist(strdup(optarg), ", ", &extraroles);
...@@ -1997,6 +1983,10 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc ...@@ -1997,6 +1983,10 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
if (temp_install) if (temp_install)
port = temp_port; port = temp_port;
inputdir = make_absolute_path(inputdir);
outputdir = make_absolute_path(outputdir);
dlpath = make_absolute_path(dlpath);
/* /*
* Initialization * Initialization
*/ */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/test/regress/pg_regress.h,v 1.3 2008/01/01 19:46:00 momjian Exp $ * $PostgreSQL: pgsql/src/test/regress/pg_regress.h,v 1.4 2008/10/01 22:38:57 petere Exp $
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -57,3 +57,4 @@ void add_stringlist_item(_stringlist ** listhead, const char *str); ...@@ -57,3 +57,4 @@ void add_stringlist_item(_stringlist ** listhead, const char *str);
PID_TYPE spawn_process(const char *cmdline); PID_TYPE spawn_process(const char *cmdline);
void exit_nicely(int code); void exit_nicely(int code);
void replace_string(char *string, char *replace, char *replacement); void replace_string(char *string, char *replace, char *replacement);
bool file_exists(const char *file);
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/test/regress/pg_regress_main.c,v 1.3 2008/01/01 19:46:00 momjian Exp $ * $PostgreSQL: pgsql/src/test/regress/pg_regress_main.c,v 1.4 2008/10/01 22:38:57 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -34,12 +34,26 @@ psql_start_test(const char *testname, ...@@ -34,12 +34,26 @@ psql_start_test(const char *testname,
char expectfile[MAXPGPATH]; char expectfile[MAXPGPATH];
char psql_cmd[MAXPGPATH * 3]; char psql_cmd[MAXPGPATH * 3];
/*
* Look for files in the output dir first, consistent with a vpath
* search. This is mainly to create more reasonable error
* messages if the file is not found. It also allows local test
* overrides when running pg_regress outside of the source tree.
*/
snprintf(infile, sizeof(infile), "%s/sql/%s.sql", snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
inputdir, testname); outputdir, testname);
if (!file_exists(infile))
snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
inputdir, testname);
snprintf(outfile, sizeof(outfile), "%s/results/%s.out", snprintf(outfile, sizeof(outfile), "%s/results/%s.out",
outputdir, testname); outputdir, testname);
snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out", snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
inputdir, testname); outputdir, testname);
if (!file_exists(expectfile))
snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
inputdir, testname);
add_stringlist_item(resultfiles, outfile); add_stringlist_item(resultfiles, outfile);
add_stringlist_item(expectfiles, expectfile); add_stringlist_item(expectfiles, expectfile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment