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

Commit27a8310

Browse files
committed
Fix pg_regress.c to report tests in a parallel group when they finish,
not when they're started. This mimics a subtle point of the behaviorof the old shell script, and gives better feedback when watching thetests.
1 parent5652ea7 commit27a8310

File tree

1 file changed

+48
-27
lines changed

1 file changed

+48
-27
lines changed

‎src/test/regress/pg_regress.c

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.6 2006/07/2001:16:57 tgl Exp $
14+
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.7 2006/07/2002:10:00 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -919,47 +919,70 @@ results_differ(const char *testname)
919919

920920
/*
921921
* Wait for specified subprocesses to finish
922+
*
923+
* If names isn't NULL, report each subprocess as it finishes
924+
*
925+
* Note: it's OK to scribble on the pids array, but not on the names array
922926
*/
923927
staticvoid
924-
wait_for_tests(PID_TYPE*pids,intnum_tests)
928+
wait_for_tests(PID_TYPE*pids,char**names,intnum_tests)
925929
{
926-
#ifndefWIN32
927930
inttests_left;
928931
inti;
929932

933+
#ifdefWIN32
934+
PID_TYPE*active_pids=malloc(num_tests*sizeof(PID_TYPE));
935+
936+
memcpy(active_pids,pids,num_tests*sizeof(PID_TYPE));
937+
#endif
938+
930939
tests_left=num_tests;
931940
while (tests_left>0)
932941
{
933-
pid_tp=wait(NULL);
942+
PID_TYPEp;
934943

935-
if (p==-1)
944+
#ifndefWIN32
945+
p=wait(NULL);
946+
947+
if (p==INVALID_PID)
936948
{
937-
fprintf(stderr,_("could not wait(): %s\n"),strerror(errno));
949+
fprintf(stderr,_("failed to wait for subprocesses: %s\n"),
950+
strerror(errno));
938951
exit_nicely(2);
939952
}
953+
#else
954+
intr;
955+
956+
r=WaitForMultipleObjects(tests_left,active_pids, FALSE,INFINITE);
957+
if (r<WAIT_OBJECT_0||r >=WAIT_OBJECT_0+tests_left)
958+
{
959+
fprintf(stderr,_("failed to wait for subprocesses: %lu\n"),
960+
GetLastError());
961+
exit_nicely(2);
962+
}
963+
p=active_pids[r-WAIT_OBJECT_0];
964+
/* compact the active_pids array */
965+
active_pids[r-WAIT_OBJECT_0]=active_pids[tests_left-1];
966+
#endif/* WIN32 */
967+
940968
for (i=0;i<num_tests;i++)
941969
{
942-
/* Make sure we only count the processes we explicitly started */
943970
if (p==pids[i])
944971
{
945-
pids[i]=-1;
972+
#ifdefWIN32
973+
CloseHandle(pids[i]);
974+
#endif
975+
pids[i]=INVALID_PID;
976+
if (names)
977+
status(" %s",names[i]);
946978
tests_left--;
979+
break;
947980
}
948981
}
949982
}
950-
#else
951-
intr;
952-
inti;
953983

954-
r=WaitForMultipleObjects(num_tests,pids, TRUE,INFINITE);
955-
if (r!=WAIT_OBJECT_0)
956-
{
957-
fprintf(stderr,_("could not wait for commands to finish: %lu\n"),
958-
GetLastError());
959-
exit_nicely(2);
960-
}
961-
for (i=0;i<num_tests;i++)
962-
CloseHandle(pids[i]);
984+
#ifdefWIN32
985+
free(active_pids);
963986
#endif
964987
}
965988

@@ -1059,7 +1082,7 @@ run_schedule(const char *schedule)
10591082
{
10601083
status(_("test %-20s ... "),tests[0]);
10611084
pids[0]=psql_start_test(tests[0]);
1062-
wait_for_tests(pids,1);
1085+
wait_for_tests(pids,NULL,1);
10631086
/* status line is finished below */
10641087
}
10651088
elseif (max_connections>0&&max_connections<num_tests)
@@ -1072,24 +1095,22 @@ run_schedule(const char *schedule)
10721095
{
10731096
if (i-oldest >=max_connections)
10741097
{
1075-
wait_for_tests(pids+oldest,i-oldest);
1098+
wait_for_tests(pids+oldest,tests+oldest,i-oldest);
10761099
oldest=i;
10771100
}
1078-
status(" %s",tests[i]);
10791101
pids[i]=psql_start_test(tests[i]);
10801102
}
1081-
wait_for_tests(pids+oldest,i-oldest);
1103+
wait_for_tests(pids+oldest,tests+oldest,i-oldest);
10821104
status_end();
10831105
}
10841106
else
10851107
{
10861108
status(_("parallel group (%d tests): "),num_tests);
10871109
for (i=0;i<num_tests;i++)
10881110
{
1089-
status(" %s",tests[i]);
10901111
pids[i]=psql_start_test(tests[i]);
10911112
}
1092-
wait_for_tests(pids,num_tests);
1113+
wait_for_tests(pids,tests,num_tests);
10931114
status_end();
10941115
}
10951116

@@ -1146,7 +1167,7 @@ run_single_test(const char *test)
11461167

11471168
status(_("test %-20s ... "),test);
11481169
pid=psql_start_test(test);
1149-
wait_for_tests(&pid,1);
1170+
wait_for_tests(&pid,NULL,1);
11501171

11511172
if (results_differ(test))
11521173
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp