Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5a1fde

Browse files
committed
Remove infinite-loop hazards in ecpg test suite.
A report from Andrew Dunstan showed that an ecpglib breakage thatcauses repeated query failures could lead to infinite loops in someecpg test scripts, because they contain "while(1)" loops with noexit condition other than successful test completion. That mightbe all right for manual testing, but it seems entirely unacceptablefor automated test environments such as our buildfarm. We don'twant buildfarm owners to have to intervene manually when a testgoes wrong.To fix, just change all those while(1) loops to exit after at most100 iterations (which is more than any of them expect to iterate).This seems sufficient since we'd see discrepancies in the test outputif any loop executed the wrong number of times.I tested this by dint of intentionally breaking ecpg_do_prologueto always fail, and verifying that the tests still got to completion.Back-patch to all supported branches, since the whole point of thisexercise is to protect the buildfarm against future mistakes.Discussion:https://postgr.es/m/18693.1548302004@sss.pgh.pa.us
1 parentbbd5c20 commitd5a1fde

18 files changed

+46
-43
lines changed

‎src/interfaces/ecpg/test/compat_informix/test_informix.pgc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static void dosqlprint(void) {
1111

1212
int main(void)
1313
{
14-
$int i = 14;
14+
$int i = 14, loopcount;
1515
$decimal j, m, n;
1616
$string c[10];
1717

@@ -52,7 +52,7 @@ int main(void)
5252

5353
deccvint(0, &j);
5454

55-
while (1)
55+
for (loopcount = 0; loopcount < 100; loopcount++)
5656
{
5757
$fetch forward c into :i, :j, :c;
5858
if (sqlca.sqlcode == 100) break;

‎src/interfaces/ecpg/test/compat_oracle/char_array.pgc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int main() {
1919
EXEC SQL WHENEVER SQLERROR SQLPRINT;
2020

2121
const char *ppppp = "XXXXX";
22-
22+
int loopcount;
2323
EXEC SQL BEGIN DECLARE SECTION;
2424
char shortstr[5];
2525
char bigstr[11];
@@ -44,7 +44,7 @@ int main() {
4444
EXEC SQL WHENEVER NOT FOUND DO BREAK;
4545

4646
printf("Full Str. : Short Ind.\n");
47-
while(1) {
47+
for (loopcount = 0; loopcount < 100; loopcount++) {
4848
strncpy(shortstr, ppppp, sizeof shortstr);
4949
memset(bigstr, 0, sizeof bigstr);
5050
EXEC SQL FETCH C into :bigstr :bigstr_ind, :shortstr :shstr_ind;

‎src/interfaces/ecpg/test/expected/compat_informix-test_informix.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int main(void)
3333
{
3434

3535
#line 14 "test_informix.pgc"
36-
inti=14 ;
36+
inti=14,loopcount;
3737

3838
#line 14 "test_informix.pgc"
3939

@@ -156,7 +156,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
156156

157157
deccvint(0,&j);
158158

159-
while (1)
159+
for (loopcount=0;loopcount<100;loopcount++)
160160
{
161161
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"fetch forward c",ECPGt_EOIT,
162162
ECPGt_int,&(i),(long)1,(long)1,sizeof(int),

‎src/interfaces/ecpg/test/expected/compat_oracle-char_array.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int main() {
4141

4242

4343
constchar*ppppp="XXXXX";
44-
44+
intloopcount;
4545
/* exec sql begin declare section */
4646

4747

@@ -156,7 +156,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
156156

157157

158158
printf("Full Str. : Short Ind.\n");
159-
while(1) {
159+
for (loopcount=0;loopcount<100;loopcount++) {
160160
strncpy(shortstr,ppppp,sizeofshortstr);
161161
memset(bigstr,0,sizeofbigstr);
162162
{ECPGdo(__LINE__,3,1,NULL,0,ECPGst_normal,"fetch C",ECPGt_EOIT,

‎src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ int
3636
main(void)
3737
{
3838
/* exec sql begin declare section */
39-
39+
4040

4141

4242

4343

4444
#line 21 "nan_test.pgc"
45-
intid ;
45+
intid,loopcount;
4646

4747
#line 22 "nan_test.pgc"
4848
doubled ;
@@ -90,7 +90,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
9090
if (sqlca.sqlcode<0)sqlprint ( );}
9191
#line 36 "nan_test.pgc"
9292

93-
while (1)
93+
for (loopcount=0;loopcount<100;loopcount++)
9494
{
9595
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch from cur",ECPGt_EOIT,
9696
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
@@ -145,7 +145,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
145145
if (sqlca.sqlcode<0)sqlprint ( );}
146146
#line 52 "nan_test.pgc"
147147

148-
while (1)
148+
for (loopcount=0;loopcount<100;loopcount++)
149149
{
150150
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch from cur",ECPGt_EOIT,
151151
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
@@ -229,7 +229,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
229229
if (sqlca.sqlcode<0)sqlprint ( );}
230230
#line 78 "nan_test.pgc"
231231

232-
while (1)
232+
for (loopcount=0;loopcount<100;loopcount++)
233233
{
234234
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch from cur1",ECPGt_EOIT,
235235
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),

‎src/interfaces/ecpg/test/expected/preproc-autoprep.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
197197

198198

199199
i=0;
200-
while (1)
200+
while (i<100)
201201
{
202202
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch cur1",ECPGt_EOIT,
203203
ECPGt_int,&(item1),(long)1,(long)1,sizeof(int),

‎src/interfaces/ecpg/test/expected/preproc-outofscope.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ main (void)
267267
{
268268
MYTYPE*myvar;
269269
MYNULLTYPE*mynullvar;
270-
270+
intloopcount;
271271
charmsg[128];
272272

273273
ECPGdebug(1,stderr);
@@ -333,7 +333,7 @@ if (sqlca.sqlcode < 0) exit (1);}
333333
#line 96 "outofscope.pgc"
334334

335335

336-
while (1)
336+
for (loopcount=0;loopcount<100;loopcount++)
337337
{
338338
memset(myvar,0,sizeof(MYTYPE));
339339
get_record1();

‎src/interfaces/ecpg/test/expected/preproc-variable.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ main (void)
120120

121121
#line 37 "variable.pgc"
122122

123-
123+
intloopcount;
124124
charmsg[128];
125125

126126
ECPGdebug(1,stderr);
@@ -204,7 +204,7 @@ if (sqlca.sqlcode < 0) exit (1);}
204204
p=&personal;
205205
i=&ind_personal;
206206
memset(i,0,sizeof(ind_personal));
207-
while (1) {
207+
for (loopcount=0;loopcount<100;loopcount++) {
208208
strcpy(msg,"fetch");
209209
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch cur",ECPGt_EOIT,
210210
ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)-1,sizeof(structbirthinfo ),

‎src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int main(void)
3333

3434

3535

36-
36+
3737

3838

3939
#line 15 "whenever_do_continue.pgc"
@@ -48,6 +48,9 @@ int main(void)
4848
floatcomm ;
4949
}emp ;
5050

51+
#line 16 "whenever_do_continue.pgc"
52+
intloopcount ;
53+
5154
#line 17 "whenever_do_continue.pgc"
5255
charmsg [128 ] ;
5356
/* exec sql end declare section */
@@ -119,7 +122,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
119122
#line 42 "whenever_do_continue.pgc"
120123

121124

122-
while (1)
125+
for (loopcount=0;loopcount<100;loopcount++)
123126
{
124127
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch c",ECPGt_EOIT,
125128
ECPGt_char,&(emp.ename),(long)12,(long)1,(12)*sizeof(char),

‎src/interfaces/ecpg/test/expected/sql-fetch.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
intmain() {
2626
/* exec sql begin declare section */
2727

28-
28+
2929

3030
#line 9 "fetch.pgc"
3131
charstr [25 ] ;
3232

3333
#line 10 "fetch.pgc"
34-
inti ,count=1 ;
34+
inti ,count=1,loopcount;
3535
/* exec sql end declare section */
3636
#line 11 "fetch.pgc"
3737

@@ -112,7 +112,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
112112
/* exec sql whenever not found break ; */
113113
#line 30 "fetch.pgc"
114114

115-
while (1) {
115+
for (loopcount=0;loopcount<100;loopcount++) {
116116
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch 1 in C",ECPGt_EOIT,
117117
ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
118118
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
@@ -191,7 +191,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
191191
/* exec sql whenever not found break ; */
192192
#line 48 "fetch.pgc"
193193

194-
while (1) {
194+
for (loopcount=0;loopcount<100;loopcount++) {
195195
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch 1 in D",ECPGt_EOIT,
196196
ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
197197
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp