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/lang/c/anonymous/TestAnonymous.py b/lldb/test/lang/c/anonymous/TestAnonymous.py
index da0ef5b..1899384 100644
--- a/lldb/test/lang/c/anonymous/TestAnonymous.py
+++ b/lldb/test/lang/c/anonymous/TestAnonymous.py
@@ -1,7 +1,8 @@
 """Test that anonymous structs/unions are transparent to member access"""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -142,9 +143,3 @@
         # The breakpoint should have a hit count of 1.
         self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
             substrs = [' resolved, hit count = 1'])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/array_types/TestArrayTypes.py b/lldb/test/lang/c/array_types/TestArrayTypes.py
index e159efc..98e839c 100644
--- a/lldb/test/lang/c/array_types/TestArrayTypes.py
+++ b/lldb/test/lang/c/array_types/TestArrayTypes.py
@@ -1,7 +1,8 @@
 """Test breakpoint by file/line number; and list variables with array types."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -193,10 +194,3 @@
         self.assertTrue(argc.GetValueType() == lldb.eValueTypeVariableArgument,
                         "Variable 'argc' should have '%s' value type." %
                         value_type_to_str(lldb.eValueTypeVariableArgument))
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/bitfields/TestBitfields.py b/lldb/test/lang/c/bitfields/TestBitfields.py
index 090b319..024af2d 100644
--- a/lldb/test/lang/c/bitfields/TestBitfields.py
+++ b/lldb/test/lang/c/bitfields/TestBitfields.py
@@ -1,7 +1,8 @@
 """Show bitfields and check that they display correctly."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -157,10 +158,3 @@
         # Now kill the process, and we are done.
         rc = target.GetProcess().Kill()
         self.assertTrue(rc.Success())
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/blocks/TestBlocks.py b/lldb/test/lang/c/blocks/TestBlocks.py
index 6dd4bec..783401e 100644
--- a/lldb/test/lang/c/blocks/TestBlocks.py
+++ b/lldb/test/lang/c/blocks/TestBlocks.py
@@ -1,7 +1,9 @@
 """Test that lldb can invoke blocks and access variables inside them"""
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 from lldbtest import *
 import lldbutil
@@ -55,9 +57,3 @@
         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
             substrs = ['stopped',
                        'stop reason = breakpoint'])
-            
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/const_variables/TestConstVariables.py b/lldb/test/lang/c/const_variables/TestConstVariables.py
index 8954e49..30fc91a 100644
--- a/lldb/test/lang/c/const_variables/TestConstVariables.py
+++ b/lldb/test/lang/c/const_variables/TestConstVariables.py
@@ -1,7 +1,8 @@
 """Check that compiler-generated constant values work correctly"""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -57,9 +58,3 @@
             substrs = ['(int) $1 = 256'])
 
         self.runCmd("kill")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/enum_types/TestEnumTypes.py b/lldb/test/lang/c/enum_types/TestEnumTypes.py
index 96d2907..6f1c52d 100644
--- a/lldb/test/lang/c/enum_types/TestEnumTypes.py
+++ b/lldb/test/lang/c/enum_types/TestEnumTypes.py
@@ -1,7 +1,8 @@
 """Look up enum type information and check for correct display."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -66,9 +67,3 @@
             self.expect("frame variable day", 'check for valid enumeration value',
                 substrs = [enum_value])
             lldbutil.continue_to_breakpoint (self.process(), bkpt)
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/forward/TestForwardDeclaration.py b/lldb/test/lang/c/forward/TestForwardDeclaration.py
index 9eb8ae6..6db0b30 100644
--- a/lldb/test/lang/c/forward/TestForwardDeclaration.py
+++ b/lldb/test/lang/c/forward/TestForwardDeclaration.py
@@ -1,7 +1,8 @@
 """Test that forward declaration of a data structure gets resolved correctly."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -42,10 +43,3 @@
             substrs = ['(bar)',
                        '(int) a = 1',
                        '(int) b = 2'])
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/function_types/TestFunctionTypes.py b/lldb/test/lang/c/function_types/TestFunctionTypes.py
index f8ac8a6..fb46ea8 100644
--- a/lldb/test/lang/c/function_types/TestFunctionTypes.py
+++ b/lldb/test/lang/c/function_types/TestFunctionTypes.py
@@ -1,7 +1,8 @@
 """Test variable with function ptr type and that break on the function works."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -71,9 +72,3 @@
         # The breakpoint should have a hit count of 1.
         self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
                     substrs = [' resolved, hit count = 1'])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/global_variables/TestGlobalVariables.py b/lldb/test/lang/c/global_variables/TestGlobalVariables.py
index 2300509..7d9c0dd 100644
--- a/lldb/test/lang/c/global_variables/TestGlobalVariables.py
+++ b/lldb/test/lang/c/global_variables/TestGlobalVariables.py
@@ -1,7 +1,8 @@
 """Show global variables and check that they do indeed have global scopes."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -72,10 +73,3 @@
                     substrs = ['g_marked_spot.y', '21'])
         self.expect("target variable g_marked_spot.y", VARIABLES_DISPLAYED_CORRECTLY, matching=False,
                     substrs = ["can't be resolved"])
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/modules/TestCModules.py b/lldb/test/lang/c/modules/TestCModules.py
index 1ac8484..5875c77 100644
--- a/lldb/test/lang/c/modules/TestCModules.py
+++ b/lldb/test/lang/c/modules/TestCModules.py
@@ -1,7 +1,8 @@
 """Test that importing modules in C works as expected."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import platform
 import lldbutil
@@ -60,9 +61,3 @@
         TestBase.setUp(self)
         # Find the line number to break inside main().
         self.line = line_number('main.c', '// Set breakpoint 0 here.')
-            
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/register_variables/TestRegisterVariables.py b/lldb/test/lang/c/register_variables/TestRegisterVariables.py
index 9274524..a73bc26 100644
--- a/lldb/test/lang/c/register_variables/TestRegisterVariables.py
+++ b/lldb/test/lang/c/register_variables/TestRegisterVariables.py
@@ -1,7 +1,8 @@
 """Check that compiler-generated register values work correctly"""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -65,9 +66,3 @@
             substrs = ['(int) $3 = 5'])
 
         self.runCmd("kill")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/set_values/TestSetValues.py b/lldb/test/lang/c/set_values/TestSetValues.py
index 4e64a41..ae70f77 100644
--- a/lldb/test/lang/c/set_values/TestSetValues.py
+++ b/lldb/test/lang/c/set_values/TestSetValues.py
@@ -1,7 +1,8 @@
 """Test settings and readings of program variables."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -106,10 +107,3 @@
         self.runCmd("expression i = 1.5")
         self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
             startstr = "(long double) i = 1.5")
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/shared_lib/TestSharedLib.py b/lldb/test/lang/c/shared_lib/TestSharedLib.py
index f2a84af..dd09527 100644
--- a/lldb/test/lang/c/shared_lib/TestSharedLib.py
+++ b/lldb/test/lang/c/shared_lib/TestSharedLib.py
@@ -1,5 +1,7 @@
 """Test that types defined in shared libraries work correctly."""
 
+import lldb_shared
+
 import unittest2
 import lldb
 from lldbtest import *
@@ -65,9 +67,3 @@
         # The breakpoint should have a hit count of 1.
         self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
             substrs = [' resolved, hit count = 1'])
-                       
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py b/lldb/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
index c6cd427..611a361 100644
--- a/lldb/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
+++ b/lldb/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
@@ -1,5 +1,7 @@
 """Test that types defined in shared libraries with stripped symbols work correctly."""
 
+import lldb_shared
+
 import unittest2
 import lldb
 from lldbtest import *
@@ -67,9 +69,3 @@
         # The breakpoint should have a hit count of 1.
         self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
             substrs = [' resolved, hit count = 1'])
-                       
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/stepping/TestStepAndBreakpoints.py b/lldb/test/lang/c/stepping/TestStepAndBreakpoints.py
index 11d639a..ed50926 100644
--- a/lldb/test/lang/c/stepping/TestStepAndBreakpoints.py
+++ b/lldb/test/lang/c/stepping/TestStepAndBreakpoints.py
@@ -1,7 +1,8 @@
 """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -237,9 +238,3 @@
 
         thread.StepInto("NoSuchFunction")
         self.assertTrue (thread.GetFrameAtIndex(0).GetFunctionName() == "main")
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/stepping/TestThreadStepping.py b/lldb/test/lang/c/stepping/TestThreadStepping.py
index 50322b8..e02551b 100644
--- a/lldb/test/lang/c/stepping/TestThreadStepping.py
+++ b/lldb/test/lang/c/stepping/TestThreadStepping.py
@@ -2,9 +2,10 @@
 Test thread stepping features in combination with frame select.
 """
 
+import lldb_shared
+
 import os, time
 import re
-import unittest2
 import lldb, lldbutil
 from lldbtest import *
 import lldbutil
@@ -75,10 +76,3 @@
         self.expect("thread backtrace", STEP_OUT_SUCCEEDED,
             substrs = ["stop reason = step out"],
             patterns = ["frame #0.*main.c:%d" % self.line4])
-        
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/strings/TestCStrings.py b/lldb/test/lang/c/strings/TestCStrings.py
index a2752df..f1d9be2 100644
--- a/lldb/test/lang/c/strings/TestCStrings.py
+++ b/lldb/test/lang/c/strings/TestCStrings.py
@@ -52,9 +52,3 @@
 
         self.expect("expression !z",
                     substrs = ['false'])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/tls_globals/TestTlsGlobals.py b/lldb/test/lang/c/tls_globals/TestTlsGlobals.py
index 564f069..305ff39 100644
--- a/lldb/test/lang/c/tls_globals/TestTlsGlobals.py
+++ b/lldb/test/lang/c/tls_globals/TestTlsGlobals.py
@@ -1,7 +1,9 @@
 """Test that thread-local storage can be read correctly."""
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 from lldbtest import *
 import lldbutil
@@ -69,9 +71,3 @@
             patterns = ["\(int\) \$.* = 44"])
         self.expect("expr var_shared", VARIABLES_DISPLAYED_CORRECTLY,
             patterns = ["\(int\) \$.* = 33"])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/c/typedef/Testtypedef.py b/lldb/test/lang/c/typedef/Testtypedef.py
index c00bcd4..5c2882b 100644
--- a/lldb/test/lang/c/typedef/Testtypedef.py
+++ b/lldb/test/lang/c/typedef/Testtypedef.py
@@ -1,7 +1,8 @@
 """Look up type information for typedefs of same name at different lexical scope and check for correct display."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -43,9 +44,3 @@
             self.expect("image lookup -t a", DATA_TYPES_DISPLAYED_CORRECTLY,
             substrs = ['name = "' + t + '"'])
             self.runCmd("continue")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/bool/TestCPPBool.py b/lldb/test/lang/cpp/bool/TestCPPBool.py
index 9138217..0724fc5 100644
--- a/lldb/test/lang/cpp/bool/TestCPPBool.py
+++ b/lldb/test/lang/cpp/bool/TestCPPBool.py
@@ -24,9 +24,3 @@
 
         self.expect("expression -- my_bool = true",
                     startstr = "(bool) $1 = true")
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py b/lldb/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py
index a8b69de..867bfed 100644
--- a/lldb/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py
+++ b/lldb/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py
@@ -2,8 +2,9 @@
 Test lldb breakpoint command for CPP methods & functions in a namespace.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 
@@ -79,11 +80,3 @@
                                                             a_out_module,
                                                             nested_comp_unit)
         self.assertTrue (plain_method_break.GetNumLocations() == 1)
-
-        
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/call-function/TestCallCPPFunction.py b/lldb/test/lang/cpp/call-function/TestCallCPPFunction.py
index 6adbcd6..bba2399 100644
--- a/lldb/test/lang/cpp/call-function/TestCallCPPFunction.py
+++ b/lldb/test/lang/cpp/call-function/TestCallCPPFunction.py
@@ -31,9 +31,3 @@
 
         self.expect("expression -- a_function_to_call()",
                     startstr = "(int) $0 = 0")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/chained-calls/TestCppChainedCalls.py b/lldb/test/lang/cpp/chained-calls/TestCppChainedCalls.py
index a6cf56c..fa9338a 100644
--- a/lldb/test/lang/cpp/chained-calls/TestCppChainedCalls.py
+++ b/lldb/test/lang/cpp/chained-calls/TestCppChainedCalls.py
@@ -71,9 +71,3 @@
 
         test_result = frame.EvaluateExpression("get(t) && get(t)")
         self.assertTrue(test_result.IsValid() and test_result.GetValue() == "true", "get(t) && get(t) = true")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/char1632_t/TestChar1632T.py b/lldb/test/lang/cpp/char1632_t/TestChar1632T.py
index f604c34..7392f79 100644
--- a/lldb/test/lang/cpp/char1632_t/TestChar1632T.py
+++ b/lldb/test/lang/cpp/char1632_t/TestChar1632T.py
@@ -3,8 +3,9 @@
 Test that the C++11 support for char16_t and char32_t works correctly.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -85,9 +86,3 @@
         # Check that we can run expressions that return charN_t
         self.expect("expression u'a'",substrs = ['(char16_t) $',"61 u'a'"])
         self.expect("expression U'a'",substrs = ['(char32_t) $',"61 U'a'"])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/class_static/TestStaticVariables.py b/lldb/test/lang/cpp/class_static/TestStaticVariables.py
index 88aeb72..c9182fe 100644
--- a/lldb/test/lang/cpp/class_static/TestStaticVariables.py
+++ b/lldb/test/lang/cpp/class_static/TestStaticVariables.py
@@ -2,8 +2,9 @@
 Test display and Python APIs on file and class static variables.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -115,10 +116,3 @@
         val = frame.FindValue("hello_world", lldb.eValueTypeVariableLocal)
         self.DebugSBValue(val)
         self.assertTrue(val.GetName() == 'hello_world')
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/class_types/TestClassTypes.py b/lldb/test/lang/cpp/class_types/TestClassTypes.py
index 2e9353b..6d737e0 100644
--- a/lldb/test/lang/cpp/class_types/TestClassTypes.py
+++ b/lldb/test/lang/cpp/class_types/TestClassTypes.py
@@ -1,7 +1,8 @@
 """Test breakpoint on a class constructor; and variable list the this object."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -210,9 +211,3 @@
         self.assertTrue (frame.IsValid(), "Got a valid frame.")
 
         self.assertTrue ("C::C" in frame.name, "Constructor name includes class name.")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/class_types/TestClassTypesDisassembly.py b/lldb/test/lang/cpp/class_types/TestClassTypesDisassembly.py
index 866b100..031c2b3 100644
--- a/lldb/test/lang/cpp/class_types/TestClassTypesDisassembly.py
+++ b/lldb/test/lang/cpp/class_types/TestClassTypesDisassembly.py
@@ -2,8 +2,9 @@
 Test the lldb disassemble command on each call frame when stopped on C's ctor.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -89,9 +90,3 @@
         # We should be stopped on the ctor function of class C.
         # self.expect("thread backtrace", BACKTRACE_DISPLAYED_CORRECTLY,
         #  substrs = ['C::C'])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/diamond/TestDiamond.py b/lldb/test/lang/cpp/diamond/TestDiamond.py
index 6c9f6e4..f4222eb 100644
--- a/lldb/test/lang/cpp/diamond/TestDiamond.py
+++ b/lldb/test/lang/cpp/diamond/TestDiamond.py
@@ -39,9 +39,3 @@
         # Some compilers (for example GCC 4.4.7 and 4.6.1) emit multiple locations for the statement with the ternary
         # operator in the test program, while others emit only 1.
         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line, num_expected_locations=-1, loc_exact=False)
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/dynamic-value/TestCppValueCast.py b/lldb/test/lang/cpp/dynamic-value/TestCppValueCast.py
index 431f19f..f46bad7 100644
--- a/lldb/test/lang/cpp/dynamic-value/TestCppValueCast.py
+++ b/lldb/test/lang/cpp/dynamic-value/TestCppValueCast.py
@@ -2,9 +2,11 @@
 Test lldb Python API SBValue::Cast(SBType) for C++ types.
 """
 
+import lldb_shared
+
+import unittest2
 import os, time
 import re
-import unittest2
 import lldb, lldbutil
 from lldbtest import *
 
@@ -122,10 +124,3 @@
         b_member_val = instanceB.GetChildMemberWithName('m_b_val')
         self.DebugSBValue(b_member_val)
         self.assertTrue(b_member_val.GetValueAsUnsigned(error, 0) == 36)
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/dynamic-value/TestDynamicValue.py b/lldb/test/lang/cpp/dynamic-value/TestDynamicValue.py
index f7f9e67..3ef4193 100644
--- a/lldb/test/lang/cpp/dynamic-value/TestDynamicValue.py
+++ b/lldb/test/lang/cpp/dynamic-value/TestDynamicValue.py
@@ -2,9 +2,10 @@
 Use lldb Python API to test dynamic values in C++
 """
 
+import lldb_shared
+
 import os, time
 import re
-import unittest2
 import lldb, lldbutil
 from lldbtest import *
 
@@ -217,10 +218,3 @@
         contained_b_static_addr = int (contained_b_static.GetValue(), 16)
         
         self.assertTrue (contained_b_addr < contained_b_static_addr)
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/enum_types/TestCPP11EnumTypes.py b/lldb/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
index e8072ef..c0fb310 100644
--- a/lldb/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
+++ b/lldb/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
@@ -1,7 +1,8 @@
 """Look up enum type information and check for correct display."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -105,8 +106,3 @@
             self.expect("frame variable day", 'check for valid enumeration value',
                 substrs = [enum_value])
             lldbutil.continue_to_breakpoint (self.process(), bkpt)
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py b/lldb/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py
index cc6805e..51135c7 100644
--- a/lldb/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py
+++ b/lldb/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py
@@ -2,8 +2,9 @@
 Test lldb exception breakpoint command for CPP.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -60,10 +61,3 @@
         self.assertTrue (frame_functions.count ("throws_exception_on_even(int)") == 0, "At catch our throw function is off the stack")
         self.assertTrue (frame_functions.count ("intervening_function(int)") == 0,     "At catch our intervening function is off the stack")
         self.assertTrue (frame_functions.count ("catches_exception(int)") == 1, "At catch our catch function is on the stack")
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/global_operators/TestCppGlobalOperators.py b/lldb/test/lang/cpp/global_operators/TestCppGlobalOperators.py
index 6299116..68ff52e 100644
--- a/lldb/test/lang/cpp/global_operators/TestCppGlobalOperators.py
+++ b/lldb/test/lang/cpp/global_operators/TestCppGlobalOperators.py
@@ -52,10 +52,3 @@
 
         test_result = frame.EvaluateExpression("operator==(s2, s3)")
         self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "operator==(s2, s3) = false")
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py b/lldb/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py
index 931f546..2764f31 100644
--- a/lldb/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py
+++ b/lldb/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py
@@ -63,9 +63,3 @@
 
         # Get frame for current thread
         return thread.GetSelectedFrame()
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/namespace/TestNamespace.py b/lldb/test/lang/cpp/namespace/TestNamespace.py
index fd59881..08825c4 100644
--- a/lldb/test/lang/cpp/namespace/TestNamespace.py
+++ b/lldb/test/lang/cpp/namespace/TestNamespace.py
@@ -2,8 +2,9 @@
 Test the printing of anonymous and named namespace variables.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -106,9 +107,3 @@
 
         self.expect("p variadic_sum",
             patterns = ['\(anonymous namespace\)::variadic_sum\(int, ...\)'])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/nsimport/TestCppNsImport.py b/lldb/test/lang/cpp/nsimport/TestCppNsImport.py
index 076356d..3411959 100644
--- a/lldb/test/lang/cpp/nsimport/TestCppNsImport.py
+++ b/lldb/test/lang/cpp/nsimport/TestCppNsImport.py
@@ -98,10 +98,3 @@
         # Test function inside namespace
         test_result = frame.EvaluateExpression("fun_var")
         self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 5, "fun_var = 5")
-        
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py b/lldb/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py
index 38cec0f..7eff685 100644
--- a/lldb/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py
+++ b/lldb/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py
@@ -34,9 +34,3 @@
 
         self.expect("expression -- Static()",
                     startstr = "(int) $1 = 1")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/rdar12991846/TestRdar12991846.py b/lldb/test/lang/cpp/rdar12991846/TestRdar12991846.py
index 23bf8a1..4ac48e1 100644
--- a/lldb/test/lang/cpp/rdar12991846/TestRdar12991846.py
+++ b/lldb/test/lang/cpp/rdar12991846/TestRdar12991846.py
@@ -3,8 +3,10 @@
 Test that the expression parser returns proper Unicode strings.
 """
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 from lldbtest import *
 import lldbutil
