]> granicus.if.org Git - postgresql/blobdiff - src/test/regress/pg_regress.c
Use a macro variable PG_PRINTF_ATTRIBUTE for the style used for checking printf type...
[postgresql] / src / test / regress / pg_regress.c
index b9ae622b04b0d272672249ec2ccba8838201fb97..1411ca4e40054e6c983676c4d0eee21fbd2e591c 100644 (file)
@@ -102,6 +102,7 @@ static bool port_specified_by_user = false;
 static char *dlpath = PKGLIBDIR;
 static char *user = NULL;
 static _stringlist *extraroles = NULL;
+static _stringlist *extra_install = NULL;
 
 /* internal variables */
 static const char *progname;
@@ -125,24 +126,26 @@ static void
 header(const char *fmt,...)
 /* This extension allows gcc to check the format string for consistency with
    the supplied arguments. */
-__attribute__((format(printf, 1, 2)));
+__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
 static void
 status(const char *fmt,...)
 /* This extension allows gcc to check the format string for consistency with
    the supplied arguments. */
-__attribute__((format(printf, 1, 2)));
+__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
 static void
 psql_command(const char *database, const char *query,...)
 /* This extension allows gcc to check the format string for consistency with
    the supplied arguments. */
-__attribute__((format(printf, 2, 3)));
+__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
 
 #ifdef WIN32
 typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
 
-/* Windows API define missing from MingW headers */
+/* Windows API define missing from some versions of MingW headers */
+#ifndef  DISABLE_MAX_PRIVILEGE
 #define DISABLE_MAX_PRIVILEGE  0x1
 #endif
+#endif
 
 /*
  * allow core files if possible.
@@ -1894,6 +1897,7 @@ help(void)
        printf(_("  --top-builddir=DIR        (relative) path to top level build directory\n"));
        printf(_("  --port=PORT               start postmaster on PORT\n"));
        printf(_("  --temp-config=PATH        append contents of PATH to temporary config\n"));
+       printf(_("  --extra-install=DIR       additional directory to install (e.g., contrib\n"));
        printf(_("\n"));
        printf(_("Options for using an existing installation:\n"));
        printf(_("  --host=HOST               use postmaster running on HOST\n"));
@@ -1941,6 +1945,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                {"use-existing", no_argument, NULL, 20},
                {"launcher", required_argument, NULL, 21},
                {"load-extension", required_argument, NULL, 22},
+               {"extra-install", required_argument, NULL, 23},
                {NULL, 0, NULL, 0}
        };
 
@@ -2040,6 +2045,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                        case 22:
                                add_stringlist_item(&loadextension, optarg);
                                break;
+                       case 23:
+                               add_stringlist_item(&extra_install, optarg);
+                               break;
                        default:
                                /* getopt_long already emitted a complaint */
                                fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
@@ -2084,6 +2092,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
        if (temp_install)
        {
                FILE       *pg_conf;
+               _stringlist *sl;
 
                /*
                 * Prepare the temp installation
@@ -2126,6 +2135,24 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                        exit_nicely(2);
                }
 
+               for (sl = extra_install; sl != NULL; sl = sl->next)
+               {
+#ifndef WIN32_ONLY_COMPILER
+                       snprintf(buf, sizeof(buf),
+                                        SYSTEMQUOTE "\"%s\" -C \"%s/%s\" DESTDIR=\"%s/install\" install >> \"%s/log/install.log\" 2>&1" SYSTEMQUOTE,
+                                        makeprog, top_builddir, sl->str, temp_install, outputdir);
+#else
+                       fprintf(stderr, _("\n%s: --extra-install option not supported on this platform\n", progname));
+                       exit_nicely(2);
+#endif
+
+                       if (system(buf))
+                       {
+                               fprintf(stderr, _("\n%s: installation failed\nExamine %s/log/install.log for the reason.\nCommand was: %s\n"), progname, outputdir, buf);
+                               exit_nicely(2);
+                       }
+               }
+
                /* initdb */
                header(_("initializing database system"));
                snprintf(buf, sizeof(buf),
@@ -2277,8 +2304,14 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
 
                postmaster_running = true;
 
+#ifdef WIN64
+/* need a series of two casts to convert HANDLE without compiler warning */
+#define ULONGPID(x) (unsigned long) (unsigned long long) (x)
+#else
+#define ULONGPID(x) (unsigned long) (x)
+#endif
                printf(_("running on port %d with pid %lu\n"),
-                          port, (unsigned long) postmaster_pid);
+                          port, ULONGPID(postmaster_pid));
        }
        else
        {