summaryrefslogtreecommitdiffstats
path: root/src/test/regress/pg_regress.h
blob: c6d015c8402a2113778ad862e148becf40dde4d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*-------------------------------------------------------------------------
 * 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);