Update every test to import `lldb_shared`.
This is necessary in order to allow third party modules to be
located under lldb/third_party rather than under the test
folder directly.
Since we're already touching every test file anyway, we also
go ahead and delete the unittest2 import and main block wherever
possible. The ability to run a test as a standalone file has
already been broken for some time, and if we decide we want this
back, we should use unittest instead of unittest2.
A few places could not have the import of unittest2 removed,because
they depend on the unittest2.expectedFailure or skip decorators.
Removing all those was orthogonal in spirit to the purpose of this
CL, so the import of unittest2 remains in those files that were
using it for its test decorators. Those can be addressed
separately.
llvm-svn: 251055
diff --git a/lldb/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py b/lldb/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
index 3907e44..5dae2a0 100644
--- a/lldb/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
+++ b/lldb/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
@@ -1,7 +1,8 @@
"""Test that the 'add-dsym', aka 'target symbols add', succeeds in the middle of debug session."""
+import lldb_shared
+
import os, time
-import unittest2
import lldb
import sys
from lldbtest import *
@@ -40,9 +41,3 @@
self.expect("frame select",
substrs = ['a.out`main at main.c'])
-
-if __name__ == '__main__':
- import atexit
- lldb.SBDebugger.Initialize()
- atexit.register(lambda: lldb.SBDebugger.Terminate())
- unittest2.main()
diff --git a/lldb/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py b/lldb/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py
index 3ff481f..6e739f5 100644
--- a/lldb/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py
+++ b/lldb/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py
@@ -2,8 +2,9 @@
Test that clang produces the __apple accelerator tables, for example, __apple_types, correctly.
"""
+import lldb_shared
+
import os, time
-import unittest2
import lldb
from lldbtest import *
from lldbutil import symbol_type_to_str
@@ -62,10 +63,3 @@
self.assertTrue(dwarf_section.FindSubSection("__apple_names") and
dwarf_section.FindSubSection("__apple_namespac") and
dwarf_section.FindSubSection("__apple_objc"))
-
-
-if __name__ == '__main__':
- import atexit
- lldb.SBDebugger.Initialize()
- atexit.register(lambda: lldb.SBDebugger.Terminate())
- unittest2.main()
diff --git a/lldb/test/macosx/indirect_symbol/TestIndirectSymbols.py b/lldb/test/macosx/indirect_symbol/TestIndirectSymbols.py
index c28d047..7f1fabc 100644
--- a/lldb/test/macosx/indirect_symbol/TestIndirectSymbols.py
+++ b/lldb/test/macosx/indirect_symbol/TestIndirectSymbols.py
@@ -1,7 +1,8 @@
"""Test stepping and setting breakpoints in indirect and re-exported symbols."""
+import lldb_shared
+
import os, time
-import unittest2
import lldb
import lldbutil
from lldbtest import *
@@ -83,11 +84,3 @@
self.assertTrue (len(threads) == 1, "Stopped at breakpoint in reexported function target.")
curr_function = thread.GetFrameAtIndex(0).GetFunctionName()
self.assertTrue (curr_function == "call_through_indirect_hidden", "Stepped into indirect symbols.")
-
-
-
-if __name__ == '__main__':
- import atexit
- lldb.SBDebugger.Initialize()
- atexit.register(lambda: lldb.SBDebugger.Terminate())
- unittest2.main()
diff --git a/lldb/test/macosx/order/TestOrderFile.py b/lldb/test/macosx/order/TestOrderFile.py
index d8b7f37..b0d9fd9 100644
--- a/lldb/test/macosx/order/TestOrderFile.py
+++ b/lldb/test/macosx/order/TestOrderFile.py
@@ -2,9 +2,10 @@
Test that debug symbols have the correct order as specified by the order file.
"""
+import lldb_shared
+
import os, time
import re
-import unittest2
import lldb
from lldbtest import *
@@ -31,9 +32,3 @@
"Symbols have correct order by the order file")
self.runCmd("run", RUN_COMPLETED)
-
-if __name__ == '__main__':
- import atexit
- lldb.SBDebugger.Initialize()
- atexit.register(lambda: lldb.SBDebugger.Terminate())
- unittest2.main()
diff --git a/lldb/test/macosx/queues/TestQueues.py b/lldb/test/macosx/queues/TestQueues.py
index b15c38a..82149e3 100644
--- a/lldb/test/macosx/queues/TestQueues.py
+++ b/lldb/test/macosx/queues/TestQueues.py
@@ -1,7 +1,9 @@
"""Test queues inspection SB APIs."""
-import os, time
+import lldb_shared
+
import unittest2
+import os, time
import lldb
import lldbutil
from lldbtest import *
@@ -237,9 +239,3 @@
self.assertTrue(queue_performer_2.GetPendingItemAtIndex(9998).IsValid(), "queue 2's pending item #9998 is valid")
self.assertTrue(queue_performer_2.GetPendingItemAtIndex(9998).GetAddress().GetSymbol().GetName() == "doing_the_work_2", "queue 2's pending item #0 should be doing_the_work_2")
self.assertTrue(queue_performer_2.GetPendingItemAtIndex(9999).IsValid() == False, "queue 2's pending item #9999 is invalid")
-
-if __name__ == '__main__':
- import atexit
- lldb.SBDebugger.Initialize()
- atexit.register(lambda: lldb.SBDebugger.Terminate())
- unittest2.main()
diff --git a/lldb/test/macosx/safe-to-func-call/TestSafeFuncCalls.py b/lldb/test/macosx/safe-to-func-call/TestSafeFuncCalls.py
index 8299bd2..6e77790 100644
--- a/lldb/test/macosx/safe-to-func-call/TestSafeFuncCalls.py
+++ b/lldb/test/macosx/safe-to-func-call/TestSafeFuncCalls.py
@@ -1,7 +1,8 @@
"""Test function call thread safety."""
+import lldb_shared
+
import os, time
-import unittest2
import lldb
import lldbutil
from lldbtest import *
@@ -58,9 +59,3 @@
def safe_to_call_func_on_select_thread (self, select_thread):
self.assertTrue(select_thread.SafeToCallFunctions() == False, "It is not safe to call functions on the select thread")
-
-if __name__ == '__main__':
- import atexit
- lldb.SBDebugger.Initialize()
- atexit.register(lambda: lldb.SBDebugger.Terminate())
- unittest2.main()
diff --git a/lldb/test/macosx/universal/TestUniversal.py b/lldb/test/macosx/universal/TestUniversal.py
index 7c3decf..9628c53 100644
--- a/lldb/test/macosx/universal/TestUniversal.py
+++ b/lldb/test/macosx/universal/TestUniversal.py
@@ -1,7 +1,9 @@
"""Test aspects of lldb commands on universal binaries."""
-import os, time
+import lldb_shared
+
import unittest2
+import os, time
import lldb
from lldbtest import *
import lldbutil
@@ -101,10 +103,3 @@
substrs = ['Name: eax'])
self.runCmd("continue")
-
-
-if __name__ == '__main__':
- import atexit
- lldb.SBDebugger.Initialize()
- atexit.register(lambda: lldb.SBDebugger.Terminate())
- unittest2.main()