36 #include "pg_config_paths.h"
127 #if defined(HAVE_GETRLIMIT)
133 getrlimit(RLIMIT_CORE, &lim);
134 if (lim.rlim_max == 0)
137 _(
"%s: could not set core size: disallowed by hard limit\n"),
141 else if (lim.rlim_max == RLIM_INFINITY || lim.rlim_cur < lim.rlim_max)
143 lim.rlim_cur = lim.rlim_max;
144 setrlimit(RLIMIT_CORE, &lim);
160 newentry->
next = NULL;
161 if (*listhead == NULL)
162 *listhead = newentry;
165 for (oldentry = *listhead; oldentry->
next; oldentry = oldentry->
next)
167 oldentry->
next = newentry;
177 if (listhead == NULL || *listhead == NULL)
179 if ((*listhead)->next != NULL)
181 free((*listhead)->str);
193 char *
token = strtok(sc, delim);
198 token = strtok(NULL, delim);
216 fprintf(
stdout,
"============== %-38s ==============\n", tmp);
266 "\"%s%spg_ctl\" stop -D \"%s/data\" -s",
274 fprintf(stderr,
_(
"\n%s: could not stop postmaster: exit code was %d\n"),
310 raise(postgres_signal_arg);
328 char *
template =
psprintf(
"%s/pg_regress-XXXXXX",
329 getenv(
"TMPDIR") ? getenv(
"TMPDIR") :
"/tmp");
334 fprintf(stderr,
_(
"%s: could not create directory \"%s\": %s\n"),
373 while (*
str && *pattern)
375 if (*pattern ==
'.' && pattern[1] ==
'*')
379 if (*pattern ==
'\0')
392 if (*
str == *pattern || *pattern ==
'.')
406 else if (*pattern !=
'.' && *
str != *pattern)
419 if (*pattern ==
'\0')
423 while (*pattern ==
'.' && pattern[1] ==
'*')
425 if (*pattern ==
'\0')
458 fprintf(stderr,
_(
"%s: could not open file \"%s\" for reading: %s\n"),
463 while (fgets(
buf,
sizeof(
buf), f))
472 while (
i > 0 && isspace((
unsigned char)
buf[
i - 1]))
476 file_type = strchr(
buf,
':');
479 fprintf(stderr,
_(
"incorrectly formatted resultmap entry: %s\n"),
485 platform = strchr(file_type,
':');
488 fprintf(stderr,
_(
"incorrectly formatted resultmap entry: %s\n"),
493 expected = strchr(platform,
'=');
496 fprintf(stderr,
_(
"incorrectly formatted resultmap entry: %s\n"),
536 if (!file || !(file_type = strrchr(file,
'.')))
543 if (strcmp(testname, rm->
test) == 0 && strcmp(file_type, rm->
type) == 0)
562 setenv(
"PGAPPNAME",
"pg_regress", 1);
570 setenv(
"PG_DLSUFFIX", DLSUFFIX, 1);
592 #if defined(WIN32) || defined(__CYGWIN__) || defined(__darwin__)
605 setenv(
"LC_MESSAGES",
"C", 1);
618 setenv(
"PGTZ",
"PST8PDT", 1);
619 setenv(
"PGDATESTYLE",
"Postgres, MDY", 1);
627 const char *my_pgoptions =
"-c intervalstyle=postgres_verbose";
628 const char *old_pgoptions = getenv(
"PGOPTIONS");
634 old_pgoptions, my_pgoptions);
635 setenv(
"PGOPTIONS", new_pgoptions, 1);
669 unsetenv(
"PGSSLMAXPROTOCOLVERSION");
670 unsetenv(
"PGSSLMINPROTOCOLVERSION");
683 sockdir = getenv(
"PG_REGRESS_SOCK_DIR");
732 pghost = getenv(
"PGHOST");
733 pgport = getenv(
"PGPORT");
746 printf(
_(
"(using postmaster on %s, default port)\n"),
pghost);
748 printf(
_(
"(using postmaster on Unix socket, port %s)\n"),
pgport);
750 printf(
_(
"(using postmaster on Unix socket, default port)\n"));
760 fmtHba(
const char *raw)
766 wp = ret =
pg_realloc(ret, 3 + strlen(raw) * 2);
769 for (rp = raw; *rp; rp++)
786 current_windows_user(
const char **acct,
const char **dom)
791 TOKEN_USER *tokenuser;
793 DWORD accountnamesize =
sizeof(accountname);
794 DWORD domainnamesize =
sizeof(domainname);
795 SID_NAME_USE accountnameuse;
797 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &
token))
800 _(
"%s: could not open process token: error code %lu\n"),
805 if (!GetTokenInformation(
token, TokenUser, NULL, 0, &retlen) && GetLastError() != 122)
808 _(
"%s: could not get token information buffer size: error code %lu\n"),
813 if (!GetTokenInformation(
token, TokenUser, tokenuser, retlen, &retlen))
816 _(
"%s: could not get token information: error code %lu\n"),
821 if (!LookupAccountSid(NULL, tokenuser->User.Sid, accountname, &accountnamesize,
822 domainname, &domainnamesize, &accountnameuse))
825 _(
"%s: could not look up account SID: error code %lu\n"),
845 config_sspi_auth(
const char *pgdata,
const char *superuser_name)
847 const char *accountname,
858 current_windows_user(&accountname, &domainname);
861 if (superuser_name == NULL)
871 if (superuser_name == NULL)
883 struct addrinfo *gai_result;
884 struct addrinfo hints;
887 hints.ai_flags = AI_NUMERICHOST;
888 hints.ai_family = AF_UNSPEC;
889 hints.ai_socktype = 0;
890 hints.ai_protocol = 0;
891 hints.ai_addrlen = 0;
892 hints.ai_canonname = NULL;
893 hints.ai_addr = NULL;
894 hints.ai_next = NULL;
896 have_ipv6 = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0 &&
897 getaddrinfo(
"::1", NULL, &hints, &gai_result) == 0);
905 fprintf(stderr, _("%s: could not write to file \"%s\": %s\n"), \
906 progname, fname, strerror(errno)); \
911 res =
snprintf(fname,
sizeof(fname),
"%s/pg_hba.conf", pgdata);
912 if (res < 0 || res >=
sizeof(fname))
921 hba = fopen(fname,
"w");
924 fprintf(stderr,
_(
"%s: could not open file \"%s\" for writing: %s\n"),
928 CW(fputs(
"# Configuration written by config_sspi_auth()\n", hba) >= 0);
929 CW(fputs(
"host all all 127.0.0.1/32 sspi include_realm=1 map=regress\n",
932 CW(fputs(
"host all all ::1/128 sspi include_realm=1 map=regress\n",
934 CW(fclose(hba) == 0);
936 snprintf(fname,
sizeof(fname),
"%s/pg_ident.conf", pgdata);
937 ident = fopen(fname,
"w");
940 fprintf(stderr,
_(
"%s: could not open file \"%s\" for writing: %s\n"),
944 CW(fputs(
"# Configuration written by config_sspi_auth()\n",
ident) >= 0);
952 accountname, domainname, fmtHba(superuser_name)) >= 0);
955 accountname, domainname, fmtHba(sl->
str)) >= 0);
956 CW(fclose(
ident) == 0);
1007 for (cmdptr = cmdbuf.
data; *cmdptr; cmdptr++)
1009 if (strchr(
"\\\"$`", *cmdptr))
1029 if (system(
buf->data) != 0)
1032 fprintf(stderr,
_(
"command failed: %s\n"),
buf->data);
1044 #define psql_command(database, ...) \
1046 StringInfo cmdbuf = psql_start_command(); \
1047 psql_add_command(cmdbuf, __VA_ARGS__); \
1048 psql_end_command(cmdbuf, database); \
1074 fprintf(stderr,
_(
"%s: could not fork: %s\n"),
1089 cmdline2 =
psprintf(
"exec %s", cmdline);
1091 fprintf(stderr,
_(
"%s: could not exec \"%s\": %s\n"),
1098 PROCESS_INFORMATION pi;
1100 HANDLE restrictedToken;
1101 const char *comspec;
1104 comspec = getenv(
"COMSPEC");
1105 if (comspec == NULL)
1108 memset(&pi, 0,
sizeof(pi));
1109 cmdline2 =
psprintf(
"\"%s\" /c \"%s\"", comspec, cmdline);
1111 if ((restrictedToken =
1112 CreateRestrictedProcess(cmdline2, &pi)) == 0)
1115 CloseHandle(pi.hThread);
1127 FILE *f = fopen(file,
"r");
1131 fprintf(stderr,
_(
"%s: could not open file \"%s\" for reading: %s\n"),
1135 fseek(f, 0, SEEK_END);
1149 FILE *f = fopen(file,
"r");
1153 fprintf(stderr,
_(
"%s: could not open file \"%s\" for reading: %s\n"),
1157 while ((
c = fgetc(f)) != EOF)
1169 FILE *f = fopen(file,
"r");
1182 if (
stat(dir, &st) != 0)
1195 fprintf(stderr,
_(
"%s: could not create directory \"%s\": %s\n"),
1208 int ssize = strlen(expectfile) + 2 + 1;
1212 if (!(tmp = (
char *)
malloc(ssize)))
1215 if (!(s = (
char *)
malloc(ssize)))
1221 strcpy(tmp, expectfile);
1222 last_dot = strrchr(tmp,
'.');
1230 snprintf(s, ssize,
"%s_%d.%s", tmp,
i, last_dot + 1);
1247 fprintf(stderr,
_(
"diff command failed with status %d: %s\n"), r, cmd);
1258 fprintf(stderr,
_(
"diff command not found: %s\n"), cmd);
1273 results_differ(
const char *testname,
const char *resultsfile,
const char *default_expectfile)
1280 int best_line_count;
1283 const char *platform_expectfile;
1291 strlcpy(expectfile, default_expectfile,
sizeof(expectfile));
1292 if (platform_expectfile)
1298 char *p = strrchr(expectfile,
'/');
1301 strcpy(++p, platform_expectfile);
1305 snprintf(diff,
sizeof(diff),
"%s.diff", resultsfile);
1309 "diff %s \"%s\" \"%s\" > \"%s\"",
1321 strcpy(best_expect_file, expectfile);
1323 for (
i = 0;
i <= 9;
i++)
1325 char *alt_expectfile;
1328 if (!alt_expectfile)
1330 fprintf(stderr,
_(
"Unable to check secondary comparison files: %s\n"),
1337 free(alt_expectfile);
1342 "diff %s \"%s\" \"%s\" > \"%s\"",
1348 free(alt_expectfile);
1353 if (l < best_line_count)
1356 best_line_count = l;
1357 strlcpy(best_expect_file, alt_expectfile,
sizeof(best_expect_file));
1359 free(alt_expectfile);
1367 if (platform_expectfile)
1370 "diff %s \"%s\" \"%s\" > \"%s\"",
1381 if (l < best_line_count)
1384 best_line_count = l;
1385 strlcpy(best_expect_file, default_expectfile,
sizeof(best_expect_file));
1406 "diff %s \"%s\" \"%s\" >> \"%s\"",
1424 char **names,
int num_tests)
1432 memcpy(active_pids, pids, num_tests *
sizeof(
PID_TYPE));
1435 tests_left = num_tests;
1436 while (tests_left > 0)
1443 p = wait(&exit_status);
1447 fprintf(stderr,
_(
"failed to wait for subprocesses: %s\n"),
1455 r = WaitForMultipleObjects(tests_left, active_pids, FALSE, INFINITE);
1456 if (r < WAIT_OBJECT_0 || r >= WAIT_OBJECT_0 + tests_left)
1458 fprintf(stderr,
_(
"failed to wait for subprocesses: error code %lu\n"),
1462 p = active_pids[r - WAIT_OBJECT_0];
1464 active_pids[r - WAIT_OBJECT_0] = active_pids[tests_left - 1];
1467 for (
i = 0;
i < num_tests;
i++)
1472 GetExitCodeProcess(pids[
i], &exit_status);
1473 CloseHandle(pids[
i]);
1476 statuses[
i] = (int) exit_status;
1498 status(
_(
" (test process exited with exit code %d)"),
1503 status(
_(
" (test process was terminated by exception 0x%X)"),
1506 status(
_(
" (test process was terminated by signal %d: %s)"),
1511 status(
_(
" (test process exited with unrecognized status %d)"),
1522 #define MAX_PARALLEL_TESTS 100
1535 memset(tests, 0,
sizeof(tests));
1536 memset(resultfiles, 0,
sizeof(resultfiles));
1537 memset(expectfiles, 0,
sizeof(expectfiles));
1538 memset(tags, 0,
sizeof(tags));
1540 scf = fopen(schedule,
"r");
1543 fprintf(stderr,
_(
"%s: could not open file \"%s\" for reading: %s\n"),
1548 while (fgets(scbuf,
sizeof(scbuf), scf))
1560 while (
i > 0 && isspace((
unsigned char) scbuf[
i - 1]))
1563 if (scbuf[0] ==
'\0' || scbuf[0] ==
'#')
1565 if (strncmp(scbuf,
"test: ", 6) == 0)
1569 fprintf(stderr,
_(
"syntax error in schedule file \"%s\" line %d: %s\n"),
1570 schedule, line_num, scbuf);
1578 if (*
c ==
'\0' || isspace((
unsigned char) *
c))
1587 fprintf(stderr,
_(
"too many parallel tests (more than %d) in schedule file \"%s\" line %d: %s\n"),
1611 fprintf(stderr,
_(
"syntax error in schedule file \"%s\" line %d: %s\n"),
1612 schedule, line_num, scbuf);
1618 status(
_(
"test %-28s ... "), tests[0]);
1619 pids[0] = (startfunc) (tests[0], &resultfiles[0], &expectfiles[0], &tags[0]);
1626 fprintf(stderr,
_(
"too many parallel tests (more than %d) in schedule file \"%s\" line %d: %s\n"),
1634 status(
_(
"parallel group (%d tests, in groups of %d): "),
1636 for (
i = 0;
i < num_tests;
i++)
1642 tests + oldest,
i - oldest);
1645 pids[
i] = (startfunc) (tests[
i], &resultfiles[
i], &expectfiles[
i], &tags[
i]);
1650 tests + oldest,
i - oldest);
1655 status(
_(
"parallel group (%d tests): "), num_tests);
1656 for (
i = 0;
i < num_tests;
i++)
1658 pids[
i] = (startfunc) (tests[
i], &resultfiles[
i], &expectfiles[
i], &tags[
i]);
1666 for (
i = 0;
i < num_tests;
i++)
1671 bool differ =
false;
1674 status(
_(
" %-28s ... "), tests[
i]);
1683 for (rl = resultfiles[
i], el = expectfiles[
i], tl = tags[
i];
1686 tl = tl ? tl->
next : NULL)
1691 (*postfunc) (rl->
str);
1700 if (statuses[
i] != 0)
1727 for (
i = 0;
i < num_tests;
i++)
1757 bool differ =
false;
1760 pid = (startfunc) (
test, &resultfiles, &expectfiles, &tags);
1771 for (rl = resultfiles, el = expectfiles, tl = tags;
1774 tl = tl ? tl->
next : NULL)
1779 (*postfunc) (rl->
str);
1788 if (exit_status != 0)
1833 fprintf(stderr,
_(
"%s: could not open file \"%s\" for writing: %s\n"),
1844 fprintf(stderr,
_(
"%s: could not open file \"%s\" for writing: %s\n"),
1882 (
nolocale) ?
" LC_COLLATE='C' LC_CTYPE='C'" :
"");
1885 (
nolocale) ?
" LC_COLLATE='C' LC_CTYPE='C'" :
"");
1887 "ALTER DATABASE \"%s\" SET lc_messages TO 'C';"
1888 "ALTER DATABASE \"%s\" SET lc_monetary TO 'C';"
1889 "ALTER DATABASE \"%s\" SET lc_numeric TO 'C';"
1890 "ALTER DATABASE \"%s\" SET lc_time TO 'C';"
1891 "ALTER DATABASE \"%s\" SET bytea_output TO 'hex';"
1892 "ALTER DATABASE \"%s\" SET timezone_abbreviations TO 'Default';",
1912 header(
_(
"dropping role \"%s\""), rolename);
1924 header(
_(
"creating role \"%s\""), rolename);
1926 for (; granted_dbs != NULL; granted_dbs = granted_dbs->
next)
1929 granted_dbs->
str, rolename);
1937 printf(
_(
"PostgreSQL regression test driver\n"));
1942 printf(
_(
" --bindir=BINPATH use BINPATH for programs that are run;\n"));
1943 printf(
_(
" if empty, use PATH from the environment\n"));
1944 printf(
_(
" --config-auth=DATADIR update authentication settings for DATADIR\n"));
1945 printf(
_(
" --create-role=ROLE create the specified role before testing\n"));
1946 printf(
_(
" --dbname=DB use database DB (default \"regression\")\n"));
1947 printf(
_(
" --debug turn on debug mode in programs that are run\n"));
1948 printf(
_(
" --dlpath=DIR look for dynamic libraries in DIR\n"));
1949 printf(
_(
" --encoding=ENCODING use ENCODING as the encoding\n"));
1950 printf(
_(
" --expecteddir=DIR take expected files from DIR (default \".\")\n"));
1951 printf(
_(
" -h, --help show this help, then exit\n"));
1952 printf(
_(
" --inputdir=DIR take input files from DIR (default \".\")\n"));
1953 printf(
_(
" --launcher=CMD use CMD as launcher of psql\n"));
1954 printf(
_(
" --load-extension=EXT load the named extension before running the\n"));
1955 printf(
_(
" tests; can appear multiple times\n"));
1956 printf(
_(
" --max-connections=N maximum number of concurrent connections\n"));
1957 printf(
_(
" (default is 0, meaning unlimited)\n"));
1958 printf(
_(
" --max-concurrent-tests=N maximum number of concurrent tests in schedule\n"));
1959 printf(
_(
" (default is 0, meaning unlimited)\n"));
1960 printf(
_(
" --outputdir=DIR place output files in DIR (default \".\")\n"));
1961 printf(
_(
" --schedule=FILE use test ordering schedule from FILE\n"));
1962 printf(
_(
" (can be used multiple times to concatenate)\n"));
1963 printf(
_(
" --temp-instance=DIR create a temporary instance in DIR\n"));
1964 printf(
_(
" --use-existing use an existing installation\n"));
1965 printf(
_(
" -V, --version output version information, then exit\n"));
1967 printf(
_(
"Options for \"temp-instance\" mode:\n"));
1968 printf(
_(
" --no-locale use C locale\n"));
1969 printf(
_(
" --port=PORT start postmaster on PORT\n"));
1970 printf(
_(
" --temp-config=FILE append contents of FILE to temporary config\n"));
1972 printf(
_(
"Options for using an existing installation:\n"));
1973 printf(
_(
" --host=HOST use postmaster running on HOST\n"));
1974 printf(
_(
" --port=PORT use postmaster running at PORT\n"));
1975 printf(
_(
" --user=USER connect as USER\n"));
1977 printf(
_(
"The exit status is 0 if all tests passed, 1 if some tests failed, and 2\n"));
1978 printf(
_(
"if the tests could not be run for some reason.\n"));
1980 printf(
_(
"Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
1981 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
1990 static struct option long_options[] = {
2018 bool use_unix_sockets;
2040 use_unix_sockets = getenv(
"PG_TEST_USE_UNIX_SOCKETS") ?
true :
false;
2042 use_unix_sockets =
true;
2045 if (!use_unix_sockets)
2054 if (getenv(
"PG_REGRESS_DIFF_OPTS"))
2057 while ((
c =
getopt_long(argc, argv,
"hV", long_options, &option_index)) != -1)
2065 puts(
"pg_regress (PostgreSQL) " PG_VERSION);
2146 fprintf(stderr,
_(
"\nTry \"%s -h\" for more information.\n"),
2155 while (argc -
optind >= 1)
2167 fprintf(stderr,
_(
"%s: no database name was specified\n"),
2175 if (!use_unix_sockets)
2190 port = 0xC000 | (PG_VERSION_NUM & 0x3FFF);
2204 #if defined(HAVE_GETRLIMIT)
2211 const char *env_wait;
2220 header(
_(
"removing existing temp instance"));
2223 fprintf(stderr,
_(
"\n%s: could not remove temp instance \"%s\"\n"),
2229 header(
_(
"creating temporary instance"));
2240 header(
_(
"initializing database system"));
2242 "\"%s%sinitdb\" -D \"%s/data\" --no-clean --no-sync%s%s > \"%s/log/initdb.log\" 2>&1",
2246 debug ?
" --debug" :
"",
2265 pg_conf = fopen(
buf,
"a");
2266 if (pg_conf == NULL)
2271 fputs(
"\n# Configuration added by pg_regress\n\n", pg_conf);
2272 fputs(
"log_autovacuum_min_duration = 0\n", pg_conf);
2273 fputs(
"log_checkpoints = on\n", pg_conf);
2274 fputs(
"log_line_prefix = '%m %b[%p] %q%a '\n", pg_conf);
2275 fputs(
"log_lock_waits = on\n", pg_conf);
2276 fputs(
"log_temp_files = 128kB\n", pg_conf);
2277 fputs(
"max_prepared_transactions = 2\n", pg_conf);
2281 char *temp_config = sl->
str;
2283 char line_buf[1024];
2285 extra_conf = fopen(temp_config,
"r");
2286 if (extra_conf == NULL)
2288 fprintf(stderr,
_(
"\n%s: could not open \"%s\" to read extra config: %s\n"),
progname, temp_config,
strerror(errno));
2291 while (fgets(line_buf,
sizeof(line_buf), extra_conf) != NULL)
2292 fputs(line_buf, pg_conf);
2299 if (!use_unix_sockets)
2306 config_sspi_auth(
buf, NULL);
2314 "\"%s%spsql\" -X postgres <%s 2>%s",
2319 for (
i = 0;
i < 16;
i++)
2322 if (system(buf2) == 0)
2328 fprintf(stderr,
_(
"port %d apparently in use\n"),
port);
2330 fprintf(stderr,
_(
"%s: could not determine an available port\n"),
progname);
2331 fprintf(stderr,
_(
"Specify an unused port using the --port option or shut down any conflicting PostgreSQL servers.\n"));
2335 fprintf(stderr,
_(
"port %d apparently in use, trying %d\n"),
port,
port + 1);
2347 header(
_(
"starting postmaster"));
2349 "\"%s%spostgres\" -D \"%s/data\" -F%s "
2350 "-c \"listen_addresses=%s\" -k \"%s\" "
2351 "> \"%s/log/postmaster.log\" 2>&1",
2360 fprintf(stderr,
_(
"\n%s: could not spawn postmaster: %s\n"),
2372 env_wait = getenv(
"PGCTLTIMEOUT");
2373 if (env_wait != NULL)
2386 if (system(buf2) == 0)
2406 fprintf(stderr,
_(
"\n%s: postmaster did not respond within %d seconds\nExamine %s/log/postmaster.log for the reason\n"),
2418 fprintf(stderr,
_(
"\n%s: could not kill failed postmaster: %s\n"),
2422 fprintf(stderr,
_(
"\n%s: could not kill failed postmaster: error code %lu\n"),
2433 #define ULONGPID(x) (unsigned long) (unsigned long long) (x)
2435 #define ULONGPID(x) (unsigned long) (x)
2437 printf(
_(
"running on port %d with PID %lu\n"),
2469 header(
_(
"running regression test queries"));
2486 header(
_(
"shutting down postmaster"));
2497 header(
_(
"removing temporary instance"));
2499 fprintf(stderr,
_(
"\n%s: could not remove temp instance \"%s\"\n"),
2510 _(
" All %d tests passed. "),
2514 _(
" %d of %d tests failed. "),
2519 for (
i = strlen(
buf);
i > 0;
i--)
2522 for (
i = strlen(
buf);
i > 0;
i--)
2529 printf(
_(
"The differences that caused some tests to fail can be viewed in the\n"
2530 "file \"%s\". A copy of the test summary that you see\n"
2531 "above is saved in the file \"%s\".\n\n"),
#define PG_TEXTDOMAIN(domain)
#define pg_attribute_printf(f, a)
void set_pglocale_pgservice(const char *argv0, const char *app)
static void PGresult * res
void * pg_realloc(void *ptr, size_t size)
char * pg_strdup(const char *in)
void * pg_malloc(size_t size)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
#define INSTR_TIME_SET_CURRENT(t)
#define INSTR_TIME_SUBTRACT(x, y)
#define INSTR_TIME_GET_MILLISEC(t)
static void const char * fmt
static void const char fflush(stdout)
vfprintf(stderr, fmt, args)
Assert(fmt[strlen(fmt) - 1] !='\n')
void pg_logging_init(const char *argv0)
void pfree(void *pointer)
#define DEFAULT_PGSOCKET_DIR
PGDLLIMPORT char * optarg
static void open_result_files(void)
static int max_connections
static void status_end(void)
static bool port_specified_by_user
static int file_line_count(const char *file)
static void load_resultmap(void)
static void psql_add_command(StringInfo buf, const char *query,...) pg_attribute_printf(2
static void static void static StringInfo psql_start_command(void)
bool file_exists(const char *file)
static void signal_remove_temp(SIGNAL_ARGS)
static void remove_temp(void)
static void stop_postmaster(void)
static int max_concurrent_tests
static void create_database(const char *dbname)
static void free_stringlist(_stringlist **listhead)
static void drop_role_if_exists(const char *rolename)
#define MAX_PARALLEL_TESTS
static void static void psql_end_command(StringInfo buf, const char *database)
static void unlimit_core_size(void)
static const char * temp_sockdir
static bool directory_exists(const char *dir)
static _stringlist * schedulelist
static _stringlist * loadextension
static char * logfilename
static _stringlist * temp_configs
static _stringlist * extra_tests
static void make_directory(const char *dir)
static void split_to_stringlist(const char *s, const char *delim, _stringlist **listhead)
static int run_diff(const char *cmd, const char *filename)
static void run_single_test(const char *test, test_start_function startfunc, postprocess_result_function postfunc)
const char * pretty_diff_opts
static void log_child_failure(int exitstatus)
int regression_main(int argc, char *argv[], init_function ifunc, test_start_function startfunc, postprocess_result_function postfunc)
static char * difffilename
static const char * get_expectfile(const char *testname, const char *file)
static _resultmap * resultmap
struct _resultmap _resultmap
static void header(const char *fmt,...) pg_attribute_printf(1
static char * config_auth_datadir
static void drop_database_if_exists(const char *dbname)
const char * basic_diff_opts
static void initialize_environment(void)
static char * temp_instance
static char sockself[MAXPGPATH]
static void wait_for_tests(PID_TYPE *pids, int *statuses, instr_time *stoptimes, char **names, int num_tests)
static const char * sockdir
static long file_size(const char *file)
static void static void status(const char *fmt,...) pg_attribute_printf(1
static bool postmaster_running
static char socklock[MAXPGPATH]
static const char * progname
static _stringlist * extraroles
static bool results_differ(const char *testname, const char *resultsfile, const char *default_expectfile)
static const char * make_temp_sockdir(void)
PID_TYPE spawn_process(const char *cmdline)
static void create_role(const char *rolename, const _stringlist *granted_dbs)
static void run_schedule(const char *schedule, test_start_function startfunc, postprocess_result_function postfunc)
void add_stringlist_item(_stringlist **listhead, const char *str)
static bool string_matches_pattern(const char *str, const char *pattern)
static char * get_alternative_expectfile(const char *expectfile, int i)
#define psql_command(database,...)
static PID_TYPE postmaster_pid
void(* init_function)(int argc, char **argv)
PID_TYPE(* test_start_function)(const char *testname, _stringlist **resultfiles, _stringlist **expectfiles, _stringlist **tags)
void(* postprocess_result_function)(const char *filename)
char * make_absolute_path(const char *path)
const char * get_progname(const char *argv0)
pqsigfunc pqsignal(int signo, pqsigfunc func)
const char * pg_strsignal(int signum)
size_t strlcpy(char *dst, const char *src, size_t siz)
char * mkdtemp(char *path)
#define UNIXSOCK_PATH(path, port, sockdir)
char * psprintf(const char *fmt,...)
void get_restricted_token(void)
bool rmtree(const char *path, bool rmtopdir)
void pg_usleep(long microsec)
int appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
StringInfo makeStringInfo(void)
void appendStringInfo(StringInfo str, const char *fmt,...)
void enlargeStringInfo(StringInfo str, int needed)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
struct _stringlist * next
const char * get_user_name(char **errstr)