PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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/username.h"
#include "getopt_long.h"
#include "lib/stringinfo.h"
#include "libpq-fe.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 TESTNAME_WIDTH   36
 
#define WAIT_TICKS_PER_SECOND   20
 
#define plan(x)   emit_tap_output(PLAN, "1..%i", (x))
 
#define note(...)   emit_tap_output(NOTE, __VA_ARGS__)
 
#define note_detail(...)   emit_tap_output(NOTE_DETAIL, __VA_ARGS__)
 
#define diag(...)   emit_tap_output(DIAG, __VA_ARGS__)
 
#define diag_detail(...)   emit_tap_output(DIAG_DETAIL, __VA_ARGS__)
 
#define diag_end()   emit_tap_output(DIAG_END, "\n");
 
#define note_end()   emit_tap_output(NOTE_END, "\n");
 
#define bail_noatexit(...)   bail_out(true, __VA_ARGS__)
 
#define bail(...)   bail_out(false, __VA_ARGS__)
 
#define psql_command(database, ...)
 
#define MAX_PARALLEL_TESTS   100
 
#define ULONGPID(x)   (unsigned long) (x)
 

Typedefs

typedef struct _resultmap _resultmap
 
typedef enum TAPtype TAPtype
 

Enumerations

enum  TAPtype {
  DIAG = 0 , DIAG_DETAIL , DIAG_END , BAIL ,
  NOTE , NOTE_DETAIL , NOTE_END , TEST_STATUS ,
  PLAN , NONE
}
 

Functions

static bool directory_exists (const char *dir)
 
static void make_directory (const char *dir)
 
static void test_status_print (bool ok, const char *testname, double runtime, bool parallel)
 
static void test_status_ok (const char *testname, double runtime, bool parallel)
 
static void test_status_failed (const char *testname, double runtime, bool parallel)
 
