Definition at line 2063 of file pg_regress.c.
2068 static struct option long_options[] = {
2096 bool use_unix_sockets;
2117 use_unix_sockets = getenv(
"PG_TEST_USE_UNIX_SOCKETS") ?
true :
false;
2119 use_unix_sockets =
true;
2122 if (!use_unix_sockets)
2131 if (getenv(
"PG_REGRESS_DIFF_OPTS"))
2134 while ((
c =
getopt_long(argc, argv,
"hV", long_options, &option_index)) != -1)
2142 puts(
"pg_regress (PostgreSQL) " PG_VERSION);
2232 while (argc -
optind >= 1)
2244 bail(
"no database name was specified");
2250 if (!use_unix_sockets)
2265 port = 0xC000 | (PG_VERSION_NUM & 0x3FFF);
2279 #if defined(HAVE_GETRLIMIT)
2287 const char *env_wait;
2289 const char *initdb_template_dir;
2290 const char *keywords[4];
2293 const char *initdb_extra_opts_env;
2315 initdb_extra_opts_env = getenv(
"PG_TEST_INITDB_EXTRA_OPTS");
2328 initdb_template_dir = getenv(
"INITDB_TEMPLATE");
2329 if (initdb_template_dir == NULL ||
nolocale ||
debug || initdb_extra_opts_env)
2331 note(
"initializing database system by running initdb");
2334 "\"%s%sinitdb\" -D \"%s/data\" --no-clean --no-sync",
2342 if (initdb_extra_opts_env)
2346 if (system(cmd.
data))
2348 bail(
"initdb failed\n"
2349 "# Examine \"%s/log/initdb.log\" for the reason.\n"
2350 "# Command was: %s",
2357 const char *copycmd =
"cp -RPp \"%s\" \"%s/data\"";
2358 int expected_exitcode = 0;
2360 const char *copycmd =
"robocopy /E /NJS /NJH /NFL /NDL /NP \"%s\" \"%s/data\"";
2361 int expected_exitcode = 1;
2364 note(
"initializing database system by copying initdb template");
2368 initdb_template_dir,
2372 if (system(cmd.
data) != expected_exitcode)
2374 bail(
"copying of initdb template failed\n"
2375 "# Examine \"%s/log/initdb.log\" for the reason.\n"
2376 "# Command was: %s",
2392 pg_conf = fopen(
buf,
"a");
2393 if (pg_conf == NULL)
2394 bail(
"could not open \"%s\" for adding extra config: %m",
buf);
2396 fputs(
"\n# Configuration added by pg_regress\n\n", pg_conf);
2397 fputs(
"log_autovacuum_min_duration = 0\n", pg_conf);
2398 fputs(
"log_checkpoints = on\n", pg_conf);
2399 fputs(
"log_line_prefix = '%m %b[%p] %q%a '\n", pg_conf);
2400 fputs(
"log_lock_waits = on\n", pg_conf);
2401 fputs(
"log_temp_files = 128kB\n", pg_conf);
2402 fputs(
"max_prepared_transactions = 2\n", pg_conf);
2406 char *temp_config = sl->
str;
2408 char line_buf[1024];
2410 extra_conf = fopen(temp_config,
"r");
2411 if (extra_conf == NULL)
2413 bail(
"could not open \"%s\" to read extra config: %m",
2416 while (fgets(line_buf,
sizeof(line_buf), extra_conf) != NULL)
2417 fputs(line_buf, pg_conf);
2424 if (!use_unix_sockets)
2431 config_sspi_auth(
buf, NULL);
2440 keywords[0] =
"dbname";
2442 keywords[1] =
"port";
2444 keywords[2] =
"host";
2452 for (
i = 0;
i < 16;
i++)
2460 note(
"port %d apparently in use",
port);
2462 note(
"could not determine an available port");
2463 bail(
"Specify an unused port using the --port option or shut down any conflicting PostgreSQL servers.");
2466 note(
"port %d apparently in use, trying %d",
port,
port + 1);
2479 "\"%s%spostgres\" -D \"%s/data\" -F%s "
2480 "-c \"listen_addresses=%s\" -k \"%s\" "
2481 "> \"%s/log/postmaster.log\" 2>&1",
2489 bail(
"could not spawn postmaster: %m");
2498 env_wait = getenv(
"PGCTLTIMEOUT");
2499 if (env_wait != NULL)
2524 bail(
"attempting to connect to postmaster failed");
2535 bail(
"postmaster failed, examine \"%s/log/postmaster.log\" for the reason",
2541 diag(
"postmaster did not respond within %d seconds, examine \"%s/log/postmaster.log\" for the reason",
2552 bail(
"could not kill failed postmaster: %m");
2555 bail(
"could not kill failed postmaster: error code %lu",
2558 bail(
"postmaster failed");
2565 #define ULONGPID(x) (unsigned long) (unsigned long long) (x)
2567 #define ULONGPID(x) (unsigned long) (x)
2569 note(
"using temp instance on port %d with PID %lu",
2627 diag(
"could not remove temp instance \"%s\"",
2646 diag(
"The differences that caused some tests to fail can be viewed in the file \"%s\".",
2648 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().