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:85
#define pg_malloc_object(type)
Definition fe_memutils.h:50
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 2031 of file pg_regress.c.

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

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

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

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

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

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

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:263

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:260
#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 2090 of file pg_regress.c.

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

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

1692{
1693 if (WIFEXITED(exitstatus))
1694 diag("(test process exited with exit code %d)",
1696 else if (WIFSIGNALED(exitstatus))
1697 {
1698#if defined(WIN32)
1699 diag("(test process was terminated by exception 0x%X)",
1701#else
1702 diag("(test process was terminated by signal %d: %s)",
1704#endif
1705 }
1706 else
1707 diag("(test process exited with unrecognized status %d)", exitstatus);
1708}
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:547
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 1987 of file pg_regress.c.

1988{
1989 char file[MAXPGPATH];
1990 FILE *difffile;
1991
1992 /* create outputdir directory if not present */
1995
1996 /* create the log file (copy of running status output) */
1997 snprintf(file, sizeof(file), "%s/regression.out", outputdir);
1998 logfilename = pg_strdup(file);
1999 logfile = fopen(logfilename, "w");
2000 if (!logfile)
2001 bail("could not open file \"%s\" for writing: %m", logfilename);
2002
2003 /* create the diffs file as empty */
2004 snprintf(file, sizeof(file), "%s/regression.diffs", outputdir);
2005 difffilename = pg_strdup(file);
2006 difffile = fopen(difffilename, "w");
2007 if (!difffile)
2008 bail("could not open file \"%s\" for writing: %m", difffilename);
2009
2010 /* we don't keep the diffs file open continuously */
2012
2013 /* also create the results directory if not present */
2014 snprintf(file, sizeof(file), "%s/results", outputdir);
2015 if (!directory_exists(file))
2016 make_directory(file);
2017}
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:1616
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 2140 of file pg_regress.c.

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

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 {
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 * Reopen the file for reading to emit the diff as TAP diagnostics. We
1555 * can't keep the file open while diff appends to it, because on
1556 * Windows the file lock prevents diff from writing.
1557 */
1558 difffile = fopen(difffilename, "r");
1559 }
1560
1561 if (difffile)
1562 {
1563 /*
1564 * In case of a crash the diff can be huge and all of the subsequent
1565 * tests will fail with essentially useless diffs too. So to avoid
1566 * flooding the output, while still providing useful info in most
1567 * cases we output only the first 80 lines of the *combined* diff. The
1568 * number 80 is chosen so that we output less than 100 lines of
1569 * diagnostics per pg_regress run. Otherwise if meson is run with the
1570 * --quiet flag only the last 100 lines are shown and usually the most
1571 * useful information is actually in the first few lines.
1572 */
1573 static int nlines = 0;
1574 const int max_diff_lines = 80;
1575 char line[1024];
1576
1578 while (nlines < max_diff_lines &&
1579 fgets(line, sizeof(line), difffile))
1580 {
1581 size_t len = strlen(line);
1582 bool newline_found = (len > 0 && line[len - 1] == '\n');
1583
1584 if (newline_found)
1585 line[len - 1] = '\0';
1586
1587 diag_detail("%s", line);
1588 if (newline_found)
1589 {
1590 diag_end();
1591 nlines++;
1592 }
1593 }
1594
1595 if (in_diag)
1596 {
1597 /*
1598 * If there was no final newline for some reason, we should still
1599 * end the diagnostic.
1600 */
1601 diag_end();
1602 nlines++;
1603 }
1604
1605 if (nlines >= max_diff_lines)
1606 diag("(diff output truncated and silencing output for further failing tests...)");
1607
1609 }
1610
1611 unlink(diff);
1612 return true;
1613}
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:133

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

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

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

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.

References fb(), 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:49

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

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

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

FILE* logfile
static

◆ 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