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

Commit1a271f0

Browse files
committed
Fix WIN32 wait() return value macros to be accurate, particularly
because they are used for testing the return value from system().(WIN32 doesn't overlay the return code with other failure conditionslike Unix does, so they are just simple macros.)Fix regression checks to properly handle diff failures on Win32 usingthe new macros.
1 parent497d39d commit1a271f0

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

‎src/include/port/win32.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.53 2006/07/16 20:17:04 tgl Exp $ */
1+
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.54 2006/07/30 01:45:21 momjian Exp $ */
22

33
/* undefine and redefine after #include */
44
#undef mkdir
@@ -109,12 +109,17 @@ intsemop(int semId, struct sembuf * sops, int flag);
109109

110110

111111
/*
112-
* Signal stuff
112+
*Signal stuff
113+
*WIN32 doesn't have wait(), so the return value for children
114+
*is simply the return value specified by the child, without
115+
*any additional information on whether the child terminated
116+
*on its own or via a signal. These macros are also used
117+
*to interpret the return value of system().
113118
*/
114-
#defineWEXITSTATUS(w)(((w) >> 8) & 0xff)
115-
#defineWIFEXITED(w)(((w) & 0xff) == 0)
116-
#defineWIFSIGNALED(w)(((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
117-
#defineWTERMSIG(w)((w) & 0x7f)
119+
#defineWEXITSTATUS(w)(w)
120+
#defineWIFEXITED(w)(true)
121+
#defineWIFSIGNALED(w)(false)
122+
#defineWTERMSIG(w)(0)
118123

119124
#definesigmask(sig) ( 1 << ((sig)-1) )
120125

‎src/test/regress/pg_regress.c

Lines changed: 21 additions & 22 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.16 2006/07/27 15:37:19 tgl Exp $
14+
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.17 2006/07/30 01:45:21 momjian Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -799,29 +799,32 @@ make_directory(const char *dir)
799799
}
800800

801801
/*
802-
* Run a "diff" command and check that it didn't crash
802+
* Run a "diff" command andalsocheck that it didn't crash
803803
*/
804-
staticvoid
805-
run_diff(constchar*cmd)
804+
staticint
805+
run_diff(constchar*cmd,constchar*filename)
806806
{
807807
intr;
808808

809809
r=system(cmd);
810-
/*
811-
* XXX FIXME: it appears that include/port/win32.h's definitions of
812-
* WIFEXITED and related macros may be wrong. They certainly don't
813-
* work for inspecting the results of system(). For the moment,
814-
* hard-wire the check on Windows.
815-
*/
816-
#ifndefWIN32
817810
if (!WIFEXITED(r)||WEXITSTATUS(r)>1)
818-
#else
819-
if (r!=0&&r!=1)
820-
#endif
821811
{
822812
fprintf(stderr,_("diff command failed with status %d: %s\n"),r,cmd);
823813
exit_nicely(2);
824814
}
815+
#ifdefWIN32
816+
/*
817+
*On WIN32, if the 'diff' command cannot be found, system() returns
818+
*1, but produces nothing to stdout, so we check for that here.
819+
*/
820+
if (WEXITSTATUS(r)==1&&file_size(filename) <=0)
821+
{
822+
fprintf(stderr,_("diff command not found: %s\n"),cmd);
823+
exit_nicely(2);
824+
}
825+
#endif
826+
827+
returnWEXITSTATUS(r);
825828
}
826829

827830
/*
@@ -844,7 +847,7 @@ results_differ(const char *testname)
844847
intbest_line_count;
845848
inti;
846849
intl;
847-
850+
848851
/* Check in resultmap if we should be looking at a different file */
849852
expectname=testname;
850853
for (rm=resultmap;rm!=NULL;rm=rm->next)
@@ -872,12 +875,10 @@ results_differ(const char *testname)
872875
snprintf(cmd,sizeof(cmd),
873876
SYSTEMQUOTE"diff %s \"%s\" \"%s\" > \"%s\""SYSTEMQUOTE,
874877
basic_diff_opts,expectfile,resultsfile,diff);
875-
run_diff(cmd);
876878

877879
/* Is the diff file empty? */
878-
if (file_size(diff)==0)
880+
if (run_diff(cmd,diff)==0)
879881
{
880-
/* No diff = no changes = good */
881882
unlink(diff);
882883
return false;
883884
}
@@ -896,11 +897,9 @@ results_differ(const char *testname)
896897
snprintf(cmd,sizeof(cmd),
897898
SYSTEMQUOTE"diff %s \"%s\" \"%s\" > \"%s\""SYSTEMQUOTE,
898899
basic_diff_opts,expectfile,resultsfile,diff);
899-
run_diff(cmd);
900900

901-
if (file_size(diff)==0)
901+
if (run_diff(cmd,diff)==0)
902902
{
903-
/* No diff = no changes = good */
904903
unlink(diff);
905904
return false;
906905
}
@@ -921,7 +920,7 @@ results_differ(const char *testname)
921920
snprintf(cmd,sizeof(cmd),
922921
SYSTEMQUOTE"diff %s \"%s\" \"%s\" >> \"%s\""SYSTEMQUOTE,
923922
pretty_diff_opts,best_expect_file,resultsfile,difffilename);
924-
run_diff(cmd);
923+
run_diff(cmd,difffilename);
925924

926925
/* And append a separator */
927926
difffile=fopen(difffilename,"a");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp