Skip to content

Commit

Permalink
update IvorySQL regression test with pg commit e70abd6
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaoshuntian committed Jul 15, 2024
1 parent fe22a5e commit 74cc2a1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 49 deletions.
37 changes: 14 additions & 23 deletions src/oracle_test/isolation/isolation_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "postgres_fe.h"

#include "lib/stringinfo.h"
#include "pg_regress.h"

char saved_argv0[MAXPGPATH];
Expand All @@ -36,8 +37,7 @@ isolation_start_test(const char *testname,
char infile[MAXPGPATH];
char outfile[MAXPGPATH];
char expectfile[MAXPGPATH];
char psql_cmd[MAXPGPATH * 3];
size_t offset = 0;
StringInfoData psql_cmd;
char *appnameenv;

/* need to do the path lookup here, check isolation_init() for details */
Expand Down Expand Up @@ -88,34 +88,23 @@ isolation_start_test(const char *testname,
add_stringlist_item(resultfiles, outfile);
add_stringlist_item(expectfiles, expectfile);

initStringInfo(&psql_cmd);

if (launcher)
{
offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
"%s ", launcher);
if (offset >= sizeof(psql_cmd))
{
fprintf(stderr, _("command too long\n"));
exit(2);
}
}
appendStringInfo(&psql_cmd, "%s ", launcher);

offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
"\"%s\" \"dbname=%s\" < \"%s\" > \"%s\" 2>&1",
isolation_exec,
dblist->str,
infile,
outfile);
if (offset >= sizeof(psql_cmd))
{
fprintf(stderr, _("command too long\n"));
exit(2);
}
appendStringInfo(&psql_cmd,
"\"%s\" \"dbname=%s\" < \"%s\" > \"%s\" 2>&1",
isolation_exec,
dblist->str,
infile,
outfile);

appnameenv = psprintf("isolation/%s", testname);
setenv("PGAPPNAME", appnameenv, 1);
free(appnameenv);

pid = spawn_process(psql_cmd);
pid = spawn_process(psql_cmd.data);

if (pid == INVALID_PID)
{
Expand All @@ -126,6 +115,8 @@ isolation_start_test(const char *testname,

unsetenv("PGAPPNAME");

pfree(psql_cmd.data);

return pid;
}

Expand Down
43 changes: 17 additions & 26 deletions src/oracle_test/regress/pg_regress_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "postgres_fe.h"

#include "lib/stringinfo.h"
#include "pg_regress.h"


Expand All @@ -36,8 +37,7 @@ psql_start_test(const char *testname,
char infile[MAXPGPATH];
char outfile[MAXPGPATH];
char expectfile[MAXPGPATH];
char psql_cmd[MAXPGPATH * 3];
size_t offset = 0;
StringInfoData psql_cmd;
char *appnameenv;

/*
Expand All @@ -64,41 +64,30 @@ psql_start_test(const char *testname,
add_stringlist_item(resultfiles, outfile);
add_stringlist_item(expectfiles, expectfile);

initStringInfo(&psql_cmd);

if (launcher)
{
offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
"%s ", launcher);
if (offset >= sizeof(psql_cmd))
{
fprintf(stderr, _("command too long\n"));
exit(2);
}
}
appendStringInfo(&psql_cmd, "%s ", launcher);

/*
* Use HIDE_TABLEAM to hide different AMs to allow to use regression tests
* against different AMs without unnecessary differences.
*/
offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
"\"%s%spsql\" -p %d -X -a -q -d \"%s\" %s < \"%s\" > \"%s\" 2>&1",
bindir ? bindir : "",
bindir ? "/" : "",
psql_get_ivorysql_port(dblist->str),
dblist->str,
"-v HIDE_TABLEAM=on -v HIDE_TOAST_COMPRESSION=on",
infile,
outfile);
if (offset >= sizeof(psql_cmd))
{
fprintf(stderr, _("command too long\n"));
exit(2);
}
appendStringInfo(&psql_cmd,
"\"%s%spsql\" -p %d -X -a -q -d \"%s\" %s < \"%s\" > \"%s\" 2>&1",
bindir ? bindir : "",
bindir ? "/" : "",
psql_get_ivorysql_port(dblist->str),
dblist->str,
"-v HIDE_TABLEAM=on -v HIDE_TOAST_COMPRESSION=on",
infile,
outfile);

appnameenv = psprintf("pg_regress/%s", testname);
setenv("PGAPPNAME", appnameenv, 1);
free(appnameenv);

pid = spawn_process(psql_cmd);
pid = spawn_process(psql_cmd.data);

if (pid == INVALID_PID)
{
Expand All @@ -109,6 +98,8 @@ psql_start_test(const char *testname,

unsetenv("PGAPPNAME");

pfree(psql_cmd.data);

return pid;
}

Expand Down

0 comments on commit 74cc2a1

Please sign in to comment.