Many many test failures after some recent changes. The problem is lldbtest.getPlatform() returns the "OS" of the selected platform's triple. This is "macosx" for desktop macosx and "ios" for iOS. It used to be "darwin".

There was a lot of code that was checking "if self.getPlatform() == 'darwin'" which is not correct. I fixed this by adding a:

lldbtest.platformIsDarwin()

which returns true if the current platform's OS is "macosx", "ios" or "darwin". These three valid darwin are now returned by a static function:

lldbtest.getDarwinOSTriples()

Fixed up all places that has 'if self.getPlatform() == "darwin":' with "if self.platformIsDarwin()" and all instances of 'if self.getPlatform() != "darwin":' with "if not self.platformIsDarwin()". I also fixed some darwin decorator functions to do the right thing as well.

llvm-svn: 233933
This commit is contained in:
Greg Clayton 2015-04-02 18:24:03 +00:00
parent a5cad0d6a6
commit e0d0a7652d
15 changed files with 34 additions and 26 deletions

View File

@ -24,8 +24,8 @@ class SBDirCheckerCase(TestBase):
def test_sb_api_directory(self): def test_sb_api_directory(self):
"""Test the SB API directory and make sure there's no unwanted stuff.""" """Test the SB API directory and make sure there's no unwanted stuff."""
# Only proceed if this is "darwin", "x86_64", and local platform. # Only proceed if this is an Apple OS, "x86_64", and local platform.
if not (self.getPlatform() == "darwin" and self.getArchitecture() == "x86_64" and not lldb.test_remote): if not (self.platformIsDarwin() 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") self.skipTest("This test is only for LLDB.framework built 64-bit and !lldb.test_remote")
if self.getArchitecture() == "i386": if self.getArchitecture() == "i386":
self.skipTest("LLDB is 64-bit and cannot be linked to 32-bit test program.") self.skipTest("LLDB is 64-bit and cannot be linked to 32-bit test program.")
@ -47,7 +47,7 @@ class SBDirCheckerCase(TestBase):
# for all the SB API headers. # for all the SB API headers.
public_headers = os.listdir(public_api_dir) public_headers = os.listdir(public_api_dir)
# For different platforms, the include statement can vary. # For different platforms, the include statement can vary.
if self.getPlatform() == "darwin": if self.platformIsDarwin():
include_stmt = "'#include <%s>' % os.path.join('LLDB', header)" include_stmt = "'#include <%s>' % os.path.join('LLDB', header)"
if self.getPlatform() == "freebsd" or self.getPlatform() == "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)" include_stmt = "'#include <%s>' % os.path.join(public_api_dir, header)"

View File

@ -174,7 +174,7 @@ class AbbreviationsTestCase(TestBase):
self.expect("i d symt", self.expect("i d symt",
patterns = ["Dumping symbol table for [0-9]+ modules."]) patterns = ["Dumping symbol table for [0-9]+ modules."])
if self.getPlatform() == "darwin": if self.platformIsDarwin():
self.expect("i li", self.expect("i li",
substrs = [ 'a.out', substrs = [ 'a.out',
'/usr/lib/dyld', '/usr/lib/dyld',

View File

@ -49,7 +49,7 @@ class ChangedInferiorTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED) self.runCmd("run", RUN_SUCCEEDED)
if self.getPlatform() == "darwin": if self.platformIsDarwin():
stop_reason = 'stop reason = EXC_BAD_ACCESS' stop_reason = 'stop reason = EXC_BAD_ACCESS'
else: else:
stop_reason = 'stop reason = invalid address' stop_reason = 'stop reason = invalid address'
@ -73,7 +73,7 @@ class ChangedInferiorTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED) self.runCmd("run", RUN_SUCCEEDED)
self.runCmd("process status") self.runCmd("process status")
if self.getPlatform() == "darwin": if self.platformIsDarwin():
stop_reason = 'EXC_BAD_ACCESS' stop_reason = 'EXC_BAD_ACCESS'
else: else:
stop_reason = 'invalid address' stop_reason = 'invalid address'

View File

@ -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) lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True)
def check_stop_reason(self): def check_stop_reason(self):
if self.getPlatform() == "darwin": if self.platformIsDarwin():
stop_reason = 'stop reason = EXC_BAD_ACCESS' stop_reason = 'stop reason = EXC_BAD_ACCESS'
else: else:
stop_reason = 'stop reason = invalid address' stop_reason = 'stop reason = invalid address'

View File

@ -90,7 +90,7 @@ class CrashingRecursiveInferiorTestCase(TestBase):
lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True) lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True)
def check_stop_reason(self): def check_stop_reason(self):
if self.getPlatform() == "darwin": if self.platformIsDarwin():
stop_reason = 'stop reason = EXC_BAD_ACCESS' stop_reason = 'stop reason = EXC_BAD_ACCESS'
else: else:
stop_reason = 'stop reason = invalid address' stop_reason = 'stop reason = invalid address'
@ -207,13 +207,13 @@ class CrashingRecursiveInferiorTestCase(TestBase):
self.check_stop_reason() self.check_stop_reason()
expected_state = 'exited' # Provide the exit code. expected_state = 'exited' # Provide the exit code.
if self.getPlatform() == "darwin": if self.platformIsDarwin():
expected_state = 'stopped' # TODO: Determine why 'next' and 'continue' have no effect after a crash. expected_state = 'stopped' # TODO: Determine why 'next' and 'continue' have no effect after a crash.
self.expect("next", self.expect("next",
substrs = ['Process', expected_state]) substrs = ['Process', expected_state])
if self.getPlatform() != "darwin": # if stopped, we will have a process around if not self.platformIsDarwin(): # if stopped, we will have a process around
self.expect("thread list", error=True,substrs = ['Process must be launched']) self.expect("thread list", error=True,substrs = ['Process must be launched'])
def recursive_inferior_crashing_expr_step_expr(self): def recursive_inferior_crashing_expr_step_expr(self):

