[Lldb-commits] [lldb] r233805 - Update sys.platform switched behavior in tests to use self.getPlatform (remote target platform)

Robert Flack flackr at gmail.com
Wed Apr 1 06:26:16 PDT 2015


Author: flackr
Date: Wed Apr  1 08:26:16 2015
New Revision: 233805

URL: http://llvm.org/viewvc/llvm-project?rev=233805&view=rev
Log:
Update sys.platform switched behavior in tests to use self.getPlatform (remote target platform)

Uses target platform when determining which platform specific behavior to use
or expect in tests. TestHelp.py was unchanged because this is asserting
behavior of the local lldb binary.

Test Plan:
Run tests on different remote os. Several previously failing tests now pass:
TestArrayTypes.py
TestInferiorChanged.py
TestInferiorCrashing.py
TestIvarProtocols.py
TestProcessIO.py
TestPublicAPIHeaders.py
TestRecursiveInferior.py

Differential Revision: http://reviews.llvm.org/D8747

Modified:
    lldb/trunk/test/api/check_public_api_headers/TestPublicAPIHeaders.py
    lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py
    lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py
    lldb/trunk/test/functionalities/inferior-crashing/TestInferiorCrashing.py
    lldb/trunk/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
    lldb/trunk/test/functionalities/inline-stepping/TestInlineStepping.py
    lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py
    lldb/trunk/test/functionalities/register/TestRegisters.py
    lldb/trunk/test/lang/c/array_types/TestArrayTypes.py
    lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py
    lldb/trunk/test/lang/c/tls_globals/TestTlsGlobals.py
    lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py
    lldb/trunk/test/lang/cpp/namespace/TestNamespace.py
    lldb/trunk/test/lang/objc/modules/TestObjCModules.py
    lldb/trunk/test/terminal/TestSTTYBeforeAndAfter.py

Modified: lldb/trunk/test/api/check_public_api_headers/TestPublicAPIHeaders.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/api/check_public_api_headers/TestPublicAPIHeaders.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/api/check_public_api_headers/TestPublicAPIHeaders.py (original)
+++ lldb/trunk/test/api/check_public_api_headers/TestPublicAPIHeaders.py Wed Apr  1 08:26:16 2015
@@ -25,7 +25,7 @@ class SBDirCheckerCase(TestBase):
         """Test the SB API directory and make sure there's no unwanted stuff."""
 
         # Only proceed if this is "darwin", "x86_64", and local platform.
-        if not (sys.platform.startswith("darwin") and self.getArchitecture() == "x86_64" and not lldb.test_remote):
+        if not (self.getPlatform() == "darwin" and self.getArchitecture() == "x86_64" and not lldb.test_remote):
             self.skipTest("This test is only for LLDB.framework built 64-bit and !lldb.test_remote")
         if self.getArchitecture() == "i386":
             self.skipTest("LLDB is 64-bit and cannot be linked to 32-bit test program.")
@@ -47,9 +47,9 @@ class SBDirCheckerCase(TestBase):
         # for all the SB API headers.
         public_headers = os.listdir(public_api_dir)
         # For different platforms, the include statement can vary.
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             include_stmt = "'#include <%s>' % os.path.join('LLDB', header)"
-        if sys.platform.startswith('freebsd') or sys.platform.startswith("linux") or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile':
+        if self.getPlatform() == "freebsd" or self.getPlatform() == "linux" or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile':
             include_stmt = "'#include <%s>' % os.path.join(public_api_dir, header)"
         list = [eval(include_stmt) for header in public_headers if (header.startswith("SB") and
                                                                     header.endswith(".h"))]

