Add valgrind target to C Makefile
The test suites can now be run under Valgrind with
make valgrind
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/2d4038df
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/2d4038df
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/2d4038df
Branch: refs/heads/master
Commit: 2d4038df13a22c3fa8370a9cac80dfbb5b082b1c
Parents: 3b5d9d0
Author: Nick Wellnhofer <[email protected]>
Authored: Sun May 15 13:36:28 2016 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Sun May 15 17:29:38 2016 +0200
----------------------------------------------------------------------
compiler/common/charmonizer.c | 9 +++++++++
compiler/common/charmonizer.main | 9 +++++++++
runtime/common/charmonizer.c | 19 +++++++++++++++++++
runtime/common/charmonizer.main | 19 +++++++++++++++++++
4 files changed, 56 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2d4038df/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index 58dfb47..085aa17 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -8156,6 +8156,15 @@ S_write_makefile(struct chaz_CLI *cli) {
chaz_MakeRule_add_prereq(rule, test_cfc_exe);
chaz_MakeRule_add_command(rule, test_cfc_exe);
+ if (chaz_OS_shell_type() == CHAZ_OS_POSIX) {
+ rule = chaz_MakeFile_add_rule(makefile, "valgrind", "all");
+ chaz_MakeRule_add_prereq(rule, test_cfc_exe);
+ scratch = chaz_Util_join(" ", "CLOWNFISH_VALGRIND=1", "valgrind",
+ "--leak-check=full", test_cfc_exe, NULL);
+ chaz_MakeRule_add_command(rule, scratch);
+ free(scratch);
+ }
+
if (chaz_CLI_defined(cli, "enable-coverage")) {
rule = chaz_MakeFile_add_rule(makefile, "coverage", test_cfc_exe);
chaz_MakeRule_add_command(rule,
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2d4038df/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.main b/compiler/common/charmonizer.main
index 0fb262e..e505c35 100644
--- a/compiler/common/charmonizer.main
+++ b/compiler/common/charmonizer.main
@@ -261,6 +261,15 @@ S_write_makefile(struct chaz_CLI *cli) {
chaz_MakeRule_add_prereq(rule, test_cfc_exe);
chaz_MakeRule_add_command(rule, test_cfc_exe);
+ if (chaz_OS_shell_type() == CHAZ_OS_POSIX) {
+ rule = chaz_MakeFile_add_rule(makefile, "valgrind", "all");
+ chaz_MakeRule_add_prereq(rule, test_cfc_exe);
+ scratch = chaz_Util_join(" ", "CLOWNFISH_VALGRIND=1", "valgrind",
+ "--leak-check=full", test_cfc_exe, NULL);
+ chaz_MakeRule_add_command(rule, scratch);
+ free(scratch);
+ }
+
if (chaz_CLI_defined(cli, "enable-coverage")) {
rule = chaz_MakeFile_add_rule(makefile, "coverage", test_cfc_exe);
chaz_MakeRule_add_command(rule,
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2d4038df/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index 7adf55f..fb30483 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -8391,6 +8391,7 @@ cfish_MakeFile_write_c_test_rules(cfish_MakeFile *self) {
char *test_cfish_exe;
char *test_cfish_c;
char *test_command;
+ char *valgrind_command = NULL;
test_cfish_exe = chaz_Util_join("", "t", dir_sep, "test_cfish", exe_ext,
NULL);
@@ -8420,6 +8421,23 @@ cfish_MakeFile_write_c_test_rules(cfish_MakeFile *self) {
}
chaz_MakeRule_add_command(rule, test_command);
+ if (chaz_OS_shell_type() == CHAZ_OS_POSIX) {
+ rule = chaz_MakeFile_add_rule(self->makefile, "valgrind",
+ test_cfish_exe);
+ if (strcmp(chaz_OS_shared_lib_ext(), ".so") == 0) {
+ valgrind_command
+ = chaz_Util_join(" ", "LD_LIBRARY_PATH=.",
+ "CLOWNFISH_VALGRIND=1", "valgrind",
+ "--leak-check=full", test_cfish_exe, NULL);
+ }
+ else {
+ valgrind_command
+ = chaz_Util_join(" ", "CLOWNFISH_VALGRIND=1", "valgrind",
+ "--leak-check=full", test_cfish_exe, NULL);
+ }
+ chaz_MakeRule_add_command(rule, valgrind_command);
+ }
+
if (chaz_CLI_defined(self->cli, "enable-coverage")) {
rule = chaz_MakeFile_add_rule(self->makefile, "coverage",
test_cfish_exe);
@@ -8459,6 +8477,7 @@ cfish_MakeFile_write_c_test_rules(cfish_MakeFile *self) {
free(test_cfish_exe);
free(test_cfish_c);
free(test_command);
+ free(valgrind_command);
}
static void
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2d4038df/runtime/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main
index 3e92f86..f396fb9 100644
--- a/runtime/common/charmonizer.main
+++ b/runtime/common/charmonizer.main
@@ -496,6 +496,7 @@ cfish_MakeFile_write_c_test_rules(cfish_MakeFile *self) {
char *test_cfish_exe;
char *test_cfish_c;
char *test_command;
+ char *valgrind_command = NULL;
test_cfish_exe = chaz_Util_join("", "t", dir_sep, "test_cfish", exe_ext,
NULL);
@@ -525,6 +526,23 @@ cfish_MakeFile_write_c_test_rules(cfish_MakeFile *self) {
}
chaz_MakeRule_add_command(rule, test_command);
+ if (chaz_OS_shell_type() == CHAZ_OS_POSIX) {
+ rule = chaz_MakeFile_add_rule(self->makefile, "valgrind",
+ test_cfish_exe);
+ if (strcmp(chaz_OS_shared_lib_ext(), ".so") == 0) {
+ valgrind_command
+ = chaz_Util_join(" ", "LD_LIBRARY_PATH=.",
+ "CLOWNFISH_VALGRIND=1", "valgrind",
+ "--leak-check=full", test_cfish_exe, NULL);
+ }
+ else {
+ valgrind_command
+ = chaz_Util_join(" ", "CLOWNFISH_VALGRIND=1", "valgrind",
+ "--leak-check=full", test_cfish_exe, NULL);
+ }
+ chaz_MakeRule_add_command(rule, valgrind_command);
+ }
+
if (chaz_CLI_defined(self->cli, "enable-coverage")) {
rule = chaz_MakeFile_add_rule(self->makefile, "coverage",
test_cfish_exe);
@@ -564,6 +582,7 @@ cfish_MakeFile_write_c_test_rules(cfish_MakeFile *self) {
free(test_cfish_exe);
free(test_cfish_c);
free(test_command);
+ free(valgrind_command);
}
static void