@@ -79,9 +81,3 @@
         if expr == 2: self.expect('expression u"hello"', substrs = ['hello'])
 
         if expr == 3: self.expect('expression U"hello"', substrs = ['hello'])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/rvalue-references/TestRvalueReferences.py b/lldb/test/lang/cpp/rvalue-references/TestRvalueReferences.py
index ea9d135..2f62be5 100644
--- a/lldb/test/lang/cpp/rvalue-references/TestRvalueReferences.py
+++ b/lldb/test/lang/cpp/rvalue-references/TestRvalueReferences.py
@@ -47,9 +47,3 @@
 
     def set_breakpoint(self, line):
         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line, num_expected_locations=1, loc_exact=True)
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/scope/TestCppScope.py b/lldb/test/lang/cpp/scope/TestCppScope.py
index 4d5ea8b..f984eed 100644
--- a/lldb/test/lang/cpp/scope/TestCppScope.py
+++ b/lldb/test/lang/cpp/scope/TestCppScope.py
@@ -65,9 +65,3 @@
             value = frame.EvaluateExpression(name)
             assert_value = global_variables_assert[name]
             self.assertTrue(value.IsValid() and value.GetValueAsSigned() == assert_value, name + " = " + str(assert_value))
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/signed_types/TestSignedTypes.py b/lldb/test/lang/cpp/signed_types/TestSignedTypes.py
index 9c1f683..8ae2e22 100644
--- a/lldb/test/lang/cpp/signed_types/TestSignedTypes.py
+++ b/lldb/test/lang/cpp/signed_types/TestSignedTypes.py
@@ -2,9 +2,10 @@
 Test that variables with signed types display correctly.
 """
 
+import lldb_shared
+
 import os, time
 import re
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -55,10 +56,3 @@
             substrs = ["(int) the_signed_int = 99",
                        "(long) the_signed_long = 99",
                        "(long long) the_signed_long_long = 99"])
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/static_members/TestCPPStaticMembers.py b/lldb/test/lang/cpp/static_members/TestCPPStaticMembers.py
index de85a57..f221a1a 100644
--- a/lldb/test/lang/cpp/static_members/TestCPPStaticMembers.py
+++ b/lldb/test/lang/cpp/static_members/TestCPPStaticMembers.py
@@ -1,6 +1,10 @@
 """
 Tests that C++ member and static variables have correct layout and scope.
 """
+
+import lldb_shared
+
+import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -51,10 +55,3 @@
 
     def set_breakpoint(self, line):
         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line, num_expected_locations=1, loc_exact=False)
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/static_methods/TestCPPStaticMethods.py b/lldb/test/lang/cpp/static_methods/TestCPPStaticMethods.py
index c44af75..4887a69 100644
--- a/lldb/test/lang/cpp/static_methods/TestCPPStaticMethods.py
+++ b/lldb/test/lang/cpp/static_methods/TestCPPStaticMethods.py
@@ -34,9 +34,3 @@
 
         self.expect("expression -- my_a.getMemberValue()",
                     startstr = "(int) $1 = 3")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/stl/TestSTL.py b/lldb/test/lang/cpp/stl/TestSTL.py
index b74009f..e326526 100644
--- a/lldb/test/lang/cpp/stl/TestSTL.py
+++ b/lldb/test/lang/cpp/stl/TestSTL.py
@@ -2,8 +2,10 @@
 Test some expressions involving STL data types.
 """
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 import lldbutil
 from lldbtest import *
@@ -112,10 +114,3 @@
 
         # Check that both entries of the dictionary have 'True' as the value.
         self.assertTrue(all(expected_types.values()))
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/stl/TestStdCXXDisassembly.py b/lldb/test/lang/cpp/stl/TestStdCXXDisassembly.py
index abcc300..dad5bf2 100644
--- a/lldb/test/lang/cpp/stl/TestStdCXXDisassembly.py
+++ b/lldb/test/lang/cpp/stl/TestStdCXXDisassembly.py
@@ -2,8 +2,10 @@
 Test the lldb disassemble command on lib stdc++.
 """
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 from lldbtest import *
 import lldbutil
@@ -104,10 +106,3 @@
             else:
                 # This entry is not a Code entry.  Reset SA = None.
                 SA = None
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/this/TestCPPThis.py b/lldb/test/lang/cpp/this/TestCPPThis.py
index e4b5d61..4c99845 100644
--- a/lldb/test/lang/cpp/this/TestCPPThis.py
+++ b/lldb/test/lang/cpp/this/TestCPPThis.py
@@ -51,9 +51,3 @@
     
     def set_breakpoint(self, line):
         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line, num_expected_locations=1, loc_exact=False)
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py b/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py
index c251563..a1c9f25 100644
--- a/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py
+++ b/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py
@@ -2,7 +2,8 @@
 Test that template instaniations of std::vector<long> and <short> in the same module have the correct types.
 """
 
-import unittest2
+import lldb_shared
+
 import lldb
 import lldbutil
 from lldbtest import *
@@ -57,10 +58,3 @@
                 continue
             self.expect(x, "Expect type 'short'", exe=False,
                 substrs = ['short'])
-        
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py b/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py
index d49d3b8..a2c8ff7 100644
--- a/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py
+++ b/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py
@@ -2,9 +2,10 @@
 Test that variables with unsigned types display correctly.
 """
 
+import lldb_shared
+
 import os, time
 import re
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -49,10 +50,3 @@
                        "(unsigned long) the_unsigned_long = 99",
                        "(unsigned long long) the_unsigned_long_long = 99",
                        "(uint32_t) the_uint32 = 99"])
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/cpp/wchar_t/TestCxxWCharT.py b/lldb/test/lang/cpp/wchar_t/TestCxxWCharT.py
index 2438873..d2b3ab9 100644
--- a/lldb/test/lang/cpp/wchar_t/TestCxxWCharT.py
+++ b/lldb/test/lang/cpp/wchar_t/TestCxxWCharT.py
@@ -3,8 +3,9 @@
 Test that C++ supports wchar_t correctly.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -69,9 +70,3 @@
         
         self.expect('frame variable wchar_zero', substrs=["L'\\0'"])
         self.expect('expression wchar_zero', substrs=["L'\\0'"])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/go/goroutines/TestGoroutines.py b/lldb/test/lang/go/goroutines/TestGoroutines.py
index 05f6aa8..6c26a3a 100644
--- a/lldb/test/lang/go/goroutines/TestGoroutines.py
+++ b/lldb/test/lang/go/goroutines/TestGoroutines.py
@@ -1,7 +1,8 @@
 """Test the Go OS Plugin."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -80,10 +81,3 @@
         self.dbg.HandleCommand("settings set plugin.os.goroutines.enable false")
         self.thread().StepInstruction(False)
         self.assertLess(len(self.process().threads), 20)
-        
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/go/types/TestGoASTContext.py b/lldb/test/lang/go/types/TestGoASTContext.py
index ccfca85..457b6d3 100644
--- a/lldb/test/lang/go/types/TestGoASTContext.py
+++ b/lldb/test/lang/go/types/TestGoASTContext.py
@@ -1,7 +1,8 @@
 """Test the go DWARF type parsing."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -128,10 +129,3 @@
         self.assertEqual(5, v.GetNumChildren())
         for i in xrange(5):
             self.assertEqual(str(i + 1), v.GetChildAtIndex(i).value)
-        
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/mixed/TestMixedLanguages.py b/lldb/test/lang/mixed/TestMixedLanguages.py
index 5d4e284..1fbf118 100644
--- a/lldb/test/lang/mixed/TestMixedLanguages.py
+++ b/lldb/test/lang/mixed/TestMixedLanguages.py
@@ -1,7 +1,8 @@
 """Test that lldb works correctly on compile units form different languages."""
 
+import lldb_shared
+
 import os, time, re
-import unittest2
 import lldb
 from lldbtest import *
 
@@ -51,9 +52,3 @@
         # (note: C++11 is enabled by default for C++).
         self.expect("expr foo != nullptr",
             patterns = ["true"])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/blocks/TestObjCIvarsInBlocks.py b/lldb/test/lang/objc/blocks/TestObjCIvarsInBlocks.py
index 281c155..a629dcf 100644
--- a/lldb/test/lang/objc/blocks/TestObjCIvarsInBlocks.py
+++ b/lldb/test/lang/objc/blocks/TestObjCIvarsInBlocks.py
@@ -1,7 +1,8 @@
 """Test printing ivars and ObjC objects captured in blocks that are made in methods of an ObjC class."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -98,9 +99,3 @@
         ret_value_signed = expr.GetValueAsSigned (error)
         # print 'ret_value_signed = %i' % (ret_value_signed)
         self.assertTrue (ret_value_signed == 5, "The local variable in the block was what we expected.")
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/forward-decl/TestForwardDecl.py b/lldb/test/lang/objc/forward-decl/TestForwardDecl.py
index 4b21e35..6c2f109 100644
--- a/lldb/test/lang/objc/forward-decl/TestForwardDecl.py
+++ b/lldb/test/lang/objc/forward-decl/TestForwardDecl.py
@@ -1,7 +1,8 @@
 """Test that a forward-declared class works when its complete definition is in a library"""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -49,9 +50,3 @@
         # This should display correctly.
         self.expect("expression [j getMember]", VARIABLES_DISPLAYED_CORRECTLY,
             substrs = ["= 0x"])
-            
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/foundation/TestConstStrings.py b/lldb/test/lang/objc/foundation/TestConstStrings.py
index a3780e0..772f5d7 100644
--- a/lldb/test/lang/objc/foundation/TestConstStrings.py
+++ b/lldb/test/lang/objc/foundation/TestConstStrings.py
@@ -3,8 +3,9 @@
 parser.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -48,10 +49,3 @@
 
         self.expect('expression (int)[@"123" length]',
             startstr = "(int) $3 = 3")
-
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/foundation/TestFoundationDisassembly.py b/lldb/test/lang/objc/foundation/TestFoundationDisassembly.py
index 3fb6792..cd03e76 100644
--- a/lldb/test/lang/objc/foundation/TestFoundationDisassembly.py
+++ b/lldb/test/lang/objc/foundation/TestFoundationDisassembly.py
@@ -2,8 +2,10 @@
 Test the lldb disassemble command on foundation framework.
 """
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 from lldbtest import *
 import lldbutil
@@ -128,10 +130,3 @@
 
         # Do the disassemble for the currently stopped function.
         self.runCmd("disassemble -f")
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/foundation/TestObjCMethods.py b/lldb/test/lang/objc/foundation/TestObjCMethods.py
index 5be2e3c..1417d01 100644
--- a/lldb/test/lang/objc/foundation/TestObjCMethods.py
+++ b/lldb/test/lang/objc/foundation/TestObjCMethods.py
@@ -3,8 +3,9 @@
 Also lookup objective-c data types and evaluate expressions.
 """
 
+import lldb_shared
+
 import os, os.path, time
-import unittest2
 import lldb
 import string
 from lldbtest import *
@@ -79,7 +80,6 @@
         self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]",
             substrs = ["Foundation`-[NSAutoreleasePool release]"])
 
-    #@unittest2.expectedFailure
     # rdar://problem/8542091
     # rdar://problem/8492646
     def test_data_type_and_expr(self):
@@ -258,9 +258,3 @@
                     print line,
             self.assertTrue(num_errors == 0, "Spurious lookups detected")
             f.close()
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/foundation/TestObjCMethods2.py b/lldb/test/lang/objc/foundation/TestObjCMethods2.py
index 59eb995..9c6ce04 100644
--- a/lldb/test/lang/objc/foundation/TestObjCMethods2.py
+++ b/lldb/test/lang/objc/foundation/TestObjCMethods2.py
@@ -2,8 +2,9 @@
 Test more expression command sequences with objective-c.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -164,9 +165,3 @@
                     error = True, 
                     patterns = ["no known method", "cast the message send to the method's return type"])
         self.runCmd("process continue")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/foundation/TestObjectDescriptionAPI.py b/lldb/test/lang/objc/foundation/TestObjectDescriptionAPI.py
index 0831032..6dd9b90 100644
--- a/lldb/test/lang/objc/foundation/TestObjectDescriptionAPI.py
+++ b/lldb/test/lang/objc/foundation/TestObjectDescriptionAPI.py
@@ -2,9 +2,10 @@
 Test SBValue.GetObjectDescription() with the value from SBTarget.FindGlobalVariables().
 """
 
+import lldb_shared
+
 import os, time
 import re
-import unittest2
 import lldb, lldbutil
 from lldbtest import *
 
@@ -65,10 +66,3 @@
                 print "object description:", v.GetObjectDescription()
             if v.GetName() == 'my_global_str':
                 self.assertTrue(v.GetObjectDescription() == 'This is a global string')
-
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/foundation/TestRuntimeTypes.py b/lldb/test/lang/objc/foundation/TestRuntimeTypes.py
index 55e9713..a302fcc 100644
--- a/lldb/test/lang/objc/foundation/TestRuntimeTypes.py
+++ b/lldb/test/lang/objc/foundation/TestRuntimeTypes.py
@@ -2,8 +2,9 @@
 Test that Objective-C methods from the runtime work correctly.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -43,9 +44,3 @@
 
         self.expect("po $1", VARIABLES_DISPLAYED_CORRECTLY,
             substrs = ["foo"])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/foundation/TestSymbolTable.py b/lldb/test/lang/objc/foundation/TestSymbolTable.py
index 0d23816..3b1d820 100644
--- a/lldb/test/lang/objc/foundation/TestSymbolTable.py
+++ b/lldb/test/lang/objc/foundation/TestSymbolTable.py
@@ -2,8 +2,9 @@
 Test symbol table access for main.m.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 
@@ -63,10 +64,3 @@
         #print "symbols unaccounted for:", expected_symbols
         self.assertTrue(len(expected_symbols) == 0,
                         "All the known symbols are accounted for")
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/hidden-ivars/TestHiddenIvars.py b/lldb/test/lang/objc/hidden-ivars/TestHiddenIvars.py
index 2942650..a36ba61 100644
--- a/lldb/test/lang/objc/hidden-ivars/TestHiddenIvars.py
+++ b/lldb/test/lang/objc/hidden-ivars/TestHiddenIvars.py
@@ -1,7 +1,9 @@
 """Test that hidden ivars in a shared library are visible from the main executable."""
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 from lldbtest import *
 import lldbutil
@@ -168,10 +170,3 @@
         else:
             self.expect("frame variable *k", VARIABLES_DISPLAYED_CORRECTLY,
                 substrs = ["foo = 2", "bar = 3", '_filteredDataSource = 0x', '"2 elements"'])
-
-                       
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py b/lldb/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py
index b614d75..2ccd8bc 100644
--- a/lldb/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py
+++ b/lldb/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py
@@ -2,9 +2,10 @@
 Test that dynamically discovered ivars of type IMP do not crash LLDB
 """
 
+import lldb_shared
+
 import os, time
 import re
-import unittest2
 import lldb, lldbutil
 from lldbtest import *
 import commands
@@ -57,9 +58,3 @@
         self.expect('disassemble --start-address `((MyClass*)object)->myImp`', substrs=[
             '-[MyClass init]'
         ])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/modules-auto-import/TestModulesAutoImport.py b/lldb/test/lang/objc/modules-auto-import/TestModulesAutoImport.py
index 8a11c24..a836cda 100644
--- a/lldb/test/lang/objc/modules-auto-import/TestModulesAutoImport.py
+++ b/lldb/test/lang/objc/modules-auto-import/TestModulesAutoImport.py
@@ -1,7 +1,9 @@
 """Test that importing modules in Objective-C works as expected."""
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 import platform
 import lldbutil
@@ -47,9 +49,3 @@
 
         self.expect("p getpid()", VARIABLES_DISPLAYED_CORRECTLY,
             substrs = ["pid_t"])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/modules-incomplete/TestIncompleteModules.py b/lldb/test/lang/objc/modules-incomplete/TestIncompleteModules.py
index 60bb82d..0db2a11 100644
--- a/lldb/test/lang/objc/modules-incomplete/TestIncompleteModules.py
+++ b/lldb/test/lang/objc/modules-incomplete/TestIncompleteModules.py
@@ -1,7 +1,9 @@
 """Test that DWARF types are trusted over module types"""
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 import platform
 import lldbutil
@@ -55,9 +57,3 @@
 
         self.expect("expr MAX(2,3)", "#undefd macro was correcltly not found",
             error=True)
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py b/lldb/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py
index 02ac9d7..b322cf0 100644
--- a/lldb/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py
+++ b/lldb/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py
@@ -1,7 +1,9 @@
 """Test that inline functions from modules are imported correctly"""
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 import platform
 import lldbutil
@@ -48,9 +50,3 @@
 
         self.expect("expr isInline(2)", VARIABLES_DISPLAYED_CORRECTLY,
             substrs = ["4"])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/modules/TestObjCModules.py b/lldb/test/lang/objc/modules/TestObjCModules.py
index b3a5d13..aa3351a 100644
--- a/lldb/test/lang/objc/modules/TestObjCModules.py
+++ b/lldb/test/lang/objc/modules/TestObjCModules.py
@@ -1,7 +1,9 @@
 """Test that importing modules in Objective-C works as expected."""
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 import platform
 import lldbutil
@@ -65,9 +67,3 @@
 
         self.expect("p [NSURL URLWithString:@\"http://lldb.llvm.org\"].scheme", VARIABLES_DISPLAYED_CORRECTLY,
             substrs = ["http"])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc++/TestObjCXX.py b/lldb/test/lang/objc/objc++/TestObjCXX.py
index 1ae73bd..2c5b320 100644
--- a/lldb/test/lang/objc/objc++/TestObjCXX.py
+++ b/lldb/test/lang/objc/objc++/TestObjCXX.py
@@ -2,8 +2,9 @@
 Make sure that ivars of Objective-C++ classes are visible in LLDB.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -28,9 +29,3 @@
 
         self.expect("expr f->f", "Found ivar in class",
             substrs = ["= 3"])
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py b/lldb/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
index f7d8d5b..da4b146 100644
--- a/lldb/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
+++ b/lldb/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
@@ -2,9 +2,10 @@
 Use lldb Python API to test base class resolution for ObjC classes
 """
 
+import lldb_shared
+
 import os, time
 import re
-import unittest2
 import lldb, lldbutil
 from lldbtest import *
 
@@ -52,9 +53,3 @@
         self.assertTrue(var_pte_type.GetDirectBaseClassAtIndex(0).IsValid(), "Foo * has a valid base class")
 
         self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex(0).GetName() == var_pte_type.GetDirectBaseClassAtIndex(0).GetName(), "Foo and its pointer type don't agree on their base class")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
index f07adb6..eeedc9b 100644
--- a/lldb/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -1,7 +1,8 @@
 """Test that the expression parser doesn't get confused by 'id' and 'Class'"""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -50,9 +51,3 @@
         self.expect("expr (foo)", patterns = ["\(ns::id\) \$.* = 0"])
 
         self.expect("expr id my_id = 0; my_id", patterns = ["\(id\) \$.* = nil"])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-checker/TestObjCCheckers.py b/lldb/test/lang/objc/objc-checker/TestObjCCheckers.py
index 8f816c5..15820b6 100644
--- a/lldb/test/lang/objc/objc-checker/TestObjCCheckers.py
+++ b/lldb/test/lang/objc/objc-checker/TestObjCCheckers.py
@@ -2,9 +2,10 @@
 Use lldb Python API to make sure the dynamic checkers are doing their jobs.
 """
 
+import lldb_shared
+
 import os, time
 import re
-import unittest2
 import lldb, lldbutil
 from lldbtest import *
 
@@ -69,9 +70,3 @@
         # Make sure the error is helpful:
         err_string = expr_error.GetCString()
         self.assertTrue ("selector" in err_string)
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-class-method/TestObjCClassMethod.py b/lldb/test/lang/objc/objc-class-method/TestObjCClassMethod.py
index 27b0915..70cb513 100644
--- a/lldb/test/lang/objc/objc-class-method/TestObjCClassMethod.py
+++ b/lldb/test/lang/objc/objc-class-method/TestObjCClassMethod.py
@@ -1,7 +1,8 @@
 """Test calling functions in class methods."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -51,9 +52,3 @@
         cmd_value = frame.EvaluateExpression ("(int)[Foo doSomethingWithString:@\"Hello\"]")
         self.assertTrue (cmd_value.IsValid())
         self.assertTrue (cmd_value.GetValueAsUnsigned() == 5)
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py b/lldb/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py
index 27f6da1..9e4a7e2 100644
--- a/lldb/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py
+++ b/lldb/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py
@@ -2,8 +2,9 @@
 Test that we are able to properly report a usable dynamic type
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -57,9 +58,3 @@
 
         self.assertTrue(object_pointee_type.GetNumberOfFields() == 2, "The dynamic type for NSObject has 2 fields")
         self.assertTrue(base_pointee_type.GetNumberOfFields() == 2, "The dynamic type for Base has 2 fields")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py b/lldb/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
index 37a7b07..bd0bbea 100644
--- a/lldb/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
+++ b/lldb/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
@@ -2,9 +2,10 @@
 Use lldb Python API to test dynamic values in ObjC
 """
 
+import lldb_shared
+
 import os, time
 import re
-import unittest2
 import lldb, lldbutil
 from lldbtest import *
 
@@ -171,9 +172,3 @@
         derivedValue = object.GetChildMemberWithName ('_derivedValue')
         self.assertTrue (derivedValue)
         self.assertTrue (int (derivedValue.GetValue(), 0) == 30)
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py b/lldb/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
index 98d6aa5..26e09da 100644
--- a/lldb/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
+++ b/lldb/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
@@ -1,7 +1,8 @@
 """Test printing ObjC objects that use unbacked properties - so that the static ivar offsets are incorrect."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -69,9 +70,3 @@
         flag2_value = mine_flag2.GetValueAsUnsigned (error)
         self.assertTrue (error.Success())
         self.assertTrue (flag2_value == 7)
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py b/lldb/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py
index 05cdc4d..dd4620f 100644
--- a/lldb/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py
+++ b/lldb/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py
@@ -1,7 +1,8 @@
 """Test printing ObjC objects that use unbacked properties - so that the static ivar offsets are incorrect."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -54,9 +55,3 @@
         ivar_value = ivar.GetValueAsSigned (error)
         self.assertTrue (error.Success())
         self.assertTrue (ivar_value == 3)
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py b/lldb/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py
index 97d8f92..66dc4d5 100644
--- a/lldb/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py
+++ b/lldb/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py
@@ -1,7 +1,9 @@
 """Test that the Objective-C syntax for dictionary/array literals and indexing works"""
 
-import os, time
+import lldb_shared
+
 import unittest2
+import os, time
 import lldb
 import platform
 import lldbutil
@@ -97,9 +99,3 @@
             substrs = ["4"])
         self.expect("expr -- @((char*)\"Hello world\" + 6)", VARIABLES_DISPLAYED_CORRECTLY,
             substrs = ["NSString", "world"])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-optimized/TestObjcOptimized.py b/lldb/test/lang/objc/objc-optimized/TestObjcOptimized.py
index e6a5958..a2769e2 100644
--- a/lldb/test/lang/objc/objc-optimized/TestObjcOptimized.py
+++ b/lldb/test/lang/objc/objc-optimized/TestObjcOptimized.py
@@ -7,8 +7,9 @@
 optimized it into a register.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -58,10 +59,3 @@
 
         self.expect('expression self->non_member', error=True,
             substrs = ["does not have a member named 'non_member'"])
-
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-property/TestObjCProperty.py b/lldb/test/lang/objc/objc-property/TestObjCProperty.py
index 0ed0836..f21ab34 100644
--- a/lldb/test/lang/objc/objc-property/TestObjCProperty.py
+++ b/lldb/test/lang/objc/objc-property/TestObjCProperty.py
@@ -2,9 +2,10 @@
 Use lldb Python API to verify that expression evaluation for property references uses the correct getters and setters
 """
 
+import lldb_shared
+
 import os, time
 import re
-import unittest2
 import lldb, lldbutil
 from lldbtest import *
 
@@ -108,9 +109,3 @@
         idWithProtocol_error = idWithProtocol_value.GetError()
         self.assertTrue (idWithProtocol_error.Success())
         self.assertTrue (idWithProtocol_value.GetTypeName() == "id")
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py b/lldb/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py
index 6cc550a..a071987 100644
--- a/lldb/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py
+++ b/lldb/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py
@@ -1,7 +1,8 @@
 """Test calling functions in static methods with a stripped binary."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -60,9 +61,3 @@
         self.assertTrue (cmd_value.IsValid())
         string_length = cmd_value.GetValueAsUnsigned()
         self.assertTrue (string_length == 27, "Got the right value from another class method on the same class.")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-static-method/TestObjCStaticMethod.py b/lldb/test/lang/objc/objc-static-method/TestObjCStaticMethod.py
index c54d23b..443c4c5 100644
--- a/lldb/test/lang/objc/objc-static-method/TestObjCStaticMethod.py
+++ b/lldb/test/lang/objc/objc-static-method/TestObjCStaticMethod.py
@@ -1,7 +1,8 @@
 """Test calling functions in static methods."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -56,9 +57,3 @@
         self.assertTrue (cmd_value.IsValid())
         string_length = cmd_value.GetValueAsUnsigned()
         self.assertTrue (string_length == 27, "Got the right value from another class method on the same class.")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-stepping/TestObjCStepping.py b/lldb/test/lang/objc/objc-stepping/TestObjCStepping.py
