Definition at line 2066 of file pg_regress.c.
2071 static struct option long_options[] = {
2099 bool use_unix_sockets;
2120 use_unix_sockets = getenv(
"PG_TEST_USE_UNIX_SOCKETS") ?
true :
false;
2122 use_unix_sockets =
true;
2125 if (!use_unix_sockets)
2134 if (getenv(
"PG_REGRESS_DIFF_OPTS"))
2137 while ((
c =
getopt_long(argc, argv,
"hV", long_options, &option_index)) != -1)
2145 puts(
"pg_regress (PostgreSQL) " PG_VERSION);
2235 while (argc -
optind >= 1)
2247 bail(
"no database name was specified");
2253 if (!use_unix_sockets)
2268 port = 0xC000 | (PG_VERSION_NUM & 0x3FFF);
2282 #if defined(HAVE_GETRLIMIT)
2290 const char *env_wait;
2292 const char *initdb_template_dir;
2293 const char *keywords[4];
2296 const char *initdb_extra_opts_env;
2318 initdb_extra_opts_env = getenv(
"PG_TEST_INITDB_EXTRA_OPTS");
2331 initdb_template_dir = getenv(
"INITDB_TEMPLATE");
2332 if (initdb_template_dir == NULL ||
nolocale ||
debug || initdb_extra_opts_env)
2334 note(
"initializing database system by running initdb");
2337 "\"%s%sinitdb\" -D \"%s/data\" --no-clean --no-sync",
2345 if (initdb_extra_opts_env)
2349 if (system(cmd.
data))
2351 bail(
"initdb failed\n"
2352 "# Examine \"%s/log/initdb.log\" for the reason.\n"
2353 "# Command was: %s",
2360 const char *copycmd =
"cp -RPp \"%s\" \"%s/data\"";
2361 int expected_exitcode = 0;
2363 const char *copycmd =
"robocopy /E /NJS /NJH /NFL /NDL /NP \"%s\" \"%s/data\"";
2364 int expected_exitcode = 1;
2367 note(
"initializing database system by copying initdb template");
2371 initdb_template_dir,
2375 if (system(cmd.
data) != expected_exitcode)
2377 bail(
"copying of initdb template failed\n"
2378 "# Examine \"%s/log/initdb.log\" for the reason.\n"
2379 "# Command was: %s",
2395 pg_conf = fopen(
buf,
"a");
2396 if (pg_conf == NULL)
2397 bail(
"could not open \"%s\" for adding extra config: %m",
buf);
2399 fputs(
"\n# Configuration added by pg_regress\n\n", pg_conf);
2400 fputs(
"log_autovacuum_min_duration = 0\n", pg_conf);
2401 fputs(
"log_checkpoints = on\n", pg_conf);
2402 fputs(
"log_line_prefix = '%m %b[%p] %q%a '\n", pg_conf);
2403 fputs(
"log_lock_waits = on\n", pg_conf);
2404 fputs(
"log_temp_files = 128kB\n", pg_conf);
2405 fputs(
"max_prepared_transactions = 2\n", pg_conf);
2409 char *temp_config = sl->
str;
2411 char line_buf[1024];
2413 extra_conf = fopen(temp_config,
"r");
2414 if (extra_conf == NULL)
2416 bail(
"could not open \"%s\" to read extra config: %m",
2419 while (fgets(line_buf,
sizeof(line_buf), extra_conf) != NULL)
2420 fputs(line_buf, pg_conf);
2427 if (!use_unix_sockets)
2434 config_sspi_auth(
buf, NULL);
2443 keywords[0] =
"dbname";
2445 keywords[1] =
"port";
2447 keywords[2] =
"host";
2455 for (
i = 0;
i < 16;
i++)
2463 note(
"port %d apparently in use",
port);
2465 note(
"could not determine an available port");
2466 bail(
"Specify an unused port using the --port option or shut down any conflicting PostgreSQL servers.");
2469 note(
"port %d apparently in use, trying %d",
port,
port + 1);
2482 "\"%s%spostgres\" -D \"%s/data\" -F%s "
2483 "-c \"listen_addresses=%s\" -k \"%s\" "
2484 "> \"%s/log/postmaster.log\" 2>&1",
2492 bail(
"could not spawn postmaster: %m");
2501 env_wait = getenv(
"PGCTLTIMEOUT");
2502 if (env_wait != NULL)
2527 bail(
"attempting to connect to postmaster failed");
2538 bail(
"postmaster failed, examine \"%s/log/postmaster.log\" for the reason",
2544 diag(
"postmaster did not respond within %d seconds, examine \"%s/log/postmaster.log\" for the reason",
2555 bail(
"could not kill failed postmaster: %m");
2558 bail(
"could not kill failed postmaster: error code %lu",
2561 bail(
"postmaster failed");
2568 #define ULONGPID(x) (unsigned long) (unsigned long long) (x)
2570 #define ULONGPID(x) (unsigned long) (x)
2572 note(
"using temp instance on port %d with PID %lu",
2630 diag(
"could not remove temp instance \"%s\"",
2649 diag(
"The differences that caused some tests to fail can be viewed in the file \"%s\".",
2651 diag(
"A copy of the test summary that you see above is saved in the file \"%s\".",
static Datum values[MAXATTR]
#define PG_TEXTDOMAIN(domain)
void set_pglocale_pgservice(const char *argv0, const char *app)
PGPing PQpingParams(const char *const *keywords, const char *const *values, int expand_dbname)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
static void const char fflush(stdout)
void pg_logging_init(const char *argv0)
#define pg_log_error_hint(...)
void pfree(void *pointer)
PGDLLIMPORT char * optarg
static void open_result_files(void)
static int max_connections
static bool port_specified_by_user
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)
static void unlimit_core_size(void)
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 make_directory(const char *dir)
static void split_to_stringlist(const char *s, const char *delim, _stringlist **listhead)
static void run_single_test(const char *test, test_start_function startfunc, postprocess_result_function postfunc)
const char * pretty_diff_opts
static char * difffilename
static char * config_auth_datadir
static void drop_database_if_exists(const char *dbname)
static void initialize_environment(void)
static char * temp_instance
static const char * sockdir
static long file_size(const char *file)
static bool postmaster_running
static const char * progname
static _stringlist * extraroles
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 PID_TYPE postmaster_pid
char * make_absolute_path(const char *path)
const char * get_progname(const char *argv0)
void get_restricted_token(void)
bool rmtree(const char *path, bool rmtopdir)
void pg_usleep(long microsec)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
References add_stringlist_item(), appendStringInfo(), appendStringInfoString(), bail, bindir, buf, config_auth_datadir, create_database(), create_role(), StringInfoData::data, dblist, debug, diag, difffilename, directory_exists(), dlpath, drop_database_if_exists(), drop_role_if_exists(), encoding, exit(), expecteddir, extra_tests, extraroles, fail_count, fflush(), file_size(), free_stringlist(), get_progname(), get_restricted_token(), getopt_long(), help(), hostname, i, initialize_environment(), initStringInfo(), inputdir, INVALID_PID, kill, launcher, loadextension, logfile, logfilename, make_absolute_path(), make_directory(), max_concurrent_tests, max_connections, MAXPGPATH, _stringlist::next, no_argument, nolocale, note, open_result_files(), optarg, optind, outputdir, pfree(), pg_log_error_hint, pg_logging_init(), pg_strdup(), PG_TEXTDOMAIN, pg_usleep(), plan, port, port_specified_by_user, portstr, postmaster_pid, postmaster_running, PQPING_NO_ATTEMPT, PQPING_OK, PQpingParams(), pretty_diff_opts, progname, required_argument, rmtree(), run_schedule(), run_single_test(), schedulelist, set_pglocale_pgservice(), setenv, SIGKILL, snprintf, sockdir, spawn_process(), split_to_stringlist(), sprintf, stop_postmaster(), _stringlist::str, success_count, temp_configs, temp_instance, true, ULONGPID, unlimit_core_size(), use_existing, user, values, wait_seconds, and WAIT_TICKS_PER_SECOND.
Referenced by main().