[PATCH] Tests and interface for LeakSanitizer.

Alexey Samsonov samsonov at google.com
Mon Apr 22 12:51:33 PDT 2013



================
Comment at: lib/lsan/tests/lsan_test.cc:32
@@ +31,3 @@
+uptr kMagic = 0xBABABABABABABABA;
+#define HIDE(p) ((void *)((uptr)(p) ^ kMagic))
+#define PEEK(p) HIDE(p)
----------------
Sergey Matveev wrote:
> Kostya Serebryany wrote:
> > any reason to use macros instead of inline functions? 
> We could in this case, but if they failed to inline for some reason, tests where stacks are enabled would break.
I think __attribute__((always_inline)) may help with this.

================
Comment at: lib/lsan/tests/lsan_test.cc:1
@@ +1,2 @@
+//=-- lsan_test.cc --------------------------------------------------------===//
+//
----------------
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.


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

BRANCH
  lsan_interface_and_tests

ARCANIST PROJECT
  compiler-rt



More information about the llvm-commits mailing list