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

Commit 11f6d2f

Browse files
committed
As a stopgap to get the Windows buildfarm members running again, hot-wire
the check on diff's exit status to check for literally 0 or 1. Someone should look into why WIFEXITED/WEXITSTATUS don't work for this, but I've spent more than enough time on it already.
1 parent 679de5e commit 11f6d2f

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

src/test/regress/pg_regress.c

Lines changed: 40 additions & 31 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.9 2006/07/20 03:30:58 tgl Exp $
14+
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.10 2006/07/20 16:25:30 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -699,7 +699,7 @@ psql_start_test(const char *testname)
699699
outputdir, testname);
700700

701701
snprintf(psql_cmd, sizeof(psql_cmd),
702-
SYSTEMQUOTE "\"%s/psql\" -X -a -q -d \"%s\" <\"%s\" >\"%s\" 2>&1" SYSTEMQUOTE,
702+
SYSTEMQUOTE "\"%s/psql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
703703
bindir, dbname, infile, outfile);
704704

705705
pid = spawn_process(psql_cmd);
@@ -795,6 +795,32 @@ make_directory(const char *dir)
795795
}
796796
}
797797

798+
/*
799+
* Run a "diff" command and check that it didn't crash
800+
*/
801+
static void
802+
run_diff(const char *cmd)
803+
{
804+
int r;
805+
806+
r = system(cmd);
807+
/*
808+
* XXX FIXME: it appears that include/port/win32.h's definitions of
809+
* WIFEXITED and related macros may be wrong. They certainly don't
810+
* work for inspecting the results of system(). For the moment,
811+
* hard-wire the check on Windows.
812+
*/
813+
#ifndef WIN32
814+
if (!WIFEXITED(r) || WEXITSTATUS(r) > 1)
815+
#else
816+
if (r != 0 && r != 1)
817+
#endif
818+
{
819+
fprintf(stderr, _("diff command failed with status %d: %s\n"), r, cmd);
820+
exit_nicely(2);
821+
}
822+
}
823+
798824
/*
799825
* Check the actual result file for the given test against expected results
800826
*
@@ -815,7 +841,6 @@ results_differ(const char *testname)
815841
int best_line_count;
816842
int i;
817843
int l;
818-
int r;
819844

820845
/* Check in resultmap if we should be looking at a different file */
821846
expectname = testname;
@@ -842,14 +867,9 @@ results_differ(const char *testname)
842867

843868
/* OK, run the diff */
844869
snprintf(cmd, sizeof(cmd),
845-
SYSTEMQUOTE "diff %s \"%s\" \"%s\" >\"%s\"" SYSTEMQUOTE,
870+
SYSTEMQUOTE "diff %s \"%s\" \"%s\" > \"%s\"" SYSTEMQUOTE,
846871
basic_diff_opts, expectfile, resultsfile, diff);
847-
r = system(cmd);
848-
if (!WIFEXITED(r) || WEXITSTATUS(r) > 1)
849-
{
850-
fprintf(stderr, _("diff command failed with status %d: %s\n"), r, cmd);
851-
exit_nicely(2);
852-
}
872+
run_diff(cmd);
853873

854874
/* Is the diff file empty? */
855875
if (file_size(diff) == 0)
@@ -871,15 +891,9 @@ results_differ(const char *testname)
871891
continue;
872892

873893
snprintf(cmd, sizeof(cmd),
874-
SYSTEMQUOTE "diff %s \"%s\" \"%s\" >\"%s\"" SYSTEMQUOTE,
894+
SYSTEMQUOTE "diff %s \"%s\" \"%s\" > \"%s\"" SYSTEMQUOTE,
875895
basic_diff_opts, expectfile, resultsfile, diff);
876-
r = system(cmd);
877-
if (!WIFEXITED(r) || WEXITSTATUS(r) > 1)
878-
{
879-
fprintf(stderr, _("diff command failed with status %d: %s\n"),
880-
r, cmd);
881-
exit_nicely(2);
882-
}
896+
run_diff(cmd);
883897

884898
if (file_size(diff) == 0)
885899
{
@@ -902,14 +916,9 @@ results_differ(const char *testname)
902916
* we append to the diffs summary file.
903917
*/
904918
snprintf(cmd, sizeof(cmd),
905-
SYSTEMQUOTE "diff %s \"%s\" \"%s\" >>\"%s\"" SYSTEMQUOTE,
919+
SYSTEMQUOTE "diff %s \"%s\" \"%s\" >> \"%s\"" SYSTEMQUOTE,
906920
pretty_diff_opts, best_expect_file, resultsfile, difffilename);
907-
r = system(cmd);
908-
if (!WIFEXITED(r) || WEXITSTATUS(r) > 1)
909-
{
910-
fprintf(stderr, _("diff command failed with status %d: %s\n"), r, cmd);
911-
exit_nicely(2);
912-
}
921+
run_diff(cmd);
913922

914923
/* And append a separator */
915924
difffile = fopen(difffilename, "a");
@@ -1435,7 +1444,7 @@ main(int argc, char *argv[])
14351444

14361445
/* "make install" */
14371446
snprintf(buf, sizeof(buf),
1438-
SYSTEMQUOTE "\"%s\" -C \"%s\" DESTDIR=\"%s/install\" install with_perl=no with_python=no >\"%s/log/install.log\" 2>&1" SYSTEMQUOTE,
1447+
SYSTEMQUOTE "\"%s\" -C \"%s\" DESTDIR=\"%s/install\" install with_perl=no with_python=no > \"%s/log/install.log\" 2>&1" SYSTEMQUOTE,
14391448
makeprog, top_builddir, temp_install, outputdir);
14401449
if (system(buf))
14411450
{
@@ -1446,10 +1455,10 @@ main(int argc, char *argv[])
14461455
/* initdb */
14471456
header(_("initializing database system"));
14481457
snprintf(buf, sizeof(buf),
1449-
SYSTEMQUOTE "\"%s/initdb\" -D \"%s/data\" -L \"%s\" --noclean %s %s >\"%s/log/initdb.log\" 2>&1" SYSTEMQUOTE,
1458+
SYSTEMQUOTE "\"%s/initdb\" -D \"%s/data\" -L \"%s\" --noclean%s%s > \"%s/log/initdb.log\" 2>&1" SYSTEMQUOTE,
14501459
bindir, temp_install, datadir,
1451-
debug ? "--debug" : "",
1452-
nolocale ? "--no-locale" : "",
1460+
debug ? " --debug" : "",
1461+
nolocale ? " --no-locale" : "",
14531462
outputdir);
14541463
if (system(buf))
14551464
{
@@ -1462,9 +1471,9 @@ main(int argc, char *argv[])
14621471
*/
14631472
header(_("starting postmaster"));
14641473
snprintf(buf, sizeof(buf),
1465-
SYSTEMQUOTE "\"%s/postmaster\" -D \"%s/data\" -F %s -c \"listen_addresses=%s\" >\"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
1474+
SYSTEMQUOTE "\"%s/postmaster\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
14661475
bindir, temp_install,
1467-
debug ? "-d 5" : "",
1476+
debug ? " -d 5" : "",
14681477
hostname ? hostname : "",
14691478
outputdir);
14701479
postmaster_pid = spawn_process(buf);

0 commit comments

Comments
 (0)