Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0992259

Browse files
committed
Rewrite ECPG regression test driver in C, by splitting the standard
regression driver into two parts and reusing half of it. Required to run ECPG tests without a shell on MSVC builds. Fix ECPG thread tests for MSVC build (incl output files). Joachim Wieland and Magnus Hagander
1 parent e514740 commit 0992259

21 files changed

+817
-1023
lines changed

src/interfaces/ecpg/test/Makefile

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.67 2007/03/29 12:02:24 meskes Exp $
1+
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.68 2007/06/12 11:07:30 mha Exp $
22

33
subdir = src/interfaces/ecpg/test
44
top_builddir = ../../../..
@@ -8,12 +8,12 @@ include $(top_builddir)/src/Makefile.global
88
# this is also defined in test/connect/Makefile
99
TEMP_PORT = 5$(DEF_PGPORT)
1010

11+
# where to find psql for testing an existing installation
12+
PSQLDIR = $(bindir)
13+
1114
# default encoding
1215
MULTIBYTE = SQL_ASCII
1316

14-
# threading
15-
THREAD := $(shell grep -q "define ENABLE_THREAD_SAFETY" ../include/ecpg_config.h && echo "--enable-threading")
16-
1717
# locale
1818
NOLOCALE =
1919
ifdef NO_LOCALE
@@ -26,6 +26,15 @@ else
2626
abs_builddir := $(shell pwd -W)
2727
endif
2828

29+
# stuff to pass into build of pg_regress
30+
EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \
31+
'-DMAKEPROG="$(MAKE)"' \
32+
'-DSHELLPROG="$(SHELL)"' \
33+
'-DDLSUFFIX="$(DLSUFFIX)"'
34+
35+
REGRESSINCLUDES = "-I$(top_builddir)/src/test/regress"
36+
REGRESSDRIVER = "$(top_builddir)/src/test/regress/pg_regress.o"
37+
2938
all install installdirs uninstall distprep:
3039
$(MAKE) -C connect $@
3140
$(MAKE) -C expected $@
@@ -45,20 +54,21 @@ clean distclean maintainer-clean:
4554
$(MAKE) -C compat_informix $@
4655
$(MAKE) -C thread $@
4756
rm -rf tmp_check results log
48-
rm -f pg_regress regression.diffs
57+
rm -f pg_regress regression.diffs pg_regress_ecpg.o
58+
59+
# Build regression test driver
60+
61+
all: pg_regress$(X)
62+
63+
pg_regress$(X): pg_regress_ecpg.o
64+
$(CC) $(CFLAGS) $^ $(REGRESSDRIVER) $(LDFLAGS) $(LIBS) -o $@
4965

50-
all: pg_regress
66+
# dependencies ensure that path changes propagate
67+
pg_regress_ecpg.o: pg_regress_ecpg.c $(top_builddir)/src/port/pg_config_paths.h
68+
$(CC) $(CFLAGS) $(CPPFLAGS) -I$(top_builddir)/src/port $(REGRESSINCLUDES) $(EXTRADEFS) -c -o $@ $<
5169

52-
pg_regress: pg_regress.sh $(top_builddir)/src/Makefile.global
53-
sed -e 's,@bindir@,$(bindir),g' \
54-
-e 's,@libdir@,$(libdir),g' \
55-
-e 's,@pkglibdir@,$(pkglibdir),g' \
56-
-e 's,@datadir@,$(datadir),g' \
57-
-e 's/@VERSION@/$(VERSION)/g' \
58-
-e 's/@host_tuple@/$(host_tuple)/g' \
59-
-e 's,@GMAKE@,$(MAKE),g' \
60-
-e 's/@enable_shared@/$(enable_shared)/g' \
61-
$< >$@
70+
$(top_builddir)/src/port/pg_config_paths.h: $(top_builddir)/src/Makefile.global
71+
$(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
6272

6373
# When doing a VPATH build, copy over the .pgc, .stdout and .stderr
6474
# files so that the driver script can find them. We have to use an
@@ -78,11 +88,11 @@ endif
7888

7989

8090
check: all
81-
sh ./pg_regress --dbname=regress1 --temp-install --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) $(THREAD)
91+
./pg_regress --dbname=regress1,connectdb --top-builddir=$(top_builddir) --temp-install=./tmp_check --temp-port=$(TEMP_PORT) --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) $(THREAD) --schedule=$(srcdir)/ecpg_schedule --create-role=connectuser,connectdb
8292

8393
# the same options, but with --listen-on-tcp
8494
checktcp: all
85-
sh ./pg_regress --dbname=regress1 --temp-install --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) --listen-on-tcp $(THREAD)
95+
./pg_regress --dbname=regress1,connectdb --top-builddir=$(top_builddir) --temp-install=./tmp_check --temp-port=$(TEMP_PORT) --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) $(THREAD) --schedule=$(srcdir)/ecpg_schedule_tcp --create-role=connectuser,connectdb --host=localhost
8696

8797
installcheck: all
88-
sh ./pg_regress --dbname=regress1 --top-builddir=$(top_builddir) --load-language=plpgsql $(NOLOCALE)
98+
./pg_regress --psqldir=$(PSQLDIR) --dbname=regress1,connectdb --top-builddir=$(top_builddir) --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) $(THREAD) --schedule=$(srcdir)/ecpg_schedule --create-role=connectuser,connectdb
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
test: compat_informix/dec_test
2+
test: compat_informix/charfuncs
3+
test: compat_informix/rfmtdate
4+
test: compat_informix/rfmtlong
5+
test: compat_informix/rnull
6+
test: compat_informix/test_informix
7+
test: compat_informix/test_informix2
8+
test: connect/test2
9+
test: connect/test3
10+
test: connect/test4
11+
test: connect/test5
12+
test: pgtypeslib/dt_test
13+
test: pgtypeslib/dt_test2
14+
test: pgtypeslib/num_test
15+
test: pgtypeslib/num_test2
16+
test: preproc/comment
17+
test: preproc/define
18+
test: preproc/init
19+
test: preproc/type
20+
test: preproc/variable
21+
test: preproc/whenever
22+
test: sql/array
23+
test: sql/binary
24+
test: sql/code100
25+
test: sql/copystdout
26+
test: sql/define
27+
test: sql/desc
28+
test: sql/dynalloc
29+
test: sql/dynalloc2
30+
test: sql/dyntest
31+
test: sql/execute
32+
test: sql/fetch
33+
test: sql/func
34+
test: sql/indicators
35+
test: sql/quote
36+
test: sql/show
37+
test: sql/insupd
38+
test: sql/parser
39+
test: thread/thread
40+
test: thread/thread_implicit

src/interfaces/ecpg/test/expected/thread-thread.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,26 +153,30 @@ void *test_thread(void *arg)
153153

154154

155155
/* build up connection name, and connect to database */
156+
#ifndef WIN32_ONLY_COMPILER
156157
snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
158+
#else
159+
_snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
160+
#endif
157161
/* exec sql whenever sqlerror sqlprint ; */
158-
#line 107 "thread.pgc"
162+
#line 111 "thread.pgc"
159163

160164
{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , l_connection, 0);
161-
#line 108 "thread.pgc"
165+
#line 112 "thread.pgc"
162166

163167
if (sqlca.sqlcode < 0) sqlprint();}
164-
#line 108 "thread.pgc"
168+
#line 112 "thread.pgc"
165169

166170
if( sqlca.sqlcode != 0 )
167171
{
168172
printf("%s: ERROR: cannot connect to database!\n", l_connection);
169173
return( NULL );
170174
}
171175
{ ECPGtrans(__LINE__, l_connection, "begin transaction ");
172-
#line 114 "thread.pgc"
176+
#line 118 "thread.pgc"
173177

174178
if (sqlca.sqlcode < 0) sqlprint();}
175-
#line 114 "thread.pgc"
179+
#line 118 "thread.pgc"
176180

177181

178182
/* insert into test_thread table */
@@ -183,27 +187,27 @@ if (sqlca.sqlcode < 0) sqlprint();}
183187
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
184188
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
185189
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
186-
#line 119 "thread.pgc"
190+
#line 123 "thread.pgc"
187191

188192
if (sqlca.sqlcode < 0) sqlprint();}
189-
#line 119 "thread.pgc"
193+
#line 123 "thread.pgc"
190194

191195
if( sqlca.sqlcode != 0 )
192196
printf("%s: ERROR: insert failed!\n", l_connection);
193197
}
194198

195199
/* all done */
196200
{ ECPGtrans(__LINE__, l_connection, "commit");
197-
#line 125 "thread.pgc"
201+
#line 129 "thread.pgc"
198202

199203
if (sqlca.sqlcode < 0) sqlprint();}
200-
#line 125 "thread.pgc"
204+
#line 129 "thread.pgc"
201205

202206
{ ECPGdisconnect(__LINE__, l_connection);
203-
#line 126 "thread.pgc"
207+
#line 130 "thread.pgc"
204208

205209
if (sqlca.sqlcode < 0) sqlprint();}
206-
#line 126 "thread.pgc"
210+
#line 130 "thread.pgc"
207211

208212
return( NULL );
209213
}

src/interfaces/ecpg/test/expected/thread-thread_implicit.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,26 +154,30 @@ void *test_thread(void *arg)
154154

155155

156156
/* build up connection name, and connect to database */
157+
#ifndef WIN32_ONLY_COMPILER
157158
snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
159+
#else
160+
_snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
161+
#endif
158162
/* exec sql whenever sqlerror sqlprint ; */
159-
#line 108 "thread_implicit.pgc"
163+
#line 112 "thread_implicit.pgc"
160164

161165
{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , l_connection, 0);
162-
#line 109 "thread_implicit.pgc"
166+
#line 113 "thread_implicit.pgc"
163167

164168
if (sqlca.sqlcode < 0) sqlprint();}
165-
#line 109 "thread_implicit.pgc"
169+
#line 113 "thread_implicit.pgc"
166170

167171
if( sqlca.sqlcode != 0 )
168172
{
169173
printf("%s: ERROR: cannot connect to database!\n", l_connection);
170174
return( NULL );
171175
}
172176
{ ECPGtrans(__LINE__, NULL, "begin transaction ");
173-
#line 115 "thread_implicit.pgc"
177+
#line 119 "thread_implicit.pgc"
174178

175179
if (sqlca.sqlcode < 0) sqlprint();}
176-
#line 115 "thread_implicit.pgc"
180+
#line 119 "thread_implicit.pgc"
177181

178182

179183
/* insert into test_thread table */
@@ -184,27 +188,27 @@ if (sqlca.sqlcode < 0) sqlprint();}
184188
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
185189
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
186190
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
187-
#line 120 "thread_implicit.pgc"
191+
#line 124 "thread_implicit.pgc"
188192

189193
if (sqlca.sqlcode < 0) sqlprint();}
190-
#line 120 "thread_implicit.pgc"
194+
#line 124 "thread_implicit.pgc"
191195

192196
if( sqlca.sqlcode != 0 )
193197
printf("%s: ERROR: insert failed!\n", l_connection);
194198
}
195199

196200
/* all done */
197201
{ ECPGtrans(__LINE__, NULL, "commit");
198-
#line 126 "thread_implicit.pgc"
202+
#line 130 "thread_implicit.pgc"
199203

200204
if (sqlca.sqlcode < 0) sqlprint();}
201-
#line 126 "thread_implicit.pgc"
205+
#line 130 "thread_implicit.pgc"
202206

203207
{ ECPGdisconnect(__LINE__, l_connection);
204-
#line 127 "thread_implicit.pgc"
208+
#line 131 "thread_implicit.pgc"
205209

206210
if (sqlca.sqlcode < 0) sqlprint();}
207-
#line 127 "thread_implicit.pgc"
211+
#line 131 "thread_implicit.pgc"
208212

209213
return( NULL );
210214
}

0 commit comments

Comments
 (0)