Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-400 4fddda4a2 -> 3da25cef4 (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/3da25cef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/3da25cef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/3da25cef

Branch: refs/heads/HAWQ-400
Commit: 3da25cef4bc10a30764a4545f764e349998723d2
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 17:03:11 2016 -0800

----------------------------------------------------------------------
 src/test/regress/pg_regress.c      | 25 ++++++++++++++++---------
 src/test/regress/pg_regress.h      |  2 ++
 src/test/regress/pg_regress_main.c |  7 ++++++-
 3 files changed, 24 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/3da25cef/src/test/regress/pg_regress.c
----------------------------------------------------------------------
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index b1f1846..e103df1 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);
        }
 
        {
@@ -892,6 +896,7 @@ initialize_environment(void)
        convert_sourcefiles();
        load_resultmap();
        load_expected_statuses(expected_statuses_file);
+       free(expected_statuses_file);
 }
 
 /*
@@ -982,6 +987,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 +1063,7 @@ spawn_process(const char *cmdline)
 
        cmdline2 = malloc(strlen(cmdline) + 8);
        sprintf(cmdline2, "cmd /c %s", cmdline);
+       free(cmdline2);
 
 #ifndef __CYGWIN__
        AddUserToTokenDacl(restrictedToken);
@@ -1276,6 +1283,7 @@ results_differ(const char *testname, const char 
*resultsfile, const char *defaul
 
          snprintf(m_pretty_diff_opts, sizeof(m_pretty_diff_opts),
                           "%s --gpd_init %s", pretty_diff_opts, initfile);
+         free(initfile);
        }
        else
        {
@@ -2072,12 +2080,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 +2179,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/3da25cef/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/3da25cef/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

Reply via email to