36#include "pg_config_paths.h"
76#define TESTNAME_WIDTH 36
82#define WAIT_TICKS_PER_SECOND 20
146static void test_status_print(
bool ok,
const char *testname,
double runtime,
bool parallel);
147static void test_status_ok(
const char *testname,
double runtime,
bool parallel);
161#define plan(x) emit_tap_output(PLAN, "1..%i", (x))
162#define note(...) emit_tap_output(NOTE, __VA_ARGS__)
163#define note_detail(...) emit_tap_output(NOTE_DETAIL, __VA_ARGS__)
164#define diag(...) emit_tap_output(DIAG, __VA_ARGS__)
165#define note_end() emit_tap_output(NOTE_END, "\n");
166#define bail_noatexit(...) bail_out(true, __VA_ARGS__)
167#define bail(...) bail_out(false, __VA_ARGS__)
172#if defined(HAVE_GETRLIMIT)
178 getrlimit(RLIMIT_CORE, &lim);
179 if (lim.rlim_max == 0)
181 diag(
"could not set core size: disallowed by hard limit");
184 else if (lim.rlim_max == RLIM_INFINITY || lim.rlim_cur < lim.rlim_max)
186 lim.rlim_cur = lim.rlim_max;
187 setrlimit(RLIMIT_CORE, &lim);
203 newentry->
next = NULL;
204 if (*listhead == NULL)
205 *listhead = newentry;
208 for (oldentry = *listhead; oldentry->
next; oldentry = oldentry->
next)
210 oldentry->
next = newentry;
220 if (listhead == NULL || *listhead == NULL)
222 if ((*listhead)->next != NULL)
224 free((*listhead)->str);
294 (ok ? (
int) strlen(
"not ") : 0),
"",
296 (parallel ?
'+' :
'-'),
343 va_list argp_logfile;
378 va_copy(argp_logfile, argp);
442 "\"%s%spg_ctl\" stop -D \"%s/data\" -s",
451 bail_noatexit(
_(
"could not stop postmaster: exit code was %d"), r);
484 pqsignal(postgres_signal_arg, SIG_DFL);
485 raise(postgres_signal_arg);
503 char *
template =
psprintf(
"%s/pg_regress-XXXXXX",
504 getenv(
"TMPDIR") ? getenv(
"TMPDIR") :
"/tmp");
508 bail(
"could not create directory \"%s\": %m",
template);
548 while (*
str && *pattern)
550 if (*pattern ==
'.' && pattern[1] ==
'*')
554 if (*pattern ==
'\0')
567 if (*
str == *pattern || *pattern ==
'.')
581 else if (*pattern !=
'.' && *
str != *pattern)
594 if (*pattern ==
'\0')
598 while (*pattern ==
'.' && pattern[1] ==
'*')
600 if (*pattern ==
'\0')
633 bail(
"could not open file \"%s\" for reading: %m",
buf);
636 while (fgets(
buf,
sizeof(
buf), f))
645 while (
i > 0 && isspace((
unsigned char)
buf[
i - 1]))
649 file_type = strchr(
buf,
':');
652 bail(
"incorrectly formatted resultmap entry: %s",
buf);
656 platform = strchr(file_type,
':');
659 bail(
"incorrectly formatted resultmap entry: %s",
buf);
662 expected = strchr(platform,
'=');
665 bail(
"incorrectly formatted resultmap entry: %s",
buf);
703 if (!file || !(file_type = strrchr(file,
'.')))
710 if (strcmp(testname, rm->
test) == 0 && strcmp(file_type, rm->
type) == 0)
729 setenv(
"PGAPPNAME",
"pg_regress", 1);
737 setenv(
"PG_DLSUFFIX", DLSUFFIX, 1);
759#if defined(WIN32) || defined(__CYGWIN__) || defined(__darwin__)
772 setenv(
"LC_MESSAGES",
"C", 1);
785 setenv(
"PGTZ",
"America/Los_Angeles", 1);
786 setenv(
"PGDATESTYLE",
"Postgres, MDY", 1);
794 const char *my_pgoptions =
"-c intervalstyle=postgres_verbose";
795 const char *old_pgoptions = getenv(
"PGOPTIONS");
801 old_pgoptions, my_pgoptions);
802 setenv(
"PGOPTIONS", new_pgoptions, 1);
837 unsetenv(
"PGSSLMAXPROTOCOLVERSION");
838 unsetenv(
"PGSSLMINPROTOCOLVERSION");
851 sockdir = getenv(
"PG_REGRESS_SOCK_DIR");
900 pghost = getenv(
"PGHOST");
901 pgport = getenv(
"PGPORT");
914 note(
"using postmaster on %s, default port",
pghost);
916 note(
"using postmaster on Unix socket, port %s",
pgport);
918 note(
"using postmaster on Unix socket, default port");
928fmtHba(
const char *raw)
934 wp = ret =
pg_realloc(ret, 3 + strlen(raw) * 2);
937 for (rp = raw; *rp; rp++)
954current_windows_user(
const char **acct,
const char **dom)
959 TOKEN_USER *tokenuser;
961 DWORD accountnamesize =
sizeof(accountname);
962 DWORD domainnamesize =
sizeof(domainname);
963 SID_NAME_USE accountnameuse;
965 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &
token))
967 bail(
"could not open process token: error code %lu", GetLastError());
970 if (!GetTokenInformation(
token, TokenUser, NULL, 0, &retlen) && GetLastError() != 122)
972 bail(
"could not get token information buffer size: error code %lu",
976 if (!GetTokenInformation(
token, TokenUser, tokenuser, retlen, &retlen))
978 bail(
"could not get token information: error code %lu",
982 if (!LookupAccountSid(NULL, tokenuser->User.Sid, accountname, &accountnamesize,
983 domainname, &domainnamesize, &accountnameuse))
985 bail(
"could not look up account SID: error code %lu",
1004config_sspi_auth(
const char *pgdata,
const char *superuser_name)
1006 const char *accountname,
1017 current_windows_user(&accountname, &domainname);
1020 if (superuser_name == NULL)
1030 if (superuser_name == NULL)
1041 struct addrinfo *gai_result;
1042 struct addrinfo hints;
1045 hints.ai_flags = AI_NUMERICHOST;
1046 hints.ai_family = AF_UNSPEC;
1047 hints.ai_socktype = 0;
1048 hints.ai_protocol = 0;
1049 hints.ai_addrlen = 0;
1050 hints.ai_canonname = NULL;
1051 hints.ai_addr = NULL;
1052 hints.ai_next = NULL;
1054 have_ipv6 = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0 &&
1055 getaddrinfo(
"::1", NULL, &hints, &gai_result) == 0);
1062 bail("could not write to file \"%s\": %m", fname); \
1065 res =
snprintf(fname,
sizeof(fname),
"%s/pg_hba.conf", pgdata);
1066 if (res < 0 || res >=
sizeof(fname))
1072 bail(
"directory name too long");
1074 hba = fopen(fname,
"w");
1077 bail(
"could not open file \"%s\" for writing: %m", fname);
1079 CW(fputs(
"# Configuration written by config_sspi_auth()\n", hba) >= 0);
1080 CW(fputs(
"host all all 127.0.0.1/32 sspi include_realm=1 map=regress\n",
1083 CW(fputs(
"host all all ::1/128 sspi include_realm=1 map=regress\n",
1085 CW(fclose(hba) == 0);
1087 snprintf(fname,
sizeof(fname),
"%s/pg_ident.conf", pgdata);
1088 ident = fopen(fname,
"w");
1091 bail(
"could not open file \"%s\" for writing: %m", fname);
1093 CW(fputs(
"# Configuration written by config_sspi_auth()\n",
ident) >= 0);
1101 accountname, domainname, fmtHba(superuser_name)) >= 0);
1104 accountname, domainname, fmtHba(sl->
str)) >= 0);
1105 CW(fclose(
ident) == 0);
1125 "\"%s%spsql\" -X -q",
1156 for (cmdptr = cmdbuf.
data; *cmdptr; cmdptr++)
1158 if (strchr(
"\\\"$`", *cmdptr))
1178 if (system(
buf->data) != 0)
1181 bail(
"command failed: %s",
buf->data);
1191#define psql_command(database, ...) \
1193 StringInfo cmdbuf = psql_start_command(); \
1194 psql_add_command(cmdbuf, __VA_ARGS__); \
1195 psql_end_command(cmdbuf, database); \
1221 bail(
"could not fork: %m");
1234 cmdline2 =
psprintf(
"exec %s", cmdline);
1242 PROCESS_INFORMATION pi;
1244 const char *comspec;
1247 comspec = getenv(
"COMSPEC");
1248 if (comspec == NULL)
1251 memset(&pi, 0,
sizeof(pi));
1252 cmdline2 =
psprintf(
"\"%s\" /c \"%s\"", comspec, cmdline);
1254 if (!CreateRestrictedProcess(cmdline2, &pi))
1257 CloseHandle(pi.hThread);
1269 FILE *f = fopen(file,
"r");
1273 diag(
"could not open file \"%s\" for reading: %m", file);
1276 fseek(f, 0, SEEK_END);
1290 FILE *f = fopen(file,
"r");
1294 diag(
"could not open file \"%s\" for reading: %m", file);
1297 while ((
c = fgetc(f)) != EOF)
1309 FILE *f = fopen(file,
"r");
1322 if (
stat(dir, &st) != 0)
1334 bail(
"could not create directory \"%s\": %m", dir);
1344 int ssize = strlen(expectfile) + 2 + 1;
1348 if (!(tmp = (
char *)
malloc(ssize)))
1351 if (!(s = (
char *)
malloc(ssize)))
1357 strcpy(tmp, expectfile);
1358 last_dot = strrchr(tmp,
'.');
1366 snprintf(s, ssize,
"%s_%d.%s", tmp,
i, last_dot + 1);
1383 bail(
"diff command failed with status %d: %s", r, cmd);
1393 bail(
"diff command not found: %s", cmd);
1407results_differ(
const char *testname,
const char *resultsfile,
const char *default_expectfile)
1414 int best_line_count;
1417 const char *platform_expectfile;
1425 strlcpy(expectfile, default_expectfile,
sizeof(expectfile));
1426 if (platform_expectfile)
1432 char *p = strrchr(expectfile,
'/');
1435 strcpy(++p, platform_expectfile);
1439 snprintf(diff,
sizeof(diff),
"%s.diff", resultsfile);
1443 "diff %s \"%s\" \"%s\" > \"%s\"",
1455 strcpy(best_expect_file, expectfile);
1457 for (
i = 0;
i <= 9;
i++)
1459 char *alt_expectfile;
1462 if (!alt_expectfile)
1463 bail(
"Unable to check secondary comparison files: %m");
1467 free(alt_expectfile);
1472 "diff %s \"%s\" \"%s\" > \"%s\"",
1478 free(alt_expectfile);
1483 if (l < best_line_count)
1486 best_line_count = l;
1487 strlcpy(best_expect_file, alt_expectfile,
sizeof(best_expect_file));
1489 free(alt_expectfile);
1497 if (platform_expectfile)
1500 "diff %s \"%s\" \"%s\" > \"%s\"",
1511 if (l < best_line_count)
1514 best_line_count = l;
1515 strlcpy(best_expect_file, default_expectfile,
sizeof(best_expect_file));
1536 "diff %s \"%s\" \"%s\" >> \"%s\"",
1554 char **names,
int num_tests)
1562 memcpy(active_pids, pids, num_tests *
sizeof(
PID_TYPE));
1565 tests_left = num_tests;
1566 while (tests_left > 0)
1573 p = wait(&exit_status);
1576 bail(
"failed to wait for subprocesses: %m");
1581 r = WaitForMultipleObjects(tests_left, active_pids, FALSE, INFINITE);
1582 if (r < WAIT_OBJECT_0 || r >= WAIT_OBJECT_0 + tests_left)
1584 bail(
"failed to wait for subprocesses: error code %lu",
1587 p = active_pids[r - WAIT_OBJECT_0];
1589 active_pids[r - WAIT_OBJECT_0] = active_pids[tests_left - 1];
1592 for (
i = 0;
i < num_tests;
i++)
1597 GetExitCodeProcess(pids[
i], &exit_status);
1598 CloseHandle(pids[
i]);
1601 statuses[
i] = (int) exit_status;
1623 diag(
"(test process exited with exit code %d)",
1628 diag(
"(test process was terminated by exception 0x%X)",
1631 diag(
"(test process was terminated by signal %d: %s)",
1636 diag(
"(test process exited with unrecognized status %d)", exitstatus);
1646#define MAX_PARALLEL_TESTS 100
1659 memset(tests, 0,
sizeof(tests));
1660 memset(resultfiles, 0,
sizeof(resultfiles));
1661 memset(expectfiles, 0,
sizeof(expectfiles));
1662 memset(tags, 0,
sizeof(tags));
1664 scf = fopen(schedule,
"r");
1666 bail(
"could not open file \"%s\" for reading: %m", schedule);
1668 while (fgets(scbuf,
sizeof(scbuf), scf))
1680 while (
i > 0 && isspace((
unsigned char) scbuf[
i - 1]))
1683 if (scbuf[0] ==
'\0' || scbuf[0] ==
'#')
1685 if (strncmp(scbuf,
"test: ", 6) == 0)
1689 bail(
"syntax error in schedule file \"%s\" line %d: %s",
1690 schedule, line_num, scbuf);
1697 if (*
c ==
'\0' || isspace((
unsigned char) *
c))
1706 bail(
"too many parallel tests (more than %d) in schedule file \"%s\" line %d: %s",
1729 bail(
"syntax error in schedule file \"%s\" line %d: %s",
1730 schedule, line_num, scbuf);
1735 pids[0] = (startfunc) (tests[0], &resultfiles[0], &expectfiles[0], &tags[0]);
1742 bail(
"too many parallel tests (more than %d) in schedule file \"%s\" line %d: %s",
1749 note_detail(
"parallel group (%d tests, in groups of %d): ",
1751 for (
i = 0;
i < num_tests;
i++)
1757 tests + oldest,
i - oldest);
1760 pids[
i] = (startfunc) (tests[
i], &resultfiles[
i], &expectfiles[
i], &tags[
i]);
1765 tests + oldest,
i - oldest);
1770 note_detail(
"parallel group (%d tests): ", num_tests);
1771 for (
i = 0;
i < num_tests;
i++)
1773 pids[
i] = (startfunc) (tests[
i], &resultfiles[
i], &expectfiles[
i], &tags[
i]);
1781 for (
i = 0;
i < num_tests;
i++)
1786 bool differ =
false;
1797 for (rl = resultfiles[
i], el = expectfiles[
i], tl = tags[
i];
1800 tl = tl ? tl->
next : NULL)
1805 (*postfunc) (rl->
str);
1814 if (statuses[
i] != 0)
1832 for (
i = 0;
i < num_tests;
i++)
1862 bool differ =
false;
1864 pid = (startfunc) (
test, &resultfiles, &expectfiles, &tags);
1875 for (rl = resultfiles, el = expectfiles, tl = tags;
1878 tl = tl ? tl->
next : NULL)
1883 (*postfunc) (rl->
str);
1894 if (exit_status != 0)
1976 "ALTER DATABASE \"%s\" SET lc_messages TO 'C';"
1977 "ALTER DATABASE \"%s\" SET lc_monetary TO 'C';"
1978 "ALTER DATABASE \"%s\" SET lc_numeric TO 'C';"
1979 "ALTER DATABASE \"%s\" SET lc_time TO 'C';"
1980 "ALTER DATABASE \"%s\" SET bytea_output TO 'hex';"
1981 "ALTER DATABASE \"%s\" SET timezone_abbreviations TO 'Default';",
2010 for (; granted_dbs != NULL; granted_dbs = granted_dbs->
next)
2013 granted_dbs->
str, rolename);
2021 printf(
_(
"PostgreSQL regression test driver\n"));
2026 printf(
_(
" --bindir=BINPATH use BINPATH for programs that are run;\n"));
2027 printf(
_(
" if empty, use PATH from the environment\n"));
2028 printf(
_(
" --config-auth=DATADIR update authentication settings for DATADIR\n"));
2029 printf(
_(
" --create-role=ROLE create the specified role before testing\n"));
2030 printf(
_(
" --dbname=DB use database DB (default \"regression\")\n"));
2031 printf(
_(
" --debug turn on debug mode in programs that are run\n"));
2032 printf(
_(
" --dlpath=DIR look for dynamic libraries in DIR\n"));
2033 printf(
_(
" --encoding=ENCODING use ENCODING as the encoding\n"));
2034 printf(
_(
" --expecteddir=DIR take expected files from DIR (default \".\")\n"));
2035 printf(
_(
" -h, --help show this help, then exit\n"));
2036 printf(
_(
" --inputdir=DIR take input files from DIR (default \".\")\n"));
2037 printf(
_(
" --launcher=CMD use CMD as launcher of psql\n"));
2038 printf(
_(
" --load-extension=EXT load the named extension before running the\n"));
2039 printf(
_(
" tests; can appear multiple times\n"));
2040 printf(
_(
" --max-connections=N maximum number of concurrent connections\n"));
2041 printf(
_(
" (default is 0, meaning unlimited)\n"));
2042 printf(
_(
" --max-concurrent-tests=N maximum number of concurrent tests in schedule\n"));
2043 printf(
_(
" (default is 0, meaning unlimited)\n"));
2044 printf(
_(
" --outputdir=DIR place output files in DIR (default \".\")\n"));
2045 printf(
_(
" --schedule=FILE use test ordering schedule from FILE\n"));
2046 printf(
_(
" (can be used multiple times to concatenate)\n"));
2047 printf(
_(
" --temp-instance=DIR create a temporary instance in DIR\n"));
2048 printf(
_(
" --use-existing use an existing installation\n"));
2049 printf(
_(
" -V, --version output version information, then exit\n"));
2051 printf(
_(
"Options for \"temp-instance\" mode:\n"));
2052 printf(
_(
" --no-locale use C locale\n"));
2053 printf(
_(
" --port=PORT start postmaster on PORT\n"));
2054 printf(
_(
" --temp-config=FILE append contents of FILE to temporary config\n"));
2056 printf(
_(
"Options for using an existing installation:\n"));
2057 printf(
_(
" --host=HOST use postmaster running on HOST\n"));
2058 printf(
_(
" --port=PORT use postmaster running at PORT\n"));
2059 printf(
_(
" --user=USER connect as USER\n"));
2061 printf(
_(
"The exit status is 0 if all tests passed, 1 if some tests failed, and 2\n"));
2062 printf(
_(
"if the tests could not be run for some reason.\n"));
2064 printf(
_(
"Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
2065 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
2074 static struct option long_options[] = {
2102 bool use_unix_sockets;
2123 use_unix_sockets = getenv(
"PG_TEST_USE_UNIX_SOCKETS") ?
true :
false;
2125 use_unix_sockets =
true;
2128 if (!use_unix_sockets)
2137 if (getenv(
"PG_REGRESS_DIFF_OPTS"))
2140 while ((
c =
getopt_long(argc, argv,
"hV", long_options, &option_index)) != -1)
2148 puts(
"pg_regress (PostgreSQL) " PG_VERSION);
2238 while (argc -
optind >= 1)
2250 bail(
"no database name was specified");
2256 if (!use_unix_sockets)
2271 port = 0xC000 | (PG_VERSION_NUM & 0x3FFF);
2285#if defined(HAVE_GETRLIMIT)
2293 const char *env_wait;
2295 const char *initdb_template_dir;
2299 const char *initdb_extra_opts_env;
2321 initdb_extra_opts_env = getenv(
"PG_TEST_INITDB_EXTRA_OPTS");
2334 initdb_template_dir = getenv(
"INITDB_TEMPLATE");
2335 if (initdb_template_dir == NULL ||
nolocale ||
debug || initdb_extra_opts_env)
2337 note(
"initializing database system by running initdb");
2340 "\"%s%sinitdb\" -D \"%s/data\" --no-clean --no-sync",
2348 if (initdb_extra_opts_env)
2352 if (system(cmd.
data))
2354 bail(
"initdb failed\n"
2355 "# Examine \"%s/log/initdb.log\" for the reason.\n"
2356 "# Command was: %s",
2363 const char *copycmd =
"cp -RPp \"%s\" \"%s/data\"";
2364 int expected_exitcode = 0;
2366 const char *copycmd =
"robocopy /E /NJS /NJH /NFL /NDL /NP \"%s\" \"%s/data\"";
2367 int expected_exitcode = 1;
2370 note(
"initializing database system by copying initdb template");
2374 initdb_template_dir,
2378 if (system(cmd.
data) != expected_exitcode)
2380 bail(
"copying of initdb template failed\n"
2381 "# Examine \"%s/log/initdb.log\" for the reason.\n"
2382 "# Command was: %s",
2398 pg_conf = fopen(
buf,
"a");
2399 if (pg_conf == NULL)
2400 bail(
"could not open \"%s\" for adding extra config: %m",
buf);
2402 fputs(
"\n# Configuration added by pg_regress\n\n", pg_conf);
2403 fputs(
"log_autovacuum_min_duration = 0\n", pg_conf);
2404 fputs(
"log_checkpoints = on\n", pg_conf);
2405 fputs(
"log_line_prefix = '%m %b[%p] %q%a '\n", pg_conf);
2406 fputs(
"log_lock_waits = on\n", pg_conf);
2407 fputs(
"log_temp_files = 128kB\n", pg_conf);
2408 fputs(
"max_prepared_transactions = 2\n", pg_conf);
2412 char *temp_config = sl->
str;
2414 char line_buf[1024];
2416 extra_conf = fopen(temp_config,
"r");
2417 if (extra_conf == NULL)
2419 bail(
"could not open \"%s\" to read extra config: %m",
2422 while (fgets(line_buf,
sizeof(line_buf), extra_conf) != NULL)
2423 fputs(line_buf, pg_conf);
2430 if (!use_unix_sockets)
2437 config_sspi_auth(
buf, NULL);
2458 for (
i = 0;
i < 16;
i++)
2466 note(
"port %d apparently in use",
port);
2468 note(
"could not determine an available port");
2469 bail(
"Specify an unused port using the --port option or shut down any conflicting PostgreSQL servers.");
2472 note(
"port %d apparently in use, trying %d",
port,
port + 1);
2485 "\"%s%spostgres\" -D \"%s/data\" -F%s "
2486 "-c \"listen_addresses=%s\" -k \"%s\" "
2487 "> \"%s/log/postmaster.log\" 2>&1",
2495 bail(
"could not spawn postmaster: %m");
2504 env_wait = getenv(
"PGCTLTIMEOUT");
2505 if (env_wait != NULL)
2530 bail(
"attempting to connect to postmaster failed");
2541 bail(
"postmaster failed, examine \"%s/log/postmaster.log\" for the reason",
2547 diag(
"postmaster did not respond within %d seconds, examine \"%s/log/postmaster.log\" for the reason",
2558 bail(
"could not kill failed postmaster: %m");
2561 bail(
"could not kill failed postmaster: error code %lu",
2564 bail(
"postmaster failed");
2571#define ULONGPID(x) (unsigned long) (unsigned long long) (x)
2573#define ULONGPID(x) (unsigned long) (x)
2575 note(
"using temp instance on port %d with PID %lu",
2633 diag(
"could not remove temp instance \"%s\"",
2652 diag(
"The differences that caused some tests to fail can be viewed in the file \"%s\".",
2654 diag(
"A copy of the test summary that you see above is saved in the file \"%s\".",
static Datum values[MAXATTR]
#define Assert(condition)
#define PG_TEXTDOMAIN(domain)
#define pg_attribute_printf(f, a)
void set_pglocale_pgservice(const char *argv0, const char *app)
#define fprintf(file, fmt, msg)
static void PGresult * res
PGPing PQpingParams(const char *const *keywords, const char *const *values, int expand_dbname)
void * pg_malloc(size_t size)
char * pg_strdup(const char *in)
void * pg_realloc(void *ptr, 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 const JsonPathKeyword keywords[]
static void const char * fmt
static void const char fflush(stdout)
vfprintf(stderr, fmt, args)
void pg_logging_init(const char *argv0)
#define pg_log_error_hint(...)
void pfree(void *pointer)
#define DEFAULT_PGSOCKET_DIR
PGDLLIMPORT char * optarg
static void open_result_files(void)
static int max_connections
static bool port_specified_by_user
static int file_line_count(const char *file)
static char * get_alternative_expectfile(const char *expectfile, int i)
static void load_resultmap(void)
static void psql_add_command(StringInfo buf, const char *query,...) pg_attribute_printf(2
static void 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 const char * get_expectfile(const char *testname, const char *file)
static void static void psql_end_command(StringInfo buf, const char *database)
static void static void emit_tap_output(TAPtype type, const char *fmt,...) pg_attribute_printf(2
static StringInfo failed_tests
static void unlimit_core_size(void)
static const char * temp_sockdir
static bool directory_exists(const char *dir)
static _stringlist * schedulelist
#define WAIT_TICKS_PER_SECOND
static _stringlist * loadextension
static char * logfilename
static _stringlist * temp_configs
static _stringlist * extra_tests
static void test_status_ok(const char *testname, double runtime, bool parallel)
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)
#define bail_noatexit(...)
static char * difffilename
static void bail_out(bool noatexit, const char *fmt,...) pg_attribute_printf(2
static const char * make_temp_sockdir(void)
static _resultmap * resultmap
struct _resultmap _resultmap
static char * config_auth_datadir
static void drop_database_if_exists(const char *dbname)
static void test_status_failed(const char *testname, double runtime, bool parallel)
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 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)
PID_TYPE spawn_process(const char *cmdline)
static void test_status_print(bool ok, const char *testname, double runtime, bool parallel)
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 void static void static void emit_tap_output_v(TAPtype type, const char *fmt, va_list argp) pg_attribute_printf(2
#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)
static const char * pghost
static const char * pgport
char * strsep(char **stringp, const char *delim)
const char * pg_strsignal(int signum)
char * make_absolute_path(const char *path)
char * mkdtemp(char *path)
const char * get_progname(const char *argv0)
size_t strlcpy(char *dst, const char *src, size_t siz)
#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)
void destroyStringInfo(StringInfo str)
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)