View File

@ -108,7 +108,7 @@ class TestInlineStepping(TestBase):
test_stack_depth = True test_stack_depth = True
# Work around for <rdar://problem/16363195>, the darwin unwinder seems flakey about whether it duplicates the first frame # 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. # or not, which makes counting stack depth unreliable.
if self.getPlatform() == "darwin": if self.platformIsDarwin():
test_stack_depth = False test_stack_depth = False
for step_pattern in step_sequence: for step_pattern in step_sequence:

View File

@ -24,7 +24,7 @@ class LoadUnloadTestCase(TestBase):
'// Set break point at this line for test_lldb_process_load_and_unload_commands().') '// Set break point at this line for test_lldb_process_load_and_unload_commands().')
self.line_d_function = line_number('d.c', self.line_d_function = line_number('d.c',
'// Find this line number within d_dunction().') '// Find this line number within d_dunction().')
if self.getPlatform() != "darwin": if not self.platformIsDarwin():
if "LD_LIBRARY_PATH" in os.environ: if "LD_LIBRARY_PATH" in os.environ:
self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.environ["LD_LIBRARY_PATH"] + ":" + os.getcwd()) self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.environ["LD_LIBRARY_PATH"] + ":" + os.getcwd())
else: else:
@ -38,7 +38,7 @@ class LoadUnloadTestCase(TestBase):
# Invoke the default build rule. # Invoke the default build rule.
self.buildDefault() self.buildDefault()
if self.getPlatform() == "darwin": if self.platformIsDarwin():
dylibName = 'libloadunload_d.dylib' dylibName = 'libloadunload_d.dylib'
else: else:
dylibName = 'libloadunload_d.so' dylibName = 'libloadunload_d.so'
@ -93,7 +93,7 @@ class LoadUnloadTestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out") exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
if self.getPlatform() == "darwin": if self.platformIsDarwin():
dylibName = 'libloadunload_d.dylib' dylibName = 'libloadunload_d.dylib'
dsymName = 'libloadunload_d.dylib.dSYM' dsymName = 'libloadunload_d.dylib.dSYM'
else: else:
@ -112,7 +112,7 @@ class LoadUnloadTestCase(TestBase):
# we pick up the hidden dylib. # we pick up the hidden dylib.
env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir
if self.getPlatform() != "darwin": if not self.platformIsDarwin():
env_cmd_string += ":" + os.getcwd() env_cmd_string += ":" + os.getcwd()
if self.TraceOn(): if self.TraceOn():
@ -164,7 +164,7 @@ class LoadUnloadTestCase(TestBase):
error=True, matching=False, error=True, matching=False,
patterns = ["1 match found .* %s" % self.mydir]) patterns = ["1 match found .* %s" % self.mydir])
if self.getPlatform() == "darwin": if self.platformIsDarwin():
dylibName = 'libloadunload_a.dylib' dylibName = 'libloadunload_a.dylib'
else: else:
dylibName = 'libloadunload_a.so' dylibName = 'libloadunload_a.so'

View File

@ -89,7 +89,7 @@ class RegisterCommandsTestCase(TestBase):
# platform specific logging of the specified category # platform specific logging of the specified category
def log_enable(self, category): def log_enable(self, category):
self.platform = "" self.platform = ""
if self.getPlatform() == "darwin": if self.platformIsDarwin():
self.platform = "" # TODO: add support for "log enable darwin registers" self.platform = "" # TODO: add support for "log enable darwin registers"
if self.getPlatform() == "freebsd": if self.getPlatform() == "freebsd":

View File

@ -130,7 +130,7 @@ class ArrayTypesTestCase(TestBase):
# Sanity check the print representation of thread. # Sanity check the print representation of thread.
thr = str(thread) thr = str(thread)
if self.getPlatform() == "darwin": if self.platformIsDarwin():
tidstr = "tid = 0x%4.4x" % thread.GetThreadID() tidstr = "tid = 0x%4.4x" % thread.GetThreadID()
else: else:
tidstr = "tid = %u" % thread.GetThreadID() tidstr = "tid = %u" % thread.GetThreadID()

View File

@ -86,7 +86,7 @@ class FunctionTypesTestCase(TestBase):
self.expect("expr string_not_empty", self.expect("expr string_not_empty",
substrs = ['(int (*)(const char *)) $0 = ', '(a.out`']) substrs = ['(int (*)(const char *)) $0 = ', '(a.out`'])
if self.getPlatform() == "darwin": if self.platformIsDarwin():
regexps = ['lib.*\.dylib`printf'] regexps = ['lib.*\.dylib`printf']
else: else:
regexps = ['printf'] regexps = ['printf']

View File

@ -73,7 +73,7 @@ class StaticVariableTestCase(TestBase):
# On Mac OS X, gcc 4.2 emits the wrong debug info for A::g_points. # 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. # A::g_points is an array of two elements.
if self.getPlatform() == "darwin" or self.getPlatform() == "linux": if self.platformIsDarwin() or self.getPlatform() == "linux":
self.expect("target variable A::g_points[1].x", VARIABLES_DISPLAYED_CORRECTLY, self.expect("target variable A::g_points[1].x", VARIABLES_DISPLAYED_CORRECTLY,
startstr = "(int) A::g_points[1].x = 11") startstr = "(int) A::g_points[1].x = 11")

View File

@ -54,7 +54,7 @@ class NamespaceTestCase(TestBase):
# On Mac OS X, gcc 4.2 emits the wrong debug info with respect to types. # 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'] slist = ['(int) a = 12', 'anon_uint', 'a_uint', 'b_uint', 'y_uint']
if self.getPlatform() == "darwin" and self.getCompiler() in ['clang', 'llvm-gcc']: if self.platformIsDarwin() and self.getCompiler() in ['clang', 'llvm-gcc']:
slist = ['(int) a = 12', slist = ['(int) a = 12',
'::my_uint_t', 'anon_uint = 0', '::my_uint_t', 'anon_uint = 0',
'(A::uint_t) a_uint = 1', '(A::uint_t) a_uint = 1',

View File

@ -593,7 +593,7 @@ def expectedFailureOS(oslist, bugnumber=None, compilers=None):
def expectedFailureDarwin(bugnumber=None, compilers=None): def expectedFailureDarwin(bugnumber=None, compilers=None):
# For legacy reasons, we support both "darwin" and "macosx" as OS X triples. # For legacy reasons, we support both "darwin" and "macosx" as OS X triples.
return expectedFailureOS(['darwin', 'macosx'], bugnumber, compilers) return expectedFailureOS(getDarwinOSTriples(), bugnumber, compilers)
def expectedFailureFreeBSD(bugnumber=None, compilers=None): def expectedFailureFreeBSD(bugnumber=None, compilers=None):
return expectedFailureOS(['freebsd'], bugnumber, compilers) return expectedFailureOS(['freebsd'], bugnumber, compilers)
@ -664,9 +664,12 @@ def skipIfFreeBSD(func):
"""Decorate the item to skip tests that should be skipped on FreeBSD.""" """Decorate the item to skip tests that should be skipped on FreeBSD."""
return skipIfPlatform(["freebsd"])(func) return skipIfPlatform(["freebsd"])(func)
def getDarwinOSTriples():
return ['darwin', 'macosx', 'ios']
def skipIfDarwin(func): def skipIfDarwin(func):
"""Decorate the item to skip tests that should be skipped on Darwin.""" """Decorate the item to skip tests that should be skipped on Darwin."""
return skipIfPlatform(["darwin", "macosx"])(func) return skipIfPlatform(getDarwinOSTriples())(func)
def skipIfLinux(func): def skipIfLinux(func):
"""Decorate the item to skip tests that should be skipped on Linux.""" """Decorate the item to skip tests that should be skipped on Linux."""
@ -678,7 +681,7 @@ def skipIfWindows(func):
def skipUnlessDarwin(func): def skipUnlessDarwin(func):
"""Decorate the item to skip tests that should be skipped on any non Darwin platform.""" """Decorate the item to skip tests that should be skipped on any non Darwin platform."""
return skipUnlessPlatform(["darwin", "macosx"])(func) return skipUnlessPlatform(getDarwinOSTriples())(func)
def skipIfPlatform(oslist): def skipIfPlatform(oslist):
"""Decorate the item to skip tests if running on one of the listed platforms.""" """Decorate the item to skip tests if running on one of the listed platforms."""
@ -1387,6 +1390,11 @@ class Base(unittest2.TestCase):
version = m.group(1) version = m.group(1)
return version return version
def platformIsDarwin(self):
"""Returns true if the OS triple for the selected platform is any valid apple OS"""
platform_name = self.getPlatform()
return platform_name in getDarwinOSTriples()
def getPlatform(self): def getPlatform(self):
"""Returns the platform the test suite is running on.""" """Returns the platform the test suite is running on."""
platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2] platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]

View File

@ -20,7 +20,7 @@ class EventAPITestCase(TestBase):
self.buildDsym() self.buildDsym()
self.do_listen_for_and_print_event() self.do_listen_for_and_print_event()
@skipUnlessPlatform(["darwin", "macosx", "freebsd"]) @skipUnlessPlatform(getDarwinOSTriples() + ["freebsd"])
@python_api_test @python_api_test
@dwarf_test @dwarf_test
def test_listen_for_and_print_event_with_dwarf(self): def test_listen_for_and_print_event_with_dwarf(self):

View File

@ -40,7 +40,7 @@ class CommandLineCompletionTestCase(TestBase):
if self.TraceOn(): if self.TraceOn():
child.logfile = sys.stdout child.logfile = sys.stdout
if self.getPlatform() == "darwin": if self.platformIsDarwin():
child.sendline('set env(TERM) xterm') child.sendline('set env(TERM) xterm')
else: else:
child.sendline('set env(TERM) vt100') child.sendline('set env(TERM) vt100')