pg_regress: stat correct paths - Mailing list pgsql-patches
From | Jorgen Austvik - Sun Norway |
---|---|
Subject | pg_regress: stat correct paths |
Date | |
Msg-id | 474AD96D.8030105@sun.com Whole thread Raw |
Responses |
Re: pg_regress: stat correct paths
|
List | pgsql-patches |
Hi, I think I have found a small problem in pg_regress. In convert_sourcefiles() it stats directories based on the current working directory, but in convert_sourcefiles_in() it reads files based in srcdir or abs_builddir. The attached patch changes the behavior of pg_regress, so that it stats the directories that it read the files from. This patch will also make pg_regress fail if the directories are missing, instead of silently ignoring the missing directories. If you think this fail-fast behavior is undesirable, I can create a patch that just ignores the files (todays behavior), or ignores them with a warning. The attached patch is tested by running pg_regress in a non-standard path and by running "make check", both on Solaris Nevada on x64. -J -- Jørgen Austvik, Software Engineering - QA Sun Microsystems Database Technology Group Index: src/test/regress/pg_regress.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/test/regress/pg_regress.c,v retrieving revision 1.38 diff -c -r1.38 pg_regress.c *** src/test/regress/pg_regress.c 15 Nov 2007 21:14:46 -0000 1.38 --- src/test/regress/pg_regress.c 26 Nov 2007 14:26:54 -0000 *************** *** 399,407 **** --- 399,410 ---- char abs_builddir[MAXPGPATH]; char testtablespace[MAXPGPATH]; char indir[MAXPGPATH]; + char destdir[MAXPGPATH]; char **name; char **names; int count = 0; + struct stat st; + int ret; #ifdef WIN32 char *c; *************** *** 424,429 **** --- 427,450 ---- strcpy(abs_srcdir, abs_builddir); snprintf(indir, MAXPGPATH, "%s/%s", abs_srcdir, source); + snprintf(destdir, MAXPGPATH, "%s/%s", abs_srcdir, dest); + + ret = stat(indir, &st); + if ((ret != 0) || (!S_ISDIR(st.st_mode))) + { + fprintf(stderr, _("%s: could not find input directory \"%s\": %s\n"), + progname, indir, strerror(errno)); + exit_nicely(2); + } + + ret = stat(destdir, &st); + if ((ret != 0) || (!S_ISDIR(st.st_mode))) + { + fprintf(stderr, _("%s: could not find destination directory \"%s\": %s\n"), + progname, destdir, strerror(errno)); + exit_nicely(2); + } + names = pgfnames(indir); if (!names) /* Error logged in pgfnames */ *************** *** 466,472 **** /* build the full actual paths to open */ snprintf(prefix, strlen(*name) - 6, "%s", *name); snprintf(srcfile, MAXPGPATH, "%s/%s", indir, *name); ! snprintf(destfile, MAXPGPATH, "%s/%s.%s", dest, prefix, suffix); infile = fopen(srcfile, "r"); if (!infile) --- 487,493 ---- /* build the full actual paths to open */ snprintf(prefix, strlen(*name) - 6, "%s", *name); snprintf(srcfile, MAXPGPATH, "%s/%s", indir, *name); ! snprintf(destfile, MAXPGPATH, "%s/%s.%s", destdir, prefix, suffix); infile = fopen(srcfile, "r"); if (!infile) *************** *** 508,527 **** pgfnames_cleanup(names); } ! /* Create the .sql and .out files from the .source files, if any */ static void convert_sourcefiles(void) { ! struct stat st; ! int ret; ! ! ret = stat("input", &st); ! if (ret == 0 && S_ISDIR(st.st_mode)) ! convert_sourcefiles_in("input", "sql", "sql"); ! ! ret = stat("output", &st); ! if (ret == 0 && S_ISDIR(st.st_mode)) ! convert_sourcefiles_in("output", "expected", "out"); } /* --- 529,540 ---- pgfnames_cleanup(names); } ! /* Create the .sql and .out files from the .source files */ static void convert_sourcefiles(void) { ! convert_sourcefiles_in("input", "sql", "sql"); ! convert_sourcefiles_in("output", "expected", "out"); } /*
Attachment
pgsql-patches by date: