PostgreSQL Source Code  git master
pg_regress.c File Reference
#include "postgres_fe.h"
#include <ctype.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <signal.h>
#include <unistd.h>
#include "common/logging.h"
#include "common/restricted_token.h"
#include "common/string.h"
#include "common/username.h"
#include "getopt_long.h"
#include "lib/stringinfo.h"
#include "libpq/pqcomm.h"
#include "pg_config_paths.h"
#include "pg_regress.h"
#include "portability/instr_time.h"
Include dependency graph for pg_regress.c:

Go to the source code of this file.

Data Structures

struct  _resultmap
 

Macros

#define psql_command(database, ...)
 
#define MAX_PARALLEL_TESTS   100
 
#define ULONGPID(x)   (unsigned long) (x)
 

Typedefs

typedef struct _resultmap _resultmap
 

Functions

static bool directory_exists (const char *dir)
 
static void make_directory (const char *dir)
 
static void header (const char *fmt,...) pg_attribute_printf(1
 
static void static void status (const char *fmt,...) pg_attribute_printf(1
 
static void static void static StringInfo psql_start_command (void)
 
static void psql_add_command (StringInfo buf, const char *query,...) pg_attribute_printf(2
 
static void static void psql_end_command (StringInfo buf, const char *database)
 
static void unlimit_core_size (void)
 
void add_stringlist_item (_stringlist **listhead, const char *str)
 
static void free_stringlist (_stringlist **listhead)
 
static void split_to_stringlist (const char *s, const char *delim, _stringlist **listhead)
 
static void status_end (void)
 
static void stop_postmaster (void)
 
static void remove_temp (void)
 
static void signal_remove_temp (SIGNAL_ARGS)
 
static const char * make_temp_sockdir (void)
 
static bool string_matches_pattern (const char *str, const char *pattern)
 
static void load_resultmap (void)
 
static const char * get_expectfile (const char *testname, const char *file)
 
static void initialize_environment (void)
 
PID_TYPE spawn_process (const char *cmdline)
 
static long file_size (const char *file)
 
static int file_line_count (const char *file)
 
bool file_exists (const char *file)
 
static char * get_alternative_expectfile (const char *expectfile, int i)
 
static int run_diff (const char *cmd, const char *filename)
 
static bool results_differ (const char *testname, const char *resultsfile, const char *default_expectfile)
 
static void wait_for_tests (PID_TYPE *pids, int *statuses, instr_time *stoptimes, char **names, int num_tests)
 
static void log_child_failure (int exitstatus)
 
static void run_schedule (const char *schedule, test_start_function startfunc, postprocess_result_function postfunc)
 
static void run_single_test (const char *test, test_start_function startfunc, postprocess_result_function postfunc)
 
static void open_result_files (void)
 
static void drop_database_if_exists (const char *dbname)
 
static void create_database (const char *dbname)
 
static void drop_role_if_exists (const char *rolename)
 
static void create_role (const char *rolename, const _stringlist *granted_dbs)
 
static void help (void)
 
int regression_main (int argc, char *argv[], init_function ifunc, test_start_function startfunc, postprocess_result_function postfunc)
 

Variables

char * host_platform = HOST_TUPLE
 
static char * shellprog = SHELLPROG
 
const char * basic_diff_opts = ""
 
const char * pretty_diff_opts = "-U3"
 
_stringlistdblist = NULL
 
bool debug = false
 
char * inputdir = "."
 
char * outputdir = "."
 
char * expecteddir = "."
 
char * bindir = PGBINDIR
 
char * launcher = NULL
 
static _stringlistloadextension = NULL
 
static int max_connections = 0
 
static int max_concurrent_tests = 0
 
static char * encoding = NULL
 
static _stringlistschedulelist = NULL
 
static _stringlistextra_tests = NULL
 
static char * temp_instance = NULL
 
static _stringlisttemp_configs = NULL
 
static bool nolocale = false
 
static bool use_existing = false
 
static char * hostname = NULL
 
static int port = -1
 
static bool port_specified_by_user = false
 
static char * dlpath = PKGLIBDIR
 
static char * user = NULL
 
static _stringlistextraroles = NULL
 
static char * config_auth_datadir = NULL
 
static const char * progname
 
static char * logfilename
 
static FILE * logfile
 
static char * difffilename
 
static const char * sockdir
 
static const char * temp_sockdir
 
static char sockself [MAXPGPATH]
 
static char socklock [MAXPGPATH]
 
static _resultmapresultmap = NULL
 
static PID_TYPE postmaster_pid = INVALID_PID
 
static bool postmaster_running = false
 
static int success_count = 0
 
static int fail_count = 0
 

Macro Definition Documentation

◆ MAX_PARALLEL_TESTS

#define MAX_PARALLEL_TESTS   100

◆ psql_command

#define psql_command (   database,
  ... 
)
Value:
do { \
StringInfo cmdbuf = psql_start_command(); \
psql_add_command(cmdbuf, __VA_ARGS__); \
psql_end_command(cmdbuf, database); \
} while (0)
static void static void static StringInfo psql_start_command(void)
Definition: pg_regress.c:971

Definition at line 1044 of file pg_regress.c.

◆ ULONGPID

#define ULONGPID (   x)    (unsigned long) (x)

Typedef Documentation

◆ _resultmap

typedef struct _resultmap _resultmap

Function Documentation

◆ add_stringlist_item()

void add_stringlist_item ( _stringlist **  listhead,
const char *  str 
)

Definition at line 154 of file pg_regress.c.

155 {
156  _stringlist *newentry = pg_malloc(sizeof(_stringlist));
157  _stringlist *oldentry;
158 
159  newentry->str = pg_strdup(str);
160  newentry->next = NULL;
161  if (*listhead == NULL)
162  *listhead = newentry;
163  else
164  {
165  for (oldentry = *listhead; oldentry->next; oldentry = oldentry->next)
166  /* skip */ ;
167  oldentry->next = newentry;
168  }
169 }
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
void * pg_malloc(size_t size)
Definition: fe_memutils.c:47
struct _stringlist * next
Definition: pg_regress.h:27
char * str
Definition: pg_regress.h:26

References _stringlist::next, pg_malloc(), pg_strdup(), generate_unaccent_rules::str, and _stringlist::str.

Referenced by ecpg_start_test(), isolation_init(), isolation_start_test(), psql_init(), psql_start_test(), regression_main(), and split_to_stringlist().

◆ create_database()

static void create_database ( const char *  dbname)
static

Definition at line 1857 of file pg_regress.c.

1858 {
1860  _stringlist *sl;
1861 
1862  /*
1863  * We use template0 so that any installation-local cruft in template1 will
1864  * not mess up the tests.
1865  */
1866  header(_("creating database \"%s\""), dbname);
1867  if (encoding)
1868  psql_add_command(buf, "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'%s", dbname, encoding,
1869  (nolocale) ? " LC_COLLATE='C' LC_CTYPE='C'" : "");
1870  else
1871  psql_add_command(buf, "CREATE DATABASE \"%s\" TEMPLATE=template0%s", dbname,
1872  (nolocale) ? " LC_COLLATE='C' LC_CTYPE='C'" : "");
1874  "ALTER DATABASE \"%s\" SET lc_messages TO 'C';"
1875  "ALTER DATABASE \"%s\" SET lc_monetary TO 'C';"
1876  "ALTER DATABASE \"%s\" SET lc_numeric TO 'C';"
1877  "ALTER DATABASE \"%s\" SET lc_time TO 'C';"
1878  "ALTER DATABASE \"%s\" SET bytea_output TO 'hex';"
1879  "ALTER DATABASE \"%s\" SET timezone_abbreviations TO 'Default';",
1881  psql_end_command(buf, "postgres");
1882 
1883  /*
1884  * Install any requested extensions. We use CREATE IF NOT EXISTS so that
1885  * this will work whether or not the extension is preinstalled.
1886  */
1887  for (sl = loadextension; sl != NULL; sl = sl->next)
1888  {
1889  header(_("installing %s"), sl->str);
1890  psql_command(dbname, "CREATE EXTENSION IF NOT EXISTS \"%s\"", sl->str);
1891  }
1892 }
#define _(x)
Definition: elog.c:91
static bool nolocale
Definition: pg_regress.c:87
static void psql_add_command(StringInfo buf, const char *query,...) pg_attribute_printf(2
Definition: pg_regress.c:983
static void static void psql_end_command(StringInfo buf, const char *database)
Definition: pg_regress.c:1020
static _stringlist * loadextension
Definition: pg_regress.c:79
static void header(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:207
static char * encoding
Definition: pg_regress.c:82
#define psql_command(database,...)
Definition: pg_regress.c:1044
static char * buf
Definition: pg_test_fsync.c:67
char * dbname
Definition: streamutil.c:51

References _, buf, dbname, encoding, header(), loadextension, _stringlist::next, nolocale, psql_add_command(), psql_command, psql_end_command(), psql_start_command(), and _stringlist::str.

Referenced by regression_main().

◆ create_role()

static void create_role ( const char *  rolename,
const _stringlist granted_dbs 
)
static

Definition at line 1907 of file pg_regress.c.

1908 {
1910 
1911  header(_("creating role \"%s\""), rolename);
1912  psql_add_command(buf, "CREATE ROLE \"%s\" WITH LOGIN", rolename);
1913  for (; granted_dbs != NULL; granted_dbs = granted_dbs->next)
1914  {
1915  psql_add_command(buf, "GRANT ALL ON DATABASE \"%s\" TO \"%s\"",
1916  granted_dbs->str, rolename);
1917  }
1918  psql_end_command(buf, "postgres");
1919 }

References _, buf, header(), _stringlist::next, psql_add_command(), psql_end_command(), psql_start_command(), and _stringlist::str.

Referenced by regression_main().

◆ directory_exists()

static bool directory_exists ( const char *  dir)
static

Definition at line 1178 of file pg_regress.c.

1179 {
1180  struct stat st;
1181 
1182  if (stat(dir, &st) != 0)
1183  return false;
1184  if (S_ISDIR(st.st_mode))
1185  return true;
1186  return false;
1187 }
#define stat
Definition: win32_port.h:286
#define S_ISDIR(m)
Definition: win32_port.h:327

References S_ISDIR, stat::st_mode, and stat.

Referenced by open_result_files(), and regression_main().

◆ drop_database_if_exists()

static void drop_database_if_exists ( const char *  dbname)
static

Definition at line 1845 of file pg_regress.c.

1846 {
1848 
1849  header(_("dropping database \"%s\""), dbname);
1850  /* Set warning level so we don't see chatter about nonexistent DB */
1851  psql_add_command(buf, "SET client_min_messages = warning");
1852  psql_add_command(buf, "DROP DATABASE IF EXISTS \"%s\"", dbname);
1853  psql_end_command(buf, "postgres");
1854 }

References _, buf, dbname, header(), psql_add_command(), psql_end_command(), and psql_start_command().

Referenced by regression_main().

◆ drop_role_if_exists()

static void drop_role_if_exists ( const char *  rolename)
static

Definition at line 1895 of file pg_regress.c.

1896 {
1898 
1899  header(_("dropping role \"%s\""), rolename);
1900  /* Set warning level so we don't see chatter about nonexistent role */
1901  psql_add_command(buf, "SET client_min_messages = warning");
1902  psql_add_command(buf, "DROP ROLE IF EXISTS \"%s\"", rolename);
1903  psql_end_command(buf, "postgres");
1904 }

References _, buf, header(), psql_add_command(), psql_end_command(), and psql_start_command().

Referenced by regression_main().

◆ file_exists()

bool file_exists ( const char *  file)

Definition at line 1167 of file pg_regress.c.

1168 {
1169  FILE *f = fopen(file, "r");
1170 
1171  if (!f)
1172  return false;
1173  fclose(f);
1174  return true;
1175 }

Referenced by results_differ().

◆ file_line_count()

static int file_line_count ( const char *  file)
static

Definition at line 1145 of file pg_regress.c.

1146 {
1147  int c;
1148  int l = 0;
1149  FILE *f = fopen(file, "r");
1150 
1151  if (!f)
1152  {
1153  fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
1154  progname, file, strerror(errno));
1155  return -1;
1156  }
1157  while ((c = fgetc(f)) != EOF)
1158  {
1159  if (c == '\n')
1160  l++;
1161  }
1162  fclose(f);
1163  return l;
1164 }
static const char * progname
Definition: pg_regress.c:98
#define strerror
Definition: port.h:251
#define fprintf
Definition: port.h:242
char * c

References _, fprintf, progname, and strerror.

Referenced by results_differ().

◆ file_size()

static long file_size ( const char *  file)
static

Definition at line 1124 of file pg_regress.c.

1125 {
1126  long r;
1127  FILE *f = fopen(file, "r");
1128 
1129  if (!f)
1130  {
1131  fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
1132  progname, file, strerror(errno));
1133  return -1;
1134  }
1135  fseek(f, 0, SEEK_END);
1136  r = ftell(f);
1137  fclose(f);
1138  return r;
1139 }

References _, fprintf, progname, and strerror.

Referenced by regression_main(), and run_diff().

◆ free_stringlist()

static void free_stringlist ( _stringlist **  listhead)
static

Definition at line 175 of file pg_regress.c.

176 {
177  if (listhead == NULL || *listhead == NULL)
178  return;
179  if ((*listhead)->next != NULL)
180  free_stringlist(&((*listhead)->next));
181  free((*listhead)->str);
182  free(*listhead);
183  *listhead = NULL;
184 }
#define free(a)
Definition: header.h:65
static void free_stringlist(_stringlist **listhead)
Definition: pg_regress.c:175

References free.

Referenced by regression_main(), and run_schedule().

◆ get_alternative_expectfile()

static char* get_alternative_expectfile ( const char *  expectfile,
int  i 
)
static

Definition at line 1205 of file pg_regress.c.

1206 {
1207  char *last_dot;
1208  int ssize = strlen(expectfile) + 2 + 1;
1209  char *tmp;
1210  char *s;
1211 
1212  if (!(tmp = (char *) malloc(ssize)))
1213  return NULL;
1214 
1215  if (!(s = (char *) malloc(ssize)))
1216  {
1217  free(tmp);
1218  return NULL;
1219  }
1220 
1221  strcpy(tmp, expectfile);
1222  last_dot = strrchr(tmp, '.');
1223  if (!last_dot)
1224  {
1225  free(tmp);
1226  free(s);
1227  return NULL;
1228  }
1229  *last_dot = '\0';
1230  snprintf(s, ssize, "%s_%d.%s", tmp, i, last_dot + 1);
1231  free(tmp);
1232  return s;
1233 }
#define malloc(a)
Definition: header.h:50
int i
Definition: isn.c:73
#define snprintf
Definition: port.h:238

References free, i, malloc, and snprintf.

Referenced by results_differ().

◆ get_expectfile()

static const char* get_expectfile ( const char *  testname,
const char *  file 
)
static

Definition at line 527 of file pg_regress.c.

528 {
529  char *file_type;
530  _resultmap *rm;
531 
532  /*
533  * Determine the file type from the file name. This is just what is
534  * following the last dot in the file name.
535  */
536  if (!file || !(file_type = strrchr(file, '.')))
537  return NULL;
538 
539  file_type++;
540 
541  for (rm = resultmap; rm != NULL; rm = rm->next)
542  {
543  if (strcmp(testname, rm->test) == 0 && strcmp(file_type, rm->type) == 0)
544  {
545  return rm->resultfile;
546  }
547  }
548 
549  return NULL;
550 }
static _resultmap * resultmap
Definition: pg_regress.c:107
char * resultfile
Definition: pg_regress.c:45
struct _resultmap * next
Definition: pg_regress.c:46
char * test
Definition: pg_regress.c:43
char * type
Definition: pg_regress.c:44

References _resultmap::next, _resultmap::resultfile, resultmap, _resultmap::test, and _resultmap::type.

Referenced by results_differ().

◆ header()

◆ help()

static void help ( void  )
static

Definition at line 1922 of file pg_regress.c.

1923 {
1924  printf(_("PostgreSQL regression test driver\n"));
1925  printf(_("\n"));
1926  printf(_("Usage:\n %s [OPTION]... [EXTRA-TEST]...\n"), progname);
1927  printf(_("\n"));
1928  printf(_("Options:\n"));
1929  printf(_(" --bindir=BINPATH use BINPATH for programs that are run;\n"));
1930  printf(_(" if empty, use PATH from the environment\n"));
1931  printf(_(" --config-auth=DATADIR update authentication settings for DATADIR\n"));
1932  printf(_(" --create-role=ROLE create the specified role before testing\n"));
1933  printf(_(" --dbname=DB use database DB (default \"regression\")\n"));
1934  printf(_(" --debug turn on debug mode in programs that are run\n"));
1935  printf(_(" --dlpath=DIR look for dynamic libraries in DIR\n"));
1936  printf(_(" --encoding=ENCODING use ENCODING as the encoding\n"));
1937  printf(_(" --expecteddir=DIR take expected files from DIR (default \".\")\n"));
1938  printf(_(" -h, --help show this help, then exit\n"));
1939  printf(_(" --inputdir=DIR take input files from DIR (default \".\")\n"));
1940  printf(_(" --launcher=CMD use CMD as launcher of psql\n"));
1941  printf(_(" --load-extension=EXT load the named extension before running the\n"));
1942  printf(_(" tests; can appear multiple times\n"));
1943  printf(_(" --max-connections=N maximum number of concurrent connections\n"));
1944  printf(_(" (default is 0, meaning unlimited)\n"));
1945  printf(_(" --max-concurrent-tests=N maximum number of concurrent tests in schedule\n"));
1946  printf(_(" (default is 0, meaning unlimited)\n"));
1947  printf(_(" --outputdir=DIR place output files in DIR (default \".\")\n"));
1948  printf(_(" --schedule=FILE use test ordering schedule from FILE\n"));
1949  printf(_(" (can be used multiple times to concatenate)\n"));
1950  printf(_(" --temp-instance=DIR create a temporary instance in DIR\n"));
1951  printf(_(" --use-existing use an existing installation\n"));
1952  printf(_(" -V, --version output version information, then exit\n"));
1953  printf(_("\n"));
1954  printf(_("Options for \"temp-instance\" mode:\n"));
1955  printf(_(" --no-locale use C locale\n"));
1956  printf(_(" --port=PORT start postmaster on PORT\n"));
1957  printf(_(" --temp-config=FILE append contents of FILE to temporary config\n"));
1958  printf(_("\n"));
1959  printf(_("Options for using an existing installation:\n"));
1960  printf(_(" --host=HOST use postmaster running on HOST\n"));
1961  printf(_(" --port=PORT use postmaster running at PORT\n"));
1962  printf(_(" --user=USER connect as USER\n"));
1963  printf(_("\n"));
1964  printf(_("The exit status is 0 if all tests passed, 1 if some tests failed, and 2\n"));
1965  printf(_("if the tests could not be run for some reason.\n"));
1966  printf(_("\n"));
1967  printf(_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
1968  printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
1969 }
#define printf(...)
Definition: port.h:244

References _, printf, and progname.

Referenced by regression_main().

◆ initialize_environment()

static void initialize_environment ( void  )
static

Definition at line 556 of file pg_regress.c.

557 {
558  /*
559  * Set default application_name. (The test_start_function may choose to
560  * override this, but if it doesn't, we have something useful in place.)
561  */
562  setenv("PGAPPNAME", "pg_regress", 1);
563 
564  /*
565  * Set variables that the test scripts may need to refer to.
566  */
567  setenv("PG_ABS_SRCDIR", inputdir, 1);
568  setenv("PG_ABS_BUILDDIR", outputdir, 1);
569  setenv("PG_LIBDIR", dlpath, 1);
570  setenv("PG_DLSUFFIX", DLSUFFIX, 1);
571 
572  if (nolocale)
573  {
574  /*
575  * Clear out any non-C locale settings
576  */
577  unsetenv("LC_COLLATE");
578  unsetenv("LC_CTYPE");
579  unsetenv("LC_MONETARY");
580  unsetenv("LC_NUMERIC");
581  unsetenv("LC_TIME");
582  unsetenv("LANG");
583 
584  /*
585  * Most platforms have adopted the POSIX locale as their
586  * implementation-defined default locale. Exceptions include native
587  * Windows, macOS with --enable-nls, and Cygwin with --enable-nls.
588  * (Use of --enable-nls matters because libintl replaces setlocale().)
589  * Also, PostgreSQL does not support macOS with locale environment
590  * variables unset; see PostmasterMain().
591  */
592 #if defined(WIN32) || defined(__CYGWIN__) || defined(__darwin__)
593  setenv("LANG", "C", 1);
594 #endif
595  }
596 
597  /*
598  * Set translation-related settings to English; otherwise psql will
599  * produce translated messages and produce diffs. (XXX If we ever support
600  * translation of pg_regress, this needs to be moved elsewhere, where psql
601  * is actually called.)
602  */
603  unsetenv("LANGUAGE");
604  unsetenv("LC_ALL");
605  setenv("LC_MESSAGES", "C", 1);
606 
607  /*
608  * Set encoding as requested
609  */
610  if (encoding)
611  setenv("PGCLIENTENCODING", encoding, 1);
612  else
613  unsetenv("PGCLIENTENCODING");
614 
615  /*
616  * Set timezone and datestyle for datetime-related tests
617  */
618  setenv("PGTZ", "PST8PDT", 1);
619  setenv("PGDATESTYLE", "Postgres, MDY", 1);
620 
621  /*
622  * Likewise set intervalstyle to ensure consistent results. This is a bit
623  * more painful because we must use PGOPTIONS, and we want to preserve the
624  * user's ability to set other variables through that.
625  */
626  {
627  const char *my_pgoptions = "-c intervalstyle=postgres_verbose";
628  const char *old_pgoptions = getenv("PGOPTIONS");
629  char *new_pgoptions;
630 
631  if (!old_pgoptions)
632  old_pgoptions = "";
633  new_pgoptions = psprintf("%s %s",
634  old_pgoptions, my_pgoptions);
635  setenv("PGOPTIONS", new_pgoptions, 1);
636  free(new_pgoptions);
637  }
638 
639  if (temp_instance)
640  {
641  /*
642  * Clear out any environment vars that might cause psql to connect to
643  * the wrong postmaster, or otherwise behave in nondefault ways. (Note
644  * we also use psql's -X switch consistently, so that ~/.psqlrc files
645  * won't mess things up.) Also, set PGPORT to the temp port, and set
646  * PGHOST depending on whether we are using TCP or Unix sockets.
647  *
648  * This list should be kept in sync with PostgreSQL/Test/Utils.pm.
649  */
650  unsetenv("PGCHANNELBINDING");
651  /* PGCLIENTENCODING, see above */
652  unsetenv("PGCONNECT_TIMEOUT");
653  unsetenv("PGDATA");
654  unsetenv("PGDATABASE");
655  unsetenv("PGGSSENCMODE");
656  unsetenv("PGGSSLIB");
657  /* PGHOSTADDR, see below */
658  unsetenv("PGKRBSRVNAME");
659  unsetenv("PGPASSFILE");
660  unsetenv("PGPASSWORD");
661  unsetenv("PGREQUIREPEER");
662  unsetenv("PGREQUIRESSL");
663  unsetenv("PGSERVICE");
664  unsetenv("PGSERVICEFILE");
665  unsetenv("PGSSLCERT");
666  unsetenv("PGSSLCRL");
667  unsetenv("PGSSLCRLDIR");
668  unsetenv("PGSSLKEY");
669  unsetenv("PGSSLMAXPROTOCOLVERSION");
670  unsetenv("PGSSLMINPROTOCOLVERSION");
671  unsetenv("PGSSLMODE");
672  unsetenv("PGSSLROOTCERT");
673  unsetenv("PGSSLSNI");
674  unsetenv("PGTARGETSESSIONATTRS");
675  unsetenv("PGUSER");
676  /* PGPORT, see below */
677  /* PGHOST, see below */
678 
679  if (hostname != NULL)
680  setenv("PGHOST", hostname, 1);
681  else
682  {
683  sockdir = getenv("PG_REGRESS_SOCK_DIR");
684  if (!sockdir)
686  setenv("PGHOST", sockdir, 1);
687  }
688  unsetenv("PGHOSTADDR");
689  if (port != -1)
690  {
691  char s[16];
692 
693  sprintf(s, "%d", port);
694  setenv("PGPORT", s, 1);
695  }
696  }
697  else
698  {
699  const char *pghost;
700  const char *pgport;
701 
702  /*
703  * When testing an existing install, we honor existing environment
704  * variables, except if they're overridden by command line options.
705  */
706  if (hostname != NULL)
707  {
708  setenv("PGHOST", hostname, 1);
709  unsetenv("PGHOSTADDR");
710  }
711  if (port != -1)
712  {
713  char s[16];
714 
715  sprintf(s, "%d", port);
716  setenv("PGPORT", s, 1);
717  }
718  if (user != NULL)
719  setenv("PGUSER", user, 1);
720 
721  /*
722  * However, we *don't* honor PGDATABASE, since we certainly don't wish
723  * to connect to whatever database the user might like as default.
724  * (Most tests override PGDATABASE anyway, but there are some ECPG
725  * test cases that don't.)
726  */
727  unsetenv("PGDATABASE");
728 
729  /*
730  * Report what we're connecting to
731  */
732  pghost = getenv("PGHOST");
733  pgport = getenv("PGPORT");
734  if (!pghost)
735  {
736  /* Keep this bit in sync with libpq's default host location: */
737  if (DEFAULT_PGSOCKET_DIR[0])
738  /* do nothing, we'll print "Unix socket" below */ ;
739  else
740  pghost = "localhost"; /* DefaultHost in fe-connect.c */
741  }
742 
743  if (pghost && pgport)
744  printf(_("(using postmaster on %s, port %s)\n"), pghost, pgport);
745  if (pghost && !pgport)
746  printf(_("(using postmaster on %s, default port)\n"), pghost);
747  if (!pghost && pgport)
748  printf(_("(using postmaster on Unix socket, port %s)\n"), pgport);
749  if (!pghost && !pgport)
750  printf(_("(using postmaster on Unix socket, default port)\n"));
751  }
752 
753  load_resultmap();
754 }
#define DEFAULT_PGSOCKET_DIR
static char * user
Definition: pg_regress.c:93
static void load_resultmap(void)
Definition: pg_regress.c:445
static int port
Definition: pg_regress.c:90
char * outputdir
Definition: pg_regress.c:75
char * inputdir
Definition: pg_regress.c:74
static char * temp_instance
Definition: pg_regress.c:85
static const char * sockdir
Definition: pg_regress.c:102
static char * dlpath
Definition: pg_regress.c:92
static const char * make_temp_sockdir(void)
Definition: pg_regress.c:326
static char * hostname
Definition: pg_regress.c:89
const char * pghost
Definition: pgbench.c:304
const char * pgport
Definition: pgbench.c:305
#define sprintf
Definition: port.h:240
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
#define unsetenv(x)
Definition: win32_port.h:535
#define setenv(x, y, z)
Definition: win32_port.h:534

References _, DEFAULT_PGSOCKET_DIR, dlpath, encoding, free, hostname, inputdir, load_resultmap(), make_temp_sockdir(), nolocale, outputdir, pghost, pgport, port, printf, psprintf(), setenv, sockdir, sprintf, temp_instance, unsetenv, and user.

Referenced by regression_main().

◆ load_resultmap()

static void load_resultmap ( void  )
static

Definition at line 445 of file pg_regress.c.

446 {
447  char buf[MAXPGPATH];
448  FILE *f;
449 
450  /* scan the file ... */
451  snprintf(buf, sizeof(buf), "%s/resultmap", inputdir);
452  f = fopen(buf, "r");
453  if (!f)
454  {
455  /* OK if it doesn't exist, else complain */
456  if (errno == ENOENT)
457  return;
458  fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
459  progname, buf, strerror(errno));
460  exit(2);
461  }
462 
463  while (fgets(buf, sizeof(buf), f))
464  {
465  char *platform;
466  char *file_type;
467  char *expected;
468  int i;
469 
470  /* strip trailing whitespace, especially the newline */
471  i = strlen(buf);
472  while (i > 0 && isspace((unsigned char) buf[i - 1]))
473  buf[--i] = '\0';
474 
475  /* parse out the line fields */
476  file_type = strchr(buf, ':');
477  if (!file_type)
478  {
479  fprintf(stderr, _("incorrectly formatted resultmap entry: %s\n"),
480  buf);
481  exit(2);
482  }
483  *file_type++ = '\0';
484 
485  platform = strchr(file_type, ':');
486  if (!platform)
487  {
488  fprintf(stderr, _("incorrectly formatted resultmap entry: %s\n"),
489  buf);
490  exit(2);
491  }
492  *platform++ = '\0';
493  expected = strchr(platform, '=');
494  if (!expected)
495  {
496  fprintf(stderr, _("incorrectly formatted resultmap entry: %s\n"),
497  buf);
498  exit(2);
499  }
500  *expected++ = '\0';
501 
502  /*
503  * if it's for current platform, save it in resultmap list. Note: by
504  * adding at the front of the list, we ensure that in ambiguous cases,
505  * the last match in the resultmap file is used. This mimics the
506  * behavior of the old shell script.
507  */
508  if (string_matches_pattern(host_platform, platform))
509  {
510  _resultmap *entry = pg_malloc(sizeof(_resultmap));
511 
512  entry->test = pg_strdup(buf);
513  entry->type = pg_strdup(file_type);
514  entry->resultfile = pg_strdup(expected);
515  entry->next = resultmap;
516  resultmap = entry;
517  }
518  }
519  fclose(f);
520 }
exit(1)
#define MAXPGPATH
char * host_platform
Definition: pg_regress.c:52
static bool string_matches_pattern(const char *str, const char *pattern)
Definition: pg_regress.c:371

References _, buf, exit(), fprintf, host_platform, i, inputdir, MAXPGPATH, _resultmap::next, pg_malloc(), pg_strdup(), progname, _resultmap::resultfile, resultmap, snprintf, strerror, string_matches_pattern(), _resultmap::test, and _resultmap::type.

Referenced by initialize_environment().

◆ log_child_failure()

static void log_child_failure ( int  exitstatus)
static

Definition at line 1495 of file pg_regress.c.

1496 {
1497  if (WIFEXITED(exitstatus))
1498  status(_(" (test process exited with exit code %d)"),
1499  WEXITSTATUS(exitstatus));
1500  else if (WIFSIGNALED(exitstatus))
1501  {
1502 #if defined(WIN32)
1503  status(_(" (test process was terminated by exception 0x%X)"),
1504  WTERMSIG(exitstatus));
1505 #else
1506  status(_(" (test process was terminated by signal %d: %s)"),
1507  WTERMSIG(exitstatus), pg_strsignal(WTERMSIG(exitstatus)));
1508 #endif
1509  }
1510  else
1511  status(_(" (test process exited with unrecognized status %d)"),
1512  exitstatus);
1513 }
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:224
const char * pg_strsignal(int signum)
Definition: pgstrsignal.c:42
#define WIFEXITED(w)
Definition: win32_port.h:160
#define WIFSIGNALED(w)
Definition: win32_port.h:161
#define WTERMSIG(w)
Definition: win32_port.h:163
#define WEXITSTATUS(w)
Definition: win32_port.h:162

References _, pg_strsignal(), status(), WEXITSTATUS, WIFEXITED, WIFSIGNALED, and WTERMSIG.

Referenced by run_schedule(), and run_single_test().

◆ make_directory()

static void make_directory ( const char *  dir)
static

Definition at line 1191 of file pg_regress.c.

1192 {
1193  if (mkdir(dir, S_IRWXU | S_IRWXG | S_IRWXO) < 0)
1194  {
1195  fprintf(stderr, _("%s: could not create directory \"%s\": %s\n"),
1196  progname, dir, strerror(errno));
1197  exit(2);
1198  }
1199 }
#define S_IRWXG
Definition: win32_port.h:312
#define S_IRWXO
Definition: win32_port.h:324
#define mkdir(a, b)
Definition: win32_port.h:80
#define S_IRWXU
Definition: win32_port.h:300

References _, exit(), fprintf, mkdir, progname, S_IRWXG, S_IRWXO, S_IRWXU, and strerror.

Referenced by open_result_files(), and regression_main().

◆ make_temp_sockdir()

static const char* make_temp_sockdir ( void  )
static

Definition at line 326 of file pg_regress.c.

327 {
328  char *template = psprintf("%s/pg_regress-XXXXXX",
329  getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp");
330 
331  temp_sockdir = mkdtemp(template);
332  if (temp_sockdir == NULL)
333  {
334  fprintf(stderr, _("%s: could not create directory \"%s\": %s\n"),
335  progname, template, strerror(errno));
336  exit(2);
337  }
338 
339  /* Stage file names for remove_temp(). Unsafe in a signal handler. */
341  snprintf(socklock, sizeof(socklock), "%s.lock", sockself);
342 
343  /* Remove the directory during clean exit. */
344  atexit(remove_temp);
345 
346  /*
347  * Remove the directory before dying to the usual signals. Omit SIGQUIT,
348  * preserving it as a quick, untidy exit.
349  */
351  pqsignal(SIGINT, signal_remove_temp);
353  pqsignal(SIGTERM, signal_remove_temp);
354 
355  return temp_sockdir;
356 }
static void signal_remove_temp(SIGNAL_ARGS)
Definition: pg_regress.c:305
static void remove_temp(void)
Definition: pg_regress.c:293
static const char * temp_sockdir
Definition: pg_regress.c:103
static char sockself[MAXPGPATH]
Definition: pg_regress.c:104
static char socklock[MAXPGPATH]
Definition: pg_regress.c:105
pqsigfunc pqsignal(int signo, pqsigfunc func)
char * mkdtemp(char *path)
Definition: mkdtemp.c:286
#define UNIXSOCK_PATH(path, port, sockdir)
Definition: pqcomm.h:32
#define SIGHUP
Definition: win32_port.h:176
#define SIGPIPE
Definition: win32_port.h:181

References _, exit(), fprintf, mkdtemp(), port, pqsignal(), progname, psprintf(), remove_temp(), SIGHUP, signal_remove_temp(), SIGPIPE, snprintf, socklock, sockself, strerror, temp_sockdir, and UNIXSOCK_PATH.

Referenced by initialize_environment().

◆ open_result_files()

static void open_result_files ( void  )
static

Definition at line 1805 of file pg_regress.c.

1806 {
1807  char file[MAXPGPATH];
1808  FILE *difffile;
1809 
1810  /* create outputdir directory if not present */
1813 
1814  /* create the log file (copy of running status output) */
1815  snprintf(file, sizeof(file), "%s/regression.out", outputdir);
1816  logfilename = pg_strdup(file);
1817  logfile = fopen(logfilename, "w");
1818  if (!logfile)
1819  {
1820  fprintf(stderr, _("%s: could not open file \"%s\" for writing: %s\n"),
1821  progname, logfilename, strerror(errno));
1822  exit(2);
1823  }
1824 
1825  /* create the diffs file as empty */
1826  snprintf(file, sizeof(file), "%s/regression.diffs", outputdir);
1827  difffilename = pg_strdup(file);
1828  difffile = fopen(difffilename, "w");
1829  if (!difffile)
1830  {
1831  fprintf(stderr, _("%s: could not open file \"%s\" for writing: %s\n"),
1832  progname, difffilename, strerror(errno));
1833  exit(2);
1834  }
1835  /* we don't keep the diffs file open continuously */
1836  fclose(difffile);
1837 
1838  /* also create the results directory if not present */
1839  snprintf(file, sizeof(file), "%s/results", outputdir);
1840  if (!directory_exists(file))
1841  make_directory(file);
1842 }
static bool directory_exists(const char *dir)
Definition: pg_regress.c:1178
static char * logfilename
Definition: pg_regress.c:99
static void make_directory(const char *dir)
Definition: pg_regress.c:1191
static char * difffilename
Definition: pg_regress.c:101
static FILE * logfile
Definition: pg_regress.c:100

References _, difffilename, directory_exists(), exit(), fprintf, logfile, logfilename, make_directory(), MAXPGPATH, outputdir, pg_strdup(), progname, snprintf, and strerror.

Referenced by regression_main().

◆ psql_add_command()

static void psql_add_command ( StringInfo  buf,
const char *  query,
  ... 
)
static

Definition at line 983 of file pg_regress.c.

984 {
985  StringInfoData cmdbuf;
986  const char *cmdptr;
987 
988  /* Add each command as a -c argument in the psql call */
989  appendStringInfoString(buf, " -c \"");
990 
991  /* Generate the query with insertion of sprintf arguments */
992  initStringInfo(&cmdbuf);
993  for (;;)
994  {
995  va_list args;
996  int needed;
997 
998  va_start(args, query);
999  needed = appendStringInfoVA(&cmdbuf, query, args);
1000  va_end(args);
1001  if (needed == 0)
1002  break; /* success */
1003  enlargeStringInfo(&cmdbuf, needed);
1004  }
1005 
1006  /* Now escape any shell double-quote metacharacters */
1007  for (cmdptr = cmdbuf.data; *cmdptr; cmdptr++)
1008  {
1009  if (strchr("\\\"$`", *cmdptr))
1010  appendStringInfoChar(buf, '\\');
1011  appendStringInfoChar(buf, *cmdptr);
1012  }
1013 
1014  appendStringInfoChar(buf, '"');
1015 
1016  pfree(cmdbuf.data);
1017 }
void pfree(void *pointer)
Definition: mcxt.c:1436
int appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
Definition: stringinfo.c:133
void enlargeStringInfo(StringInfo str, int needed)
Definition: stringinfo.c:283
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
void appendStringInfoChar(StringInfo str, char ch)
Definition: stringinfo.c:188
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59

References appendStringInfoChar(), appendStringInfoString(), appendStringInfoVA(), generate_unaccent_rules::args, buf, StringInfoData::data, enlargeStringInfo(), initStringInfo(), pfree(), va_end(), and va_start().

Referenced by create_database(), create_role(), drop_database_if_exists(), and drop_role_if_exists().

◆ psql_end_command()

static void psql_end_command ( StringInfo  buf,
const char *  database 
)
static

Definition at line 1020 of file pg_regress.c.

1021 {
1022  /* Add the database name --- assume it needs no extra escaping */
1024  " \"%s\"",
1025  database);
1026 
1027  /* And now we can execute the shell command */
1028  fflush(NULL);
1029  if (system(buf->data) != 0)
1030  {
1031  /* psql probably already reported the error */
1032  fprintf(stderr, _("command failed: %s\n"), buf->data);
1033  exit(2);
1034  }
1035 
1036  /* Clean up */
1037  pfree(buf->data);
1038  pfree(buf);
1039 }
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91

References _, appendStringInfo(), buf, exit(), fflush(), fprintf, and pfree().

Referenced by create_database(), create_role(), drop_database_if_exists(), and drop_role_if_exists().

◆ psql_start_command()

static StringInfo psql_start_command ( void  )
static

Definition at line 971 of file pg_regress.c.

972 {
974 
976  "\"%s%spsql\" -X",
977  bindir ? bindir : "",
978  bindir ? "/" : "");
979  return buf;
980 }
char * bindir
Definition: pg_regress.c:77
StringInfo makeStringInfo(void)
Definition: stringinfo.c:41

References appendStringInfo(), bindir, buf, and makeStringInfo().

Referenced by create_database(), create_role(), drop_database_if_exists(), and drop_role_if_exists().

◆ regression_main()

int regression_main ( int  argc,
char *  argv[],
init_function  ifunc,
test_start_function  startfunc,
postprocess_result_function  postfunc 
)

Definition at line 1972 of file pg_regress.c.

1976 {
1977  static struct option long_options[] = {
1978  {"help", no_argument, NULL, 'h'},
1979  {"version", no_argument, NULL, 'V'},
1980  {"dbname", required_argument, NULL, 1},
1981  {"debug", no_argument, NULL, 2},
1982  {"inputdir", required_argument, NULL, 3},
1983  {"max-connections", required_argument, NULL, 5},
1984  {"encoding", required_argument, NULL, 6},
1985  {"outputdir", required_argument, NULL, 7},
1986  {"schedule", required_argument, NULL, 8},
1987  {"temp-instance", required_argument, NULL, 9},
1988  {"no-locale", no_argument, NULL, 10},
1989  {"host", required_argument, NULL, 13},
1990  {"port", required_argument, NULL, 14},
1991  {"user", required_argument, NULL, 15},
1992  {"bindir", required_argument, NULL, 16},
1993  {"dlpath", required_argument, NULL, 17},
1994  {"create-role", required_argument, NULL, 18},
1995  {"temp-config", required_argument, NULL, 19},
1996  {"use-existing", no_argument, NULL, 20},
1997  {"launcher", required_argument, NULL, 21},
1998  {"load-extension", required_argument, NULL, 22},
1999  {"config-auth", required_argument, NULL, 24},
2000  {"max-concurrent-tests", required_argument, NULL, 25},
2001  {"expecteddir", required_argument, NULL, 26},
2002  {NULL, 0, NULL, 0}
2003  };
2004 
2005  bool use_unix_sockets;
2006  _stringlist *sl;
2007  int c;
2008  int i;
2009  int option_index;
2010  char buf[MAXPGPATH * 4];
2011  char buf2[MAXPGPATH * 4];
2012 
2013  pg_logging_init(argv[0]);
2014  progname = get_progname(argv[0]);
2015  set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_regress"));
2016 
2018 
2019  atexit(stop_postmaster);
2020 
2021 #if defined(WIN32)
2022 
2023  /*
2024  * We don't use Unix-domain sockets on Windows by default (see comment at
2025  * remove_temp() for a reason). Override at your own risk.
2026  */
2027  use_unix_sockets = getenv("PG_TEST_USE_UNIX_SOCKETS") ? true : false;
2028 #else
2029  use_unix_sockets = true;
2030 #endif
2031 
2032  if (!use_unix_sockets)
2033  hostname = "localhost";
2034 
2035  /*
2036  * We call the initialization function here because that way we can set
2037  * default parameters and let them be overwritten by the commandline.
2038  */
2039  ifunc(argc, argv);
2040 
2041  if (getenv("PG_REGRESS_DIFF_OPTS"))
2042  pretty_diff_opts = getenv("PG_REGRESS_DIFF_OPTS");
2043 
2044  while ((c = getopt_long(argc, argv, "hV", long_options, &option_index)) != -1)
2045  {
2046  switch (c)
2047  {
2048  case 'h':
2049  help();
2050  exit(0);
2051  case 'V':
2052  puts("pg_regress (PostgreSQL) " PG_VERSION);
2053  exit(0);
2054  case 1:
2055 
2056  /*
2057  * If a default database was specified, we need to remove it
2058  * before we add the specified one.
2059  */
2062  break;
2063  case 2:
2064  debug = true;
2065  break;
2066  case 3:
2068  break;
2069  case 5:
2070  max_connections = atoi(optarg);
2071  break;
2072  case 6:
2074  break;
2075  case 7:
2077  break;
2078  case 8:
2080  break;
2081  case 9:
2083  break;
2084  case 10:
2085  nolocale = true;
2086  break;
2087  case 13:
2089  break;
2090  case 14:
2091  port = atoi(optarg);
2092  port_specified_by_user = true;
2093  break;
2094  case 15:
2095  user = pg_strdup(optarg);
2096  break;
2097  case 16:
2098  /* "--bindir=" means to use PATH */
2099  if (strlen(optarg))
2100  bindir = pg_strdup(optarg);
2101  else
2102  bindir = NULL;
2103  break;
2104  case 17:
2105  dlpath = pg_strdup(optarg);
2106  break;
2107  case 18:
2109  break;
2110  case 19:
2112  break;
2113  case 20:
2114  use_existing = true;
2115  break;
2116  case 21:
2118  break;
2119  case 22:
2121  break;
2122  case 24:
2124  break;
2125  case 25:
2126  max_concurrent_tests = atoi(optarg);
2127  break;
2128  case 26:
2130  break;
2131  default:
2132  /* getopt_long already emitted a complaint */
2133  fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
2134  progname);
2135  exit(2);
2136  }
2137  }
2138 
2139  /*
2140  * if we still have arguments, they are extra tests to run
2141  */
2142  while (argc - optind >= 1)
2143  {
2145  optind++;
2146  }
2147 
2148  /*
2149  * We must have a database to run the tests in; either a default name, or
2150  * one supplied by the --dbname switch.
2151  */
2152  if (!(dblist && dblist->str && dblist->str[0]))
2153  {
2154  fprintf(stderr, _("%s: no database name was specified\n"),
2155  progname);
2156  exit(2);
2157  }
2158 
2159  if (config_auth_datadir)
2160  {
2161 #ifdef ENABLE_SSPI
2162  if (!use_unix_sockets)
2163  config_sspi_auth(config_auth_datadir, user);
2164 #endif
2165  exit(0);
2166  }
2167 
2169 
2170  /*
2171  * To reduce chances of interference with parallel installations, use
2172  * a port number starting in the private range (49152-65535)
2173  * calculated from the version number. This aids non-Unix socket mode
2174  * systems; elsewhere, the use of a private socket directory already
2175  * prevents interference.
2176  */
2177  port = 0xC000 | (PG_VERSION_NUM & 0x3FFF);
2178 
2183 
2184  /*
2185  * Initialization
2186  */
2188 
2190 
2191 #if defined(HAVE_GETRLIMIT)
2193 #endif
2194 
2195  if (temp_instance)
2196  {
2197  FILE *pg_conf;
2198  const char *env_wait;
2199  int wait_seconds;
2200 
2201  /*
2202  * Prepare the temp instance
2203  */
2204 
2206  {
2207  header(_("removing existing temp instance"));
2208  if (!rmtree(temp_instance, true))
2209  {
2210  fprintf(stderr, _("\n%s: could not remove temp instance \"%s\"\n"),
2212  exit(2);
2213  }
2214  }
2215 
2216  header(_("creating temporary instance"));
2217 
2218  /* make the temp instance top directory */
2220 
2221  /* and a directory for log files */
2222  snprintf(buf, sizeof(buf), "%s/log", outputdir);
2223  if (!directory_exists(buf))
2225 
2226  /* initdb */
2227  header(_("initializing database system"));
2228  snprintf(buf, sizeof(buf),
2229  "\"%s%sinitdb\" -D \"%s/data\" --no-clean --no-sync%s%s > \"%s/log/initdb.log\" 2>&1",
2230  bindir ? bindir : "",
2231  bindir ? "/" : "",
2232  temp_instance,
2233  debug ? " --debug" : "",
2234  nolocale ? " --no-locale" : "",
2235  outputdir);
2236  fflush(NULL);
2237  if (system(buf))
2238  {
2239  fprintf(stderr, _("\n%s: initdb failed\nExamine %s/log/initdb.log for the reason.\nCommand was: %s\n"), progname, outputdir, buf);
2240  exit(2);
2241  }
2242 
2243  /*
2244  * Adjust the default postgresql.conf for regression testing. The user
2245  * can specify a file to be appended; in any case we expand logging
2246  * and set max_prepared_transactions to enable testing of prepared
2247  * xacts. (Note: to reduce the probability of unexpected shmmax
2248  * failures, don't set max_prepared_transactions any higher than
2249  * actually needed by the prepared_xacts regression test.)
2250  */
2251  snprintf(buf, sizeof(buf), "%s/data/postgresql.conf", temp_instance);
2252  pg_conf = fopen(buf, "a");
2253  if (pg_conf == NULL)
2254  {
2255  fprintf(stderr, _("\n%s: could not open \"%s\" for adding extra config: %s\n"), progname, buf, strerror(errno));
2256  exit(2);
2257  }
2258  fputs("\n# Configuration added by pg_regress\n\n", pg_conf);
2259  fputs("log_autovacuum_min_duration = 0\n", pg_conf);
2260  fputs("log_checkpoints = on\n", pg_conf);
2261  fputs("log_line_prefix = '%m %b[%p] %q%a '\n", pg_conf);
2262  fputs("log_lock_waits = on\n", pg_conf);
2263  fputs("log_temp_files = 128kB\n", pg_conf);
2264  fputs("max_prepared_transactions = 2\n", pg_conf);
2265 
2266  for (sl = temp_configs; sl != NULL; sl = sl->next)
2267  {
2268  char *temp_config = sl->str;
2269  FILE *extra_conf;
2270  char line_buf[1024];
2271 
2272  extra_conf = fopen(temp_config, "r");
2273  if (extra_conf == NULL)
2274  {
2275  fprintf(stderr, _("\n%s: could not open \"%s\" to read extra config: %s\n"), progname, temp_config, strerror(errno));
2276  exit(2);
2277  }
2278  while (fgets(line_buf, sizeof(line_buf), extra_conf) != NULL)
2279  fputs(line_buf, pg_conf);
2280  fclose(extra_conf);
2281  }
2282 
2283  fclose(pg_conf);
2284 
2285 #ifdef ENABLE_SSPI
2286  if (!use_unix_sockets)
2287  {
2288  /*
2289  * Since we successfully used the same buffer for the much-longer
2290  * "initdb" command, this can't truncate.
2291  */
2292  snprintf(buf, sizeof(buf), "%s/data", temp_instance);
2293  config_sspi_auth(buf, NULL);
2294  }
2295 #endif
2296 
2297  /*
2298  * Check if there is a postmaster running already.
2299  */
2300  snprintf(buf2, sizeof(buf2),
2301  "\"%s%spsql\" -X postgres <%s 2>%s",
2302  bindir ? bindir : "",
2303  bindir ? "/" : "",
2304  DEVNULL, DEVNULL);
2305 
2306  for (i = 0; i < 16; i++)
2307  {
2308  fflush(NULL);
2309  if (system(buf2) == 0)
2310  {
2311  char s[16];
2312 
2313  if (port_specified_by_user || i == 15)
2314  {
2315  fprintf(stderr, _("port %d apparently in use\n"), port);
2317  fprintf(stderr, _("%s: could not determine an available port\n"), progname);
2318  fprintf(stderr, _("Specify an unused port using the --port option or shut down any conflicting PostgreSQL servers.\n"));
2319  exit(2);
2320  }
2321 
2322  fprintf(stderr, _("port %d apparently in use, trying %d\n"), port, port + 1);
2323  port++;
2324  sprintf(s, "%d", port);
2325  setenv("PGPORT", s, 1);
2326  }
2327  else
2328  break;
2329  }
2330 
2331  /*
2332  * Start the temp postmaster
2333  */
2334  header(_("starting postmaster"));
2335  snprintf(buf, sizeof(buf),
2336  "\"%s%spostgres\" -D \"%s/data\" -F%s "
2337  "-c \"listen_addresses=%s\" -k \"%s\" "
2338  "> \"%s/log/postmaster.log\" 2>&1",
2339  bindir ? bindir : "",
2340  bindir ? "/" : "",
2341  temp_instance, debug ? " -d 5" : "",
2342  hostname ? hostname : "", sockdir ? sockdir : "",
2343  outputdir);
2345  if (postmaster_pid == INVALID_PID)
2346  {
2347  fprintf(stderr, _("\n%s: could not spawn postmaster: %s\n"),
2348  progname, strerror(errno));
2349  exit(2);
2350  }
2351 
2352  /*
2353  * Wait till postmaster is able to accept connections; normally this
2354  * is only a second or so, but Cygwin is reportedly *much* slower, and
2355  * test builds using Valgrind or similar tools might be too. Hence,
2356  * allow the default timeout of 60 seconds to be overridden from the
2357  * PGCTLTIMEOUT environment variable.
2358  */
2359  env_wait = getenv("PGCTLTIMEOUT");
2360  if (env_wait != NULL)
2361  {
2362  wait_seconds = atoi(env_wait);
2363  if (wait_seconds <= 0)
2364  wait_seconds = 60;
2365  }
2366  else
2367  wait_seconds = 60;
2368 
2369  for (i = 0; i < wait_seconds; i++)
2370  {
2371  /* Done if psql succeeds */
2372  fflush(NULL);
2373  if (system(buf2) == 0)
2374  break;
2375 
2376  /*
2377  * Fail immediately if postmaster has exited
2378  */
2379 #ifndef WIN32
2380  if (waitpid(postmaster_pid, NULL, WNOHANG) == postmaster_pid)
2381 #else
2382  if (WaitForSingleObject(postmaster_pid, 0) == WAIT_OBJECT_0)
2383 #endif
2384  {
2385  fprintf(stderr, _("\n%s: postmaster failed\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir);
2386  exit(2);
2387  }
2388 
2389  pg_usleep(1000000L);
2390  }
2391  if (i >= wait_seconds)
2392  {
2393  fprintf(stderr, _("\n%s: postmaster did not respond within %d seconds\nExamine %s/log/postmaster.log for the reason\n"),
2395 
2396  /*
2397  * If we get here, the postmaster is probably wedged somewhere in
2398  * startup. Try to kill it ungracefully rather than leaving a
2399  * stuck postmaster that might interfere with subsequent test
2400  * attempts.
2401  */
2402 #ifndef WIN32
2403  if (kill(postmaster_pid, SIGKILL) != 0 &&
2404  errno != ESRCH)
2405  fprintf(stderr, _("\n%s: could not kill failed postmaster: %s\n"),
2406  progname, strerror(errno));
2407 #else
2408  if (TerminateProcess(postmaster_pid, 255) == 0)
2409  fprintf(stderr, _("\n%s: could not kill failed postmaster: error code %lu\n"),
2410  progname, GetLastError());
2411 #endif
2412 
2413  exit(2);
2414  }
2415 
2416  postmaster_running = true;
2417 
2418 #ifdef _WIN64
2419 /* need a series of two casts to convert HANDLE without compiler warning */
2420 #define ULONGPID(x) (unsigned long) (unsigned long long) (x)
2421 #else
2422 #define ULONGPID(x) (unsigned long) (x)
2423 #endif
2424  printf(_("running on port %d with PID %lu\n"),
2426  }
2427  else
2428  {
2429  /*
2430  * Using an existing installation, so may need to get rid of
2431  * pre-existing database(s) and role(s)
2432  */
2433  if (!use_existing)
2434  {
2435  for (sl = dblist; sl; sl = sl->next)
2437  for (sl = extraroles; sl; sl = sl->next)
2438  drop_role_if_exists(sl->str);
2439  }
2440  }
2441 
2442  /*
2443  * Create the test database(s) and role(s)
2444  */
2445  if (!use_existing)
2446  {
2447  for (sl = dblist; sl; sl = sl->next)
2448  create_database(sl->str);
2449  for (sl = extraroles; sl; sl = sl->next)
2450  create_role(sl->str, dblist);
2451  }
2452 
2453  /*
2454  * Ready to run the tests
2455  */
2456  header(_("running regression test queries"));
2457 
2458  for (sl = schedulelist; sl != NULL; sl = sl->next)
2459  {
2460  run_schedule(sl->str, startfunc, postfunc);
2461  }
2462 
2463  for (sl = extra_tests; sl != NULL; sl = sl->next)
2464  {
2465  run_single_test(sl->str, startfunc, postfunc);
2466  }
2467 
2468  /*
2469  * Shut down temp installation's postmaster
2470  */
2471  if (temp_instance)
2472  {
2473  header(_("shutting down postmaster"));
2474  stop_postmaster();
2475  }
2476 
2477  /*
2478  * If there were no errors, remove the temp instance immediately to
2479  * conserve disk space. (If there were errors, we leave the instance in
2480  * place for possible manual investigation.)
2481  */
2482  if (temp_instance && fail_count == 0)
2483  {
2484  header(_("removing temporary instance"));
2485  if (!rmtree(temp_instance, true))
2486  fprintf(stderr, _("\n%s: could not remove temp instance \"%s\"\n"),
2488  }
2489 
2490  fclose(logfile);
2491 
2492  /*
2493  * Emit nice-looking summary message
2494  */
2495  if (fail_count == 0)
2496  snprintf(buf, sizeof(buf),
2497  _(" All %d tests passed. "),
2498  success_count);
2499  else
2500  snprintf(buf, sizeof(buf),
2501  _(" %d of %d tests failed. "),
2502  fail_count,
2504 
2505  putchar('\n');
2506  for (i = strlen(buf); i > 0; i--)
2507  putchar('=');
2508  printf("\n%s\n", buf);
2509  for (i = strlen(buf); i > 0; i--)
2510  putchar('=');
2511  putchar('\n');
2512  putchar('\n');
2513 
2514  if (file_size(difffilename) > 0)
2515  {
2516  printf(_("The differences that caused some tests to fail can be viewed in the\n"
2517  "file \"%s\". A copy of the test summary that you see\n"
2518  "above is saved in the file \"%s\".\n\n"),
2520  }
2521  else
2522  {
2523  unlink(difffilename);
2524  unlink(logfilename);
2525  }
2526 
2527  if (fail_count != 0)
2528  exit(1);
2529 
2530  return 0;
2531 }
#define PG_TEXTDOMAIN(domain)
Definition: c.h:1204
void set_pglocale_pgservice(const char *argv0, const char *app)
Definition: exec.c:460
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
Definition: getopt_long.c:57
#define no_argument
Definition: getopt_long.h:24
#define required_argument
Definition: getopt_long.h:25
return true
Definition: isn.c:126
void pg_logging_init(const char *argv0)
Definition: logging.c:83
static int wait_seconds
Definition: pg_ctl.c:75
PGDLLIMPORT int optind
Definition: getopt.c:50
PGDLLIMPORT char * optarg
Definition: getopt.c:52
static bool use_existing
Definition: pg_regress.c:88
static void open_result_files(void)
Definition: pg_regress.c:1805
static int max_connections
Definition: pg_regress.c:80
static bool port_specified_by_user
Definition: pg_regress.c:91
static void stop_postmaster(void)
Definition: pg_regress.c:257
static int max_concurrent_tests
Definition: pg_regress.c:81
static void create_database(const char *dbname)
Definition: pg_regress.c:1857
static void drop_role_if_exists(const char *rolename)
Definition: pg_regress.c:1895
bool debug
Definition: pg_regress.c:73
static void unlimit_core_size(void)
Definition: pg_regress.c:129
static _stringlist * schedulelist
Definition: pg_regress.c:83
static _stringlist * temp_configs
Definition: pg_regress.c:86
static _stringlist * extra_tests
Definition: pg_regress.c:84
static void split_to_stringlist(const char *s, const char *delim, _stringlist **listhead)
Definition: pg_regress.c:190
static void run_single_test(const char *test, test_start_function startfunc, postprocess_result_function postfunc)
Definition: pg_regress.c:1737
char * launcher
Definition: pg_regress.c:78
const char * pretty_diff_opts
Definition: pg_regress.c:65
char * expecteddir
Definition: pg_regress.c:76
static char * config_auth_datadir
Definition: pg_regress.c:95
static void drop_database_if_exists(const char *dbname)
Definition: pg_regress.c:1845
static void initialize_environment(void)
Definition: pg_regress.c:556
static void help(void)
Definition: pg_regress.c:1922
static long file_size(const char *file)
Definition: pg_regress.c:1124
static bool postmaster_running
Definition: pg_regress.c:110
_stringlist * dblist
Definition: pg_regress.c:72
static _stringlist * extraroles
Definition: pg_regress.c:94
PID_TYPE spawn_process(const char *cmdline)
Definition: pg_regress.c:1057
static void create_role(const char *rolename, const _stringlist *granted_dbs)
Definition: pg_regress.c:1907
static void run_schedule(const char *schedule, test_start_function startfunc, postprocess_result_function postfunc)
Definition: pg_regress.c:1519
void add_stringlist_item(_stringlist **listhead, const char *str)
Definition: pg_regress.c:154
static int success_count
Definition: pg_regress.c:112
#define ULONGPID(x)
static int fail_count
Definition: pg_regress.c:113
static PID_TYPE postmaster_pid
Definition: pg_regress.c:109
#define INVALID_PID
Definition: pg_regress.h:15
char * make_absolute_path(const char *path)
Definition: path.c:729
const char * get_progname(const char *argv0)
Definition: path.c:574
#define DEVNULL
Definition: port.h:160
void get_restricted_token(void)
bool rmtree(const char *path, bool rmtopdir)
Definition: rmtree.c:50
void pg_usleep(long microsec)
Definition: signal.c:53
#define kill(pid, sig)
Definition: win32_port.h:482
#define SIGKILL
Definition: win32_port.h:180

References _, add_stringlist_item(), bindir, buf, config_auth_datadir, create_database(), create_role(), dblist, debug, DEVNULL, difffilename, directory_exists(), dlpath, drop_database_if_exists(), drop_role_if_exists(), encoding, exit(), expecteddir, extra_tests, extraroles, fail_count, fflush(), file_size(), fprintf, free_stringlist(), get_progname(), get_restricted_token(), getopt_long(), header(), help(), hostname, i, initialize_environment(), inputdir, INVALID_PID, kill, launcher, loadextension, logfile, logfilename, make_absolute_path(), make_directory(), max_concurrent_tests, max_connections, MAXPGPATH, _stringlist::next, no_argument, nolocale, open_result_files(), optarg, optind, outputdir, pg_logging_init(), pg_strdup(), PG_TEXTDOMAIN, pg_usleep(), port, port_specified_by_user, postmaster_pid, postmaster_running, pretty_diff_opts, printf, 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, strerror, success_count, temp_configs, temp_instance, true, ULONGPID, unlimit_core_size(), use_existing, user, and wait_seconds.

Referenced by main().

◆ remove_temp()

static void remove_temp ( void  )
static

Definition at line 293 of file pg_regress.c.

294 {
296  unlink(sockself);
297  unlink(socklock);
298  rmdir(temp_sockdir);
299 }
Assert(fmt[strlen(fmt) - 1] !='\n')

References Assert(), socklock, sockself, and temp_sockdir.

Referenced by make_temp_sockdir(), and signal_remove_temp().

◆ results_differ()

static bool results_differ ( const char *  testname,
const char *  resultsfile,
const char *  default_expectfile 
)
static

Definition at line 1273 of file pg_regress.c.

1274 {
1275  char expectfile[MAXPGPATH];
1276  char diff[MAXPGPATH];
1277  char cmd[MAXPGPATH * 3];
1278  char best_expect_file[MAXPGPATH];
1279  FILE *difffile;
1280  int best_line_count;
1281  int i;
1282  int l;
1283  const char *platform_expectfile;
1284 
1285  /*
1286  * We can pass either the resultsfile or the expectfile, they should have
1287  * the same type (filename.type) anyway.
1288  */
1289  platform_expectfile = get_expectfile(testname, resultsfile);
1290 
1291  strlcpy(expectfile, default_expectfile, sizeof(expectfile));
1292  if (platform_expectfile)
1293  {
1294  /*
1295  * Replace everything after the last slash in expectfile with what the
1296  * platform_expectfile contains.
1297  */
1298  char *p = strrchr(expectfile, '/');
1299 
1300  if (p)
1301  strcpy(++p, platform_expectfile);
1302  }
1303 
1304  /* Name to use for temporary diff file */
1305  snprintf(diff, sizeof(diff), "%s.diff", resultsfile);
1306 
1307  /* OK, run the diff */
1308  snprintf(cmd, sizeof(cmd),
1309  "diff %s \"%s\" \"%s\" > \"%s\"",
1310  basic_diff_opts, expectfile, resultsfile, diff);
1311 
1312  /* Is the diff file empty? */
1313  if (run_diff(cmd, diff) == 0)
1314  {
1315  unlink(diff);
1316  return false;
1317  }
1318 
1319  /* There may be secondary comparison files that match better */
1320  best_line_count = file_line_count(diff);
1321  strcpy(best_expect_file, expectfile);
1322 
1323  for (i = 0; i <= 9; i++)
1324  {
1325  char *alt_expectfile;
1326 
1327  alt_expectfile = get_alternative_expectfile(expectfile, i);
1328  if (!alt_expectfile)
1329  {
1330  fprintf(stderr, _("Unable to check secondary comparison files: %s\n"),
1331  strerror(errno));
1332  exit(2);
1333  }
1334 
1335  if (!file_exists(alt_expectfile))
1336  {
1337  free(alt_expectfile);
1338  continue;
1339  }
1340 
1341  snprintf(cmd, sizeof(cmd),
1342  "diff %s \"%s\" \"%s\" > \"%s\"",
1343  basic_diff_opts, alt_expectfile, resultsfile, diff);
1344 
1345  if (run_diff(cmd, diff) == 0)
1346  {
1347  unlink(diff);
1348  free(alt_expectfile);
1349  return false;
1350  }
1351 
1352  l = file_line_count(diff);
1353  if (l < best_line_count)
1354  {
1355  /* This diff was a better match than the last one */
1356  best_line_count = l;
1357  strlcpy(best_expect_file, alt_expectfile, sizeof(best_expect_file));
1358  }
1359  free(alt_expectfile);
1360  }
1361 
1362  /*
1363  * fall back on the canonical results file if we haven't tried it yet and
1364  * haven't found a complete match yet.
1365  */
1366 
1367  if (platform_expectfile)
1368  {
1369  snprintf(cmd, sizeof(cmd),
1370  "diff %s \"%s\" \"%s\" > \"%s\"",
1371  basic_diff_opts, default_expectfile, resultsfile, diff);
1372 
1373  if (run_diff(cmd, diff) == 0)
1374  {
1375  /* No diff = no changes = good */
1376  unlink(diff);
1377  return false;
1378  }
1379 
1380  l = file_line_count(diff);
1381  if (l < best_line_count)
1382  {
1383  /* This diff was a better match than the last one */
1384  best_line_count = l;
1385  strlcpy(best_expect_file, default_expectfile, sizeof(best_expect_file));
1386  }
1387  }
1388 
1389  /*
1390  * Use the best comparison file to generate the "pretty" diff, which we
1391  * append to the diffs summary file.
1392  */
1393 
1394  /* Write diff header */
1395  difffile = fopen(difffilename, "a");
1396  if (difffile)
1397  {
1398  fprintf(difffile,
1399  "diff %s %s %s\n",
1400  pretty_diff_opts, best_expect_file, resultsfile);
1401  fclose(difffile);
1402  }
1403 
1404  /* Run diff */
1405  snprintf(cmd, sizeof(cmd),
1406  "diff %s \"%s\" \"%s\" >> \"%s\"",
1407  pretty_diff_opts, best_expect_file, resultsfile, difffilename);
1408  run_diff(cmd, difffilename);
1409 
1410  unlink(diff);
1411  return true;
1412 }
static int file_line_count(const char *file)
Definition: pg_regress.c:1145
bool file_exists(const char *file)
Definition: pg_regress.c:1167
static int run_diff(const char *cmd, const char *filename)
Definition: pg_regress.c:1239
static const char * get_expectfile(const char *testname, const char *file)
Definition: pg_regress.c:527
const char * basic_diff_opts
Definition: pg_regress.c:64
static char * get_alternative_expectfile(const char *expectfile, int i)
Definition: pg_regress.c:1205
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45

References _, basic_diff_opts, difffilename, exit(), file_exists(), file_line_count(), fprintf, free, get_alternative_expectfile(), get_expectfile(), i, MAXPGPATH, pretty_diff_opts, run_diff(), snprintf, strerror, and strlcpy().

Referenced by run_schedule(), and run_single_test().

◆ run_diff()

static int run_diff ( const char *  cmd,
const char *  filename 
)
static

Definition at line 1239 of file pg_regress.c.

1240 {
1241  int r;
1242 
1243  fflush(NULL);
1244  r = system(cmd);
1245  if (!WIFEXITED(r) || WEXITSTATUS(r) > 1)
1246  {
1247  fprintf(stderr, _("diff command failed with status %d: %s\n"), r, cmd);
1248  exit(2);
1249  }
1250 #ifdef WIN32
1251 
1252  /*
1253  * On WIN32, if the 'diff' command cannot be found, system() returns 1,
1254  * but produces nothing to stdout, so we check for that here.
1255  */
1256  if (WEXITSTATUS(r) == 1 && file_size(filename) <= 0)
1257  {
1258  fprintf(stderr, _("diff command not found: %s\n"), cmd);
1259  exit(2);
1260  }
1261 #endif
1262 
1263  return WEXITSTATUS(r);
1264 }
static char * filename
Definition: pg_dumpall.c:119

References _, exit(), fflush(), file_size(), filename, fprintf, WEXITSTATUS, and WIFEXITED.

Referenced by results_differ().

◆ run_schedule()

static void run_schedule ( const char *  schedule,
test_start_function  startfunc,
postprocess_result_function  postfunc 
)
static

Definition at line 1519 of file pg_regress.c.

1521 {
1522 #define MAX_PARALLEL_TESTS 100
1523  char *tests[MAX_PARALLEL_TESTS];
1524  _stringlist *resultfiles[MAX_PARALLEL_TESTS];
1525  _stringlist *expectfiles[MAX_PARALLEL_TESTS];
1528  instr_time starttimes[MAX_PARALLEL_TESTS];
1529  instr_time stoptimes[MAX_PARALLEL_TESTS];
1530  int statuses[MAX_PARALLEL_TESTS];
1531  char scbuf[1024];
1532  FILE *scf;
1533  int line_num = 0;
1534 
1535  memset(tests, 0, sizeof(tests));
1536  memset(resultfiles, 0, sizeof(resultfiles));
1537  memset(expectfiles, 0, sizeof(expectfiles));
1538  memset(tags, 0, sizeof(tags));
1539 
1540  scf = fopen(schedule, "r");
1541  if (!scf)
1542  {
1543  fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
1544  progname, schedule, strerror(errno));
1545  exit(2);
1546  }
1547 
1548  while (fgets(scbuf, sizeof(scbuf), scf))
1549  {
1550  char *test = NULL;
1551  char *c;
1552  int num_tests;
1553  bool inword;
1554  int i;
1555 
1556  line_num++;
1557 
1558  /* strip trailing whitespace, especially the newline */
1559  i = strlen(scbuf);
1560  while (i > 0 && isspace((unsigned char) scbuf[i - 1]))
1561  scbuf[--i] = '\0';
1562 
1563  if (scbuf[0] == '\0' || scbuf[0] == '#')
1564  continue;
1565  if (strncmp(scbuf, "test: ", 6) == 0)
1566  test = scbuf + 6;
1567  else
1568  {
1569  fprintf(stderr, _("syntax error in schedule file \"%s\" line %d: %s\n"),
1570  schedule, line_num, scbuf);
1571  exit(2);
1572  }
1573 
1574  num_tests = 0;
1575  inword = false;
1576  for (c = test;; c++)
1577  {
1578  if (*c == '\0' || isspace((unsigned char) *c))
1579  {
1580  if (inword)
1581  {
1582  /* Reached end of a test name */
1583  char sav;
1584 
1585  if (num_tests >= MAX_PARALLEL_TESTS)
1586  {
1587  fprintf(stderr, _("too many parallel tests (more than %d) in schedule file \"%s\" line %d: %s\n"),
1588  MAX_PARALLEL_TESTS, schedule, line_num, scbuf);
1589  exit(2);
1590  }
1591  sav = *c;
1592  *c = '\0';
1593  tests[num_tests] = pg_strdup(test);
1594  num_tests++;
1595  *c = sav;
1596  inword = false;
1597  }
1598  if (*c == '\0')
1599  break; /* loop exit is here */
1600  }
1601  else if (!inword)
1602  {
1603  /* Start of a test name */
1604  test = c;
1605  inword = true;
1606  }
1607  }
1608 
1609  if (num_tests == 0)
1610  {
1611  fprintf(stderr, _("syntax error in schedule file \"%s\" line %d: %s\n"),
1612  schedule, line_num, scbuf);
1613  exit(2);
1614  }
1615 
1616  if (num_tests == 1)
1617  {
1618  status(_("test %-28s ... "), tests[0]);
1619  pids[0] = (startfunc) (tests[0], &resultfiles[0], &expectfiles[0], &tags[0]);
1620  INSTR_TIME_SET_CURRENT(starttimes[0]);
1621  wait_for_tests(pids, statuses, stoptimes, NULL, 1);
1622  /* status line is finished below */
1623  }
1624  else if (max_concurrent_tests > 0 && max_concurrent_tests < num_tests)
1625  {
1626  fprintf(stderr, _("too many parallel tests (more than %d) in schedule file \"%s\" line %d: %s\n"),
1627  max_concurrent_tests, schedule, line_num, scbuf);
1628  exit(2);
1629  }
1630  else if (max_connections > 0 && max_connections < num_tests)
1631  {
1632  int oldest = 0;
1633 
1634  status(_("parallel group (%d tests, in groups of %d): "),
1635  num_tests, max_connections);
1636  for (i = 0; i < num_tests; i++)
1637  {
1638  if (i - oldest >= max_connections)
1639  {
1640  wait_for_tests(pids + oldest, statuses + oldest,
1641  stoptimes + oldest,
1642  tests + oldest, i - oldest);
1643  oldest = i;
1644  }
1645  pids[i] = (startfunc) (tests[i], &resultfiles[i], &expectfiles[i], &tags[i]);
1646  INSTR_TIME_SET_CURRENT(starttimes[i]);
1647  }
1648  wait_for_tests(pids + oldest, statuses + oldest,
1649  stoptimes + oldest,
1650  tests + oldest, i - oldest);
1651  status_end();
1652  }
1653  else
1654  {
1655  status(_("parallel group (%d tests): "), num_tests);
1656  for (i = 0; i < num_tests; i++)
1657  {
1658  pids[i] = (startfunc) (tests[i], &resultfiles[i], &expectfiles[i], &tags[i]);
1659  INSTR_TIME_SET_CURRENT(starttimes[i]);
1660  }
1661  wait_for_tests(pids, statuses, stoptimes, tests, num_tests);
1662  status_end();
1663  }
1664 
1665  /* Check results for all tests */
1666  for (i = 0; i < num_tests; i++)
1667  {
1668  _stringlist *rl,
1669  *el,
1670  *tl;
1671  bool differ = false;
1672 
1673  if (num_tests > 1)
1674  status(_(" %-28s ... "), tests[i]);
1675 
1676  /*
1677  * Advance over all three lists simultaneously.
1678  *
1679  * Compare resultfiles[j] with expectfiles[j] always. Tags are
1680  * optional but if there are tags, the tag list has the same
1681  * length as the other two lists.
1682  */
1683  for (rl = resultfiles[i], el = expectfiles[i], tl = tags[i];
1684  rl != NULL; /* rl and el have the same length */
1685  rl = rl->next, el = el->next,
1686  tl = tl ? tl->next : NULL)
1687  {
1688  bool newdiff;
1689 
1690  if (postfunc)
1691  (*postfunc) (rl->str);
1692  newdiff = results_differ(tests[i], rl->str, el->str);
1693  if (newdiff && tl)
1694  {
1695  printf("%s ", tl->str);
1696  }
1697  differ |= newdiff;
1698  }
1699 
1700  if (differ)
1701  {
1702  status(_("FAILED"));
1703  fail_count++;
1704  }
1705  else
1706  {
1707  status(_("ok ")); /* align with FAILED */
1708  success_count++;
1709  }
1710 
1711  if (statuses[i] != 0)
1712  log_child_failure(statuses[i]);
1713 
1714  INSTR_TIME_SUBTRACT(stoptimes[i], starttimes[i]);
1715  status(_(" %8.0f ms"), INSTR_TIME_GET_MILLISEC(stoptimes[i]));
1716 
1717  status_end();
1718  }
1719 
1720  for (i = 0; i < num_tests; i++)
1721  {
1722  pg_free(tests[i]);
1723  tests[i] = NULL;
1724  free_stringlist(&resultfiles[i]);
1725  free_stringlist(&expectfiles[i]);
1726  free_stringlist(&tags[i]);
1727  }
1728  }
1729 
1730  fclose(scf);
1731 }
void pg_free(void *ptr)
Definition: fe_memutils.c:105
#define INSTR_TIME_SET_CURRENT(t)
Definition: instr_time.h:122
#define INSTR_TIME_SUBTRACT(x, y)
Definition: instr_time.h:181
#define INSTR_TIME_GET_MILLISEC(t)
Definition: instr_time.h:191
static void status_end(void)
Definition: pg_regress.c:245
#define MAX_PARALLEL_TESTS
static void log_child_failure(int exitstatus)
Definition: pg_regress.c:1495
static void wait_for_tests(PID_TYPE *pids, int *statuses, instr_time *stoptimes, char **names, int num_tests)
Definition: pg_regress.c:1423
static bool results_differ(const char *testname, const char *resultsfile, const char *default_expectfile)
Definition: pg_regress.c:1273
#define PID_TYPE
Definition: pg_regress.h:14
static void test(void)

References _, exit(), fail_count, fprintf, free_stringlist(), i, INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SUBTRACT, log_child_failure(), max_concurrent_tests, max_connections, MAX_PARALLEL_TESTS, _stringlist::next, pg_free(), pg_strdup(), PID_TYPE, printf, progname, results_differ(), status(), status_end(), _stringlist::str, strerror, success_count, test(), and wait_for_tests().

Referenced by regression_main().

◆ run_single_test()

static void run_single_test ( const char *  test,
test_start_function  startfunc,
postprocess_result_function  postfunc 
)
static

Definition at line 1737 of file pg_regress.c.

1739 {
1740  PID_TYPE pid;
1741  instr_time starttime;
1742  instr_time stoptime;
1743  int exit_status;
1744  _stringlist *resultfiles = NULL;
1745  _stringlist *expectfiles = NULL;
1746  _stringlist *tags = NULL;
1747  _stringlist *rl,
1748  *el,
1749  *tl;
1750  bool differ = false;
1751 
1752  status(_("test %-28s ... "), test);
1753  pid = (startfunc) (test, &resultfiles, &expectfiles, &tags);
1754  INSTR_TIME_SET_CURRENT(starttime);
1755  wait_for_tests(&pid, &exit_status, &stoptime, NULL, 1);
1756 
1757  /*
1758  * Advance over all three lists simultaneously.
1759  *
1760  * Compare resultfiles[j] with expectfiles[j] always. Tags are optional
1761  * but if there are tags, the tag list has the same length as the other
1762  * two lists.
1763  */
1764  for (rl = resultfiles, el = expectfiles, tl = tags;
1765  rl != NULL; /* rl and el have the same length */
1766  rl = rl->next, el = el->next,
1767  tl = tl ? tl->next : NULL)
1768  {
1769  bool newdiff;
1770 
1771  if (postfunc)
1772  (*postfunc) (rl->str);
1773  newdiff = results_differ(test, rl->str, el->str);
1774  if (newdiff && tl)
1775  {
1776  printf("%s ", tl->str);
1777  }
1778  differ |= newdiff;
1779  }
1780 
1781  if (differ)
1782  {
1783  status(_("FAILED"));
1784  fail_count++;
1785  }
1786  else
1787  {
1788  status(_("ok ")); /* align with FAILED */
1789  success_count++;
1790  }
1791 
1792  if (exit_status != 0)
1793  log_child_failure(exit_status);
1794 
1795  INSTR_TIME_SUBTRACT(stoptime, starttime);
1796  status(_(" %8.0f ms"), INSTR_TIME_GET_MILLISEC(stoptime));
1797 
1798  status_end();
1799 }

References _, fail_count, INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SUBTRACT, log_child_failure(), _stringlist::next, PID_TYPE, printf, results_differ(), status(), status_end(), _stringlist::str, success_count, test(), and wait_for_tests().

Referenced by regression_main().

◆ signal_remove_temp()

static void signal_remove_temp ( SIGNAL_ARGS  )
static

Definition at line 305 of file pg_regress.c.

306 {
307  remove_temp();
308 
309  pqsignal(postgres_signal_arg, SIG_DFL);
310  raise(postgres_signal_arg);
311 }
#define SIG_DFL
Definition: win32_port.h:171

References pqsignal(), remove_temp(), and SIG_DFL.

Referenced by make_temp_sockdir().

◆ spawn_process()

PID_TYPE spawn_process ( const char *  cmdline)

Definition at line 1057 of file pg_regress.c.

1058 {
1059 #ifndef WIN32
1060  pid_t pid;
1061 
1062  /*
1063  * Must flush I/O buffers before fork.
1064  */
1065  fflush(NULL);
1066 
1067 #ifdef EXEC_BACKEND
1068  pg_disable_aslr();
1069 #endif
1070 
1071  pid = fork();
1072  if (pid == -1)
1073  {
1074  fprintf(stderr, _("%s: could not fork: %s\n"),
1075  progname, strerror(errno));
1076  exit(2);
1077  }
1078  if (pid == 0)
1079  {
1080  /*
1081  * In child
1082  *
1083  * Instead of using system(), exec the shell directly, and tell it to
1084  * "exec" the command too. This saves two useless processes per
1085  * parallel test case.
1086  */
1087  char *cmdline2;
1088 
1089  cmdline2 = psprintf("exec %s", cmdline);
1090  execl(shellprog, shellprog, "-c", cmdline2, (char *) NULL);
1091  fprintf(stderr, _("%s: could not exec \"%s\": %s\n"),
1092  progname, shellprog, strerror(errno));
1093  _exit(1); /* not exit() here... */
1094  }
1095  /* in parent */
1096  return pid;
1097 #else
1098  PROCESS_INFORMATION pi;
1099  char *cmdline2;
1100  HANDLE restrictedToken;
1101  const char *comspec;
1102 
1103  /* Find CMD.EXE location using COMSPEC, if it's set */
1104  comspec = getenv("COMSPEC");
1105  if (comspec == NULL)
1106  comspec = "CMD";
1107 
1108  memset(&pi, 0, sizeof(pi));
1109  cmdline2 = psprintf("\"%s\" /c \"%s\"", comspec, cmdline);
1110 
1111  if ((restrictedToken =
1112  CreateRestrictedProcess(cmdline2, &pi)) == 0)
1113  exit(2);
1114 
1115  CloseHandle(pi.hThread);
1116  return pi.hProcess;
1117 #endif
1118 }
static char * shellprog
Definition: pg_regress.c:55

References _, exit(), fflush(), fprintf, progname, psprintf(), shellprog, and strerror.

Referenced by ecpg_start_test(), isolation_start_test(), psql_start_test(), and regression_main().

◆ split_to_stringlist()

static void split_to_stringlist ( const char *  s,
const char *  delim,
_stringlist **  listhead 
)
static

Definition at line 190 of file pg_regress.c.

191 {
192  char *sc = pg_strdup(s);
193  char *token = strtok(sc, delim);
194 
195  while (token)
196  {
197  add_stringlist_item(listhead, token);
198  token = strtok(NULL, delim);
199  }
200  free(sc);
201 }

References add_stringlist_item(), free, and pg_strdup().

Referenced by regression_main().

◆ status()

static void status ( const char *  fmt,
  ... 
)
static

Definition at line 224 of file pg_regress.c.

225 {
226  va_list ap;
227 
228  va_start(ap, fmt);
229  vfprintf(stdout, fmt, ap);
230  fflush(stdout);
231  va_end(ap);
232 
233  if (logfile)
234  {
235  va_start(ap, fmt);
236  vfprintf(logfile, fmt, ap);
237  va_end(ap);
238  }
239 }
vfprintf(stderr, fmt, args)

References fflush(), fmt, logfile, generate_unaccent_rules::stdout, va_end(), va_start(), and vfprintf().

Referenced by _bt_first(), _bt_parallel_seize(), _bt_readnextpage(), _bt_steppage(), apw_start_leader_worker(), AtAbort_Portals(), AtCleanup_Portals(), AtEOSubXact_RelationCache(), AtEOXact_RelationCache(), AtPrepare_Locks(), AtSubAbort_Portals(), AtSubCleanup_Portals(), AtSubCommit_Portals(), auth_delay_checks(), auth_failed(), BackendInitialize(), BaseBackup(), be_lo_lseek(), be_lo_lseek64(), BeginReportingGUCOptions(), bf_check_supported_key_len(), buildWorkerResponse(), check_icu_locale(), check_worker_status(), CheckForSessionAndXactLocks(), ClientAuthentication(), compute_new_xmax_infomask(), ConditionalMultiXactIdWait(), dblink_get_connections(), DestroyPartitionDirectory(), do_lo_export(), do_lo_unlink(), Do_MultiXactIdWait(), DoesMultiXactIdConflict(), dshash_delete_current(), dshash_seq_init(), dshash_seq_next(), dshash_seq_term(), ecpg_process_output(), ecpg_store_result(), exec_command(), exec_command_bind(), exec_command_crosstabview(), exec_command_d(), exec_command_edit(), exec_command_ef_ev(), exec_command_g(), exec_command_gdesc(), exec_command_gexec(), exec_command_gset(), exec_command_lo(), exec_command_quit(), exec_command_sf_sv(), exec_command_write(), executeQueryOrDie(), ExecuteSqlQuery(), ExitPostmaster(), fdatasync(), FindStreamingStart(), finish_spin_delay(), forget_invalid_pages(), forget_invalid_pages_db(), ForgetPortalSnapshots(), get_collation_actual_version(), get_guc_variables(), get_prompt(), GetMultiXactIdHintBits(), HandleSlashCmds(), hash_seq_init(), hash_seq_search(), hash_seq_term(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), HoldPinnedPortals(), init_spin_delay(), InitializeGUCOptions(), InvalidateAttoptCacheCallback(), InvalidateOprCacheCallBack(), InvalidateOprProofCacheCallBack(), InvalidateShippableCacheCallback(), InvalidateTableSpaceCacheCallback(), InvalidateTSCacheCallBack(), libpqsrv_connect_internal(), ListenToWorkers(), lo_read(), lo_write(), LockReassignCurrentOwner(), LockReleaseAll(), LockReleaseCurrentOwner(), LockReleaseSession(), log_child_failure(), logicalrep_partmap_invalidate_cb(), logicalrep_partmap_reset_relmap(), logicalrep_relmap_invalidate_cb(), make_icu_collator(), mark_dump_job_done(), mark_restore_job_done(), MarkGUCPrefixReserved(), MultiXactIdCreateFromMembers(), MultiXactIdExpand(), MultiXactIdGetUpdateXid(), MultiXactIdWait(), mxid_to_string(), mxstatus_to_string(), parallel_restore(), parseServiceInfo(), parseWorkerResponse(), perform_spin_delay(), pg_backup_start(), pg_backup_stop(), pg_cryptohash_final(), pg_cryptohash_init(), pg_cryptohash_update(), pg_hmac_final(), pg_hmac_init(), pg_hmac_update(), pg_prepared_xact(), pg_xact_status(), pgrowlocks(), plperl_spi_execute_fetch_result(), PLy_spi_execute_fetch_result(), PortalErrorCleanup(), PortalHashTableDeleteAll(), PostmasterMain(), PostPrepare_Locks(), pqFunctionCall3(), pqGetline3(), PQmakeEmptyPGresult(), PQresetPoll(), PQresStatus(), PQsetClientEncoding(), PreCommit_Portals(), ProcessConfigFileInternal(), RecordNewMultiXact(), rel_sync_cache_publication_cb(), rel_sync_cache_relation_cb(), RelationCacheInitializePhase3(), RelationCacheInvalidate(), RelfilenumberMapInvalidateCallback(), restore_toc_entry(), run_reindex_command(), run_schedule(), run_single_test(), run_vacuum_command(), SendBaseBackup(), sepgsql_client_auth(), SerializeUncommittedEnums(), set_status_by_pages(), shm_mq_counterparty_gone(), shm_mq_wait_internal(), smgrcloseall(), smgrreleaseall(), StandbyReleaseAllLocks(), StandbyReleaseOldLocks(), test_config_settings(), test_lockmode_for_conflict(), test_pipelined_insert(), ThereAreNoReadyPortals(), TransactionGroupUpdateXidStatus(), TransactionIdGetStatus(), TransactionIdSetPageStatus(), TransactionIdSetPageStatusInternal(), TransactionIdSetStatusBit(), TransactionIdSetTreeStatus(), TypeCacheOpcCallback(), TypeCacheRelCallback(), TypeCacheTypCallback(), usage(), uuid_generate_internal(), varstr_abbrev_convert(), varstr_cmp(), varstrfastcmp_locale(), wait_for_postmaster_start(), wait_for_tests(), WaitForBackgroundWorkerShutdown(), WaitForBackgroundWorkerStartup(), WaitForCommands(), WaitForParallelWorkersToAttach(), WaitForParallelWorkersToExit(), WaitForReplicationWorkerAttach(), WaitForTerminatingWorkers(), worker_spi_launch(), write_relcache_init_file(), and XLogCheckInvalidPages().

◆ status_end()

static void status_end ( void  )
static

Definition at line 245 of file pg_regress.c.

246 {
247  fprintf(stdout, "\n");
248  fflush(stdout);
249  if (logfile)
250  fprintf(logfile, "\n");
251 }

References fflush(), fprintf, logfile, and generate_unaccent_rules::stdout.

Referenced by run_schedule(), and run_single_test().

◆ stop_postmaster()

static void stop_postmaster ( void  )
static

Definition at line 257 of file pg_regress.c.

258 {
259  if (postmaster_running)
260  {
261  /* We use pg_ctl to issue the kill and wait for stop */
262  char buf[MAXPGPATH * 2];
263  int r;
264 
265  snprintf(buf, sizeof(buf),
266  "\"%s%spg_ctl\" stop -D \"%s/data\" -s",
267  bindir ? bindir : "",
268  bindir ? "/" : "",
269  temp_instance);
270  fflush(NULL);
271  r = system(buf);
272  if (r != 0)
273  {
274  fprintf(stderr, _("\n%s: could not stop postmaster: exit code was %d\n"),
275  progname, r);
276  _exit(2); /* not exit(), that could be recursive */
277  }
278 
279  postmaster_running = false;
280  }
281 }

References _, bindir, buf, fflush(), fprintf, MAXPGPATH, postmaster_running, progname, snprintf, and temp_instance.

Referenced by regression_main().

◆ string_matches_pattern()

static bool string_matches_pattern ( const char *  str,
const char *  pattern 
)
static

Definition at line 371 of file pg_regress.c.

372 {
373  while (*str && *pattern)
374  {
375  if (*pattern == '.' && pattern[1] == '*')
376  {
377  pattern += 2;
378  /* Trailing .* matches everything. */
379  if (*pattern == '\0')
380  return true;
381 
382  /*
383  * Otherwise, scan for a text position at which we can match the
384  * rest of the pattern.
385  */
386  while (*str)
387  {
388  /*
389  * Optimization to prevent most recursion: don't recurse
390  * unless first pattern char might match this text char.
391  */
392  if (*str == *pattern || *pattern == '.')
393  {
394  if (string_matches_pattern(str, pattern))
395  return true;
396  }
397 
398  str++;
399  }
400 
401  /*
402  * End of text with no match.
403  */
404  return false;
405  }
406  else if (*pattern != '.' && *str != *pattern)
407  {
408  /*
409  * Not the single-character wildcard and no explicit match? Then
410  * time to quit...
411  */
412  return false;
413  }
414 
415  str++;
416  pattern++;
417  }
418 
419  if (*pattern == '\0')
420  return true; /* end of pattern, so declare match */
421 
422  /* End of input string. Do we have matching pattern remaining? */
423  while (*pattern == '.' && pattern[1] == '*')
424  pattern += 2;
425  if (*pattern == '\0')
426  return true; /* end of pattern, so declare match */
427 
428  return false;
429 }

References generate_unaccent_rules::str.

Referenced by load_resultmap().

◆ unlimit_core_size()

static void unlimit_core_size ( void  )
static

Definition at line 129 of file pg_regress.c.

130 {
131  struct rlimit lim;
132 
133  getrlimit(RLIMIT_CORE, &lim);
134  if (lim.rlim_max == 0)
135  {
136  fprintf(stderr,
137  _("%s: could not set core size: disallowed by hard limit\n"),
138  progname);
139  return;
140  }
141  else if (lim.rlim_max == RLIM_INFINITY || lim.rlim_cur < lim.rlim_max)
142  {
143  lim.rlim_cur = lim.rlim_max;
144  setrlimit(RLIMIT_CORE, &lim);
145  }
146 }

References _, fprintf, and progname.

Referenced by regression_main().

◆ wait_for_tests()

static void wait_for_tests ( PID_TYPE pids,
int *  statuses,
instr_time stoptimes,
char **  names,
int  num_tests 
)
static

Definition at line 1423 of file pg_regress.c.

1425 {
1426  int tests_left;
1427  int i;
1428 
1429 #ifdef WIN32
1430  PID_TYPE *active_pids = pg_malloc(num_tests * sizeof(PID_TYPE));
1431 
1432  memcpy(active_pids, pids, num_tests * sizeof(PID_TYPE));
1433 #endif
1434 
1435  tests_left = num_tests;
1436  while (tests_left > 0)
1437  {
1438  PID_TYPE p;
1439 
1440 #ifndef WIN32
1441  int exit_status;
1442 
1443  p = wait(&exit_status);
1444 
1445  if (p == INVALID_PID)
1446  {
1447  fprintf(stderr, _("failed to wait for subprocesses: %s\n"),
1448  strerror(errno));
1449  exit(2);
1450  }
1451 #else
1452  DWORD exit_status;
1453  int r;
1454 
1455  r = WaitForMultipleObjects(tests_left, active_pids, FALSE, INFINITE);
1456  if (r < WAIT_OBJECT_0 || r >= WAIT_OBJECT_0 + tests_left)
1457  {
1458  fprintf(stderr, _("failed to wait for subprocesses: error code %lu\n"),
1459  GetLastError());
1460  exit(2);
1461  }
1462  p = active_pids[r - WAIT_OBJECT_0];
1463  /* compact the active_pids array */
1464  active_pids[r - WAIT_OBJECT_0] = active_pids[tests_left - 1];
1465 #endif /* WIN32 */
1466 
1467  for (i = 0; i < num_tests; i++)
1468  {
1469  if (p == pids[i])
1470  {
1471 #ifdef WIN32
1472  GetExitCodeProcess(pids[i], &exit_status);
1473  CloseHandle(pids[i]);
1474 #endif
1475  pids[i] = INVALID_PID;
1476  statuses[i] = (int) exit_status;
1477  INSTR_TIME_SET_CURRENT(stoptimes[i]);
1478  if (names)
1479  status(" %s", names[i]);
1480  tests_left--;
1481  break;
1482  }
1483  }
1484  }
1485 
1486 #ifdef WIN32
1487  free(active_pids);
1488 #endif
1489 }

References _, exit(), fprintf, free, i, INSTR_TIME_SET_CURRENT, INVALID_PID, pg_malloc(), PID_TYPE, status(), and strerror.

Referenced by run_schedule(), and run_single_test().

Variable Documentation

◆ basic_diff_opts

const char* basic_diff_opts = ""

Definition at line 64 of file pg_regress.c.

Referenced by results_differ().

◆ bindir

char* bindir = PGBINDIR

Definition at line 77 of file pg_regress.c.

Referenced by psql_start_command(), psql_start_test(), regression_main(), and stop_postmaster().

◆ config_auth_datadir

char* config_auth_datadir = NULL
static

Definition at line 95 of file pg_regress.c.

Referenced by regression_main().

◆ dblist

◆ debug

bool debug = false

Definition at line 73 of file pg_regress.c.

Referenced by regression_main().

◆ difffilename

char* difffilename
static

Definition at line 101 of file pg_regress.c.

Referenced by open_result_files(), regression_main(), and results_differ().

◆ dlpath

char* dlpath = PKGLIBDIR
static

Definition at line 92 of file pg_regress.c.

Referenced by initialize_environment(), and regression_main().

◆ encoding

char* encoding = NULL
static

Definition at line 82 of file pg_regress.c.

Referenced by create_database(), initialize_environment(), and regression_main().

◆ expecteddir

char* expecteddir = "."

Definition at line 76 of file pg_regress.c.

Referenced by ecpg_start_test(), and regression_main().

◆ extra_tests

_stringlist* extra_tests = NULL
static

Definition at line 84 of file pg_regress.c.

Referenced by regression_main().

◆ extraroles

_stringlist* extraroles = NULL
static

Definition at line 94 of file pg_regress.c.

Referenced by regression_main().

◆ fail_count

int fail_count = 0
static

Definition at line 113 of file pg_regress.c.

Referenced by regression_main(), run_schedule(), and run_single_test().

◆ host_platform

char* host_platform = HOST_TUPLE

Definition at line 52 of file pg_regress.c.

Referenced by load_resultmap().

◆ hostname

char* hostname = NULL
static

◆ inputdir

◆ launcher

char* launcher = NULL

Definition at line 78 of file pg_regress.c.

Referenced by isolation_start_test(), psql_start_test(), and regression_main().

◆ loadextension

_stringlist* loadextension = NULL
static

Definition at line 79 of file pg_regress.c.

Referenced by create_database(), and regression_main().

◆ logfile

FILE* logfile
static

◆ logfilename

char* logfilename
static

Definition at line 99 of file pg_regress.c.

Referenced by open_result_files(), and regression_main().

◆ max_concurrent_tests

int max_concurrent_tests = 0
static

Definition at line 81 of file pg_regress.c.

Referenced by regression_main(), and run_schedule().

◆ max_connections

int max_connections = 0
static

Definition at line 80 of file pg_regress.c.

Referenced by regression_main(), and run_schedule().

◆ nolocale

bool nolocale = false
static

Definition at line 87 of file pg_regress.c.

Referenced by create_database(), initialize_environment(), and regression_main().

◆ outputdir

◆ port

int port = -1
static

Definition at line 90 of file pg_regress.c.

Referenced by auth_delay_checks(), auth_failed(), auth_peer(), BackendInitialize(), BackendRun(), BackendStartup(), be_gssapi_get_auth(), be_gssapi_get_enc(), be_gssapi_get_princ(), be_gssapi_read(), be_gssapi_write(), be_tls_close(), be_tls_get_cipher(), be_tls_get_cipher_bits(), be_tls_get_peer_issuer_name(), be_tls_get_peer_serial(), be_tls_get_peer_subject_name(), be_tls_get_version(), be_tls_open_server(), be_tls_read(), be_tls_write(), check_hba(), check_hostname(), CheckMD5Auth(), CheckPasswordAuth(), CheckPWChallengeAuth(), CheckRADIUSAuth(), CheckSASLAuth(), ClientAuthentication(), ConnCreate(), ConnFree(), conninfo_uri_parse_options(), do_connect(), ECPGconnect(), hba_getauthmethod(), ident_inet(), inet_client_addr(), inet_client_port(), inet_server_addr(), inet_server_port(), initialize_environment(), log_disconnections(), main(), make_temp_sockdir(), my_SSL_set_fd(), passwordFromFile(), PerformAuthentication(), PerformRadiusTransaction(), pq_getkeepalivescount(), pq_getkeepalivesidle(), pq_getkeepalivesinterval(), pq_gettcpusertimeout(), pq_setkeepalivescount(), pq_setkeepalivesidle(), pq_setkeepalivesinterval(), pq_settcpusertimeout(), process_startup_options(), ProcessStartupPacket(), read_or_wait(), regression_main(), report_fork_failure_to_client(), scram_get_mechanisms(), scram_init(), secure_close(), secure_open_gssapi(), secure_open_server(), secure_raw_read(), secure_raw_write(), secure_read(), secure_write(), sepgsql_client_auth(), ServerLoop(), set_authn_id(), and StreamConnection().

◆ port_specified_by_user

bool port_specified_by_user = false
static

Definition at line 91 of file pg_regress.c.

Referenced by regression_main().

◆ postmaster_pid

PID_TYPE postmaster_pid = INVALID_PID
static

Definition at line 109 of file pg_regress.c.

Referenced by regression_main().

◆ postmaster_running

bool postmaster_running = false
static

Definition at line 110 of file pg_regress.c.

Referenced by regression_main(), and stop_postmaster().

◆ pretty_diff_opts

const char* pretty_diff_opts = "-U3"

Definition at line 65 of file pg_regress.c.

Referenced by regression_main(), and results_differ().

◆ progname

◆ resultmap

_resultmap* resultmap = NULL
static

Definition at line 107 of file pg_regress.c.

Referenced by get_expectfile(), and load_resultmap().

◆ schedulelist

_stringlist* schedulelist = NULL
static

Definition at line 83 of file pg_regress.c.

Referenced by regression_main().

◆ shellprog

char* shellprog = SHELLPROG
static

Definition at line 55 of file pg_regress.c.

Referenced by spawn_process().

◆ sockdir

const char* sockdir
static

Definition at line 102 of file pg_regress.c.

Referenced by initialize_environment(), and regression_main().

◆ socklock

char socklock[MAXPGPATH]
static

Definition at line 105 of file pg_regress.c.

Referenced by make_temp_sockdir(), and remove_temp().

◆ sockself

char sockself[MAXPGPATH]
static

Definition at line 104 of file pg_regress.c.

Referenced by make_temp_sockdir(), and remove_temp().

◆ success_count

int success_count = 0
static

Definition at line 112 of file pg_regress.c.

Referenced by regression_main(), run_schedule(), and run_single_test().

◆ temp_configs

_stringlist* temp_configs = NULL
static

Definition at line 86 of file pg_regress.c.

Referenced by regression_main().

◆ temp_instance

char* temp_instance = NULL
static

Definition at line 85 of file pg_regress.c.

Referenced by initialize_environment(), regression_main(), and stop_postmaster().

◆ temp_sockdir

const char* temp_sockdir
static

Definition at line 103 of file pg_regress.c.

Referenced by make_temp_sockdir(), and remove_temp().

◆ use_existing

bool use_existing = false
static

Definition at line 88 of file pg_regress.c.

Referenced by regression_main().

◆ user