1"""
2Test that CoreFoundation classes CFGregorianDate and CFRange are not improperly uniqued
3"""
4
5import os, time
6import unittest2
7import lldb
8from lldbtest import *
9import lldbutil
10
11@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
12class Rdar10967107TestCase(TestBase):
13
14    mydir = os.path.join("lang", "objc", "rdar-10967107")
15
16    @dsym_test
17    def test_cfrange_diff_cfgregoriandate_with_dsym(self):
18        """Test that CoreFoundation classes CFGregorianDate and CFRange are not improperly uniqued."""
19        d = {'EXE': self.exe_name}
20        self.buildDsym(dictionary=d)
21        self.setTearDownCleanup(dictionary=d)
22        self.cfrange_diff_cfgregoriandate(self.exe_name)
23
24    @dwarf_test
25    def test_cfrange_diff_cfgregoriandate_with_dwarf(self):
26        """Test that CoreFoundation classes CFGregorianDate and CFRange are not improperly uniqued."""
27        d = {'EXE': self.exe_name}
28        self.buildDwarf(dictionary=d)
29        self.setTearDownCleanup(dictionary=d)
30        self.cfrange_diff_cfgregoriandate(self.exe_name)
31
32    def setUp(self):
33        # Call super's setUp().
34        TestBase.setUp(self)
35        # We'll use the test method name as the exe_name.
36        self.exe_name = self.testMethodName
37        # Find the line number to break inside main().
38        self.main_source = "main.m"
39        self.line = line_number(self.main_source, '// Set breakpoint here.')
40
41    def cfrange_diff_cfgregoriandate(self, exe_name):
42        """Test that CoreFoundation classes CFGregorianDate and CFRange are not improperly uniqued."""
43        exe = os.path.join(os.getcwd(), exe_name)
44        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
45
46        lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True)
47
48        self.runCmd("run", RUN_SUCCEEDED)
49        # check that each type is correctly bound to its list of children
50        self.expect("frame variable cf_greg_date --raw", substrs = ['year','month','day','hour','minute','second'])
51        self.expect("frame variable cf_range --raw", substrs = ['location','length'])
52        # check that printing both does not somehow confuse LLDB
53        self.expect("frame variable  --raw", substrs = ['year','month','day','hour','minute','second','location','length'])
54
55if __name__ == '__main__':
56    import atexit
57    lldb.SBDebugger.Initialize()
58    atexit.register(lambda: lldb.SBDebugger.Terminate())
59    unittest2.main()
60