diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-01-24 16:46:55 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-01-24 16:47:06 -0500 |
commit | d5a1fde397269bd60b99e70a4eb2934b75fd31ec (patch) | |
tree | 16b5d39d7efe4be09c2baa281d39028bc1907b1b /src/interfaces/ecpg/test/expected | |
parent | bbd5c207b960dd072445a3547f16abea0c27f726 (diff) | |
download | postgresql-d5a1fde397269bd60b99e70a4eb2934b75fd31ec.tar.gz postgresql-d5a1fde397269bd60b99e70a4eb2934b75fd31ec.zip |
Remove infinite-loop hazards in ecpg test suite.
A report from Andrew Dunstan showed that an ecpglib breakage that
causes repeated query failures could lead to infinite loops in some
ecpg test scripts, because they contain "while(1)" loops with no
exit condition other than successful test completion. That might
be all right for manual testing, but it seems entirely unacceptable
for automated test environments such as our buildfarm. We don't
want buildfarm owners to have to intervene manually when a test
goes wrong.
To fix, just change all those while(1) loops to exit after at most
100 iterations (which is more than any of them expect to iterate).
This seems sufficient since we'd see discrepancies in the test output
if any loop executed the wrong number of times.
I tested this by dint of intentionally breaking ecpg_do_prologue
to always fail, and verifying that the tests still got to completion.
Back-patch to all supported branches, since the whole point of this
exercise is to protect the buildfarm against future mistakes.
Discussion: https://postgr.es/m/18693.1548302004@sss.pgh.pa.us
Diffstat (limited to 'src/interfaces/ecpg/test/expected')
9 files changed, 26 insertions, 23 deletions
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c index 99349475f87..64415344981 100644 --- a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c +++ b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c @@ -33,7 +33,7 @@ int main(void) { #line 14 "test_informix.pgc" - int i = 14 ; + int i = 14 , loopcount ; #line 14 "test_informix.pgc" @@ -156,7 +156,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );} deccvint(0, &j); - while (1) + for (loopcount = 0; loopcount < 100; loopcount++) { { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch forward c", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), diff --git a/src/interfaces/ecpg/test/expected/compat_oracle-char_array.c b/src/interfaces/ecpg/test/expected/compat_oracle-char_array.c index c9d2badb6a6..ee8624f0ec5 100644 --- a/src/interfaces/ecpg/test/expected/compat_oracle-char_array.c +++ b/src/interfaces/ecpg/test/expected/compat_oracle-char_array.c @@ -41,7 +41,7 @@ int main() { const char *ppppp = "XXXXX"; - + int loopcount; /* exec sql begin declare section */ @@ -156,7 +156,7 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("Full Str. : Short Ind.\n"); - while(1) { + for (loopcount = 0; loopcount < 100; loopcount++) { strncpy(shortstr, ppppp, sizeof shortstr); memset(bigstr, 0, sizeof bigstr); { ECPGdo(__LINE__, 3, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c index c8312840591..b7e80547950 100644 --- a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c +++ b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c @@ -36,13 +36,13 @@ int main(void) { /* exec sql begin declare section */ - + #line 21 "nan_test.pgc" - int id ; + int id , loopcount ; #line 22 "nan_test.pgc" double d ; @@ -90,7 +90,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} if (sqlca.sqlcode < 0) sqlprint ( );} #line 36 "nan_test.pgc" - while (1) + for (loopcount = 0; loopcount < 100; loopcount++) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -145,7 +145,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} if (sqlca.sqlcode < 0) sqlprint ( );} #line 52 "nan_test.pgc" - while (1) + for (loopcount = 0; loopcount < 100; loopcount++) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -229,7 +229,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} if (sqlca.sqlcode < 0) sqlprint ( );} #line 78 "nan_test.pgc" - while (1) + for (loopcount = 0; loopcount < 100; loopcount++) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur1", ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), diff --git a/src/interfaces/ecpg/test/expected/preproc-autoprep.c b/src/interfaces/ecpg/test/expected/preproc-autoprep.c index 10ede3ec627..8ed5a2ca2c1 100644 --- a/src/interfaces/ecpg/test/expected/preproc-autoprep.c +++ b/src/interfaces/ecpg/test/expected/preproc-autoprep.c @@ -197,7 +197,7 @@ if (sqlca.sqlcode < 0) sqlprint();} i = 0; - while (1) + while (i < 100) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur1", ECPGt_EOIT, ECPGt_int,&(item1),(long)1,(long)1,sizeof(int), diff --git a/src/interfaces/ecpg/test/expected/preproc-outofscope.c b/src/interfaces/ecpg/test/expected/preproc-outofscope.c index b23107714c9..dc9cdbc909e 100644 --- a/src/interfaces/ecpg/test/expected/preproc-outofscope.c +++ b/src/interfaces/ecpg/test/expected/preproc-outofscope.c @@ -267,7 +267,7 @@ main (void) { MYTYPE *myvar; MYNULLTYPE *mynullvar; - + int loopcount; char msg[128]; ECPGdebug(1, stderr); @@ -333,7 +333,7 @@ if (sqlca.sqlcode < 0) exit (1);} #line 96 "outofscope.pgc" - while (1) + for (loopcount = 0; loopcount < 100; loopcount++) { memset(myvar, 0, sizeof(MYTYPE)); get_record1(); diff --git a/src/interfaces/ecpg/test/expected/preproc-variable.c b/src/interfaces/ecpg/test/expected/preproc-variable.c index 08e2355d169..3954f837690 100644 --- a/src/interfaces/ecpg/test/expected/preproc-variable.c +++ b/src/interfaces/ecpg/test/expected/preproc-variable.c @@ -120,7 +120,7 @@ main (void) #line 37 "variable.pgc" - + int loopcount; char msg[128]; ECPGdebug(1, stderr); @@ -204,7 +204,7 @@ if (sqlca.sqlcode < 0) exit (1);} p=&personal; i=&ind_personal; memset(i, 0, sizeof(ind_personal)); - while (1) { + for (loopcount = 0; loopcount < 100; loopcount++) { strcpy(msg, "fetch"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur", ECPGt_EOIT, ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)-1,sizeof( struct birthinfo ), diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c index a367af00f37..86b9984c044 100644 --- a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c +++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c @@ -33,7 +33,7 @@ int main(void) - + #line 15 "whenever_do_continue.pgc" @@ -48,6 +48,9 @@ int main(void) float comm ; } emp ; +#line 16 "whenever_do_continue.pgc" + int loopcount ; + #line 17 "whenever_do_continue.pgc" char msg [ 128 ] ; /* exec sql end declare section */ @@ -119,7 +122,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 42 "whenever_do_continue.pgc" - while (1) + for (loopcount = 0; loopcount < 100; loopcount++) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch c", ECPGt_EOIT, ECPGt_char,&(emp.ename),(long)12,(long)1,(12)*sizeof(char), diff --git a/src/interfaces/ecpg/test/expected/sql-fetch.c b/src/interfaces/ecpg/test/expected/sql-fetch.c index b547b25c7a8..b1b13aeb752 100644 --- a/src/interfaces/ecpg/test/expected/sql-fetch.c +++ b/src/interfaces/ecpg/test/expected/sql-fetch.c @@ -25,13 +25,13 @@ int main() { /* exec sql begin declare section */ - + #line 9 "fetch.pgc" char str [ 25 ] ; #line 10 "fetch.pgc" - int i , count = 1 ; + int i , count = 1 , loopcount ; /* exec sql end declare section */ #line 11 "fetch.pgc" @@ -112,7 +112,7 @@ if (sqlca.sqlcode < 0) sqlprint();} /* exec sql whenever not found break ; */ #line 30 "fetch.pgc" - while (1) { + for (loopcount = 0; loopcount < 100; loopcount++) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, @@ -191,7 +191,7 @@ if (sqlca.sqlcode < 0) sqlprint();} /* exec sql whenever not found break ; */ #line 48 "fetch.pgc" - while (1) { + for (loopcount = 0; loopcount < 100; loopcount++) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in D", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, diff --git a/src/interfaces/ecpg/test/expected/sql-quote.c b/src/interfaces/ecpg/test/expected/sql-quote.c index 0a3b77c5756..7943384fd87 100644 --- a/src/interfaces/ecpg/test/expected/sql-quote.c +++ b/src/interfaces/ecpg/test/expected/sql-quote.c @@ -25,13 +25,13 @@ int main() { /* exec sql begin declare section */ - + #line 9 "quote.pgc" char var [ 25 ] ; #line 10 "quote.pgc" - int i ; + int i , loopcount ; /* exec sql end declare section */ #line 11 "quote.pgc" @@ -176,7 +176,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 47 "quote.pgc" - while (true) + for (loopcount = 0; loopcount < 100; loopcount++) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), |