static void bail_out (bool noatexit, const char *fmt,...) pg_attribute_printf(2
 
static void static void emit_tap_output (TAPtype type, const char *fmt,...) pg_attribute_printf(2
 
static void static void static void emit_tap_output_v (TAPtype type, const char *fmt, va_list argp) pg_attribute_printf(2
 
static void 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 stop_postmaster (void)
 
static void remove_temp (void)
 
static void signal_remove_temp (SIGNAL_ARGS)
 
static const charmake_temp_sockdir (void)
 
static bool string_matches_pattern (const char *str, const char *pattern)
 
static void load_resultmap (void)
 
static const charget_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 charget_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

charhost_platform = HOST_TUPLE
 
static charshellprog = SHELLPROG
 
const charbasic_diff_opts = ""
 
const charpretty_diff_opts = "-U3"
 
_stringlistdblist = NULL
 
bool debug = false
 
charinputdir = "."
 
charoutputdir = "."
 
charexpecteddir = "."
 
charbindir = PGBINDIR
 
charlauncher = NULL
 
static _stringlistloadextension = NULL
 
static int max_connections = 0
 
static int max_concurrent_tests = 0
 
static charencoding = NULL
 
static _stringlistschedulelist = NULL
 
static _stringlistextra_tests = NULL
 
static chartemp_instance = NULL
 
static _stringlisttemp_configs = NULL
 
static bool nolocale = false
 
static bool use_existing = false
 
static charhostname = NULL
 
static int port = -1
 
static char portstr [16]
 
static bool port_specified_by_user = false
 
static chardlpath = PKGLIBDIR
 
static charuser = NULL
 
static _stringlistextraroles = NULL
 
static charconfig_auth_datadir = NULL
 
static const charprogname
 
static charlogfilename
 
static FILElogfile
 
static chardifffilename
 
static const charsockdir
 
static const chartemp_sockdir
 
static char sockself [MAXPGPATH]
 
static char socklock [MAXPGPATH]
 
static StringInfo failed_tests = NULL
 
static bool in_note = false
 
static bool in_diag = false
 
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

◆ bail

#define bail (   ...)    bail_out(false, __VA_ARGS__)

Definition at line 172 of file pg_regress.c.

◆ bail_noatexit

#define bail_noatexit (   ...)    bail_out(true, __VA_ARGS__)

Definition at line 171 of file pg_regress.c.

◆ diag

#define diag (   ...)    emit_tap_output(DIAG, __VA_ARGS__)

Definition at line 167 of file pg_regress.c.

◆ diag_detail

#define diag_detail (   ...)    emit_tap_output(DIAG_DETAIL, __VA_ARGS__)

Definition at line 168 of file pg_regress.c.

◆ diag_end

#define diag_end ( )    emit_tap_output(DIAG_END, "\n");

Definition at line 169 of file pg_regress.c.

◆ MAX_PARALLEL_TESTS

#define MAX_PARALLEL_TESTS   100

◆ note

#define note (   ...)    emit_tap_output(NOTE, __VA_ARGS__)

Definition at line 165 of file pg_regress.c.

◆ note_detail

#define note_detail (   ...)    emit_tap_output(NOTE_DETAIL, __VA_ARGS__)

Definition at line 166 of file pg_regress.c.

◆ note_end

#define note_end ( )    emit_tap_output(NOTE_END, "\n");

Definition at line 170 of file pg_regress.c.

◆ plan

#define plan (   x)    emit_tap_output(PLAN, "1..%i", (x))

Definition at line 164 of file pg_regress.c.

◆ psql_command

#define psql_command (   database,
  ... 
)
Value:
do { \
} while (0)
static void static void static void static StringInfo psql_start_command(void)
static int fb(int x)

Definition at line 1202 of file pg_regress.c.

1203 { \
1206 psql_end_command(cmdbuf, database); \
1207 } while (0)

◆ TESTNAME_WIDTH

#define TESTNAME_WIDTH   36

Definition at line 76 of file pg_regress.c.

◆ ULONGPID

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

◆ WAIT_TICKS_PER_SECOND

#define WAIT_TICKS_PER_SECOND   20

Definition at line 82 of file pg_regress.c.

Typedef Documentation

◆ _resultmap

◆ TAPtype

Enumeration Type Documentation

◆ TAPtype

Enumerator
DIAG 
DIAG_DETAIL 
DIAG_END 
BAIL 
NOTE 
NOTE_DETAIL 
NOTE_END 
TEST_STATUS 
PLAN 
NONE 

Definition at line 84 of file pg_regress.c.

85{
86 DIAG = 0,
89 BAIL,
90 NOTE,
94 PLAN,
95 NONE,
96} TAPtype;
TAPtype
Definition pg_regress.c:85
@ PLAN
Definition pg_regress.c:94
@ NOTE
Definition pg_regress.c:90
@ DIAG
Definition pg_regress.c:86
@ NOTE_DETAIL
Definition pg_regress.c:91
@ DIAG_END
Definition pg_regress.c:88
@ NONE
Definition pg_regress.c:95
@ TEST_STATUS
Definition pg_regress.c:93
@ BAIL
Definition pg_regress.c:89
@ NOTE_END
Definition pg_regress.c:92
@ DIAG_DETAIL
Definition pg_regress.c:87

Function Documentation

◆ add_stringlist_item()

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

Definition at line 202 of file pg_regress.c.

203{
206
208 newentry->next = NULL;
209 if (*listhead == NULL)
211 else
212 {
213 for (oldentry = *listhead; oldentry->next; oldentry = oldentry->next)
214 /* skip */ ;
215 oldentry->next = newentry;
216 }
217}
char * pg_strdup(const char *in)
Definition fe_memutils.c:91
#define pg_malloc_object(type)
Definition fe_memutils.h:60
const char * str
char * str
Definition initdb.c:92

References fb(), pg_malloc_object, pg_strdup(), _stringlist::str, and str.

Referenced by regression_main(), and split_to_stringlist().

◆ bail_out()

static void bail_out ( bool  noatexit,
const char fmt,
  ... 
)
static

Definition at line 260 of file pg_regress.c.

261{
262 va_list ap;
263
264 va_start(ap, fmt);
266 va_end(ap);
267
268 if (noatexit)
269 _exit(2);
270
271 exit(2);
272}
static void static void static void emit_tap_output_v(TAPtype type, const char *fmt, va_list argp) pg_attribute_printf(2
Definition pg_regress.c:346

References BAIL, emit_tap_output_v(), and fb().

Referenced by ProcessConfigFileInternal().

◆ create_database()

static void create_database ( const char dbname)
static

Definition at line 2033 of file pg_regress.c.

2034{
2036 _stringlist *sl;
2037
2038 /*
2039 * We use template0 so that any installation-local cruft in template1 will
2040 * not mess up the tests.
2041 */
2042 if (encoding)
2043 psql_add_command(buf, "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'%s", dbname, encoding,
2044 (nolocale) ? " LOCALE='C' LOCALE_PROVIDER='builtin'" : "");
2045 else
2046 psql_add_command(buf, "CREATE DATABASE \"%s\" TEMPLATE=template0%s", dbname,
2047 (nolocale) ? " LOCALE='C' LOCALE_PROVIDER='builtin'" : "");
2049 "ALTER DATABASE \"%s\" SET lc_messages TO 'C';"
2050 "ALTER DATABASE \"%s\" SET lc_monetary TO 'C';"
2051 "ALTER DATABASE \"%s\" SET lc_numeric TO 'C';"
2052 "ALTER DATABASE \"%s\" SET lc_time TO 'C';"
2053 "ALTER DATABASE \"%s\" SET bytea_output TO 'hex';"
2054 "ALTER DATABASE \"%s\" SET timezone_abbreviations TO 'Default';",
2056 psql_end_command(buf, "postgres");
2057
2058 /*
2059 * Install any requested extensions. We use CREATE IF NOT EXISTS so that
2060 * this will work whether or not the extension is preinstalled.
2061 */
2062 for (sl = loadextension; sl != NULL; sl = sl->next)
2063 psql_command(dbname, "CREATE EXTENSION IF NOT EXISTS \"%s\"", sl->str);
2064}
static bool nolocale
Definition pg_regress.c:114
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 _stringlist * loadextension
Definition pg_regress.c:106
static char * encoding
Definition pg_regress.c:109
#define psql_command(database,...)
static char buf[DEFAULT_XLOG_SEG_SIZE]
char * dbname
Definition streamutil.c:49
struct _stringlist * next
Definition initdb.c:93

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

Referenced by regression_main().

◆ create_role()

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

Definition at line 2078 of file pg_regress.c.

2079{
2081
2082 psql_add_command(buf, "CREATE ROLE \"%s\" WITH LOGIN", rolename);
2083 for (; granted_dbs != NULL; granted_dbs = granted_dbs->next)
2084 {
2085 psql_add_command(buf, "GRANT ALL ON DATABASE \"%s\" TO \"%s\"",
2086 granted_dbs->str, rolename);
2087 }
2088 psql_end_command(buf, "postgres");
2089}

References buf, fb(), psql_add_command(), psql_end_command(), and psql_start_command().

Referenced by regression_main().

◆ directory_exists()

static bool directory_exists ( const char dir)
static

Definition at line 1329 of file pg_regress.c.

1330{
1331 struct stat st;
1332
1333 if (stat(dir, &st) != 0)
1334 return false;
1335 if (S_ISDIR(st.st_mode))
1336 return true;
1337 return false;
1338}
#define stat
Definition win32_port.h:74
#define S_ISDIR(m)
Definition win32_port.h:315

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 2022 of file pg_regress.c.

2023{
2025
2026 /* Set warning level so we don't see chatter about nonexistent DB */
2027 psql_add_command(buf, "SET client_min_messages = warning");
2028 psql_add_command(buf, "DROP DATABASE IF EXISTS \"%s\"", dbname);
2029 psql_end_command(buf, "postgres");
2030}

References buf, dbname, 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 2067 of file pg_regress.c.

2068{
2070
2071 /* Set warning level so we don't see chatter about nonexistent role */
2072 psql_add_command(buf, "SET client_min_messages = warning");
2073 psql_add_command(buf, "DROP ROLE IF EXISTS \"%s\"", rolename);
2074 psql_end_command(buf, "postgres");
2075}

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

Referenced by regression_main().

◆ emit_tap_output()

static void emit_tap_output ( TAPtype  type,
const char fmt,
  ... 
)
static

Definition at line 336 of file pg_regress.c.

337{
339
340 va_start(argp, fmt);
342 va_end(argp);
343}
const char * type

References emit_tap_output_v(), fb(), and type.

Referenced by test_status_print().

◆ emit_tap_output_v()

static void emit_tap_output_v ( TAPtype  type,
const char fmt,
va_list  argp 
)
static

Definition at line 346 of file pg_regress.c.

347{
349 FILE *fp;
350 int save_errno;
351
352 /*
353 * The fprintf() calls used to output TAP-protocol elements might clobber
354 * errno, so save it here and restore it before vfprintf()-ing the user's
355 * format string, in case it contains %m placeholders.
356 */
358
359 /*
360 * Diagnostic output will be hidden by prove unless printed to stderr. The
361 * Bail message is also printed to stderr to aid debugging under a harness
362 * which might otherwise not emit such an important message.
363 */
364 if (type == DIAG || type == DIAG_DETAIL || type == DIAG_END || type == BAIL)
365 fp = stderr;
366 else
367 fp = stdout;
368
369 /*
370 * If we are ending a note_detail line we can avoid further processing and
371 * immediately return following a newline.
372 */
373 if (type == NOTE_END || type == DIAG_END)
374 {
375 if (type == NOTE_END)
376 in_note = false;
377 else
378 in_diag = false;
379 fprintf(fp, "\n");
380 if (logfile)
381 fprintf(logfile, "\n");
382 return;
383 }
384
385 /* Make a copy of the va args for printing to the logfile */
387
388 /*
389 * Non-protocol output such as diagnostics or notes must be prefixed by a
390 * '#' character. We print the Bail message like this too.
391 */
392 if ((type == NOTE || type == DIAG || type == BAIL)
393 || (type == NOTE_DETAIL && !in_note)
394 || (type == DIAG_DETAIL && !in_diag))
395 {
396 fprintf(fp, "# ");
397 if (logfile)
398 fprintf(logfile, "# ");
399 }
401 vfprintf(fp, fmt, argp);
402 if (logfile)
403 {
406 }
407
408 /*
409 * If we are entering into a note with more details to follow, register
410 * that the leading '#' has been printed such that subsequent details
411 * aren't prefixed as well.
412 */
413 if (type == NOTE_DETAIL)
414 in_note = true;
415 if (type == DIAG_DETAIL)
416 in_diag = true;
417
418 /*
419 * If this was a Bail message, the bail protocol message must go to stdout
420 * separately.
421 */
422 if (type == BAIL)
423 {
424 fprintf(stdout, "Bail out!");
425 if (logfile)
426 fprintf(logfile, "Bail out!");
427 }
428
430
431 if (type != NOTE_DETAIL && type != DIAG_DETAIL)
432 {
433 fprintf(fp, "\n");
434 if (logfile)
435 fprintf(logfile, "\n");
436 }
437 fflush(NULL);
438}
#define fprintf(file, fmt, msg)
Definition cubescan.l:21
static bool in_note
Definition pg_regress.c:135
static bool in_diag
Definition pg_regress.c:136
static FILE * logfile
Definition pg_regress.c:128
#define vfprintf
Definition port.h:264

References BAIL, DIAG, DIAG_DETAIL, DIAG_END, fb(), fprintf, in_diag, in_note, logfile, NOTE, NOTE_DETAIL, NOTE_END, type, and vfprintf.

Referenced by bail_out(), and emit_tap_output().

◆ file_exists()

bool file_exists ( const char file)

Definition at line 1318 of file pg_regress.c.

1319{
1320 FILE *f = fopen(file, "r");
1321
1322 if (!f)
1323 return false;
1324 fclose(f);
1325 return true;
1326}

References fb().

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

◆ file_line_count()

static int file_line_count ( const char file)
static

Definition at line 1297 of file pg_regress.c.

1298{
1299 int c;
1300 int l = 0;
1301 FILE *f = fopen(file, "r");
1302
1303 if (!f)
1304 {
1305 diag("could not open file \"%s\" for reading: %m", file);
1306 return -1;
1307 }
1308 while ((c = fgetc(f)) != EOF)
1309 {
1310 if (c == '\n')
1311 l++;
1312 }
1313 fclose(f);
1314 return l;
1315}
#define diag(...)
Definition pg_regress.c:167
char * c

References diag, and fb().

Referenced by results_differ().

◆ file_size()

static long file_size ( const char file)
static

Definition at line 1277 of file pg_regress.c.

1278{
1279 long r;
1280 FILE *f = fopen(file, "r");
1281
1282 if (!f)
1283 {
1284 diag("could not open file \"%s\" for reading: %m", file);
1285 return -1;
1286 }
1287 fseek(f, 0, SEEK_END);
1288 r = ftell(f);
1289 fclose(f);
1290 return r;
1291}

References diag, and fb().

Referenced by regression_main(), and run_diff().

◆ free_stringlist()

static void free_stringlist ( _stringlist **  listhead)
static

Definition at line 223 of file pg_regress.c.

224{
225 if (listhead == NULL || *listhead == NULL)
226 return;
227 if ((*listhead)->next != NULL)
228 free_stringlist(&((*listhead)->next));
229 free((*listhead)->str);
230 free(*listhead);
231 *listhead = NULL;
232}
static void free_stringlist(_stringlist **listhead)
Definition pg_regress.c:223
#define free(a)

References fb(), free, and free_stringlist().

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

◆ get_alternative_expectfile()

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

Definition at line 1352 of file pg_regress.c.

1353{
1354 char *last_dot;
1355 int ssize = strlen(expectfile) + 2 + 1;
1356 char *tmp;
1357 char *s;
1358
1359 if (!(tmp = (char *) malloc(ssize)))
1360 return NULL;
1361
1362 if (!(s = (char *) malloc(ssize)))
1363 {
1364 free(tmp);
1365 return NULL;
1366 }
1367
1368 strcpy(tmp, expectfile);
1369 last_dot = strrchr(tmp, '.');
1370 if (!last_dot)
1371 {
1372 free(tmp);
1373 free(s);
1374 return NULL;
1375 }
1376 *last_dot = '\0';
1377 snprintf(s, ssize, "%s_%d.%s", tmp, i, last_dot + 1);
1378 free(tmp);
1379 return s;
1380}
int i
Definition isn.c:77
#define snprintf
Definition port.h:261
#define malloc(a)

References fb(), 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 705 of file pg_regress.c.

706{
707 const char *file_type;
708 _resultmap *rm;
709
710 /*
711 * Determine the file type from the file name. This is just what is
712 * following the last dot in the file name.
713 */
714 if (!file || !(file_type = strrchr(file, '.')))
715 return NULL;
716
717 file_type++;
718
719 for (rm = resultmap; rm != NULL; rm = rm->next)
720 {
721 if (strcmp(testname, rm->test) == 0 && strcmp(file_type, rm->type) == 0)
722 {
723 return rm->resultfile;
724 }
725 }
726
727 return NULL;
728}
static _resultmap * resultmap
Definition pg_regress.c:138
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 fb(), _resultmap::next, _resultmap::resultfile, resultmap, _resultmap::test, and _resultmap::type.

Referenced by results_differ().

◆ help()

static void help ( void  )
static

Definition at line 2092 of file pg_regress.c.

2093{
2094 printf(_("PostgreSQL regression test driver\n"));
2095 printf(_("\n"));
2096 printf(_("Usage:\n %s [OPTION]... [EXTRA-TEST]...\n"), progname);
2097 printf(_("\n"));
2098 printf(_("Options:\n"));
2099 printf(_(" --bindir=BINPATH use BINPATH for programs that are run;\n"));
2100 printf(_(" if empty, use PATH from the environment\n"));
2101 printf(_(" --config-auth=DATADIR update authentication settings for DATADIR\n"));
2102 printf(_(" --create-role=ROLE create the specified role before testing\n"));
2103 printf(_(" --dbname=DB use database DB (default \"regression\")\n"));
2104 printf(_(" --debug turn on debug mode in programs that are run\n"));
2105 printf(_(" --dlpath=DIR look for dynamic libraries in DIR\n"));
2106 printf(_(" --encoding=ENCODING use ENCODING as the encoding\n"));
2107 printf(_(" --expecteddir=DIR take expected files from DIR (default \".\")\n"));
2108 printf(_(" -h, --help show this help, then exit\n"));
2109 printf(_(" --inputdir=DIR take input files from DIR (default \".\")\n"));
2110 printf(_(" --launcher=CMD use CMD as launcher of psql\n"));
2111 printf(_(" --load-extension=EXT load the named extension before running the\n"));
2112 printf(_(" tests; can appear multiple times\n"));
2113 printf(_(" --max-connections=N maximum number of concurrent connections\n"));
2114 printf(_(" (default is 0, meaning unlimited)\n"));
2115 printf(_(" --max-concurrent-tests=N maximum number of concurrent tests in schedule\n"));
2116 printf(_(" (default is 0, meaning unlimited)\n"));
2117 printf(_(" --outputdir=DIR place output files in DIR (default \".\")\n"));
2118 printf(_(" --schedule=FILE use test ordering schedule from FILE\n"));
2119 printf(_(" (can be used multiple times to concatenate)\n"));
2120 printf(_(" --temp-instance=DIR create a temporary instance in DIR\n"));
2121 printf(_(" --use-existing use an existing installation\n"));
2122 printf(_(" -V, --version output version information, then exit\n"));
2123 printf(_("\n"));
2124 printf(_("Options for \"temp-instance\" mode:\n"));
2125 printf(_(" --no-locale use C locale\n"));
2126 printf(_(" --port=PORT start postmaster on PORT\n"));
2127 printf(_(" --temp-config=FILE append contents of FILE to temporary config\n"));
2128 printf(_("\n"));
2129 printf(_("Options for using an existing installation:\n"));
2130 printf(_(" --host=HOST use postmaster running on HOST\n"));
2131 printf(_(" --port=PORT use postmaster running at PORT\n"));
2132 printf(_(" --user=USER connect as USER\n"));
2133 printf(_("\n"));
2134 printf(_("The exit status is 0 if all tests passed, 1 if some tests failed, and 2\n"));
2135 printf(_("if the tests could not be run for some reason.\n"));
2136 printf(_("\n"));
2137 printf(_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
2138 printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
2139}
#define _(x)
Definition elog.c:96
static const char * progname
Definition pg_regress.c:126
#define printf(...)
Definition port.h:267

References _, fb(), printf, and progname.

Referenced by regression_main().

◆ initialize_environment()

static void initialize_environment ( void  )
static

Definition at line 734 of file pg_regress.c.

735{
736 /*
737 * Set default application_name. (The test_start_function may choose to
738 * override this, but if it doesn't, we have something useful in place.)
739 */
740 setenv("PGAPPNAME", "pg_regress", 1);
741
742 /*
743 * Set variables that the test scripts may need to refer to.
744 */
745 setenv("PG_ABS_SRCDIR", inputdir, 1);
746 setenv("PG_ABS_BUILDDIR", outputdir, 1);
747 setenv("PG_LIBDIR", dlpath, 1);
748 setenv("PG_DLSUFFIX", DLSUFFIX, 1);
749
750 if (nolocale)
751 {
752 /*
753 * Clear out any non-C locale settings
754 */
755 unsetenv("LC_COLLATE");
756 unsetenv("LC_CTYPE");
757 unsetenv("LC_MONETARY");
758 unsetenv("LC_NUMERIC");
759 unsetenv("LC_TIME");
760 unsetenv("LANG");
761
762 /*
763 * Most platforms have adopted the POSIX locale as their
764 * implementation-defined default locale. Exceptions include native
765 * Windows, macOS with --enable-nls, and Cygwin with --enable-nls.
766 * (Use of --enable-nls matters because libintl replaces setlocale().)
767 * Also, PostgreSQL does not support macOS with locale environment
768 * variables unset; see PostmasterMain().
769 */
770#if defined(WIN32) || defined(__CYGWIN__) || defined(__darwin__)
771 setenv("LANG", "C", 1);
772#endif
773 }
774
775 /*
776 * Set translation-related settings to English; otherwise psql will
777 * produce translated messages and produce diffs. (XXX If we ever support
778 * translation of pg_regress, this needs to be moved elsewhere, where psql
779 * is actually called.)
780 */
781 unsetenv("LANGUAGE");
782 unsetenv("LC_ALL");
783 setenv("LC_MESSAGES", "C", 1);
784
785 /*
786 * Set encoding as requested
787 */
788 if (encoding)
789 setenv("PGCLIENTENCODING", encoding, 1);
790 else
791 unsetenv("PGCLIENTENCODING");
792
793 /*
794 * Set timezone and datestyle for datetime-related tests
795 */
796 setenv("PGTZ", "America/Los_Angeles", 1);
797 setenv("PGDATESTYLE", "Postgres, MDY", 1);
798
799 /*
800 * Likewise set intervalstyle to ensure consistent results. This is a bit
801 * more painful because we must use PGOPTIONS, and we want to preserve the
802 * user's ability to set other variables through that.
803 */
804 {
805 const char *my_pgoptions = "-c intervalstyle=postgres_verbose";
806 const char *old_pgoptions = getenv("PGOPTIONS");
807 char *new_pgoptions;
808
809 if (!old_pgoptions)
810 old_pgoptions = "";
811 new_pgoptions = psprintf("%s %s",
813 setenv("PGOPTIONS", new_pgoptions, 1);
815 }
816
817 if (temp_instance)
818 {
819 /*
820 * Clear out any environment vars that might cause psql to connect to
821 * the wrong postmaster, or otherwise behave in nondefault ways. (Note
822 * we also use psql's -X switch consistently, so that ~/.psqlrc files
823 * won't mess things up.) Also, set PGPORT to the temp port, and set
824 * PGHOST depending on whether we are using TCP or Unix sockets.
825 *
826 * This list should be kept in sync with PostgreSQL/Test/Utils.pm.
827 */
828 unsetenv("PGCHANNELBINDING");
829 /* PGCLIENTENCODING, see above */
830 unsetenv("PGCONNECT_TIMEOUT");
831 unsetenv("PGDATA");
832 unsetenv("PGDATABASE");
833 unsetenv("PGGSSDELEGATION");
834 unsetenv("PGGSSENCMODE");
835 unsetenv("PGGSSLIB");
836 /* PGHOSTADDR, see below */
837 unsetenv("PGKRBSRVNAME");
838 unsetenv("PGPASSFILE");
839 unsetenv("PGPASSWORD");
840 unsetenv("PGREQUIREPEER");
841 unsetenv("PGREQUIRESSL");
842 unsetenv("PGSERVICE");
843 unsetenv("PGSERVICEFILE");
844 unsetenv("PGSSLCERT");
845 unsetenv("PGSSLCRL");
846 unsetenv("PGSSLCRLDIR");
847 unsetenv("PGSSLKEY");
848 unsetenv("PGSSLMAXPROTOCOLVERSION");
849 unsetenv("PGSSLMINPROTOCOLVERSION");
850 unsetenv("PGSSLMODE");
851 unsetenv("PGSSLROOTCERT");
852 unsetenv("PGSSLSNI");
853 unsetenv("PGTARGETSESSIONATTRS");
854 unsetenv("PGUSER");
855 /* PGPORT, see below */
856 /* PGHOST, see below */
857
858 if (hostname != NULL)
859 setenv("PGHOST", hostname, 1);
860 else
861 {
862 sockdir = getenv("PG_REGRESS_SOCK_DIR");
863 if (!sockdir)
865 setenv("PGHOST", sockdir, 1);
866 }
867 unsetenv("PGHOSTADDR");
868 if (port != -1)
869 {
870 char s[16];
871
872 snprintf(s, sizeof(s), "%d", port);
873 setenv("PGPORT", s, 1);
874 }
875 }
876 else
877 {
878 const char *pghost;
879 const char *pgport;
880
881 /*
882 * When testing an existing install, we honor existing environment
883 * variables, except if they're overridden by command line options.
884 */
885 if (hostname != NULL)
886 {
887 setenv("PGHOST", hostname, 1);
888 unsetenv("PGHOSTADDR");
889 }
890 if (port != -1)
891 {
892 char s[16];
893
894 snprintf(s, sizeof(s), "%d", port);
895 setenv("PGPORT", s, 1);
896 }
897 if (user != NULL)
898 setenv("PGUSER", user, 1);
899
900 /*
901 * However, we *don't* honor PGDATABASE, since we certainly don't wish
902 * to connect to whatever database the user might like as default.
903 * (Most tests override PGDATABASE anyway, but there are some ECPG
904 * test cases that don't.)
905 */
906 unsetenv("PGDATABASE");
907
908 /*
909 * Report what we're connecting to
910 */
911 pghost = getenv("PGHOST");
912 pgport = getenv("PGPORT");
913 if (!pghost)
914 {
915 /* Keep this bit in sync with libpq's default host location: */
917 /* do nothing, we'll print "Unix socket" below */ ;
918 else
919 pghost = "localhost"; /* DefaultHost in fe-connect.c */
920 }
921
922 if (pghost && pgport)
923 note("using postmaster on %s, port %s", pghost, pgport);
924 if (pghost && !pgport)
925 note("using postmaster on %s, default port", pghost);
926 if (!pghost && pgport)
927 note("using postmaster on Unix socket, port %s", pgport);
928 if (!pghost && !pgport)
929 note("using postmaster on Unix socket, default port");
930 }
931
933}
#define DEFAULT_PGSOCKET_DIR
static char * user
Definition pg_regress.c:121
static void load_resultmap(void)
Definition pg_regress.c:631
static int port
Definition pg_regress.c:117
char * outputdir
Definition pg_regress.c:102
#define note(...)
Definition pg_regress.c:165
char * inputdir
Definition pg_regress.c:101
static const char * make_temp_sockdir(void)
Definition pg_regress.c:512
static char * temp_instance
Definition pg_regress.c:112
static const char * sockdir
Definition pg_regress.c:130
static char * dlpath
Definition pg_regress.c:120
static char * hostname
Definition pg_regress.c:116
static const char * pghost
Definition pgbench.c:295
static const char * pgport
Definition pgbench.c:296
char * psprintf(const char *fmt,...)
Definition psprintf.c:43
#define unsetenv(x)
Definition win32_port.h:543
#define setenv(x, y, z)
Definition win32_port.h:542

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

Referenced by regression_main().

◆ load_resultmap()

static void load_resultmap ( void  )
static

Definition at line 631 of file pg_regress.c.

632{
633 char buf[MAXPGPATH];
634 FILE *f;
635
636 /* scan the file ... */
637 snprintf(buf, sizeof(buf), "%s/resultmap", inputdir);
638 f = fopen(buf, "r");
639 if (!f)
640 {
641 /* OK if it doesn't exist, else complain */
642 if (errno == ENOENT)
643 return;
644 bail("could not open file \"%s\" for reading: %m", buf);
645 }
646
647 while (fgets(buf, sizeof(buf), f))
648 {
649 char *platform;
650 char *file_type;
651 char *expected;
652 int i;
653
654 /* strip trailing whitespace, especially the newline */
655 i = strlen(buf);
656 while (i > 0 && isspace((unsigned char) buf[i - 1]))
657 buf[--i] = '\0';
658
659 /* parse out the line fields */
660 file_type = strchr(buf, ':');
661 if (!file_type)
662 {
663 bail("incorrectly formatted resultmap entry: %s", buf);
664 }
665 *file_type++ = '\0';
666
667 platform = strchr(file_type, ':');
668 if (!platform)
669 {
670 bail("incorrectly formatted resultmap entry: %s", buf);
671 }
672 *platform++ = '\0';
673 expected = strchr(platform, '=');
674 if (!expected)
675 {
676 bail("incorrectly formatted resultmap entry: %s", buf);
677 }
678 *expected++ = '\0';
679
680 /*
681 * if it's for current platform, save it in resultmap list. Note: by
682 * adding at the front of the list, we ensure that in ambiguous cases,
683 * the last match in the resultmap file is used. This mimics the
684 * behavior of the old shell script.
685 */
687 {
689
690 entry->test = pg_strdup(buf);
691 entry->type = pg_strdup(file_type);
692 entry->resultfile = pg_strdup(expected);
693 entry->next = resultmap;
694 resultmap = entry;
695 }
696 }
697 fclose(f);
698}
#define MAXPGPATH
char * host_platform
Definition pg_regress.c:52
#define bail(...)
Definition pg_regress.c:172
static bool string_matches_pattern(const char *str, const char *pattern)
Definition pg_regress.c:557

References bail, buf, fb(), host_platform, i, inputdir, MAXPGPATH, _resultmap::next, pg_malloc_object, pg_strdup(), _resultmap::resultfile, resultmap, snprintf, 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 1693 of file pg_regress.c.

1694{
1695 if (WIFEXITED(exitstatus))
1696 diag("(test process exited with exit code %d)",
1698 else if (WIFSIGNALED(exitstatus))
1699 {
1700#if defined(WIN32)
1701 diag("(test process was terminated by exception 0x%X)",
1703#else
1704 diag("(test process was terminated by signal %d: %s)",
1706#endif
1707 }
1708 else
1709 diag("(test process exited with unrecognized status %d)", exitstatus);
1710}
const char * pg_strsignal(int signum)
Definition pgstrsignal.c:39
#define WIFEXITED(w)
Definition win32_port.h:150
#define WIFSIGNALED(w)
Definition win32_port.h:151
#define WTERMSIG(w)
Definition win32_port.h:153
#define WEXITSTATUS(w)
Definition win32_port.h:152

References diag, fb(), pg_strsignal(), 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 1342 of file pg_regress.c.

1343{
1344 if (mkdir(dir, S_IRWXU | S_IRWXG | S_IRWXO) < 0)
1345 bail("could not create directory \"%s\": %m", dir);
1346}
#define S_IRWXG
Definition win32_port.h:300
#define S_IRWXO
Definition win32_port.h:312
#define mkdir(a, b)
Definition win32_port.h:80
#define S_IRWXU
Definition win32_port.h:288

References bail, mkdir, S_IRWXG, S_IRWXO, and S_IRWXU.

Referenced by open_result_files(), and regression_main().

◆ make_temp_sockdir()

static const char * make_temp_sockdir ( void  )
static

Definition at line 512 of file pg_regress.c.

513{
514 char *template = psprintf("%s/pg_regress-XXXXXX",
515 getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp");
516
517 temp_sockdir = mkdtemp(template);
518 if (temp_sockdir == NULL)
519 bail("could not create directory \"%s\": %m", template);
520
521 /* Stage file names for remove_temp(). Unsafe in a signal handler. */
523 snprintf(socklock, sizeof(socklock), "%s.lock", sockself);
524
525 /* Remove the directory during clean exit. */
527
528 /*
529 * Remove the directory before dying to the usual signals. Omit SIGQUIT,
530 * preserving it as a quick, untidy exit.
531 */
534
535 /* the following are not valid on Windows */
536#ifndef WIN32
539#endif
540
541 return temp_sockdir;
542}
static void signal_remove_temp(SIGNAL_ARGS)
Definition pg_regress.c:491
static void remove_temp(void)
Definition pg_regress.c:479
static const char * temp_sockdir
Definition pg_regress.c:131
static char sockself[MAXPGPATH]
Definition pg_regress.c:132
static char socklock[MAXPGPATH]
Definition pg_regress.c:133
#define pqsignal
Definition port.h:548
char * mkdtemp(char *path)
Definition mkdtemp.c:286
#define UNIXSOCK_PATH(path, port, sockdir)
Definition pqcomm.h:43
#define SIGHUP
Definition win32_port.h:158
#define SIGPIPE
Definition win32_port.h:163

References bail, fb(), mkdtemp(), port, pqsignal, psprintf(), remove_temp(), SIGHUP, signal_remove_temp(), SIGPIPE, snprintf, socklock, sockself, temp_sockdir, and UNIXSOCK_PATH.

Referenced by initialize_environment().

◆ open_result_files()

static void open_result_files ( void  )
static

Definition at line 1989 of file pg_regress.c.

1990{
1991 char file[MAXPGPATH];
1992 FILE *difffile;
1993
1994 /* create outputdir directory if not present */
1997
1998 /* create the log file (copy of running status output) */
1999 snprintf(file, sizeof(file), "%s/regression.out", outputdir);
2000 logfilename = pg_strdup(file);
2001 logfile = fopen(logfilename, "w");
2002 if (!logfile)
2003 bail("could not open file \"%s\" for writing: %m", logfilename);
2004
2005 /* create the diffs file as empty */
2006 snprintf(file, sizeof(file), "%s/regression.diffs", outputdir);
2007 difffilename = pg_strdup(file);
2008 difffile = fopen(difffilename, "w");
2009 if (!difffile)
2010 bail("could not open file \"%s\" for writing: %m", difffilename);
2011
2012 /* we don't keep the diffs file open continuously */
2014
2015 /* also create the results directory if not present */
2016 snprintf(file, sizeof(file), "%s/results", outputdir);
2017 if (!directory_exists(file))
2018 make_directory(file);
2019}
static bool directory_exists(const char *dir)
static char * logfilename
Definition pg_regress.c:127
static void make_directory(const char *dir)
static char * difffilename
Definition pg_regress.c:129

References bail, difffilename, directory_exists(), fb(), logfile, logfilename, make_directory(), MAXPGPATH, outputdir, pg_strdup(), and snprintf.

Referenced by regression_main().

◆ psql_add_command()

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

Definition at line 1143 of file pg_regress.c.

1144{
1146 const char *cmdptr;
1147
1148 /* Add each command as a -c argument in the psql call */
1149 appendStringInfoString(buf, " -c \"");
1150
1151 /* Generate the query with insertion of sprintf arguments */
1153 for (;;)
1154 {
1155 va_list args;
1156 int needed;
1157
1158 va_start(args, query);
1159 needed = appendStringInfoVA(&cmdbuf, query, args);
1160 va_end(args);
1161 if (needed == 0)
1162 break; /* success */
1164 }
1165
1166 /* Now escape any shell double-quote metacharacters */
1167 for (cmdptr = cmdbuf.data; *cmdptr; cmdptr++)
1168 {
1169 if (strchr("\\\"$`", *cmdptr))
1172 }
1173
1175
1176 pfree(cmdbuf.data);
1177}
void pfree(void *pointer)
Definition mcxt.c:1619
int appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
Definition stringinfo.c:187
void enlargeStringInfo(StringInfo str, int needed)
Definition stringinfo.c:337
void appendStringInfoString(StringInfo str, const char *s)
Definition stringinfo.c:230
void appendStringInfoChar(StringInfo str, char ch)
Definition stringinfo.c:242
void initStringInfo(StringInfo str)
Definition stringinfo.c:97

References appendStringInfoChar(), appendStringInfoString(), appendStringInfoVA(), buf, enlargeStringInfo(), fb(), initStringInfo(), and pfree().

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 1180 of file pg_regress.c.

1181{
1182 /* Add the database name --- assume it needs no extra escaping */
1184 " \"%s\"",
1185 database);
1186
1187 /* And now we can execute the shell command */
1188 fflush(NULL);
1189 if (system(buf->data) != 0)
1190 {
1191 /* psql probably already reported the error */
1192 bail("command failed: %s", buf->data);
1193 }
1194
1195 /* Clean up */
1197}
void destroyStringInfo(StringInfo str)
Definition stringinfo.c:409
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition stringinfo.c:145

References appendStringInfo(), bail, buf, destroyStringInfo(), and fb().

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 1131 of file pg_regress.c.

1132{
1134
1136 "\"%s%spsql\" -X -q",
1137 bindir ? bindir : "",
1138 bindir ? "/" : "");
1139 return buf;
1140}
char * bindir
Definition pg_regress.c:104
StringInfo makeStringInfo(void)
Definition stringinfo.c:72

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 2142 of file pg_regress.c.

2146{
2147 static struct option long_options[] = {
2148 {"help", no_argument, NULL, 'h'},
2149 {"version", no_argument, NULL, 'V'},
2150 {"dbname", required_argument, NULL, 1},
2151 {"debug", no_argument, NULL, 2},
2152 {"inputdir", required_argument, NULL, 3},
2153 {"max-connections", required_argument, NULL, 5},
2154 {"encoding", required_argument, NULL, 6},
2155 {"outputdir", required_argument, NULL, 7},
2156 {"schedule", required_argument, NULL, 8},
2157 {"temp-instance", required_argument, NULL, 9},
2158 {"no-locale", no_argument, NULL, 10},
2159 {"host", required_argument, NULL, 13},
2160 {"port", required_argument, NULL, 14},
2161 {"user", required_argument, NULL, 15},
2162 {"bindir", required_argument, NULL, 16},
2163 {"dlpath", required_argument, NULL, 17},
2164 {"create-role", required_argument, NULL, 18},
2165 {"temp-config", required_argument, NULL, 19},
2166 {"use-existing", no_argument, NULL, 20},
2167 {"launcher", required_argument, NULL, 21},
2168 {"load-extension", required_argument, NULL, 22},
2169 {"config-auth", required_argument, NULL, 24},
2170 {"max-concurrent-tests", required_argument, NULL, 25},
2171 {"expecteddir", required_argument, NULL, 26},
2172 {NULL, 0, NULL, 0}
2173 };
2174
2175 bool use_unix_sockets;
2176 _stringlist *sl;
2177 int c;
2178 int i;
2179 int option_index;
2180 char buf[MAXPGPATH * 4];
2181
2182 pg_logging_init(argv[0]);
2183 progname = get_progname(argv[0]);
2184 set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_regress"));
2185
2187
2189
2191
2192#if defined(WIN32)
2193
2194 /*
2195 * We don't use Unix-domain sockets on Windows by default (see comment at
2196 * remove_temp() for a reason). Override at your own risk.
2197 */
2198 use_unix_sockets = getenv("PG_TEST_USE_UNIX_SOCKETS") ? true : false;
2199#else
2200 use_unix_sockets = true;
2201#endif
2202
2203 if (!use_unix_sockets)
2204 hostname = "localhost";
2205
2206 /*
2207 * We call the initialization function here because that way we can set
2208 * default parameters and let them be overwritten by the commandline.
2209 */
2210 ifunc(argc, argv);
2211
2212 if (getenv("PG_REGRESS_DIFF_OPTS"))
2213 pretty_diff_opts = getenv("PG_REGRESS_DIFF_OPTS");
2214
2215 while ((c = getopt_long(argc, argv, "hV", long_options, &option_index)) != -1)
2216 {
2217 switch (c)
2218 {
2219 case 'h':
2220 help();
2221 exit(0);
2222 case 'V':
2223 puts("pg_regress (PostgreSQL) " PG_VERSION);
2224 exit(0);
2225 case 1:
2226
2227 /*
2228 * If a default database was specified, we need to remove it
2229 * before we add the specified one.
2230 */
2233 break;
2234 case 2:
2235 debug = true;
2236 break;
2237 case 3:
2239 break;
2240 case 5:
2242 break;
2243 case 6:
2245 break;
2246 case 7:
2248 break;
2249 case 8:
2251 break;
2252 case 9:
2254 break;
2255 case 10:
2256 nolocale = true;
2257 break;
2258 case 13:
2260 break;
2261 case 14:
2262 port = atoi(optarg);
2264 break;
2265 case 15:
2267 break;
2268 case 16:
2269 /* "--bindir=" means to use PATH */
2270 if (strlen(optarg))
2272 else
2273 bindir = NULL;
2274 break;
2275 case 17:
2277 break;
2278 case 18:
2280 break;
2281 case 19:
2283 break;
2284 case 20:
2285 use_existing = true;
2286 break;
2287 case 21:
2289 break;
2290 case 22:
2292 break;
2293 case 24:
2295 break;
2296 case 25:
2298 break;
2299 case 26:
2301 break;
2302 default:
2303 /* getopt_long already emitted a complaint */
2304 pg_log_error_hint("Try \"%s --help\" for more information.",
2305 progname);
2306 exit(2);
2307 }
2308 }
2309
2310 /*
2311 * if we still have arguments, they are extra tests to run
2312 */
2313 while (argc - optind >= 1)
2314 {
2316 optind++;
2317 }
2318
2319 /*
2320 * We must have a database to run the tests in; either a default name, or
2321 * one supplied by the --dbname switch.
2322 */
2323 if (!(dblist && dblist->str && dblist->str[0]))
2324 {
2325 bail("no database name was specified");
2326 }
2327
2329 {
2330#ifdef ENABLE_SSPI
2331 if (!use_unix_sockets)
2333#endif
2334 exit(0);
2335 }
2336
2338
2339 /*
2340 * To reduce chances of interference with parallel installations, use
2341 * a port number starting in the private range (49152-65535)
2342 * calculated from the version number. This aids non-Unix socket mode
2343 * systems; elsewhere, the use of a private socket directory already
2344 * prevents interference.
2345 */
2346 port = 0xC000 | (PG_VERSION_NUM & 0x3FFF);
2347
2352
2353 /*
2354 * Initialization
2355 */
2357
2359
2360#if defined(HAVE_GETRLIMIT)
2362#endif
2363
2364 if (temp_instance)
2365 {
2366 StringInfoData cmd;
2367 FILE *pg_conf;
2368 const char *env_wait;
2369 int wait_seconds;
2370 const char *initdb_template_dir;
2371 const char *keywords[4];
2372 const char *values[4];
2373 PGPing rv;
2374 const char *initdb_extra_opts_env;
2375
2376 /*
2377 * Prepare the temp instance
2378 */
2379
2381 {
2382 if (!rmtree(temp_instance, true))
2383 {
2384 bail("could not remove temp instance \"%s\"", temp_instance);
2385 }
2386 }
2387
2388 /* make the temp instance top directory */
2390
2391 /* and a directory for log files */
2392 snprintf(buf, sizeof(buf), "%s/log", outputdir);
2393 if (!directory_exists(buf))
2395
2396 initdb_extra_opts_env = getenv("PG_TEST_INITDB_EXTRA_OPTS");
2397
2398 initStringInfo(&cmd);
2399
2400 /*
2401 * Create data directory.
2402 *
2403 * If available, use a previously initdb'd cluster as a template by
2404 * copying it. For a lot of tests, that's substantially cheaper.
2405 *
2406 * There's very similar code in Cluster.pm, but we can't easily de
2407 * duplicate it until we require perl at build time.
2408 */
2409 initdb_template_dir = getenv("INITDB_TEMPLATE");
2411 {
2412 note("initializing database system by running initdb");
2413
2414 appendStringInfo(&cmd,
2415 "\"%s%sinitdb\" -D \"%s/data\" --no-clean --no-sync",
2416 bindir ? bindir : "",
2417 bindir ? "/" : "",
2419 if (debug)
2420 appendStringInfoString(&cmd, " --debug");
2421 if (nolocale)
2422 appendStringInfoString(&cmd, " --no-locale");
2425 appendStringInfo(&cmd, " > \"%s/log/initdb.log\" 2>&1", outputdir);
2426 fflush(NULL);
2427 if (system(cmd.data))
2428 {
2429 bail("initdb failed\n"
2430 "# Examine \"%s/log/initdb.log\" for the reason.\n"
2431 "# Command was: %s",
2432 outputdir, cmd.data);
2433 }
2434 }
2435 else
2436 {
2437#ifndef WIN32
2438 const char *copycmd = "cp -RPp \"%s\" \"%s/data\"";
2439 int expected_exitcode = 0;
2440#else
2441 const char *copycmd = "robocopy /E /NJS /NJH /NFL /NDL /NP \"%s\" \"%s/data\"";
2442 int expected_exitcode = 1; /* 1 denotes files were copied */
2443#endif
2444
2445 note("initializing database system by copying initdb template");
2446
2447 appendStringInfo(&cmd,
2448 copycmd,
2451 appendStringInfo(&cmd, " > \"%s/log/initdb.log\" 2>&1", outputdir);
2452 fflush(NULL);
2453 if (system(cmd.data) != expected_exitcode)
2454 {
2455 bail("copying of initdb template failed\n"
2456 "# Examine \"%s/log/initdb.log\" for the reason.\n"
2457 "# Command was: %s",
2458 outputdir, cmd.data);
2459 }
2460 }
2461
2462 pfree(cmd.data);
2463
2464 /*
2465 * Adjust the default postgresql.conf for regression testing. The user
2466 * can specify a file to be appended; in any case we expand logging
2467 * and set max_prepared_transactions to enable testing of prepared
2468 * xacts. (Note: to reduce the probability of unexpected shmmax
2469 * failures, don't set max_prepared_transactions any higher than
2470 * actually needed by the prepared_xacts regression test.)
2471 */
2472 snprintf(buf, sizeof(buf), "%s/data/postgresql.conf", temp_instance);
2473 pg_conf = fopen(buf, "a");
2474 if (pg_conf == NULL)
2475 bail("could not open \"%s\" for adding extra config: %m", buf);
2476
2477 fputs("\n# Configuration added by pg_regress\n\n", pg_conf);
2478 fputs("log_autovacuum_min_duration = 0\n", pg_conf);
2479 fputs("log_autoanalyze_min_duration = 0\n", pg_conf);
2480 fputs("log_checkpoints = on\n", pg_conf);
2481 fputs("log_line_prefix = '%m %b[%p] %q%a '\n", pg_conf);
2482 fputs("log_lock_waits = on\n", pg_conf);
2483 fputs("log_temp_files = 128kB\n", pg_conf);
2484 fputs("max_prepared_transactions = 2\n", pg_conf);
2485
2486 for (sl = temp_configs; sl != NULL; sl = sl->next)
2487 {
2488 char *temp_config = sl->str;
2490 char line_buf[1024];
2491
2493 if (extra_conf == NULL)
2494 {
2495 bail("could not open \"%s\" to read extra config: %m",
2496 temp_config);
2497 }
2498 while (fgets(line_buf, sizeof(line_buf), extra_conf) != NULL)
2499 fputs(line_buf, pg_conf);
2501 }
2502
2503 fclose(pg_conf);
2504
2505#ifdef ENABLE_SSPI
2506 if (!use_unix_sockets)
2507 {
2508 /*
2509 * Since we successfully used the same buffer for the much-longer
2510 * "initdb" command, this can't truncate.
2511 */
2512 snprintf(buf, sizeof(buf), "%s/data", temp_instance);
2514 }
2515#endif
2516
2517 /*
2518 * Prepare the connection params for checking the state of the server
2519 * before starting the tests.
2520 */
2521 sprintf(portstr, "%d", port);
2522 keywords[0] = "dbname";
2523 values[0] = "postgres";
2524 keywords[1] = "port";
2525 values[1] = portstr;
2526 keywords[2] = "host";
2528 keywords[3] = NULL;
2529 values[3] = NULL;
2530
2531 /*
2532 * Check if there is a postmaster running already.
2533 */
2534 for (i = 0; i < 16; i++)
2535 {
2536 rv = PQpingParams(keywords, values, 1);
2537
2538 if (rv == PQPING_OK)
2539 {
2540 if (port_specified_by_user || i == 15)
2541 {
2542 note("port %d apparently in use", port);
2544 note("could not determine an available port");
2545 bail("Specify an unused port using the --port option or shut down any conflicting PostgreSQL servers.");
2546 }
2547
2548 note("port %d apparently in use, trying %d", port, port + 1);
2549 port++;
2550 sprintf(portstr, "%d", port);
2551 setenv("PGPORT", portstr, 1);
2552 }
2553 else
2554 break;
2555 }
2556
2557 /*
2558 * Start the temp postmaster
2559 */
2560 snprintf(buf, sizeof(buf),
2561 "\"%s%spostgres\" -D \"%s/data\" -F%s "
2562 "-c \"listen_addresses=%s\" -k \"%s\" "
2563 "> \"%s/log/postmaster.log\" 2>&1",
2564 bindir ? bindir : "",
2565 bindir ? "/" : "",
2566 temp_instance, debug ? " -d 5" : "",
2567 hostname ? hostname : "", sockdir ? sockdir : "",
2568 outputdir);
2571 bail("could not spawn postmaster: %m");
2572
2573 /*
2574 * Wait till postmaster is able to accept connections; normally takes
2575 * only a fraction of a second or so, but Cygwin is reportedly *much*
2576 * slower, and test builds using Valgrind or similar tools might be
2577 * too. Hence, allow the default timeout of 60 seconds to be
2578 * overridden from the PGCTLTIMEOUT environment variable.
2579 */
2580 env_wait = getenv("PGCTLTIMEOUT");
2581 if (env_wait != NULL)
2582 {
2584 if (wait_seconds <= 0)
2585 wait_seconds = 60;
2586 }
2587 else
2588 wait_seconds = 60;
2589
2590 for (i = 0; i < wait_seconds * WAIT_TICKS_PER_SECOND; i++)
2591 {
2592 /*
2593 * It's fairly unlikely that the server is responding immediately
2594 * so we start with sleeping before checking instead of the other
2595 * way around.
2596 */
2597 pg_usleep(1000000L / WAIT_TICKS_PER_SECOND);
2598
2599 rv = PQpingParams(keywords, values, 1);
2600
2601 /* Done if the server is running and accepts connections */
2602 if (rv == PQPING_OK)
2603 break;
2604
2605 if (rv == PQPING_NO_ATTEMPT)
2606 bail("attempting to connect to postmaster failed");
2607
2608 /*
2609 * Fail immediately if postmaster has exited
2610 */
2611#ifndef WIN32
2613#else
2615#endif
2616 {
2617 bail("postmaster failed, examine \"%s/log/postmaster.log\" for the reason",
2618 outputdir);
2619 }
2620 }
2622 {
2623 diag("postmaster did not respond within %d seconds, examine \"%s/log/postmaster.log\" for the reason",
2625
2626 /*
2627 * If we get here, the postmaster is probably wedged somewhere in
2628 * startup. Try to kill it ungracefully rather than leaving a
2629 * stuck postmaster that might interfere with subsequent test
2630 * attempts.
2631 */
2632#ifndef WIN32
2633 if (kill(postmaster_pid, SIGKILL) != 0 && errno != ESRCH)
2634 bail("could not kill failed postmaster: %m");
2635#else
2636 if (TerminateProcess(postmaster_pid, 255) == 0)
2637 bail("could not kill failed postmaster: error code %lu",
2638 GetLastError());
2639#endif
2640 bail("postmaster failed");
2641 }
2642
2643 postmaster_running = true;
2644
2645#ifdef _WIN64
2646/* need a series of two casts to convert HANDLE without compiler warning */
2647#define ULONGPID(x) (unsigned long) (unsigned long long) (x)
2648#else
2649#define ULONGPID(x) (unsigned long) (x)
2650#endif
2651 note("using temp instance on port %d with PID %lu",
2653 }
2654 else
2655 {
2656 /*
2657 * Using an existing installation, so may need to get rid of
2658 * pre-existing database(s) and role(s)
2659 */
2660 if (!use_existing)
2661 {
2662 for (sl = dblist; sl; sl = sl->next)
2664 for (sl = extraroles; sl; sl = sl->next)
2665 drop_role_if_exists(sl->str);
2666 }
2667 }
2668
2669 /*
2670 * Create the test database(s) and role(s)
2671 */
2672 if (!use_existing)
2673 {
2674 for (sl = dblist; sl; sl = sl->next)
2675 create_database(sl->str);
2676 for (sl = extraroles; sl; sl = sl->next)
2677 create_role(sl->str, dblist);
2678 }
2679
2680 /*
2681 * Ready to run the tests
2682 */
2683 for (sl = schedulelist; sl != NULL; sl = sl->next)
2684 {
2686 }
2687
2688 for (sl = extra_tests; sl != NULL; sl = sl->next)
2689 {
2691 }
2692
2693 /*
2694 * Shut down temp installation's postmaster
2695 */
2696 if (temp_instance)
2697 {
2699 }
2700
2701 /*
2702 * If there were no errors, remove the temp instance immediately to
2703 * conserve disk space. (If there were errors, we leave the instance in
2704 * place for possible manual investigation.)
2705 */
2706 if (temp_instance && fail_count == 0)
2707 {
2708 if (!rmtree(temp_instance, true))
2709 diag("could not remove temp instance \"%s\"",
2711 }
2712
2713 /*
2714 * Emit a TAP compliant Plan
2715 */
2717
2718 /*
2719 * Emit nice-looking summary message
2720 */
2721 if (fail_count == 0)
2722 note("All %d tests passed.", success_count);
2723 else
2724 diag("%d of %d tests failed.", fail_count, success_count + fail_count);
2725
2726 if (file_size(difffilename) > 0)
2727 {
2728 diag("The differences that caused some tests to fail can be viewed in the file \"%s\".",
2729 difffilename);
2730 diag("A copy of the test summary that you see above is saved in the file \"%s\".",
2731 logfilename);
2732 }
2733 else
2734 {
2737 }
2738
2739 fclose(logfile);
2740 logfile = NULL;
2741
2742 if (fail_count != 0)
2743 exit(1);
2744
2745 return 0;
2746}
static Datum values[MAXATTR]
Definition bootstrap.c:190
#define PG_TEXTDOMAIN(domain)
Definition c.h:1359
void set_pglocale_pgservice(const char *argv0, const char *app)
Definition exec.c:430
PGPing PQpingParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition fe-connect.c:793
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
Definition getopt_long.c:60
#define no_argument
Definition getopt_long.h:25
#define required_argument
Definition getopt_long.h:26
void pg_initialize_timing(void)
Definition instr_time.c:84
return true
Definition isn.c:130
static const JsonPathKeyword keywords[]
PGPing
Definition libpq-fe.h:181
@ PQPING_OK
Definition libpq-fe.h:182
@ PQPING_NO_ATTEMPT
Definition libpq-fe.h:185
void pg_logging_init(const char *argv0)
Definition logging.c:85
#define pg_log_error_hint(...)
Definition logging.h:114
static int wait_seconds
Definition pg_ctl.c:77
PGDLLIMPORT int optind
Definition getopt.c:47
PGDLLIMPORT char * optarg
Definition getopt.c:49
#define plan(x)
Definition pg_regress.c:164
static bool use_existing
Definition pg_regress.c:115
static void open_result_files(void)
static int max_connections
Definition pg_regress.c:107
static bool port_specified_by_user
Definition pg_regress.c:119
static void stop_postmaster(void)
Definition pg_regress.c:444
static int max_concurrent_tests
Definition pg_regress.c:108
static void create_database(const char *dbname)
static void drop_role_if_exists(const char *rolename)
bool debug
Definition pg_regress.c:100
static void unlimit_core_size(void)
Definition pg_regress.c:179
static _stringlist * schedulelist
Definition pg_regress.c:110
#define WAIT_TICKS_PER_SECOND
Definition pg_regress.c:82
static _stringlist * temp_configs
Definition pg_regress.c:113
static _stringlist * extra_tests
Definition pg_regress.c:111
static void split_to_stringlist(const char *s, const char *delim, _stringlist **listhead)
Definition pg_regress.c:238
static void run_single_test(const char *test, test_start_function startfunc, postprocess_result_function postfunc)
char * launcher
Definition pg_regress.c:105
const char * pretty_diff_opts
Definition pg_regress.c:65
char * expecteddir
Definition pg_regress.c:103
static char * config_auth_datadir
Definition pg_regress.c:123
static void drop_database_if_exists(const char *dbname)
static char portstr[16]
Definition pg_regress.c:118
static void initialize_environment(void)
Definition pg_regress.c:734
static void help(void)
static long file_size(const char *file)
static bool postmaster_running
Definition pg_regress.c:141
_stringlist * dblist
Definition pg_regress.c:99
static _stringlist * extraroles
Definition pg_regress.c:122
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)
Definition pg_regress.c:202
static int success_count
Definition pg_regress.c:143
#define ULONGPID(x)
static int fail_count
Definition pg_regress.c:144
static PID_TYPE postmaster_pid
Definition pg_regress.c:140
#define INVALID_PID
Definition pg_regress.h:15
#define sprintf
Definition port.h:263
char * make_absolute_path(const char *path)
Definition path.c:824
const char * get_progname(const char *argv0)
Definition path.c:669
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:490
#define SIGKILL
Definition win32_port.h:162

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, expecteddir, extra_tests, extraroles, fail_count, fb(), file_size(), free_stringlist(), get_progname(), get_restricted_token(), getopt_long(), help(), hostname, i, initialize_environment(), initStringInfo(), inputdir, INVALID_PID, keywords, 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_initialize_timing(), 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().

◆ remove_temp()

static void remove_temp ( void  )
static

Definition at line 479 of file pg_regress.c.

480{
485}
#define Assert(condition)
Definition c.h:999

References Assert, fb(), 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 1418 of file pg_regress.c.

1419{
1420 char expectfile[MAXPGPATH];
1421 char diff[MAXPGPATH];
1422 char cmd[MAXPGPATH * 3];
1424 FILE *difffile;
1425 int best_line_count;
1426 int i;
1427 int l;
1428 long startpos;
1429 const char *platform_expectfile;
1430
1431 /*
1432 * We can pass either the resultsfile or the expectfile, they should have
1433 * the same type (filename.type) anyway.
1434 */
1436
1439 {
1440 /*
1441 * Replace everything after the last slash in expectfile with what the
1442 * platform_expectfile contains.
1443 */
1444 char *p = strrchr(expectfile, '/');
1445
1446 if (p)
1448 }
1449
1450 /* Name to use for temporary diff file */
1451 snprintf(diff, sizeof(diff), "%s.diff", resultsfile);
1452
1453 /* OK, run the diff */
1454 snprintf(cmd, sizeof(cmd),
1455 "diff %s \"%s\" \"%s\" > \"%s\"",
1457
1458 /* Is the diff file empty? */
1459 if (run_diff(cmd, diff) == 0)
1460 {
1461 unlink(diff);
1462 return false;
1463 }
1464
1465 /* There may be secondary comparison files that match better */
1468
1469 for (i = 0; i <= 9; i++)
1470 {
1471 char *alt_expectfile;
1472
1474 if (!alt_expectfile)
1475 bail("Unable to check secondary comparison files: %m");
1476
1478 {
1480 continue;
1481 }
1482
1483 snprintf(cmd, sizeof(cmd),
1484 "diff %s \"%s\" \"%s\" > \"%s\"",
1486
1487 if (run_diff(cmd, diff) == 0)
1488 {
1489 unlink(diff);
1491 return false;
1492 }
1493
1494 l = file_line_count(diff);
1495 if (l < best_line_count)
1496 {
1497 /* This diff was a better match than the last one */
1498 best_line_count = l;
1500 }
1502 }
1503
1504 /*
1505 * fall back on the canonical results file if we haven't tried it yet and
1506 * haven't found a complete match yet.
1507 */
1508
1510 {
1511 snprintf(cmd, sizeof(cmd),
1512 "diff %s \"%s\" \"%s\" > \"%s\"",
1514
1515 if (run_diff(cmd, diff) == 0)
1516 {
1517 /* No diff = no changes = good */
1518 unlink(diff);
1519 return false;
1520 }
1521
1522 l = file_line_count(diff);
1523 if (l < best_line_count)
1524 {
1525 /* This diff was a better match than the last one */
1526 best_line_count = l;
1528 }
1529 }
1530
1531 /*
1532 * Use the best comparison file to generate the "pretty" diff, which we
1533 * append to the diffs summary file.
1534 */
1535
1536 difffile = fopen(difffilename, "a");
1537 if (!difffile)
1538 bail("could not open file \"%s\" for writing: %m", difffilename);
1540
1541 /* Write diff header */
1543 "diff %s %s %s\n",
1546
1547 /* Run diff */
1548 snprintf(cmd, sizeof(cmd),
1549 "diff %s \"%s\" \"%s\" >> \"%s\"",
1551 run_diff(cmd, difffilename);
1552
1553 /*
1554 * Emit the diff output as TAP diagnostics
1555 *
1556 * Reopen the file for reading. We can't keep the file open while diff
1557 * appends to it, because on Windows the file lock prevents diff from
1558 * writing.
1559 */
1560 difffile = fopen(difffilename, "r");
1561 if (!difffile)
1562 bail("could not open file \"%s\" for reading: %m", difffilename);
1563 else
1564 {
1565 /*
1566 * In case of a crash the diff can be huge and all of the subsequent
1567 * tests will fail with essentially useless diffs too. So to avoid
1568 * flooding the output, while still providing useful info in most
1569 * cases we output only the first 80 lines of the *combined* diff. The
1570 * number 80 is chosen so that we output less than 100 lines of
1571 * diagnostics per pg_regress run. Otherwise if meson is run with the
1572 * --quiet flag only the last 100 lines are shown and usually the most
1573 * useful information is actually in the first few lines.
1574 */
1575 static int nlines = 0;
1576 const int max_diff_lines = 80;
1577 char line[1024];
1578
1580 while (nlines < max_diff_lines &&
1581 fgets(line, sizeof(line), difffile))
1582 {
1583 size_t len = strlen(line);
1584 bool newline_found = (len > 0 && line[len - 1] == '\n');
1585
1586 if (newline_found)
1587 line[len - 1] = '\0';
1588
1589 diag_detail("%s", line);
1590 if (newline_found)
1591 {
1592 diag_end();
1593 nlines++;
1594 }
1595 }
1596
1597 if (in_diag)
1598 {
1599 /*
1600 * If there was no final newline for some reason, we should still
1601 * end the diagnostic.
1602 */
1603 diag_end();
1604 nlines++;
1605 }
1606
1607 if (nlines >= max_diff_lines)
1608 diag("(diff output truncated and silencing output for further failing tests...)");
1609
1611 }
1612
1613 unlink(diff);
1614 return true;
1615}
const void size_t len
static XLogRecPtr startpos
#define diag_detail(...)
Definition pg_regress.c:168
#define diag_end()
Definition pg_regress.c:169
static int file_line_count(const char *file)
static char * get_alternative_expectfile(const char *expectfile, int i)
bool file_exists(const char *file)
static const char * get_expectfile(const char *testname, const char *file)
Definition pg_regress.c:705
static int run_diff(const char *cmd, const char *filename)
const char * basic_diff_opts
Definition pg_regress.c:64
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition strlcpy.c:45

References bail, basic_diff_opts, diag, diag_detail, diag_end, difffilename, fb(), file_exists(), file_line_count(), fprintf, free, get_alternative_expectfile(), get_expectfile(), i, in_diag, len, MAXPGPATH, pretty_diff_opts, run_diff(), snprintf, startpos, 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 1386 of file pg_regress.c.

1387{
1388 int r;
1389
1390 fflush(NULL);
1391 r = system(cmd);
1392 if (!WIFEXITED(r) || WEXITSTATUS(r) > 1)
1393 {
1394 bail("diff command failed with status %d: %s", r, cmd);
1395 }
1396#ifdef WIN32
1397
1398 /*
1399 * On WIN32, if the 'diff' command cannot be found, system() returns 1,
1400 * but produces nothing to stdout, so we check for that here.
1401 */
1402 if (WEXITSTATUS(r) == 1 && file_size(filename) <= 0)
1403 {
1404 bail("diff command not found: %s", cmd);
1405 }
1406#endif
1407
1408 return WEXITSTATUS(r);
1409}
static char * filename
Definition pg_dumpall.c:120

References bail, fb(), file_size(), filename, 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 1716 of file pg_regress.c.

1718{
1719#define MAX_PARALLEL_TESTS 100
1728 char scbuf[1024];
1729 FILE *scf;
1730 int line_num = 0;
1731
1732 memset(tests, 0, sizeof(tests));
1733 memset(resultfiles, 0, sizeof(resultfiles));
1734 memset(expectfiles, 0, sizeof(expectfiles));
1735 memset(tags, 0, sizeof(tags));
1736
1737 scf = fopen(schedule, "r");
1738 if (!scf)
1739 bail("could not open file \"%s\" for reading: %m", schedule);
1740
1741 while (fgets(scbuf, sizeof(scbuf), scf))
1742 {
1743 char *test = NULL;
1744 char *c;
1745 int num_tests;
1746 bool inword;
1747 int i;
1748
1749 line_num++;
1750
1751 /* strip trailing whitespace, especially the newline */
1752 i = strlen(scbuf);
1753 while (i > 0 && isspace((unsigned char) scbuf[i - 1]))
1754 scbuf[--i] = '\0';
1755
1756 if (scbuf[0] == '\0' || scbuf[0] == '#')
1757 continue;
1758 if (strncmp(scbuf, "test: ", 6) == 0)
1759 test = scbuf + 6;
1760 else
1761 {
1762 bail("syntax error in schedule file \"%s\" line %d: %s",
1763 schedule, line_num, scbuf);
1764 }
1765
1766 num_tests = 0;
1767 inword = false;
1768 for (c = test;; c++)
1769 {
1770 if (*c == '\0' || isspace((unsigned char) *c))
1771 {
1772 if (inword)
1773 {
1774 /* Reached end of a test name */
1775 char sav;
1776
1778 {
1779 bail("too many parallel tests (more than %d) in schedule file \"%s\" line %d: %s",
1780 MAX_PARALLEL_TESTS, schedule, line_num, scbuf);
1781 }
1782 sav = *c;
1783 *c = '\0';
1785 num_tests++;
1786 *c = sav;
1787 inword = false;
1788 }
1789 if (*c == '\0')
1790 break; /* loop exit is here */
1791 }
1792 else if (!inword)
1793 {
1794 /* Start of a test name */
1795 test = c;
1796 inword = true;
1797 }
1798 }
1799
1800 if (num_tests == 0)
1801 {
1802 bail("syntax error in schedule file \"%s\" line %d: %s",
1803 schedule, line_num, scbuf);
1804 }
1805
1806 if (num_tests == 1)
1807 {
1808 pids[0] = (startfunc) (tests[0], &resultfiles[0], &expectfiles[0], &tags[0]);
1811 /* status line is finished below */
1812 }
1814 {
1815 bail("too many parallel tests (more than %d) in schedule file \"%s\" line %d: %s",
1816 max_concurrent_tests, schedule, line_num, scbuf);
1817 }
1818 else if (max_connections > 0 && max_connections < num_tests)
1819 {
1820 int oldest = 0;
1821
1822 note_detail("parallel group (%d tests, in groups of %d): ",
1824 for (i = 0; i < num_tests; i++)
1825 {
1826 if (i - oldest >= max_connections)
1827 {
1829 stoptimes + oldest,
1830 tests + oldest, i - oldest);
1831 oldest = i;
1832 }
1833 pids[i] = (startfunc) (tests[i], &resultfiles[i], &expectfiles[i], &tags[i]);
1835 }
1837 stoptimes + oldest,
1838 tests + oldest, i - oldest);
1839 note_end();
1840 }
1841 else
1842 {
1843 note_detail("parallel group (%d tests): ", num_tests);
1844 for (i = 0; i < num_tests; i++)
1845 {
1846 pids[i] = (startfunc) (tests[i], &resultfiles[i], &expectfiles[i], &tags[i]);
1848 }
1850 note_end();
1851 }
1852
1853 /* Check results for all tests */
1854 for (i = 0; i < num_tests; i++)
1855 {
1856 _stringlist *rl,
1857 *el,
1858 *tl;
1859 bool differ = false;
1860
1862
1863 /*
1864 * Advance over all three lists simultaneously.
1865 *
1866 * Compare resultfiles[j] with expectfiles[j] always. Tags are
1867 * optional but if there are tags, the tag list has the same
1868 * length as the other two lists.
1869 */
1870 for (rl = resultfiles[i], el = expectfiles[i], tl = tags[i];
1871 rl != NULL; /* rl and el have the same length */
1872 rl = rl->next, el = el->next,
1873 tl = tl ? tl->next : NULL)
1874 {
1875 bool newdiff;
1876
1877 if (postfunc)
1878 (*postfunc) (rl->str);
1879 newdiff = results_differ(tests[i], rl->str, el->str);
1880 if (newdiff && tl)
1881 {
1882 diag("tag: %s", tl->str);
1883 }
1884 differ |= newdiff;
1885 }
1886
1887 if (statuses[i] != 0)
1888 {
1891 }
1892 else
1893 {
1894 if (differ)
1895 {
1897 }
1898 else
1899 {
1901 }
1902 }
1903 }
1904
1905 for (i = 0; i < num_tests; i++)
1906 {
1907 pg_free(tests[i]);
1908 tests[i] = NULL;
1912 }
1913 }
1914
1915 fclose(scf);
1916}
void pg_free(void *ptr)
#define INSTR_TIME_SET_CURRENT(t)
Definition instr_time.h:434
#define INSTR_TIME_SUBTRACT(x, y)
Definition instr_time.h:444
#define INSTR_TIME_GET_MILLISEC(t)
Definition instr_time.h:459
#define note_detail(...)
Definition pg_regress.c:166
#define MAX_PARALLEL_TESTS
static void test_status_ok(const char *testname, double runtime, bool parallel)
Definition pg_regress.c:308
static void log_child_failure(int exitstatus)
static void test_status_failed(const char *testname, double runtime, bool parallel)
Definition pg_regress.c:316
static void wait_for_tests(PID_TYPE *pids, int *statuses, instr_time *stoptimes, char **names, int num_tests)
static bool results_differ(const char *testname, const char *resultsfile, const char *default_expectfile)
#define note_end()
Definition pg_regress.c:170
#define PID_TYPE
Definition pg_regress.h:14
static void test(void)

References bail, diag, fb(), 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, note_detail, note_end, pg_free(), pg_strdup(), PID_TYPE, results_differ(), test(), test_status_failed(), test_status_ok(), 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 1922 of file pg_regress.c.

1924{
1925 PID_TYPE pid;
1926 instr_time starttime;
1927 instr_time stoptime;
1928 int exit_status;
1932 _stringlist *rl,
1933 *el,
1934 *tl;
1935 bool differ = false;
1936
1937 pid = (startfunc) (test, &resultfiles, &expectfiles, &tags);
1938 INSTR_TIME_SET_CURRENT(starttime);
1939 wait_for_tests(&pid, &exit_status, &stoptime, NULL, 1);
1940
1941 /*
1942 * Advance over all three lists simultaneously.
1943 *
1944 * Compare resultfiles[j] with expectfiles[j] always. Tags are optional
1945 * but if there are tags, the tag list has the same length as the other
1946 * two lists.
1947 */
1948 for (rl = resultfiles, el = expectfiles, tl = tags;
1949 rl != NULL; /* rl and el have the same length */
1950 rl = rl->next, el = el->next,
1951 tl = tl ? tl->next : NULL)
1952 {
1953 bool newdiff;
1954
1955 if (postfunc)
1956 (*postfunc) (rl->str);
1957 newdiff = results_differ(test, rl->str, el->str);
1958 if (newdiff && tl)
1959 {
1960 diag("tag: %s", tl->str);
1961 }
1962 differ |= newdiff;
1963 }
1964
1965 INSTR_TIME_SUBTRACT(stoptime, starttime);
1966
1967 if (exit_status != 0)
1968 {
1971 }
1972 else
1973 {
1974 if (differ)
1975 {
1977 }
1978 else
1979 {
1980 test_status_ok(test, INSTR_TIME_GET_MILLISEC(stoptime), false);
1981 }
1982 }
1983}

References diag, fb(), INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SUBTRACT, log_child_failure(), PID_TYPE, results_differ(), test(), test_status_failed(), test_status_ok(), and wait_for_tests().

Referenced by regression_main().

◆ signal_remove_temp()

static void signal_remove_temp ( SIGNAL_ARGS  )
static

Definition at line 491 of file pg_regress.c.

492{
493 remove_temp();
494
497}
#define PG_SIG_DFL
Definition port.h:551

References fb(), PG_SIG_DFL, pqsignal, and remove_temp().

Referenced by make_temp_sockdir().

◆ spawn_process()

PID_TYPE spawn_process ( const char cmdline)

Definition at line 1215 of file pg_regress.c.

1216{
1217#ifndef WIN32
1218 pid_t pid;
1219
1220 /*
1221 * Must flush I/O buffers before fork.
1222 */
1223 fflush(NULL);
1224
1225#ifdef EXEC_BACKEND
1227#endif
1228
1229 pid = fork();
1230 if (pid == -1)
1231 {
1232 bail("could not fork: %m");
1233 }
1234 if (pid == 0)
1235 {
1236 /*
1237 * In child
1238 *
1239 * Instead of using system(), exec the shell directly, and tell it to
1240 * "exec" the command too. This saves two useless processes per
1241 * parallel test case.
1242 */
1243 char *cmdline2;
1244
1245 cmdline2 = psprintf("exec %s", cmdline);
1246 execl(shellprog, shellprog, "-c", cmdline2, (char *) NULL);
1247 /* Not using the normal bail() here as we want _exit */
1248 bail_noatexit("could not exec \"%s\": %m", shellprog);
1249 }
1250 /* in parent */
1251 return pid;
1252#else
1254 char *cmdline2;
1255 const char *comspec;
1256
1257 /* Find CMD.EXE location using COMSPEC, if it's set */
1258 comspec = getenv("COMSPEC");
1259 if (comspec == NULL)
1260 comspec = "CMD";
1261
1262 memset(&pi, 0, sizeof(pi));
1263 cmdline2 = psprintf("\"%s\" /c \"%s\"", comspec, cmdline);
1264
1266 exit(2);
1267
1268 CloseHandle(pi.hThread);
1269 return pi.hProcess;
1270#endif
1271}
static char * shellprog
Definition pg_regress.c:55
#define bail_noatexit(...)
Definition pg_regress.c:171

References bail, bail_noatexit, fb(), psprintf(), and shellprog.

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 238 of file pg_regress.c.

239{
240 char *token;
241 char *sc;
242 char *tofree;
243
244 tofree = sc = pg_strdup(s);
245
246 while ((token = strsep(&sc, delim)))
247 {
249 }
250 free(tofree);
251}
#define token
char * strsep(char **stringp, const char *delim)
Definition strsep.c:50

References add_stringlist_item(), fb(), free, pg_strdup(), strsep(), and token.

Referenced by regression_main().

◆ stop_postmaster()

static void stop_postmaster ( void  )
static

Definition at line 444 of file pg_regress.c.

445{
447 {
448 /* We use pg_ctl to issue the kill and wait for stop */
449 char buf[MAXPGPATH * 2];
450 int r;
451
452 snprintf(buf, sizeof(buf),
453 "\"%s%spg_ctl\" stop -D \"%s/data\" -s",
454 bindir ? bindir : "",
455 bindir ? "/" : "",
457 fflush(NULL);
458 r = system(buf);
459 if (r != 0)
460 {
461 /* Not using the normal bail() as we want _exit */
462 bail_noatexit(_("could not stop postmaster: exit code was %d"), r);
463 }
464
465 postmaster_running = false;
466 }
467}

References _, bail_noatexit, bindir, buf, fb(), MAXPGPATH, postmaster_running, snprintf, and temp_instance.

Referenced by check_and_dump_old_cluster(), issue_warnings_and_set_wal_level(), main(), regression_main(), report_clusters_compatible(), setup(), and stop_postmaster_atexit().

◆ string_matches_pattern()

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

Definition at line 557 of file pg_regress.c.

558{
559 while (*str && *pattern)
560 {
561 if (*pattern == '.' && pattern[1] == '*')
562 {
563 pattern += 2;
564 /* Trailing .* matches everything. */
565 if (*pattern == '\0')
566 return true;
567
568 /*
569 * Otherwise, scan for a text position at which we can match the
570 * rest of the pattern.
571 */
572 while (*str)
573 {
574 /*
575 * Optimization to prevent most recursion: don't recurse
576 * unless first pattern char might match this text char.
577 */
578 if (*str == *pattern || *pattern == '.')
579 {
580 if (string_matches_pattern(str, pattern))
581 return true;
582 }
583
584 str++;
585 }
586
587 /*
588 * End of text with no match.
589 */
590 return false;
591 }
592 else if (*pattern != '.' && *str != *pattern)
593 {
594 /*
595 * Not the single-character wildcard and no explicit match? Then
596 * time to quit...
597 */
598 return false;
599 }
600
601 str++;
602 pattern++;
603 }
604
605 if (*pattern == '\0')
606 return true; /* end of pattern, so declare match */
607
608 /* End of input string. Do we have matching pattern remaining? */
609 while (*pattern == '.' && pattern[1] == '*')
610 pattern += 2;
611 if (*pattern == '\0')
612 return true; /* end of pattern, so declare match */
613
614 return false;
615}

References str, and string_matches_pattern().

Referenced by load_resultmap(), and string_matches_pattern().

◆ test_status_failed()

static void test_status_failed ( const char testname,
double  runtime,
bool  parallel 
)
static

Definition at line 316 of file pg_regress.c.

317{
318 /*
319 * Save failed tests in a buffer such that we can print a summary at the
320 * end with diag() to ensure it's shown even under test harnesses.
321 */
322 if (!failed_tests)
324 else
326
328
329 fail_count++;
330
332}
static StringInfo failed_tests
Definition pg_regress.c:134
static void test_status_print(bool ok, const char *testname, double runtime, bool parallel)
Definition pg_regress.c:285

References appendStringInfo(), appendStringInfoChar(), fail_count, failed_tests, fb(), makeStringInfo(), and test_status_print().

Referenced by run_schedule(), and run_single_test().

◆ test_status_ok()

static void test_status_ok ( const char testname,
double  runtime,
bool  parallel 
)
static

Definition at line 308 of file pg_regress.c.

309{
311
313}

References fb(), success_count, and test_status_print().

Referenced by run_schedule(), and run_single_test().

◆ test_status_print()

static void test_status_print ( bool  ok,
const char testname,
double  runtime,
bool  parallel 
)
static

Definition at line 285 of file pg_regress.c.

286{
288
289 /*
290 * Testnumbers are padded to 5 characters to ensure that testnames align
291 * vertically (assuming at most 9999 tests). Testnames are prefixed with
292 * a leading character to indicate being run in parallel or not. A leading
293 * '+' indicates a parallel test, '-' indicates a single test.
294 */
295 emit_tap_output(TEST_STATUS, "%sok %-5i%*s %c %-*s %8.0f ms",
296 (ok ? "" : "not "),
298 /* If ok, indent with four spaces matching "not " */
299 (ok ? (int) strlen("not ") : 0), "",
300 /* Prefix a parallel test '+' and a single test with '-' */
301 (parallel ? '+' : '-'),
302 /* Testnames are padded to align runtimes */
304 runtime);
305}
static void static void emit_tap_output(TAPtype type, const char *fmt,...) pg_attribute_printf(2
Definition pg_regress.c:336
#define TESTNAME_WIDTH
Definition pg_regress.c:76

References emit_tap_output(), fail_count, fb(), success_count, TEST_STATUS, and TESTNAME_WIDTH.

Referenced by test_status_failed(), and test_status_ok().

◆ unlimit_core_size()

static void unlimit_core_size ( void  )
static

Definition at line 179 of file pg_regress.c.

180{
181 struct rlimit lim;
182
184 if (lim.rlim_max == 0)
185 {
186 diag("could not set core size: disallowed by hard limit");
187 return;
188 }
189 else if (lim.rlim_max == RLIM_INFINITY || lim.rlim_cur < lim.rlim_max)
190 {
191 lim.rlim_cur = lim.rlim_max;
193 }
194}

References diag, and fb().

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 1626 of file pg_regress.c.

1628{
1629 int tests_left;
1630 int i;
1631
1632#ifdef WIN32
1634
1636#endif
1637
1639 while (tests_left > 0)
1640 {
1641 PID_TYPE p;
1642
1643#ifndef WIN32
1644 int exit_status;
1645
1646 p = wait(&exit_status);
1647
1648 if (p == INVALID_PID)
1649 bail("failed to wait for subprocesses: %m");
1650#else
1652 int r;
1653
1656 {
1657 bail("failed to wait for subprocesses: error code %lu",
1658 GetLastError());
1659 }
1660 p = active_pids[r - WAIT_OBJECT_0];
1661 /* compact the active_pids array */
1663#endif /* WIN32 */
1664
1665 for (i = 0; i < num_tests; i++)
1666 {
1667 if (p == pids[i])
1668 {
1669#ifdef WIN32
1671 CloseHandle(pids[i]);
1672#endif
1673 pids[i] = INVALID_PID;
1676 if (names)
1677 note_detail(" %s", names[i]);
1678 tests_left--;
1679 break;
1680 }
1681 }
1682 }
1683
1684#ifdef WIN32
1686#endif
1687}
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
#define pg_malloc_array(type, count)
Definition fe_memutils.h:66

References bail, fb(), free, i, INSTR_TIME_SET_CURRENT, INVALID_PID, memcpy(), note_detail, pg_malloc_array, and PID_TYPE.

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

◆ config_auth_datadir

char* config_auth_datadir = NULL
static

Definition at line 123 of file pg_regress.c.

Referenced by regression_main().

◆ dblist

◆ debug

bool debug = false

Definition at line 100 of file pg_regress.c.

Referenced by regression_main().

◆ difffilename

char* difffilename
static

Definition at line 129 of file pg_regress.c.

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

◆ dlpath

char* dlpath = PKGLIBDIR
static

Definition at line 120 of file pg_regress.c.

Referenced by initialize_environment(), and regression_main().

◆ encoding

char* encoding = NULL
static

Definition at line 109 of file pg_regress.c.

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

◆ expecteddir

char* expecteddir = "."

Definition at line 103 of file pg_regress.c.

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

◆ extra_tests

_stringlist* extra_tests = NULL
static

Definition at line 111 of file pg_regress.c.

Referenced by regression_main().

◆ extraroles

_stringlist* extraroles = NULL
static

Definition at line 122 of file pg_regress.c.

Referenced by regression_main().

◆ fail_count

int fail_count = 0
static

Definition at line 144 of file pg_regress.c.

Referenced by regression_main(), test_status_failed(), and test_status_print().

◆ failed_tests

StringInfo failed_tests = NULL
static

Definition at line 134 of file pg_regress.c.

Referenced by test_status_failed().

◆ host_platform

char* host_platform = HOST_TUPLE

Definition at line 52 of file pg_regress.c.

Referenced by load_resultmap().

◆ hostname

◆ in_diag

bool in_diag = false
static

Definition at line 136 of file pg_regress.c.

Referenced by emit_tap_output_v(), and results_differ().

◆ in_note

bool in_note = false
static

Definition at line 135 of file pg_regress.c.

Referenced by emit_tap_output_v().

◆ inputdir

◆ launcher

char* launcher = NULL

Definition at line 105 of file pg_regress.c.

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

◆ loadextension

_stringlist* loadextension = NULL
static

Definition at line 106 of file pg_regress.c.

Referenced by create_database(), and regression_main().

◆ logfile

◆ logfilename

char* logfilename
static

Definition at line 127 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 108 of file pg_regress.c.

Referenced by regression_main(), and run_schedule().

◆ max_connections

int max_connections = 0
static

Definition at line 107 of file pg_regress.c.

Referenced by regression_main(), and run_schedule().

◆ nolocale

bool nolocale = false
static

Definition at line 114 of file pg_regress.c.

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

◆ outputdir

◆ port

int port = -1
static

Definition at line 117 of file pg_regress.c.

Referenced by auth_delay_checks(), auth_failed(), auth_peer(), BackendInitialize(), be_gssapi_get_auth(), be_gssapi_get_delegation(), be_gssapi_get_enc(), be_gssapi_get_princ(), be_gssapi_read(), be_gssapi_write(), be_tls_close(), be_tls_get_certificate_hash(), 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(), check_validator_hba_options(), CheckMD5Auth(), CheckPasswordAuth(), CheckPWChallengeAuth(), CheckSASLAuth(), ClientAuthentication(), 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(), main(), make_temp_sockdir(), oauth_init(), passwordFromFile(), PerformAuthentication(), port_bio_ctrl(), port_bio_read(), pq_getkeepalivescount(), pq_getkeepalivesidle(), pq_getkeepalivesinterval(), pq_gettcpusertimeout(), pq_init(), pq_setkeepalivescount(), pq_setkeepalivesidle(), pq_setkeepalivesinterval(), pq_settcpusertimeout(), process_startup_options(), ProcessSSLStartup(), ProcessStartupPacket(), read_or_wait(), regression_main(), 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(), set_authn_id(), ssl_set_port_bio(), and validate().

◆ port_specified_by_user

bool port_specified_by_user = false
static

Definition at line 119 of file pg_regress.c.

Referenced by regression_main().

◆ portstr

char portstr[16]
static

Definition at line 118 of file pg_regress.c.

Referenced by PQconnectPoll(), and regression_main().

◆ postmaster_pid

PID_TYPE postmaster_pid = INVALID_PID
static

Definition at line 140 of file pg_regress.c.

Referenced by regression_main().

◆ postmaster_running

bool postmaster_running = false
static

Definition at line 141 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

const char* progname
static

Definition at line 126 of file pg_regress.c.

Referenced by help(), and regression_main().

◆ resultmap

_resultmap* resultmap = NULL
static

Definition at line 138 of file pg_regress.c.

Referenced by get_expectfile(), and load_resultmap().

◆ schedulelist

_stringlist* schedulelist = NULL
static

Definition at line 110 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 130 of file pg_regress.c.

Referenced by initialize_environment(), and regression_main().

◆ socklock

char socklock[MAXPGPATH]
static

Definition at line 133 of file pg_regress.c.

Referenced by make_temp_sockdir(), and remove_temp().

◆ sockself

char sockself[MAXPGPATH]
static

Definition at line 132 of file pg_regress.c.

Referenced by make_temp_sockdir(), and remove_temp().

◆ success_count

int success_count = 0
static

Definition at line 143 of file pg_regress.c.

Referenced by regression_main(), test_status_ok(), and test_status_print().

◆ temp_configs

_stringlist* temp_configs = NULL
static

Definition at line 113 of file pg_regress.c.

Referenced by regression_main().

◆ temp_instance

char* temp_instance = NULL
static

Definition at line 112 of file pg_regress.c.

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

◆ temp_sockdir

const char* temp_sockdir
static

Definition at line 131 of file pg_regress.c.

Referenced by make_temp_sockdir(), and remove_temp().

◆ use_existing

bool use_existing = false
static

Definition at line 115 of file pg_regress.c.

Referenced by regression_main().

◆ user