|
From: Olly B. <ol...@su...> - 2006-11-13 15:08:19
|
On 2006-11-13, Mattias Ståhlberg XX <mat...@er...> wrote:
> I'm trying to understand how to use the option --error-exitcode to make
> my testcases started from make stop when a memory leak is found.
I don't think leaks count as errors (at least not for these purposes).
Your best option might be to add this just before the test case exits:
if (RUNNING_ON_VALGRIND) {
VALGRIND_DO_LEAK_CHECK;
long vg_leaks = 0, vg_dubious = 0, vg_reachable = 0, dummy;
VALGRIND_COUNT_LEAKS(vg_leaks, vg_dubious, vg_reachable, dummy);
if (vg_leaks || vg_dubious || vg_reachable) exit(1);
}
You only want to test vg_dubious if you ever hold on to allocated blocks
only by a pointer which isn't to the start. Otherwise it just increases
the small chance that a garbage value will accidentally act as a
reference to a leaked block and hide a leak.
Cheers,
Olly
|