[PATCH] Tests and interface for LeakSanitizer.

Dmitry Vyukov dvyukov at google.com
Tue Apr 23 01:30:34 PDT 2013



================
Comment at: lib/lsan/tests/lsan_test.cc:1
@@ +1,2 @@
+//=-- lsan_test.cc --------------------------------------------------------===//
+//
----------------
Alexey Samsonov wrote:
> Kostya Serebryany wrote:
> > I like gtest very much, but I am not sure if it is well suited for testing lsan. 
> > lsan has a global state (allocator) which changes from one test to another. 
> > And we are actually testing how this global state is handled. 
> > So, I am inclined to use lit-style tests for lsan (maybe with a common header),
> >  leaving gtest tests for only a small ubset of lsan testing
> > 
> > What others think here? 
> We definitely should have unit test for LSan like this one, as it's more or less "real" program, with multiple files, STL etc.
> But adding a bunch of positive/negative lit tests for specific cases, that would match resulting error report, would certainly be good. I think we may (should) add such lit tests as a separate commit later.
Gtest-based system tests worked not very well for tsan. There are several reasons:
1. This required exposing tool guts and introduce additional external interfaces.
2. This had problems with cumulative state. E.g. when you malloc-free, malloc-free, the second malloc can return the same pointer as the first one, if the first pointer has settled somewhere, the leak of the second pointer won't be detected.
3. Extremely difficult to check reports (what we actually care about in system tests).
I switched mostly to lit tests now.

However I successfully use gtest for unit tests of internal components.




http://llvm-reviews.chandlerc.com/D677

BRANCH
  lsan_interface_and_tests

ARCANIST PROJECT
  compiler-rt



More information about the llvm-commits mailing list