File: TestDataFormatterObjCCF.py

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (84 lines) | stat: -rw-r--r-- 3,773 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# encoding: utf-8
"""
Test lldb data formatter subsystem.
"""


import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil

from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase


class ObjCDataFormatterCF(ObjCDataFormatterTestCase):

    def test_coreframeworks_and_run_command(self):
        """Test formatters for Core OSX frameworks."""
        self.build()
        self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
            self, '// Set break point at this line.',
            lldb.SBFileSpec('main.m', False))

        # The stop reason of the thread should be breakpoint.
        self.expect(
            "thread list",
            STOPPED_DUE_TO_BREAKPOINT,
            substrs=['stopped', 'stop reason = breakpoint'])

        self.runCmd('settings set target.prefer-dynamic-value no-dynamic-values')

        # check formatters for common Objective-C types
        expect_strings = [
            '(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds',
            '(CFGregorianDate) cf_greg_date = @"4/10/1985 18:0:0"',
            '(CFRange) cf_range = location=4 length=4',
            '(NSPoint) ns_point = (x = 4, y = 4)',
            '(NSRange) ns_range = location=4, length=4',
            '(NSRect) ns_rect = (origin = (x = 1, y = 1), size = (width = 5, height = 5))',
            '(NSRectArray) ns_rect_arr = ((x = 1, y = 1), (width = 5, height = 5)), ...',
            '(NSSize) ns_size = (width = 5, height = 7)',
            '(CGSize) cg_size = (width = 1, height = 6)',
            '(CGPoint) cg_point = (x = 2, y = 7)',
            '(CGRect) cg_rect = (origin = (x = 1, y = 2), size = (width = 7, height = 7))',
            '(Rect) rect = (t=4, l=8, b=4, r=7)',
            '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)',
            '(Point) point = (v=7, h=12)', '(Point *) point_ptr = (v=7, h=12)',
            '(SEL) foo_selector = "foo_selector_impl"'
        ]
        self.expect("frame variable", substrs=expect_strings)

        if self.getArchitecture() in ['i386', 'x86_64']:
            extra_string = [
                '(RGBColor) rgb_color = red=3 green=56 blue=35',
                '(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35',
                '(HIPoint) hi_point = (x=7, y=12)',
                '(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)',
            ]
            self.expect("frame variable", substrs=extra_string)

        # The original tests left out testing the NSNumber values, so do that here.
        # This set is all pointers, with summaries, so we only check the summary.
        var_list_pointer = [
            ['NSNumber *', 'num1',    '(int)5'],
            ['NSNumber *', 'num2',    '(float)3.140000'],
            ['NSNumber *', 'num3',    '(double)3.14'],
            ['NSNumber *', 'num4',    '(int128_t)18446744073709551614'],
            ['NSNumber *', 'num5',    '(char)65'],
            ['NSNumber *', 'num6',    '(long)255'],
            ['NSNumber *', 'num7',    '(long)2000000'],
            ['NSNumber *', 'num8_Y',  'YES'],
            ['NSNumber *', 'num8_N',  'NO'],
            ['NSNumber *', 'num9',    '(short)-31616'],
            ['NSNumber *', 'num_at1', '(int)12'],
            ['NSNumber *', 'num_at2', '(int)-12'],
            ['NSNumber *', 'num_at3', '(double)12.5'],
            ['NSNumber *', 'num_at4', '(double)-12.5'],
            ['NSDecimalNumber *', 'decimal_number', '123456 x 10^-10'],
            ['NSDecimalNumber *', 'decimal_number_neg', '-123456 x 10^10']
        ]
        for type, var_path, summary in var_list_pointer:
            self.expect_var_path(var_path, summary, None, type)