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

Commitb11f0d3

Browse files
committed
Improve pg_regress's error reporting for schedule-file problems.
The previous coding here trashed the line buffer as it scanned it,making it impossible to print the source line in subsequent errormessages. With a few save/restore/strdup pushups we can improvethat situation.In passing, move the free'ing of the various strings that are collectedwhile processing one set of tests down to the bottom of the loop.That's simpler, less surprising, and should make valgrind less unhappyabout the strings that were previously leaked by the last iteration.
1 parentef73a81 commitb11f0d3

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

‎src/test/regress/pg_regress.c

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,7 @@ run_schedule(const char *schedule, test_function tfunc)
15931593
FILE*scf;
15941594
intline_num=0;
15951595

1596+
memset(tests,0,sizeof(tests));
15961597
memset(resultfiles,0,sizeof(resultfiles));
15971598
memset(expectfiles,0,sizeof(expectfiles));
15981599
memset(tags,0,sizeof(tags));
@@ -1615,16 +1616,6 @@ run_schedule(const char *schedule, test_function tfunc)
16151616

16161617
line_num++;
16171618

1618-
/* clear out string lists left over from previous line */
1619-
for (i=0;i<MAX_PARALLEL_TESTS;i++)
1620-
{
1621-
if (resultfiles[i]==NULL)
1622-
break;
1623-
free_stringlist(&resultfiles[i]);
1624-
free_stringlist(&expectfiles[i]);
1625-
free_stringlist(&tags[i]);
1626-
}
1627-
16281619
/* strip trailing whitespace, especially the newline */
16291620
i=strlen(scbuf);
16301621
while (i>0&&isspace((unsignedchar)scbuf[i-1]))
@@ -1657,24 +1648,35 @@ run_schedule(const char *schedule, test_function tfunc)
16571648

16581649
num_tests=0;
16591650
inword= false;
1660-
for (c=test;*c;c++)
1651+
for (c=test;;c++)
16611652
{
1662-
if (isspace((unsignedchar)*c))
1653+
if (*c=='\0'||isspace((unsignedchar)*c))
16631654
{
1664-
*c='\0';
1665-
inword= false;
1655+
if (inword)
1656+
{
1657+
/* Reached end of a test name */
1658+
charsav;
1659+
1660+
if (num_tests >=MAX_PARALLEL_TESTS)
1661+
{
1662+
fprintf(stderr,_("too many parallel tests (more than %d) in schedule file \"%s\" line %d: %s\n"),
1663+
MAX_PARALLEL_TESTS,schedule,line_num,scbuf);
1664+
exit(2);
1665+
}
1666+
sav=*c;
1667+
*c='\0';
1668+
tests[num_tests]=pg_strdup(test);
1669+
num_tests++;
1670+
*c=sav;
1671+
inword= false;
1672+
}
1673+
if (*c=='\0')
1674+
break;/* loop exit is here */
16661675
}
16671676
elseif (!inword)
16681677
{
1669-
if (num_tests >=MAX_PARALLEL_TESTS)
1670-
{
1671-
/* can't print scbuf here, it's already been trashed */
1672-
fprintf(stderr,_("too many parallel tests (more than %d) in schedule file \"%s\" line %d\n"),
1673-
MAX_PARALLEL_TESTS,schedule,line_num);
1674-
exit(2);
1675-
}
1676-
tests[num_tests]=c;
1677-
num_tests++;
1678+
/* Start of a test name */
1679+
test=c;
16781680
inword= true;
16791681
}
16801682
}
@@ -1695,9 +1697,8 @@ run_schedule(const char *schedule, test_function tfunc)
16951697
}
16961698
elseif (max_concurrent_tests>0&&max_concurrent_tests<num_tests)
16971699
{
1698-
/* can't print scbuf here, it's already been trashed */
1699-
fprintf(stderr,_("too many parallel tests (more than %d) in schedule file \"%s\" line %d\n"),
1700-
max_concurrent_tests,schedule,line_num);
1700+
fprintf(stderr,_("too many parallel tests (more than %d) in schedule file \"%s\" line %d: %s\n"),
1701+
max_concurrent_tests,schedule,line_num,scbuf);
17011702
exit(2);
17021703
}
17031704
elseif (max_connections>0&&max_connections<num_tests)
@@ -1802,6 +1803,15 @@ run_schedule(const char *schedule, test_function tfunc)
18021803

18031804
status_end();
18041805
}
1806+
1807+
for (i=0;i<num_tests;i++)
1808+
{
1809+
pg_free(tests[i]);
1810+
tests[i]=NULL;
1811+
free_stringlist(&resultfiles[i]);
1812+
free_stringlist(&expectfiles[i]);
1813+
free_stringlist(&tags[i]);
1814+
}
18051815
}
18061816

18071817
free_stringlist(&ignorelist);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp