]> granicus.if.org Git - postgresql/commitdiff
Provide for a file specifying non-standard config options for temp install
authorAndrew Dunstan <andrew@dunslane.net>
Sun, 9 Sep 2007 20:40:54 +0000 (20:40 +0000)
committerAndrew Dunstan <andrew@dunslane.net>
Sun, 9 Sep 2007 20:40:54 +0000 (20:40 +0000)
for pg_regress, via --temp-config option. Pick this up in the make file
via TEMP_CONFIG setting.

src/test/regress/GNUmakefile
src/test/regress/pg_regress.c

index 52aa7c75bcaacb6275c9b1e185cd49673f45e2f7..2e0a6466644aa3914cb480e61d7426c60a135d10 100644 (file)
@@ -6,7 +6,7 @@
 # Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.68 2007/06/12 11:07:32 mha Exp $
+# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.69 2007/09/09 20:40:54 adunstan Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -19,6 +19,12 @@ contribdir = $(top_builddir)/contrib
 # port number for temp-installation test postmaster
 TEMP_PORT = 5$(DEF_PGPORT)
 
+# file with extra config for temp build
+TEMP_CONF =
+ifdef TEMP_CONFIG
+TEMP_CONF += --temp-config=S(TEMP_CONFIG)
+endif
+
 # where to find psql for testing an existing installation
 PSQLDIR = $(bindir)
 
@@ -135,7 +141,7 @@ tablespace-setup:
 ##
 
 check: all
-       ./pg_regress --temp-install=./tmp_check --top-builddir=$(top_builddir) --srcdir=$(abs_srcdir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE)
+       ./pg_regress --temp-install=./tmp_check --top-builddir=$(top_builddir) --srcdir=$(abs_srcdir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE) $(TEMP_CONF)
 
 installcheck: all
        ./pg_regress --psqldir=$(PSQLDIR) --schedule=$(srcdir)/serial_schedule --srcdir=$(abs_srcdir) --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE)
index 9c52df7cafee10e4d7eda4ce31f249f2bdbc5ed9..741eb11d1822bea1c37c82f6f4efd56efa21945f 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.36 2007/07/18 21:19:17 alvherre Exp $
+ * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.37 2007/09/09 20:40:54 adunstan Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -76,6 +76,7 @@ static char *encoding = NULL;
 static _stringlist *schedulelist = NULL;
 static _stringlist *extra_tests = NULL;
 static char *temp_install = NULL;
+static char *temp_config = NULL;
 static char *top_builddir = NULL;
 static int     temp_port = 65432;
 static bool nolocale = false;
@@ -1718,11 +1719,12 @@ help(void)
        printf(_("                            (can be used multiple times to concatenate)\n"));
        printf(_("  --srcdir=DIR              absolute path to source directory (for VPATH builds)\n"));
        printf(_("  --temp-install=DIR        create a temporary installation in DIR\n"));
-       printf(_("  --no-locale               use C locale\n"));
        printf(_("\n"));
        printf(_("Options for \"temp-install\" mode:\n"));
+       printf(_("  --no-locale               use C locale\n"));
        printf(_("  --top-builddir=DIR        (relative) path to top level build directory\n"));
        printf(_("  --temp-port=PORT          port number to start temp postmaster on\n"));
+       printf(_("  --temp-config=PATH        append contents of PATH to temporary config\n"));
        printf(_("\n"));
        printf(_("Options for using an existing installation:\n"));
        printf(_("  --host=HOST               use postmaster running on HOST\n"));
@@ -1766,6 +1768,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                {"psqldir", required_argument, NULL, 16},
                {"srcdir", required_argument, NULL, 17},
                {"create-role", required_argument, NULL, 18},
+               {"temp-config", required_argument, NULL, 19},
                {NULL, 0, NULL, 0}
        };
 
@@ -1874,6 +1877,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                        case 18:
                                split_to_stringlist(strdup(optarg), ", ", &extraroles);
                                break;
+                       case 19:
+                               temp_config = strdup(optarg);
+                               break;
                        default:
                                /* getopt_long already emitted a complaint */
                                fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
@@ -1962,6 +1968,32 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                        exit_nicely(2);
                }
 
+               /* add any extra config specified to the postgresql.conf */
+               if (temp_config != NULL)
+               {
+                       FILE * extra_conf;
+                       FILE * pg_conf;
+                       char line_buf[1024];
+
+                       snprintf(buf, sizeof(buf),"%s/data/postgresql.conf", temp_install);
+                       pg_conf = fopen(buf,"a");
+                       if (pg_conf == NULL)
+                       {
+                               fprintf(stderr, _("\n%s: could not open %s for adding extra config:\nError was %s\n"), progname, buf, strerror(errno));
+                               exit_nicely(2);                         
+                       }
+                       extra_conf = fopen(temp_config,"r");
+                       if (extra_conf == NULL)
+                       {
+                               fprintf(stderr, _("\n%s: could not open %s to read extra config:\nError was %s\n"), progname, buf, strerror(errno));
+                               exit_nicely(2);                         
+                       }
+                       while(fgets(line_buf, sizeof(line_buf),extra_conf) != NULL)
+                               fputs(line_buf, pg_conf);
+                       fclose(extra_conf);
+                       fclose(pg_conf);
+               }
+
                /*
                 * Start the temp postmaster
                 */