Skip to content

Commit

Permalink
Merge pull request #4566 from elliefm/v39/cunit-under-valgrind-should…
Browse files Browse the repository at this point in the history
…-fail-if-mem-errors

make 'check' etc fail on cunit valgrind errors
  • Loading branch information
elliefm authored Aug 16, 2023
2 parents f717cd3 + f33d6c6 commit 95e0a9f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,11 @@ cunit/registers.h: $(CUNIT_PROJECT)
$(AM_V_GEN)$(CUNIT_PL) --generate-register-function $@

# To run under Valgrind, do: make VG=1 check
VALGRIND = libtool --mode=execute valgrind --tool=memcheck --leak-check=full --suppressions=vg.supp
VALGRIND = libtool --mode=execute valgrind \
--tool=memcheck \
--leak-check=full \
--suppressions=vg.supp \
--error-exitcode=75

check-local:
@echo "Running unit tests"
Expand All @@ -729,7 +733,7 @@ check-local:
check-discrete: cunit/unit
@echo "Running unit tests, one at a time"
@vg= ; \
test -z "$$VG" || vg="$(VALGRIND) --quiet --error-exitcode=75 --log-fd=3" ; \
test -z "$$VG" || vg="$(VALGRIND) --quiet --log-fd=3" ; \
cd cunit ; \
fails=0 ; \
tests=0 ; \
Expand Down
2 changes: 2 additions & 0 deletions cunit/annotate.testc
Original file line number Diff line number Diff line change
Expand Up @@ -2151,6 +2151,8 @@ static void test_canon_value(void)
ealist = NULL;
}

buf_free(&val);

annotate_state_abort(&astate);
mailbox_close(&mailbox);
annotatemore_close();
Expand Down
6 changes: 6 additions & 0 deletions cunit/strarray.testc
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,8 @@ static void test_appendv(void)
s = strarray_appendv(&sa, "ipsum");
CU_ASSERT_PTR_EQUAL(s, strarray_nth(&sa, 1));
CU_ASSERT_EQUAL(strarray_size(&sa), 2);

strarray_fini(&sa);
}

static void test_addv(void)
Expand All @@ -1744,6 +1746,8 @@ static void test_addv(void)
s = strarray_addv(&sa, "lorem");
CU_ASSERT_PTR_EQUAL(s, strarray_nth(&sa, 0));
CU_ASSERT_EQUAL(strarray_size(&sa), 2);

strarray_fini(&sa);
}

static void test_add_casev(void)
Expand All @@ -1762,6 +1766,8 @@ static void test_add_casev(void)
s = strarray_add_casev(&sa, "lOREm");
CU_ASSERT_PTR_EQUAL(s, strarray_nth(&sa, 0));
CU_ASSERT_EQUAL(strarray_size(&sa), 2);

strarray_fini(&sa);
}

/* vim: set ft=c: */

0 comments on commit 95e0a9f

Please sign in to comment.