Modified: lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py (original)
+++ lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py Wed Apr  1 08:26:16 2015
@@ -174,7 +174,7 @@ class AbbreviationsTestCase(TestBase):
         self.expect("i d symt",
                     patterns = ["Dumping symbol table for [0-9]+ modules."])
 
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             self.expect("i li",
                         substrs = [ 'a.out',
                                     '/usr/lib/dyld',

Modified: lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py (original)
+++ lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py Wed Apr  1 08:26:16 2015
@@ -49,7 +49,7 @@ class ChangedInferiorTestCase(TestBase):
 
         self.runCmd("run", RUN_SUCCEEDED)
 
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             stop_reason = 'stop reason = EXC_BAD_ACCESS'
         else:
             stop_reason = 'stop reason = invalid address'
@@ -73,7 +73,7 @@ class ChangedInferiorTestCase(TestBase):
         self.runCmd("run", RUN_SUCCEEDED)
         self.runCmd("process status")
 
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             stop_reason = 'EXC_BAD_ACCESS'
         else:
             stop_reason = 'invalid address'

Modified: lldb/trunk/test/functionalities/inferior-crashing/TestInferiorCrashing.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inferior-crashing/TestInferiorCrashing.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/inferior-crashing/TestInferiorCrashing.py (original)
+++ lldb/trunk/test/functionalities/inferior-crashing/TestInferiorCrashing.py Wed Apr  1 08:26:16 2015
@@ -87,7 +87,7 @@ class CrashingInferiorTestCase(TestBase)
         lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True)
 
     def check_stop_reason(self):
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             stop_reason = 'stop reason = EXC_BAD_ACCESS'
         else:
             stop_reason = 'stop reason = invalid address'

Modified: lldb/trunk/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py (original)
+++ lldb/trunk/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py Wed Apr  1 08:26:16 2015
@@ -90,7 +90,7 @@ class CrashingRecursiveInferiorTestCase(
         lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True)
 
     def check_stop_reason(self):
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             stop_reason = 'stop reason = EXC_BAD_ACCESS'
         else:
             stop_reason = 'stop reason = invalid address'
@@ -209,13 +209,13 @@ class CrashingRecursiveInferiorTestCase(
         self.check_stop_reason()
 
         expected_state = 'exited' # Provide the exit code.
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             expected_state = 'stopped' # TODO: Determine why 'next' and 'continue' have no effect after a crash.
 
         self.expect("next",
             substrs = ['Process', expected_state])
 
-        if not(sys.platform.startswith("darwin")): # if stopped, we will have a process around
+        if self.getPlatform() != "darwin": # if stopped, we will have a process around
             self.expect("thread list", error=True,substrs = ['Process must be launched'])
 
     def recursive_inferior_crashing_expr_step_expr(self):

Modified: lldb/trunk/test/functionalities/inline-stepping/TestInlineStepping.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inline-stepping/TestInlineStepping.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/inline-stepping/TestInlineStepping.py (original)
+++ lldb/trunk/test/functionalities/inline-stepping/TestInlineStepping.py Wed Apr  1 08:26:16 2015
@@ -108,7 +108,7 @@ class TestInlineStepping(TestBase):
         test_stack_depth = True
         # Work around for <rdar://problem/16363195>, the darwin unwinder seems flakey about whether it duplicates the first frame 
         # or not, which makes counting stack depth unreliable.
-        if "darwin" in sys.platform:
+        if self.getPlatform() == "darwin":
             test_stack_depth = False
 
         for step_pattern in step_sequence:

Modified: lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py (original)
+++ lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py Wed Apr  1 08:26:16 2015
@@ -24,7 +24,7 @@ class LoadUnloadTestCase(TestBase):
                                 '// Set break point at this line for test_lldb_process_load_and_unload_commands().')
         self.line_d_function = line_number('d.c',
                                            '// Find this line number within d_dunction().')
-        if not sys.platform.startswith("darwin"):
+        if self.getPlatform() != "darwin":
             if "LD_LIBRARY_PATH" in os.environ:
                 self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.environ["LD_LIBRARY_PATH"] + ":" + os.getcwd())
             else:
@@ -38,7 +38,7 @@ class LoadUnloadTestCase(TestBase):
         # Invoke the default build rule.
         self.buildDefault()
 
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             dylibName = 'libloadunload_d.dylib'
         else:
             dylibName = 'libloadunload_d.so'
@@ -93,7 +93,7 @@ class LoadUnloadTestCase(TestBase):
         exe = os.path.join(os.getcwd(), "a.out")
         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             dylibName = 'libloadunload_d.dylib'
             dsymName = 'libloadunload_d.dylib.dSYM'
         else:
@@ -112,7 +112,7 @@ class LoadUnloadTestCase(TestBase):
         # we pick up the hidden dylib.
 
         env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir
-        if not sys.platform.startswith("darwin"):
+        if self.getPlatform() != "darwin":
             env_cmd_string += ":" + os.getcwd()
 
         if self.TraceOn():
@@ -164,7 +164,7 @@ class LoadUnloadTestCase(TestBase):
                     error=True, matching=False,
             patterns = ["1 match found .* %s" % self.mydir])
 
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             dylibName = 'libloadunload_a.dylib'
         else:
             dylibName = 'libloadunload_a.so'

Modified: lldb/trunk/test/functionalities/register/TestRegisters.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/register/TestRegisters.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/register/TestRegisters.py (original)
+++ lldb/trunk/test/functionalities/register/TestRegisters.py Wed Apr  1 08:26:16 2015
@@ -89,13 +89,13 @@ class RegisterCommandsTestCase(TestBase)
     # platform specific logging of the specified category
     def log_enable(self, category):
         self.platform = ""
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             self.platform = "" # TODO: add support for "log enable darwin registers"
 
-        if sys.platform.startswith("freebsd"):
+        if self.getPlatform() == "freebsd":
             self.platform = "freebsd"
 
-        if sys.platform.startswith("linux"):
+        if self.getPlatform() == "linux":
             self.platform = "linux"
 
         if self.platform != "":

