Skip to content

Commit

Permalink
Revert "Add asan tests for libsanitizers. (#88349)"
Browse files Browse the repository at this point in the history
This reverts commit 82f479b due to bot breakage.
  • Loading branch information
adrian-prantl committed Apr 16, 2024
1 parent bf1ad1d commit f8e2ec1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 97 deletions.
6 changes: 1 addition & 5 deletions lldb/test/API/functionalities/asan/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
C_SOURCES := main.c
asan: CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
asan: all

libsanitizers: CFLAGS_EXTRAS := -fsanitize=address -fsanitize-stable-abi -g -gcolumn-info
libsanitizers: all
CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info

include Makefile.rules
73 changes: 1 addition & 72 deletions lldb/test/API/functionalities/asan/TestMemoryHistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,15 @@
from lldbsuite.test import lldbplatform
from lldbsuite.test import lldbutil

from functionalities.libsanitizers.util import no_libsanitizers

class AsanTestCase(TestBase):
@skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
@expectedFailureNetBSD
@skipUnlessAddressSanitizer
def test(self):
self.build(make_targets=["asan"])
self.build()
self.asan_tests()

@skipIf(oslist=no_match(["macosx"]))
def test_libsanitizers_asan(self):
self.build(make_targets=["libsanitizers"])
self.libsanitizer_tests()

def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
Expand All @@ -32,71 +26,6 @@ def setUp(self):
self.line_free = line_number("main.c", "// free line")
self.line_breakpoint = line_number("main.c", "// break line")

# Test line numbers: rdar://126237493
def libsanitizer_tests(self):
target = self.createTestTarget()

if no_libsanitizers(self):
self.skipTest("libsanitizers not found")

self.runCmd(
"env SanitizersAddress=1 MallocSanitizerZone=1 MallocSecureAllocator=0"
)

self.runCmd("run")

# In libsanitizers, memory history is not supported until a report has been generated
self.expect(
"thread list",
"Process should be stopped due to ASan report",
substrs=["stopped", "stop reason = Use of deallocated memory"],
)

# test the 'memory history' command
self.expect(
"memory history 'pointer'",
substrs=[
"Memory deallocated by Thread",
"a.out`f2",
"main.c",
"Memory allocated by Thread",
"a.out`f1",
"main.c",
],
)

# do the same using SB API
process = self.dbg.GetSelectedTarget().process
val = (
process.GetSelectedThread().GetSelectedFrame().EvaluateExpression("pointer")
)
addr = val.GetValueAsUnsigned()
threads = process.GetHistoryThreads(addr)
self.assertEqual(threads.GetSize(), 2)

history_thread = threads.GetThreadAtIndex(0)
self.assertTrue(history_thread.num_frames >= 2)
self.assertEqual(
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
"main.c",
)

history_thread = threads.GetThreadAtIndex(1)
self.assertTrue(history_thread.num_frames >= 2)
self.assertEqual(
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
"main.c",
)

# let's free the container (SBThreadCollection) and see if the
# SBThreads still live
threads = None
self.assertTrue(history_thread.num_frames >= 2)
self.assertEqual(
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
"main.c",
)

def asan_tests(self):
target = self.createTestTarget()

Expand Down
20 changes: 3 additions & 17 deletions lldb/test/API/functionalities/asan/TestReportData.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,16 @@
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil

from functionalities.libsanitizers.util import no_libsanitizers

class AsanTestReportDataCase(TestBase):
@skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
@expectedFailureNetBSD
@skipUnlessAddressSanitizer
@skipIf(archs=["i386"], bugnumber="llvm.org/PR36710")
def test(self):
self.build(make_targets=["asan"])
self.build()
self.asan_tests()

@skipIf(oslist=no_match(["macosx"]))
def test_libsanitizers_asan(self):
self.build(make_targets=["libsanitizers"])
self.asan_tests(libsanitizers=True)

def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
Expand All @@ -35,18 +29,10 @@ def setUp(self):
self.line_crash = line_number("main.c", "// BOOM line")
self.col_crash = 16

def asan_tests(self, libsanitizers=False):
def asan_tests(self):
target = self.createTestTarget()

if libsanitizers and no_libsanitizers(self):
self.skipTest("libsanitizers not found")

if libsanitizers:
self.runCmd(
"env SanitizersAddress=1 MallocSanitizerZone=1 MallocSecureAllocator=0"
)
else:
self.registerSanitizerLibrariesWithTarget(target)
self.registerSanitizerLibrariesWithTarget(target)

self.runCmd("run")

Expand Down
3 changes: 0 additions & 3 deletions lldb/test/API/functionalities/libsanitizers/util.py

This file was deleted.

0 comments on commit f8e2ec1

Please sign in to comment.