Repository: incubator-hawq Updated Branches: refs/heads/HAWQ-400 c91aed5b0 -> 1aec59ce5 (forced update)
HAWQ-400. Support expected exit codes for regression tests, fixed leaks. Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/1aec59ce Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/1aec59ce Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/1aec59ce Branch: refs/heads/HAWQ-400 Commit: 1aec59ce5169e26d5b63bca2da49eb3485429db5 Parents: 73eb65f Author: Oleksandr Diachenko <odiache...@pivotal.io> Authored: Thu Feb 18 15:03:20 2016 -0800 Committer: Oleksandr Diachenko <odiache...@pivotal.io> Committed: Fri Feb 19 13:45:58 2016 -0800 ---------------------------------------------------------------------- src/test/regress/pg_regress.c | 23 ++++++++++++++--------- src/test/regress/pg_regress.h | 2 ++ src/test/regress/pg_regress_main.c | 7 ++++++- 3 files changed, 22 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/1aec59ce/src/test/regress/pg_regress.c ---------------------------------------------------------------------- diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index b1f1846..9ba82eb 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -91,8 +91,8 @@ static int port = -1; static char *user = NULL; static char *srcdir = NULL; static _stringlist *extraroles = NULL; -static char *initfile = "./init_file"; -static char *expected_statuses_file = "expected_statuses"; +char *initfile = NULL; +char *expected_statuses_file = NULL; /* internal variables */ static const char *progname; @@ -575,7 +575,7 @@ load_expected_statuses(char *filename) f = fopen(filename, "r"); if (!f) { - fprintf(stderr, _("could not open file with expected statuses for reading: \n")); + fprintf(stderr, _("could not open file with expected statuses for reading: %s\n"), filename); exit_nicely(2); } @@ -780,6 +780,8 @@ doputenv(const char *var, const char *val) sprintf(s, "%s=%s", var, val); putenv(s); + + free(s); } /* @@ -844,6 +846,8 @@ initialize_environment(void) new_pgoptions = malloc(strlen(old_pgoptions) + strlen(my_pgoptions) + 12); sprintf(new_pgoptions, "PGOPTIONS=%s %s", old_pgoptions, my_pgoptions); putenv(new_pgoptions); + + free(new_pgoptions); } { @@ -982,6 +986,7 @@ spawn_process(const char *cmdline) execl(shellprog, shellprog, "-c", cmdline2, (char *) NULL); fprintf(stderr, _("%s: could not exec \"%s\": %s\n"), progname, shellprog, strerror(errno)); + free(cmdline2); exit(1); /* not exit_nicely here... */ } /* in parent */ @@ -1057,6 +1062,7 @@ spawn_process(const char *cmdline) cmdline2 = malloc(strlen(cmdline) + 8); sprintf(cmdline2, "cmd /c %s", cmdline); + free(cmdline2); #ifndef __CYGWIN__ AddUserToTokenDacl(restrictedToken); @@ -2072,12 +2078,6 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc hostname = "localhost"; #endif - /* - * We call the initialization function here because that way we can set - * default parameters and let them be overwritten by the commandline. - */ - ifunc(); - while ((c = getopt_long(argc, argv, "hV", long_options, &option_index)) != -1) { switch (c) @@ -2177,6 +2177,11 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc } /* + * Set default values if user didn't pass arguments + */ + ifunc(); + + /* * Initialization */ open_result_files(); http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/1aec59ce/src/test/regress/pg_regress.h ---------------------------------------------------------------------- diff --git a/src/test/regress/pg_regress.h b/src/test/regress/pg_regress.h index 94db0b4..906cef4 100644 --- a/src/test/regress/pg_regress.h +++ b/src/test/regress/pg_regress.h @@ -38,6 +38,8 @@ extern char *datadir; extern char *host_platform; extern _stringlist *dblist; +extern char *initfile; +extern char *expected_statuses_file; extern bool debug; extern char *inputdir; extern char *outputdir; http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/1aec59ce/src/test/regress/pg_regress_main.c ---------------------------------------------------------------------- diff --git a/src/test/regress/pg_regress_main.c b/src/test/regress/pg_regress_main.c index b3245b5..afbf132 100644 --- a/src/test/regress/pg_regress_main.c +++ b/src/test/regress/pg_regress_main.c @@ -108,7 +108,12 @@ static void psql_init(void) { /* set default regression database name */ - add_stringlist_item(&dblist, "regression"); + if (!dblist) + add_stringlist_item(&dblist, "regression"); + if(!expected_statuses_file) + expected_statuses_file = "expected_statuses"; + if(!initfile) + initfile = "./init_file"; } int