Modified: lldb/trunk/test/lang/c/array_types/TestArrayTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/array_types/TestArrayTypes.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/lang/c/array_types/TestArrayTypes.py (original)
+++ lldb/trunk/test/lang/c/array_types/TestArrayTypes.py Wed Apr  1 08:26:16 2015
@@ -130,7 +130,7 @@ class ArrayTypesTestCase(TestBase):
 
         # Sanity check the print representation of thread.
         thr = str(thread)
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             tidstr = "tid = 0x%4.4x" % thread.GetThreadID()
         else:
             tidstr = "tid = %u" % thread.GetThreadID()

Modified: lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py (original)
+++ lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py Wed Apr  1 08:26:16 2015
@@ -86,7 +86,7 @@ class FunctionTypesTestCase(TestBase):
         self.expect("expr string_not_empty",
                     substrs = ['(int (*)(const char *)) $0 = ', '(a.out`'])
 
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             regexps = ['lib.*\.dylib`printf']
         else:
             regexps = ['printf']

Modified: lldb/trunk/test/lang/c/tls_globals/TestTlsGlobals.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/tls_globals/TestTlsGlobals.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/lang/c/tls_globals/TestTlsGlobals.py (original)
+++ lldb/trunk/test/lang/c/tls_globals/TestTlsGlobals.py Wed Apr  1 08:26:16 2015
@@ -28,7 +28,7 @@ class TlsGlobalTestCase(TestBase):
     def setUp(self):
         TestBase.setUp(self)
 
-        if sys.platform.startswith("freebsd") or sys.platform.startswith("linux"):
+        if self.getPlatform() == "freebsd" or self.getPlatform() == "linux":
             # LD_LIBRARY_PATH must be set so the shared libraries are found on startup
             if "LD_LIBRARY_PATH" in os.environ:
                 self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.environ["LD_LIBRARY_PATH"] + ":" + os.getcwd())

Modified: lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py (original)
+++ lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py Wed Apr  1 08:26:16 2015
@@ -73,7 +73,7 @@ class StaticVariableTestCase(TestBase):
 
         # On Mac OS X, gcc 4.2 emits the wrong debug info for A::g_points.
         # A::g_points is an array of two elements.
-        if sys.platform.startswith("darwin") or sys.platform.startswith("linux"):
+        if self.getPlatform() == "darwin" or self.getPlatform() == "linux":
             self.expect("target variable A::g_points[1].x", VARIABLES_DISPLAYED_CORRECTLY,
                 startstr = "(int) A::g_points[1].x = 11")
 

Modified: lldb/trunk/test/lang/cpp/namespace/TestNamespace.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/namespace/TestNamespace.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/lang/cpp/namespace/TestNamespace.py (original)
+++ lldb/trunk/test/lang/cpp/namespace/TestNamespace.py Wed Apr  1 08:26:16 2015
@@ -54,7 +54,7 @@ class NamespaceTestCase(TestBase):
 
         # On Mac OS X, gcc 4.2 emits the wrong debug info with respect to types.
         slist = ['(int) a = 12', 'anon_uint', 'a_uint', 'b_uint', 'y_uint']
-        if sys.platform.startswith("darwin") and self.getCompiler() in ['clang', 'llvm-gcc']:
+        if self.getPlatform() == "darwin" and self.getCompiler() in ['clang', 'llvm-gcc']:
             slist = ['(int) a = 12',
                      '::my_uint_t', 'anon_uint = 0',
                      '(A::uint_t) a_uint = 1',

Modified: lldb/trunk/test/lang/objc/modules/TestObjCModules.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/modules/TestObjCModules.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/modules/TestObjCModules.py (original)
+++ lldb/trunk/test/lang/objc/modules/TestObjCModules.py Wed Apr  1 08:26:16 2015
@@ -14,7 +14,7 @@ class ObjCModulesTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    @skipUnlessDarwin
     @dsym_test
     def test_expr_with_dsym(self):
         self.buildDsym()

Modified: lldb/trunk/test/terminal/TestSTTYBeforeAndAfter.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/terminal/TestSTTYBeforeAndAfter.py?rev=233805&r1=233804&r2=233805&view=diff
==============================================================================
--- lldb/trunk/test/terminal/TestSTTYBeforeAndAfter.py (original)
+++ lldb/trunk/test/terminal/TestSTTYBeforeAndAfter.py Wed Apr  1 08:26:16 2015
@@ -40,7 +40,7 @@ class CommandLineCompletionTestCase(Test
         if self.TraceOn():
             child.logfile = sys.stdout
 
-        if sys.platform.startswith("darwin"):
+        if self.getPlatform() == "darwin":
             child.sendline('set env(TERM) xterm')
         else:
             child.sendline('set env(TERM) vt100')





More information about the lldb-commits mailing list