psqlodbc.git / summary / log / commit / refs

commit    276cb5e413eafe970dbb60fcc41f56a7c1ddf2ac
Author:   Hiroshi Inoue <inoue@tpf.co.jp>
Date:     Tue Oct 21 07:57:28 2014 +0000

    Allow building test suite in a different place other than the source code is.
    Change the test suite so that it works not only with unixODBC but also with iodbc.


test/Makefile.in | 42 +++++++++++++++++++++++++----- test/expected/odbcini-gen.out | 3 +++ test/launcher_i | 6 +++++ test/src/odbcini-gen.sh | 59 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 7 deletions(-) diff --git a/test/Makefile.in b/test/Makefile.in index 4a913f3d..488a35c7 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1,36 +1,64 @@ # The list of test is stored in a separate file, so that it can be shared with # the Windows makefile, win.mak. -include tests + +origdir = @srcdir@ + +vpath %.c $(origdir) +vpath %.sh $(origdir) + +include $(origdir)/tests # The included file defined variable TESTBINS, which is a list of program # names in format src/<testname>-test. Extract the base test names from it. TESTNAMES = $(patsubst src/%-test,%, $(TESTBINS)) TESTSQLS = $(patsubst %,sql/%.sql, $(TESTNAMES)) +INIGEN=odbcini-gen +INIGENSQL=sql/$(INIGEN).sql + # Set by autoconf LDFLAGS = @LDFLAGS@ CFLAGS = @CFLAGS@ PG_CONFIG = @PG_CONFIG@ +ODBC_CONFIG = @ODBC_CONFIG@ + +ifneq (,$(findstring iodbc,$(ODBC_CONFIG))) + launcher=launcher_i +else + launcher=launcher +endif + +REGRESS = sampletables $(INIGEN) $(TESTNAMES) -REGRESS = sampletables $(TESTNAMES) +LIBODBC := $(shell $(ODBC_CONFIG) --libs) -all: $(TESTBINS) $(TESTSQLS) +all: $(TESTBINS) $(TESTSQLS) $(INIGENSQL) installcheck: all -override CFLAGS += -Wno-pointer-sign +override CFLAGS += -Wno-pointer-sign $(CFLAGS_ADD) src/common.o: src/common.c + @if test ! -d src; then mkdir -p src; fi + $(COMPILE.c) -c $< -o $@ # For each test file, compile the .c file, and create a .sql file that # when executed from psql, just runs the binary. src/%-test sql/%.sql: src/%-test.c src/common.o - $(CC) $(CFLAGS) $(LDFLAGS) src/$*-test.c src/common.o -o src/$*-test -lodbc + $(CC) $(CFLAGS) $(LDFLAGS) $^ -o src/$*-test $(LIBODBC) + @if test ! -d sql; then mkdir -p sql; fi echo "\! \"./src/$*-test\"" > sql/$*.sql -EXTRA_CLEAN = $(TESTBINS) $(TESTSQLS) src/common.o +# For each shell file, create a .sql file that when executed from psql, +# just runs the shell. +sql/%.sql: src/%.sh + @if test ! -d sql; then mkdir -p sql; fi + echo "\! \"$<\"" > $@ -REGRESS_OPTS = --launcher=./launcher +EXTRA_CLEAN = $(TESTBINS) $(TESTSQLS) src/common.o $(INIGENSQL) +REGRESS_OPTS = --launcher=$(origdir)/$(launcher) --inputdir=$(origdir) +ifndef PGXS PGXS := $(shell $(PG_CONFIG) --pgxs) +endif include $(PGXS) diff --git a/test/expected/odbcini-gen.out b/test/expected/odbcini-gen.out new file mode 100644 index 00000000..19503798 --- /dev/null +++ b/test/expected/odbcini-gen.out @@ -0,0 +1,3 @@ +\! "./src/odbcini-gen.sh" +This isn't a test application +Initializing odbc(inst).ini diff --git a/test/launcher_i b/test/launcher_i new file mode 100755 index 00000000..6537830a --- /dev/null +++ b/test/launcher_i @@ -0,0 +1,6 @@ +#!/bin/sh + +# Lancher script for iodbc +# Pass ODBCINSTINI and ODBCINI env variables to psql, so that it finds +# the odbc.ini and odbcinst.ini files from the current dir. +ODBCINSTINI=./odbcinst.ini ODBCINI=./odbc.ini $* diff --git a/test/src/odbcini-gen.sh b/test/src/odbcini-gen.sh new file mode 100755 index 00000000..2c3ee6ff --- /dev/null +++ b/test/src/odbcini-gen.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# +# This isn't a test application. +# Initial setting of odbc(inst).ini. +# +echo This isn\'t a test application +echo Initializing odbc\(inst\).ini + +outini=odbc.ini +outinstini=odbcinst.ini +if test -s ${outini}; then exit; fi + +drvr=../.libs/psqlodbcw +driver=${drvr}.so +if test ! -e $driver ; then + driver=${drvr}.dll + if test ! -e $driver ; then + echo Failure:driver ${drvr}.so\(.dll\) not found + exit 2 + fi +fi + +echo creating $outinstini +cat << _EOT_ > $outinstini +[psqlodbc test driver] +Description = PostgreSQL ODBC driver (Unicode version), for regression tests +Driver = $driver +Debug = 0 +CommLog = 1 +_EOT_ + +server=localhost +if test "${PGHOST}" != "" ; then + server=${PGHOST} +fi +port=5432 +if test "${PGPORT}" != "" ; then + port=${PGPORT} +fi + +echo creating $outini +cat << _EOT_ > $outini +[psqlodbc_test_dsn] +Description = psqlodbc regression test DSN +Driver = psqlodbc test driver +Trace = No +TraceFile = +Database = contrib_regression +Servername = ${server} +Username = +Password = +Port = ${port} +ReadOnly = No +RowVersioning = No +ShowSystemTables = No +ShowOidColumn = No +FakeOidIndex = No +ConnSettings = +_EOT_ [parent: 85c729be3073]