Files
clang-p2996/lldb/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py
Todd Fiala c25fd190ef Modified some test annotations so that tests on Linux that should be skipped don't show up as XFAIL.
The following two tests showed up as XFAIL even though they should
always be skipped on Linux, due to the @unittest2.expectedFailure
annotation appearing above the @dsym_test annotation:

TestObjCNewSyntax.ObjCNewSyntaxTestCase.test_expr_with_dsym
TestBlocks.BlocksTestCase.test_expr_with_dsym.

For those two, I simply moved the @dsym_test annotation to the top so
that it would be marked for skip ahead of being marked for XFAIL.

TestObjCNewSyntax.ObjCNewSyntaxTestCase.test_expr_with_dwarf I marked
as @skipIfLinux since my understanding is that isn't a valid test to
run on Linux. So rather than categorize as a fail (i.e. something
wrong to be fixed), just skip it. (My recent changes to Linux tests
have been following that model: if it could never work, skip; if it's
broken, mark XFAIL so we can easily track, fix, notice the fix and
adjust accordingly).

TestDeadStrip.DeadStripTestCase.test_with_dwarf I had previously
marked as XFAIL but this would never work on Linux with the current
linker AFAICT.  Marked it as skip.

llvm-svn: 202788
2014-03-04 05:28:24 +00:00

132 lines
4.7 KiB
Python

"""Test that the Objective-C syntax for dictionary/array literals and indexing works"""
import os, time
import unittest2
import lldb
import platform
import lldbutil
from distutils.version import StrictVersion
from lldbtest import *
class ObjCNewSyntaxTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@dsym_test
@unittest2.expectedFailure
def test_expr_with_dsym(self):
self.buildDsym()
self.expr()
@dwarf_test
@skipIfLinux
@unittest2.expectedFailure
def test_expr_with_dwarf(self):
self.buildDwarf()
self.expr()
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
# Find the line number to break inside main().
self.line = line_number('main.m', '// Set breakpoint 0 here.')
def applies(self):
if platform.system() != "Darwin":
return False
if StrictVersion('12.0.0') > platform.release():
return False
return True
def common_setup(self):
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Break inside the foo function which takes a bar_ptr argument.
lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
self.runCmd("run", RUN_SUCCEEDED)
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs = ['stopped',
'stop reason = breakpoint'])
# The breakpoint should have a hit count of 1.
self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
substrs = [' resolved, hit count = 1'])
def expr(self):
if not self.applies():
return
self.common_setup()
self.expect("expr --object-description -- immutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["foo"])
self.expect("expr --object-description -- mutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["foo"])
self.expect("expr --object-description -- mutable_array[0] = @\"bar\"", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["bar"])
self.expect("expr --object-description -- mutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["bar"])
self.expect("expr --object-description -- immutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["value"])
self.expect("expr --object-description -- mutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["value"])
self.expect("expr --object-description -- mutable_dictionary[@\"key\"] = @\"object\"", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["object"])
self.expect("expr --object-description -- mutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["object"])
self.expect("expr --object-description -- @[ @\"foo\", @\"bar\" ]", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSArray", "foo", "bar"])
self.expect("expr --object-description -- @{ @\"key\" : @\"object\" }", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSDictionary", "key", "object"])
self.expect("expr --object-description -- @'a'", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSNumber", str(ord('a'))])
self.expect("expr --object-description -- @1", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSNumber", "1"])
self.expect("expr --object-description -- @1l", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSNumber", "1"])
self.expect("expr --object-description -- @1ul", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSNumber", "1"])
self.expect("expr --object-description -- @1ll", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSNumber", "1"])
self.expect("expr --object-description -- @1ull", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSNumber", "1"])
self.expect("expr --object-description -- @123.45", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSNumber", "123.45"])
self.expect("expr --object-description -- @123.45f", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSNumber", "123.45"])
self.expect("expr --object-description -- @( 1 + 3 )", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSNumber", "4"])
self.expect("expr --object-description -- @(\"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()