postgresql/src/test/regress/pg_regress.h
Tom Lane 800d93f314 Allow pg_regress.c wrappers to postprocess test result files.
Add an optional callback to regression_main() that, if provided,
is invoked on each test output file before we try to compare it
to the expected-result file.

The main and isolation test programs don't need this (yet).
In pg_regress_ecpg, add a filter that eliminates target-host
details from "could not connect" error reports.  This filter
doesn't do anything as of this commit, but it will be needed
by the next one.

In the long run we might want to provide some more general,
perhaps pattern-based, filtering mechanism for test output.
For now, this will solve the immediate problem.

Discussion: https://postgr.es/m/BN6PR05MB3492948E4FD76C156E747E8BC9160@BN6PR05MB3492.namprd05.prod.outlook.com
2021-01-11 13:43:19 -05:00

71 lines
1.9 KiB
C

/*-------------------------------------------------------------------------
* pg_regress.h --- regression test driver
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/test/regress/pg_regress.h
*-------------------------------------------------------------------------
*/
#include <unistd.h>
#ifndef WIN32
#define PID_TYPE pid_t
#define INVALID_PID (-1)
#else
#define PID_TYPE HANDLE
#define INVALID_PID INVALID_HANDLE_VALUE
#endif
struct StringInfoData; /* avoid including stringinfo.h here */
/* simple list of strings */
typedef struct _stringlist
{
char *str;
struct _stringlist *next;
} _stringlist;
/*
* Callback function signatures for test programs that use regression_main()
*/
/* Initialize at program start */
typedef void (*init_function) (int argc, char **argv);
/* Launch one test case */
typedef PID_TYPE(*test_start_function) (const char *testname,
_stringlist **resultfiles,
_stringlist **expectfiles,
_stringlist **tags);
/* Postprocess one result file (optional) */
typedef void (*postprocess_result_function) (const char *filename);
extern char *bindir;
extern char *libdir;
extern char *datadir;
extern char *host_platform;
extern _stringlist *dblist;
extern bool debug;
extern char *inputdir;
extern char *outputdir;
extern char *launcher;
extern const char *basic_diff_opts;
extern const char *pretty_diff_opts;
int regression_main(int argc, char *argv[],
init_function ifunc,
test_start_function startfunc,
postprocess_result_function postfunc);
void add_stringlist_item(_stringlist **listhead, const char *str);
PID_TYPE spawn_process(const char *cmdline);
void replace_string(struct StringInfoData *string,
const char *replace, const char *replacement);
bool file_exists(const char *file);