test_write_local.py revision a3c6f62775506c95afd556e617f14d7a28839f01
1'''Module that contains the test TestWriteLocal.''' 2 3from __future__ import absolute_import 4 5from harness.test_base_remote import TestBaseRemote 6from harness.decorators import ( 7 ordered_test, 8 wimpy 9) 10 11 12class TestWriteLocal(TestBaseRemote): 13 '''Tests modifying local variables of all types.''' 14 15 bundle_target = { 16 'java': 'KernelVariables', 17 'jni': 'JNIKernelVariables', 18 'cpp': 'CppKernelVariables' 19 } 20 21 def _try_modifying_local(self, local_name, new_value, data_type_in, 22 expected_output, expected_output_regex=None): 23 '''Try getting lldb to modify a local and check the output. 24 25 Run the "expr" command to set a given local to a new value and 26 check that it is set afterwards by running the "target variable" 27 command. 28 29 Args: 30 local_name: String which is the name of the local to modify. 31 new_value: A string that is the new value of the local. 32 data_type_in: A string containing a c-style parenthesised data type 33 representing the type of the local. 34 expected_output: List of strings that should be found in the output 35 of both commands. 36 expected_output_regex: List of regular expressions that should be 37 found in the output of the target variable 38 command. 39 40 Raises: 41 TestFail: One of the lldb commands did not provide the expected 42 output. 43 ''' 44 # pylint: disable=too-many-arguments 45 self.try_command('expr %s = %s%s' 46 % (local_name, data_type_in, new_value), 47 expected_output, 48 expected_output_regex) 49 self.try_command('frame variable ' + local_name, 50 expected_output, 51 expected_output_regex) 52 53 @wimpy 54 @ordered_test(0) 55 def test_setup(self): 56 self.try_command('language renderscript status', 57 ['Runtime Library discovered', 58 'Runtime Driver discovered']) 59 60 self.try_command('b -f simple.rs -l 129', []) 61 62 self.try_command('process continue', 63 ['resuming', 64 'stopped', 65 'stop reason = breakpoint']) 66 67 @wimpy 68 def test_modify_char(self): 69 self._try_modifying_local('char_local', '-2', 70 '(signed char)', ['\'\\xfe\''], 71 [r'\((signed )?char\)']) 72 73 def test_modify_primitive(self): 74 self._try_modifying_local('uchar_local', '22', 75 '(uchar)', ['(uchar)', '\'\\x16\'']) 76 77 self._try_modifying_local('short_local', '-33', 78 '(short)', ['(short)', '-33']) 79 80 self._try_modifying_local('ushort_local', '44', 81 '(ushort)', ['(ushort)', '44']) 82 83 self._try_modifying_local('int_local', '-55', 84 '(int)', ['(int)', '-55']) 85 86 self._try_modifying_local('uint_local', '66', 87 '(uint)', ['(uint)', '66']) 88 89 self._try_modifying_local('float_local', '-7.5', 90 '(float)', ['(float)', '-7.5']) 91 92 self._try_modifying_local('long_local', '-888888', 93 '(long long)', ['-888888'], 94 [r'\((long )?long\)']) 95 96 self._try_modifying_local('ulong_local', '99999999', 97 '(ulong)', ['(ulong)', '99999999']) 98 99 self._try_modifying_local('double_local', '-10101.5', 100 '(double)', ['(double)', '-10101.5']) 101 102 self._try_modifying_local('char2_local', '{22, 4}', 103 '(char2)', ['(char2)', '(22, 4)']) 104 105 @wimpy 106 def test_modify_uchar2(self): 107 self._try_modifying_local('uchar2_local', '{44, 55}', 108 '(uchar2)', ['(uchar2)', '(0x2c, 0x37)']) 109 110 def test_modify_vec2(self): 111 self._try_modifying_local('short2_local', '{-66, 77}', 112 '(short2)', ['(short2)', '(-66, 77)']) 113 114 self._try_modifying_local('ushort2_local', '{88, 99}', 115 '(ushort2)', ['(ushort2)', '(88, 99)']) 116 117 self._try_modifying_local('int2_local', '{111, -222}', 118 '(int2)', ['(int2)', '(111, -222)']) 119 120 self._try_modifying_local('uint2_local', '{333, 444}', 121 '(uint2)', ['(uint2)', '(333, 444)']) 122 123 self._try_modifying_local('float2_local', '{-55.5f, 6.0}', 124 '(float2)', ['(float2)', '(-55.5, 6)']) 125 126 self._try_modifying_local('long2_local', '{666666, -777777}', 127 '(long2)', ['(long2)', '(666666, -777777)']) 128 129 self._try_modifying_local('ulong2_local', '{888888, 999999}', 130 '(ulong2)', ['(ulong2)', '(888888, 999999)']) 131 132 self._try_modifying_local('double2_local', '{11.0000000, -0.0l}', 133 '(double2)', ['(double2)', '(11, -0)']) 134 135 self._try_modifying_local('char3_local', '{2, -3, 4}', 136 '(char3)', ['(char3)', '(2, -3, 4,']) 137 138 self._try_modifying_local('uchar3_local', '{\'a\', \'b\', \'c\'}', 139 '(uchar3)', ['(uchar3)', '(0x61, 0x62, 0x63,']) 140 141 @wimpy 142 def test_modify_short3(self): 143 self._try_modifying_local('short3_local', '{44, -55, 66}', 144 '(short3)', ['(short3)', '(44, -55, 66,']) 145 146 def test_modify_vec3(self): 147 self._try_modifying_local('ushort3_local', '{88, 99, 111}', 148 '(ushort3)', ['(ushort3)', '(88, 99, 111,']) 149 150 self._try_modifying_local('int3_local', '{-111, 222, -333}', 151 '(int3)', ['(int3)', '(-111, 222, -333,']) 152 153 self._try_modifying_local('uint3_local', '{444, 555, 666}', 154 '(uint3)', ['(uint3)', '(444, 555, 666,']) 155 156 self._try_modifying_local('float3_local', '{7.5F, 0008.000, 9}', 157 '(float3)', ['(float3)', '(7.5, 8, 9,']) 158 159 self._try_modifying_local('long3_local', '{111111, -22222222, 3333333}', 160 '(long3)', ['(long3)', '(111111, -22222222, 3333333,']) 161 162 self._try_modifying_local('ulong3_local', '{4444444, 5555555, 66666666}', 163 '(ulong3)', ['(ulong3)', '(4444444, 5555555, 66666666,']) 164 165 self._try_modifying_local('double3_local', '{7.5L, -0, 8.9e1}', 166 '(double3)', ['(double3)', '(7.5, 0, 89,']) 167 168 self._try_modifying_local('char4_local', '{0x1, 0x2, 0x3, 0x4}', 169 '(char4)', 170 ['(char4)', '(1, 2, 3, 4)']) 171 172 self._try_modifying_local('uchar4_local', '{0x5, 0x6, 0x7, 0x8}', 173 '(uchar4)', 174 ['(uchar4)', '(0x05, 0x06, 0x07, 0x08)']) 175 176 self._try_modifying_local('short4_local', '{0x9, 0xa, 0xb, 0xc}', 177 '(short4)', 178 ['(short4)', '(9, 10, 11, 12)']) 179 180 @wimpy 181 def test_modify_ushort4(self): 182 self._try_modifying_local('ushort4_local', '{0xd, 0xe, 0xf, 0x10}', 183 '(ushort4)', 184 ['(ushort4)', '(13, 14, 15, 16)']) 185 186 def test_modify_vec4(self): 187 self._try_modifying_local('int4_local', '{0x11, 0x12, 0x13, 0x14}', 188 '(int4)', 189 ['(int4)', '(17, 18, 19, 20)']) 190 191 self._try_modifying_local('uint4_local', '{0x15, 0x16, 0x17, 0x18}', 192 '(uint4)', 193 ['(uint4)', '(21, 22, 23, 24)']) 194 195 self._try_modifying_local('float4_local', '{19.0, 20.5, -21, -22.5}', 196 '(float4)', 197 ['(float4)', '(19, 20.5, -21, -22.5)']) 198 199 self._try_modifying_local('long4_local', '{0x1d, 0x1e, 0x1f, 0x20}', 200 '(long4)', 201 ['(long4)', '(29, 30, 31, 32)']) 202 203 self._try_modifying_local('ulong4_local', '{0x21, 0x22, 0x23, 0x24}', 204 '(ulong4)', 205 ['(ulong4)', '(33, 34, 35, 36)']) 206 207 self._try_modifying_local('double4_local', '{25.000, -26, -27.5, 28.0}', 208 '(double4)', 209 ['(double4)', '(25, -26, -27.5, 28)']) 210