index 0fb8bce..015992c 100644
--- a/lldb/test/lang/objc/objc-stepping/TestObjCStepping.py
+++ b/lldb/test/lang/objc/objc-stepping/TestObjCStepping.py
@@ -1,7 +1,8 @@
 """Test stepping through ObjC method dispatch in various forms."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -167,9 +168,3 @@
         thread.StepInto()
         line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
         self.assertTrue (line_number == self.stepped_past_nil_line, "Step in over dispatch to nil stepped over.")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py b/lldb/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py
index 47d1ea4..be6e87b 100644
--- a/lldb/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py
+++ b/lldb/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py
@@ -1,7 +1,8 @@
 """Test passing structs to Objective-C methods."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -52,9 +53,3 @@
         # Now make sure we can call a method that returns a struct without crashing.
         cmd_value = frame.EvaluateExpression ("[provider getRange]")
         self.assertTrue (cmd_value.IsValid())
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-struct-return/TestObjCStructReturn.py b/lldb/test/lang/objc/objc-struct-return/TestObjCStructReturn.py
index 27a3c3e..d6fafd7 100644
--- a/lldb/test/lang/objc/objc-struct-return/TestObjCStructReturn.py
+++ b/lldb/test/lang/objc/objc-struct-return/TestObjCStructReturn.py
@@ -1,7 +1,8 @@
 """Test calling functions in class methods."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -48,9 +49,3 @@
         # Now make sure we can call a method that returns a struct without crashing.
         cmd_value = frame.EvaluateExpression ("[provider getRange]")
         self.assertTrue (cmd_value.IsValid())
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/objc-super/TestObjCSuper.py b/lldb/test/lang/objc/objc-super/TestObjCSuper.py
index 1d1f43b..4aba9e9 100644
--- a/lldb/test/lang/objc/objc-super/TestObjCSuper.py
+++ b/lldb/test/lang/objc/objc-super/TestObjCSuper.py
@@ -1,7 +1,8 @@
 """Test calling methods on super."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 import lldbutil
 from lldbtest import *
@@ -54,9 +55,3 @@
         cmd_value = frame.EvaluateExpression ("[super get]")
         self.assertTrue (cmd_value.IsValid())
         self.assertTrue (cmd_value.GetValueAsUnsigned() == 1)
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/print-obj/TestPrintObj.py b/lldb/test/lang/objc/print-obj/TestPrintObj.py
index f6143b0..b1205cf 100644
--- a/lldb/test/lang/objc/print-obj/TestPrintObj.py
+++ b/lldb/test/lang/objc/print-obj/TestPrintObj.py
@@ -2,8 +2,9 @@
 Test "print object" where another thread blocks the print object from making progress.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 
@@ -82,10 +83,3 @@
 
         self.expect("po lock_me", OBJECT_PRINTED_CORRECTLY,
             substrs = ['I am pretty special.'])
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py b/lldb/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py
index b33741b..726ec82 100644
--- a/lldb/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py
+++ b/lldb/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py
@@ -2,8 +2,9 @@
 Test that objective-c method returning BOOL works correctly.
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -40,10 +41,3 @@
 
         # rdar://problem/9691614
         self.runCmd('p (int)[my isValid]')
-
-        
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/rdar-10967107/TestRdar10967107.py b/lldb/test/lang/objc/rdar-10967107/TestRdar10967107.py
index 17d1015..be9b6cf 100644
--- a/lldb/test/lang/objc/rdar-10967107/TestRdar10967107.py
+++ b/lldb/test/lang/objc/rdar-10967107/TestRdar10967107.py
@@ -2,8 +2,9 @@
 Test that CoreFoundation classes CFGregorianDate and CFRange are not improperly uniqued
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -39,9 +40,3 @@
         self.expect("frame variable cf_range --raw", substrs = ['location','length'])
         # check that printing both does not somehow confuse LLDB
         self.expect("frame variable  --raw", substrs = ['year','month','day','hour','minute','second','location','length'])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py b/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py
index 14f85c4..3523695 100644
--- a/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py
+++ b/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py
@@ -2,8 +2,9 @@
 Test that we do not attempt to make a dynamic type for a 'const char*'
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -60,9 +61,3 @@
         # check that expr also gets it right
         self.expect("expr my_foolie", substrs = ['FoolMeOnce *'])
         self.expect("expr -d run -- my_foolie", substrs = ['FoolMeOnce *'])
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/rdar-12408181/TestRdar12408181.py b/lldb/test/lang/objc/rdar-12408181/TestRdar12408181.py
index d1d2292..54fa80c 100644
--- a/lldb/test/lang/objc/rdar-12408181/TestRdar12408181.py
+++ b/lldb/test/lang/objc/rdar-12408181/TestRdar12408181.py
@@ -2,8 +2,9 @@
 Test that we are able to find out how many children NSWindow has
 """
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -40,9 +41,3 @@
         self.assertTrue(window_dynamic.GetNumChildren() > 1, "NSWindow (dynamic) only has 1 child!")
         self.assertTrue(window.GetChildAtIndex(0).IsValid(), "NSWindow (static) has an invalid child")
         self.assertTrue(window_dynamic.GetChildAtIndex(0).IsValid(), "NSWindow (dynamic) has an invalid child")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/real-definition/TestRealDefinition.py b/lldb/test/lang/objc/real-definition/TestRealDefinition.py
index 8557423..04e4986 100644
--- a/lldb/test/lang/objc/real-definition/TestRealDefinition.py
+++ b/lldb/test/lang/objc/real-definition/TestRealDefinition.py
@@ -1,7 +1,8 @@
 """Test that types defined in shared libraries work correctly."""
 
+import lldb_shared
+
 import os, time
-import unittest2
 import lldb
 from lldbtest import *
 import lldbutil
@@ -81,9 +82,3 @@
         # Break inside the foo function which takes a bar_ptr argument.
         line = line_number('main.m', '// Set breakpoint in main')
         lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True)
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
diff --git a/lldb/test/lang/objc/self/TestObjCSelf.py b/lldb/test/lang/objc/self/TestObjCSelf.py
index 239e2de..44736fe 100644
--- a/lldb/test/lang/objc/self/TestObjCSelf.py
+++ b/lldb/test/lang/objc/self/TestObjCSelf.py
@@ -34,9 +34,3 @@
 
     def set_breakpoint(self, line):
         lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True)
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()