Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "pg_regress.h"
00020
00021
00022
00023
00024
00025 static PID_TYPE
00026 psql_start_test(const char *testname,
00027 _stringlist ** resultfiles,
00028 _stringlist ** expectfiles,
00029 _stringlist ** tags)
00030 {
00031 PID_TYPE pid;
00032 char infile[MAXPGPATH];
00033 char outfile[MAXPGPATH];
00034 char expectfile[MAXPGPATH];
00035 char psql_cmd[MAXPGPATH * 3];
00036 size_t offset = 0;
00037
00038
00039
00040
00041
00042
00043
00044 snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
00045 outputdir, testname);
00046 if (!file_exists(infile))
00047 snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
00048 inputdir, testname);
00049
00050 snprintf(outfile, sizeof(outfile), "%s/results/%s.out",
00051 outputdir, testname);
00052
00053 snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
00054 outputdir, testname);
00055 if (!file_exists(expectfile))
00056 snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
00057 inputdir, testname);
00058
00059 add_stringlist_item(resultfiles, outfile);
00060 add_stringlist_item(expectfiles, expectfile);
00061
00062 if (launcher)
00063 offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
00064 "%s ", launcher);
00065
00066 snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
00067 SYSTEMQUOTE "\"%s%spsql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
00068 psqldir ? psqldir : "",
00069 psqldir ? "/" : "",
00070 dblist->str,
00071 infile,
00072 outfile);
00073
00074 pid = spawn_process(psql_cmd);
00075
00076 if (pid == INVALID_PID)
00077 {
00078 fprintf(stderr, _("could not start process for test %s\n"),
00079 testname);
00080 exit(2);
00081 }
00082
00083 return pid;
00084 }
00085
00086 static void
00087 psql_init(void)
00088 {
00089
00090 add_stringlist_item(&dblist, "regression");
00091 }
00092
00093 int
00094 main(int argc, char *argv[])
00095 {
00096 return regression_main(argc, argv, psql_init, psql_start_test);
00097 }