11
11
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
12
12
* Portions Copyright (c) 1994, Regents of the University of California
13
13
*
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 $
15
15
*
16
16
*-------------------------------------------------------------------------
17
17
*/
@@ -699,7 +699,7 @@ psql_start_test(const char *testname)
699
699
outputdir , testname );
700
700
701
701
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 ,
703
703
bindir , dbname , infile , outfile );
704
704
705
705
pid = spawn_process (psql_cmd );
@@ -795,6 +795,32 @@ make_directory(const char *dir)
795
795
}
796
796
}
797
797
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
+
798
824
/*
799
825
* Check the actual result file for the given test against expected results
800
826
*
@@ -815,7 +841,6 @@ results_differ(const char *testname)
815
841
int best_line_count ;
816
842
int i ;
817
843
int l ;
818
- int r ;
819
844
820
845
/* Check in resultmap if we should be looking at a different file */
821
846
expectname = testname ;
@@ -842,14 +867,9 @@ results_differ(const char *testname)
842
867
843
868
/* OK, run the diff */
844
869
snprintf (cmd , sizeof (cmd ),
845
- SYSTEMQUOTE "diff %s \"%s\" \"%s\" >\"%s\"" SYSTEMQUOTE ,
870
+ SYSTEMQUOTE "diff %s \"%s\" \"%s\" > \"%s\"" SYSTEMQUOTE ,
846
871
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 );
853
873
854
874
/* Is the diff file empty? */
855
875
if (file_size (diff ) == 0 )
@@ -871,15 +891,9 @@ results_differ(const char *testname)
871
891
continue ;
872
892
873
893
snprintf (cmd , sizeof (cmd ),
874
- SYSTEMQUOTE "diff %s \"%s\" \"%s\" >\"%s\"" SYSTEMQUOTE ,
894
+ SYSTEMQUOTE "diff %s \"%s\" \"%s\" > \"%s\"" SYSTEMQUOTE ,
875
895
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 );
883
897
884
898
if (file_size (diff ) == 0 )
885
899
{
@@ -902,14 +916,9 @@ results_differ(const char *testname)
902
916
* we append to the diffs summary file.
903
917
*/
904
918
snprintf (cmd , sizeof (cmd ),
905
- SYSTEMQUOTE "diff %s \"%s\" \"%s\" >>\"%s\"" SYSTEMQUOTE ,
919
+ SYSTEMQUOTE "diff %s \"%s\" \"%s\" >> \"%s\"" SYSTEMQUOTE ,
906
920
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 );
913
922
914
923
/* And append a separator */
915
924
difffile = fopen (difffilename , "a" );
@@ -1435,7 +1444,7 @@ main(int argc, char *argv[])
1435
1444
1436
1445
/* "make install" */
1437
1446
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 ,
1439
1448
makeprog , top_builddir , temp_install , outputdir );
1440
1449
if (system (buf ))
1441
1450
{
@@ -1446,10 +1455,10 @@ main(int argc, char *argv[])
1446
1455
/* initdb */
1447
1456
header (_ ("initializing database system" ));
1448
1457
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 ,
1450
1459
bindir , temp_install , datadir ,
1451
- debug ? "--debug" : "" ,
1452
- nolocale ? "--no-locale" : "" ,
1460
+ debug ? " --debug" : "" ,
1461
+ nolocale ? " --no-locale" : "" ,
1453
1462
outputdir );
1454
1463
if (system (buf ))
1455
1464
{
@@ -1462,9 +1471,9 @@ main(int argc, char *argv[])
1462
1471
*/
1463
1472
header (_ ("starting postmaster" ));
1464
1473
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 ,
1466
1475
bindir , temp_install ,
1467
- debug ? "-d 5" : "" ,
1476
+ debug ? " -d 5" : "" ,
1468
1477
hostname ? hostname : "" ,
1469
1478
outputdir );
1470
1479
postmaster_pid = spawn_process (buf );
0 commit comments