Skip to content

Commit 42fd80d

Browse files
committed
Fix pg_regress to check the directory it is actually reading files from,
not the image that (theoretically) should exist in the current directory. Jørgen Austvik
1 parent 3f89964 commit 42fd80d

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/test/regress/pg_regress.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2007, 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.38 2007/11/15 21:14:46 momjian Exp $
14+
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.39 2007/11/27 19:13:30 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -399,6 +399,8 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix)
399399
char abs_builddir[MAXPGPATH];
400400
char testtablespace[MAXPGPATH];
401401
char indir[MAXPGPATH];
402+
struct stat st;
403+
int ret;
402404
char **name;
403405
char **names;
404406
int count = 0;
@@ -419,11 +421,23 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix)
419421
* current directory.
420422
*/
421423
if (srcdir)
422-
strcpy(abs_srcdir, srcdir);
424+
strlcpy(abs_srcdir, srcdir, MAXPGPATH);
423425
else
424-
strcpy(abs_srcdir, abs_builddir);
426+
strlcpy(abs_srcdir, abs_builddir, MAXPGPATH);
425427

426428
snprintf(indir, MAXPGPATH, "%s/%s", abs_srcdir, source);
429+
430+
/* Check that indir actually exists and is a directory */
431+
ret = stat(indir, &st);
432+
if (ret != 0 || !S_ISDIR(st.st_mode))
433+
{
434+
/*
435+
* No warning, to avoid noise in tests that do not have
436+
* these directories; for example, ecpg, contrib and src/pl.
437+
*/
438+
return;
439+
}
440+
427441
names = pgfnames(indir);
428442
if (!names)
429443
/* Error logged in pgfnames */
@@ -512,16 +526,8 @@ convert_sourcefiles_in(char *source, char *dest, char *suffix)
512526
static void
513527
convert_sourcefiles(void)
514528
{
515-
struct stat st;
516-
int ret;
517-
518-
ret = stat("input", &st);
519-
if (ret == 0 && S_ISDIR(st.st_mode))
520-
convert_sourcefiles_in("input", "sql", "sql");
521-
522-
ret = stat("output", &st);
523-
if (ret == 0 && S_ISDIR(st.st_mode))
524-
convert_sourcefiles_in("output", "expected", "out");
529+
convert_sourcefiles_in("input", "sql", "sql");
530+
convert_sourcefiles_in("output", "expected", "out");
525531
}
526532

527533
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy