#include "pg_regress.h"
Go to the source code of this file.
Defines | |
#define | LINEBUFSIZE 300 |
Functions | |
static void | ecpg_filter (const char *sourcefile, const char *outfile) |
static PID_TYPE | ecpg_start_test (const char *testname, _stringlist **resultfiles, _stringlist **expectfiles, _stringlist **tags) |
static void | ecpg_init (void) |
int | main (int argc, char *argv[]) |
#define LINEBUFSIZE 300 |
Definition at line 21 of file pg_regress_ecpg.c.
Referenced by ecpg_filter().
static void ecpg_filter | ( | const char * | sourcefile, | |
const char * | outfile | |||
) | [static] |
Definition at line 23 of file pg_regress_ecpg.c.
References LINEBUFSIZE, malloc, NULL, and replace_string().
Referenced by ecpg_start_test().
{ /* * Create a filtered copy of sourcefile, replacing #line x * "./../bla/foo.h" with #line x "foo.h" */ FILE *s, *t; char linebuf[LINEBUFSIZE]; s = fopen(sourcefile, "r"); if (!s) { fprintf(stderr, "Could not open file %s for reading\n", sourcefile); exit(2); } t = fopen(outfile, "w"); if (!t) { fprintf(stderr, "Could not open file %s for writing\n", outfile); exit(2); } while (fgets(linebuf, LINEBUFSIZE, s)) { /* check for "#line " in the beginning */ if (strstr(linebuf, "#line ") == linebuf) { char *p = strchr(linebuf, '"'); char *n; int plen = 1; while (*p && (*(p + plen) == '.' || strchr(p + plen, '/') != NULL)) { plen++; } /* plen is one more than the number of . and / characters */ if (plen > 1) { n = (char *) malloc(plen); strncpy(n, p + 1, plen - 1); n[plen - 1] = '\0'; replace_string(linebuf, n, ""); } } fputs(linebuf, t); } fclose(s); fclose(t); }
static void ecpg_init | ( | void | ) | [static] |
Definition at line 162 of file pg_regress_ecpg.c.
{
/* nothing to do here at the moment */
}
static PID_TYPE ecpg_start_test | ( | const char * | testname, | |
_stringlist ** | resultfiles, | |||
_stringlist ** | expectfiles, | |||
_stringlist ** | tags | |||
) | [static] |
Definition at line 80 of file pg_regress_ecpg.c.
References _, add_stringlist_item(), ecpg_filter(), free, inputdir, INVALID_PID, MAXPGPATH, outputdir, PID_TYPE, replace_string(), snprintf(), spawn_process(), and SYSTEMQUOTE.
Referenced by main().
{ PID_TYPE pid; char inprg[MAXPGPATH]; char insource[MAXPGPATH]; char *outfile_stdout, expectfile_stdout[MAXPGPATH]; char *outfile_stderr, expectfile_stderr[MAXPGPATH]; char *outfile_source, expectfile_source[MAXPGPATH]; char cmd[MAXPGPATH * 3]; char *testname_dash; snprintf(inprg, sizeof(inprg), "%s/%s", inputdir, testname); testname_dash = strdup(testname); replace_string(testname_dash, "/", "-"); snprintf(expectfile_stdout, sizeof(expectfile_stdout), "%s/expected/%s.stdout", outputdir, testname_dash); snprintf(expectfile_stderr, sizeof(expectfile_stderr), "%s/expected/%s.stderr", outputdir, testname_dash); snprintf(expectfile_source, sizeof(expectfile_source), "%s/expected/%s.c", outputdir, testname_dash); /* * We can use replace_string() here because the replacement string does * not occupy more space than the replaced one. */ outfile_stdout = strdup(expectfile_stdout); replace_string(outfile_stdout, "/expected/", "/results/"); outfile_stderr = strdup(expectfile_stderr); replace_string(outfile_stderr, "/expected/", "/results/"); outfile_source = strdup(expectfile_source); replace_string(outfile_source, "/expected/", "/results/"); add_stringlist_item(resultfiles, outfile_stdout); add_stringlist_item(expectfiles, expectfile_stdout); add_stringlist_item(tags, "stdout"); add_stringlist_item(resultfiles, outfile_stderr); add_stringlist_item(expectfiles, expectfile_stderr); add_stringlist_item(tags, "stderr"); add_stringlist_item(resultfiles, outfile_source); add_stringlist_item(expectfiles, expectfile_source); add_stringlist_item(tags, "source"); snprintf(insource, sizeof(insource), "%s.c", testname); ecpg_filter(insource, outfile_source); snprintf(inprg, sizeof(inprg), "%s/%s", inputdir, testname); snprintf(cmd, sizeof(cmd), SYSTEMQUOTE "\"%s\" >\"%s\" 2>\"%s\"" SYSTEMQUOTE, inprg, outfile_stdout, outfile_stderr); pid = spawn_process(cmd); if (pid == INVALID_PID) { fprintf(stderr, _("could not start process for test %s\n"), testname); exit(2); } free(outfile_stdout); free(outfile_stderr); free(outfile_source); return pid; }
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 168 of file pg_regress_ecpg.c.
References ecpg_init(), ecpg_start_test(), and regression_main().
{ return regression_main(argc, argv, ecpg_init, ecpg_start_test); }