summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorglider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-13 13:34:17 +0000
committerglider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-13 13:34:17 +0000
commitf732dfd8be9cb88fdb3a2ab26c234b5b7e71b592 (patch)
tree89655a9298aa6abe9d78405d7ef7e7f60f540d73 /base
parent191c8eda0122ce2cfa0cbf216a4440a7f053e7df (diff)
downloadchromium_src-f732dfd8be9cb88fdb3a2ab26c234b5b7e71b592.zip
chromium_src-f732dfd8be9cb88fdb3a2ab26c234b5b7e71b592.tar.gz
chromium_src-f732dfd8be9cb88fdb3a2ab26c234b5b7e71b592.tar.bz2
Enable ToolsSanityTest.SingleElementDeletedWithBraces and ToolsSanityTest.ArrayDeletedWithoutBraces under AddressSanitizer on Linux.
Make the tests free the memory to avoid leak reports from LSan. BUG=172614 R=thakis@chromium.org Review URL: https://codereview.chromium.org/276493002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/tools_sanity_unittest.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/base/tools_sanity_unittest.cc b/base/tools_sanity_unittest.cc
index b1da3e1..602efb7 100644
--- a/base/tools_sanity_unittest.cc
+++ b/base/tools_sanity_unittest.cc
@@ -100,24 +100,25 @@ TEST(ToolsSanityTest, MemoryLeak) {
// error report mechanism is different than with Asan so these tests will fail.
#define MAYBE_AccessesToNewMemory DISABLED_AccessesToNewMemory
#define MAYBE_AccessesToMallocMemory DISABLED_AccessesToMallocMemory
+#define MAYBE_SingleElementDeletedWithBraces \
+ DISABLED_SingleElementDeletedWithBraces
+#define MAYBE_ArrayDeletedWithoutBraces DISABLED_ArrayDeletedWithoutBraces
#else
#define MAYBE_AccessesToNewMemory AccessesToNewMemory
#define MAYBE_AccessesToMallocMemory AccessesToMallocMemory
+
+#if !defined(OS_MACOSX)
+// AddressSanitizer for OSX doesn't support alloc-dealloc mismatch checks.
#define MAYBE_ArrayDeletedWithoutBraces ArrayDeletedWithoutBraces
#define MAYBE_SingleElementDeletedWithBraces SingleElementDeletedWithBraces
-#endif
-
-// The following tests pass with Clang r170392, but not r172454, which
-// makes AddressSanitizer detect errors in them. We disable these tests under
-// AddressSanitizer until we fully switch to Clang r172454. After that the
-// tests should be put back under the (defined(OS_IOS) || defined(OS_WIN))
-// clause above.
-// See also http://crbug.com/172614.
-#if defined(ADDRESS_SANITIZER) || defined(SYZYASAN)
+#else
+#define MAYBE_ArrayDeletedWithoutBraces DISABLED_ArrayDeletedWithoutBraces
#define MAYBE_SingleElementDeletedWithBraces \
DISABLED_SingleElementDeletedWithBraces
-#define MAYBE_ArrayDeletedWithoutBraces DISABLED_ArrayDeletedWithoutBraces
#endif
+
+#endif
+
TEST(ToolsSanityTest, MAYBE_AccessesToNewMemory) {
char *foo = new char[10];
MakeSomeErrors(foo, 10);
@@ -144,7 +145,12 @@ TEST(ToolsSanityTest, MAYBE_ArrayDeletedWithoutBraces) {
// Without the |volatile|, clang optimizes away the next two lines.
int* volatile foo = new int[10];
- delete foo;
+ HARMFUL_ACCESS(delete foo, "alloc-dealloc-mismatch");
+#if defined(ADDRESS_SANITIZER)
+ // Under ASan the crash happens in the process spawned by HARMFUL_ACCESS,
+ // need to free the memory in the parent.
+ delete [] foo;
+#endif
}
TEST(ToolsSanityTest, MAYBE_SingleElementDeletedWithBraces) {
@@ -158,7 +164,12 @@ TEST(ToolsSanityTest, MAYBE_SingleElementDeletedWithBraces) {
// Without the |volatile|, clang optimizes away the next two lines.
int* volatile foo = new int;
(void) foo;
- delete [] foo;
+ HARMFUL_ACCESS(delete [] foo, "alloc-dealloc-mismatch");
+#if defined(ADDRESS_SANITIZER)
+ // Under ASan the crash happens in the child process, need to free the memory
+ // in the parent.
+ delete foo;
+#endif
}
#if defined(ADDRESS_SANITIZER) || defined(SYZYASAN)