1# Copyright (C) 2016 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15'''Module that contains the test TestAllocationDump1.''' 16from __future__ import absolute_import 17 18import os 19 20from harness.test_base_remote import TestBaseRemote 21from harness.decorators import ( 22 ordered_test, 23 wimpy, 24 cpp_only_test, 25) 26 27 28class TestAllocationDump1(TestBaseRemote): 29 '''Tests printing the contents of allocations.''' 30 31 bundle_target = { 32 'java': 'Allocations', 33 'jni': 'JNIAllocations', 34 'cpp': 'CppAllocations' 35 } 36 37 @wimpy 38 @ordered_test(0) 39 def test_setup(self): 40 self.try_command('language renderscript kernel breakpoint all enable', 41 ['Breakpoints will be set on all kernels']) 42 43 self.try_command('process continue', 44 ['resuming', 45 'stopped', 46 'stop reason = breakpoint']) 47 48 @wimpy 49 def test_dump_to_file1(self): 50 # Test dumping large allocations to file 51 output_file_1 = self.get_tmp_file_path() 52 53 self.try_command('language renderscript allocation dump 1 -f ' + 54 output_file_1, 55 ["Results written to '%s'" % output_file_1]) 56 57 # Check the file was created 58 self.assert_true(os.path.isfile(output_file_1)) 59 os.remove(output_file_1) 60 61 def test_dump_to_file2(self): 62 output_file_2 = self.get_tmp_file_path() 63 64 self.try_command('language renderscript allocation dump 2 -f ' + 65 output_file_2, 66 ["Results written to '%s'" % output_file_2]) 67 68 self.assert_true(os.path.isfile(output_file_2)) 69 os.remove(output_file_2) 70 71 @wimpy 72 def test_dump_char(self): 73 self.try_command('language renderscript allocation dump 3', 74 ['(0, 0, 0) = 0', 75 '(0, 1, 0) = 1', 76 '(0, 2, 0) = 2', 77 '(0, 0, 1) = 3', 78 '(0, 1, 1) = 4', 79 '(0, 2, 1) = 5', 80 '(0, 0, 2) = 6', 81 '(0, 1, 2) = 7', 82 '(0, 2, 2) = 8', 83 '(0, 0, 3) = 9', 84 '(0, 1, 3) = 10', 85 '(0, 2, 3) = 11', 86 '(0, 0, 4) = 12', 87 '(0, 1, 4) = 13', 88 '(0, 2, 4) = 14', 89 '(0, 0, 5) = 15', 90 '(0, 1, 5) = 16', 91 '(0, 2, 5) = 17', 92 '(0, 0, 6) = 18', 93 '(0, 1, 6) = 19', 94 '(0, 2, 6) = 20', 95 '(0, 0, 7) = 21', 96 '(0, 1, 7) = 22', 97 '(0, 2, 7) = 23']) 98 99 def test_dump_char2(self): 100 self.try_command('language renderscript allocation dump 4', 101 ['(0, 0, 0) = {0 1}', 102 '(1, 0, 0) = {2 3}', 103 '(2, 0, 0) = {4 5}', 104 '(3, 0, 0) = {6 7}', 105 '(4, 0, 0) = {8 9}', 106 '(5, 0, 0) = {10 11}', 107 '(6, 0, 0) = {12 13}', 108 '(7, 0, 0) = {14 15}', 109 '(8, 0, 0) = {16 17}', 110 '(9, 0, 0) = {18 19}', 111 '(10, 0, 0) = {20 21}', 112 '(11, 0, 0) = {22 23}']) 113 114 def test_dump_char3(self): 115 self.try_command('language renderscript allocation dump 5', 116 ['(0, 0, 0) = {0 1 2}', 117 '(1, 0, 0) = {4 5 6}', 118 '(2, 0, 0) = {8 9 10}', 119 '(3, 0, 0) = {12 13 14}', 120 '(4, 0, 0) = {16 17 18}', 121 '(5, 0, 0) = {20 21 22}']) 122 123 def test_dump_char4(self): 124 self.try_command('language renderscript allocation dump 6', 125 ['(0, 0, 0) = {0 1 2 3}', 126 '(1, 0, 0) = {4 5 6 7}', 127 '(2, 0, 0) = {8 9 10 11}', 128 '(3, 0, 0) = {12 13 14 15}', 129 '(4, 0, 0) = {16 17 18 19}', 130 '(5, 0, 0) = {20 21 22 23}']) 131 132 def test_dump_short(self): 133 self.try_command('language renderscript allocation dump 7', 134 ['(0, 0, 0) = 0', 135 '(1, 0, 0) = 1', 136 '(2, 0, 0) = 2', 137 '(3, 0, 0) = 3', 138 '(4, 0, 0) = 4', 139 '(5, 0, 0) = 5', 140 '(6, 0, 0) = 6', 141 '(7, 0, 0) = 7', 142 '(8, 0, 0) = 8', 143 '(9, 0, 0) = 9', 144 '(10, 0, 0) = 10', 145 '(11, 0, 0) = 11', 146 '(12, 0, 0) = 12', 147 '(13, 0, 0) = 13', 148 '(14, 0, 0) = 14', 149 '(15, 0, 0) = 15', 150 '(16, 0, 0) = 16', 151 '(17, 0, 0) = 17', 152 '(18, 0, 0) = 18', 153 '(19, 0, 0) = 19', 154 '(20, 0, 0) = 20', 155 '(21, 0, 0) = 21', 156 '(22, 0, 0) = 22', 157 '(23, 0, 0) = 23']) 158 159 def test_dump_short2(self): 160 self.try_command('language renderscript allocation dump 8', 161 ['(0, 0, 0) = {0 1}', 162 '(1, 0, 0) = {2 3}', 163 '(2, 0, 0) = {4 5}', 164 '(3, 0, 0) = {6 7}', 165 '(4, 0, 0) = {8 9}', 166 '(5, 0, 0) = {10 11}', 167 '(0, 0, 1) = {12 13}', 168 '(1, 0, 1) = {14 15}', 169 '(2, 0, 1) = {16 17}', 170 '(3, 0, 1) = {18 19}', 171 '(4, 0, 1) = {20 21}', 172 '(5, 0, 1) = {22 23}']) 173 174 def test_dump_short3(self): 175 self.try_command('language renderscript allocation dump 9', 176 ['(0, 0, 0) = {0 1 2}', 177 '(1, 0, 0) = {4 5 6}', 178 '(2, 0, 0) = {8 9 10}', 179 '(3, 0, 0) = {12 13 14}', 180 '(4, 0, 0) = {16 17 18}', 181 '(5, 0, 0) = {20 21 22}']) 182 183 def test_dump_short4(self): 184 self.try_command('language renderscript allocation dump 10', 185 ['(0, 0, 0) = {0 1 2 3}', 186 '(1, 0, 0) = {4 5 6 7}', 187 '(2, 0, 0) = {8 9 10 11}', 188 '(3, 0, 0) = {12 13 14 15}', 189 '(4, 0, 0) = {16 17 18 19}', 190 '(5, 0, 0) = {20 21 22 23}']) 191 192 def test_dump_int(self): 193 self.try_command('language renderscript allocation dump 11', 194 ['(0, 0, 0) = 0', 195 '(1, 0, 0) = 1', 196 '(2, 0, 0) = 2', 197 '(3, 0, 0) = 3', 198 '(4, 0, 0) = 4', 199 '(5, 0, 0) = 5', 200 '(6, 0, 0) = 6', 201 '(7, 0, 0) = 7', 202 '(8, 0, 0) = 8', 203 '(9, 0, 0) = 9', 204 '(10, 0, 0) = 10', 205 '(11, 0, 0) = 11', 206 '(12, 0, 0) = 12', 207 '(13, 0, 0) = 13', 208 '(14, 0, 0) = 14', 209 '(15, 0, 0) = 15', 210 '(16, 0, 0) = 16', 211 '(17, 0, 0) = 17', 212 '(18, 0, 0) = 18', 213 '(19, 0, 0) = 19', 214 '(20, 0, 0) = 20', 215 '(21, 0, 0) = 21', 216 '(22, 0, 0) = 22', 217 '(23, 0, 0) = 23']) 218 219 def test_dump_int2(self): 220 self.try_command('language renderscript allocation dump 12', 221 ['(0, 0, 0) = {0 1}', 222 '(1, 0, 0) = {2 3}', 223 '(2, 0, 0) = {4 5}', 224 '(3, 0, 0) = {6 7}', 225 '(4, 0, 0) = {8 9}', 226 '(5, 0, 0) = {10 11}', 227 '(6, 0, 0) = {12 13}', 228 '(7, 0, 0) = {14 15}', 229 '(8, 0, 0) = {16 17}', 230 '(9, 0, 0) = {18 19}', 231 '(10, 0, 0) = {20 21}', 232 '(11, 0, 0) = {22 23}']) 233 234 def test_dump_int3(self): 235 self.try_command('language renderscript allocation dump 13', 236 ['(0, 0, 0) = {0 1 2}', 237 '(1, 0, 0) = {4 5 6}', 238 '(2, 0, 0) = {8 9 10}', 239 '(0, 1, 0) = {12 13 14}', 240 '(1, 1, 0) = {16 17 18}', 241 '(2, 1, 0) = {20 21 22}']) 242 243 def test_dump_int4(self): 244 self.try_command('language renderscript allocation dump 14', 245 ['(0, 0, 0) = {0 1 2 3}', 246 '(1, 0, 0) = {4 5 6 7}', 247 '(2, 0, 0) = {8 9 10 11}', 248 '(3, 0, 0) = {12 13 14 15}', 249 '(4, 0, 0) = {16 17 18 19}', 250 '(5, 0, 0) = {20 21 22 23}']) 251 252 def test_dump_int5(self): 253 self.try_command('language renderscript allocation dump 15', 254 ['(0, 0, 0) = 0', 255 '(1, 0, 0) = 1', 256 '(2, 0, 0) = 2', 257 '(3, 0, 0) = 3', 258 '(4, 0, 0) = 4', 259 '(5, 0, 0) = 5', 260 '(6, 0, 0) = 6', 261 '(7, 0, 0) = 7', 262 '(8, 0, 0) = 8', 263 '(9, 0, 0) = 9', 264 '(10, 0, 0) = 10', 265 '(11, 0, 0) = 11', 266 '(12, 0, 0) = 12', 267 '(13, 0, 0) = 13', 268 '(14, 0, 0) = 14', 269 '(15, 0, 0) = 15', 270 '(16, 0, 0) = 16', 271 '(17, 0, 0) = 17', 272 '(18, 0, 0) = 18', 273 '(19, 0, 0) = 19', 274 '(20, 0, 0) = 20', 275 '(21, 0, 0) = 21', 276 '(22, 0, 0) = 22', 277 '(23, 0, 0) = 23']) 278 279 def test_dump_long2(self): 280 self.try_command('language renderscript allocation dump 16', 281 ['(0, 0, 0) = {0 1}', 282 '(1, 0, 0) = {2 3}', 283 '(2, 0, 0) = {4 5}', 284 '(3, 0, 0) = {6 7}', 285 '(4, 0, 0) = {8 9}', 286 '(5, 0, 0) = {10 11}', 287 '(6, 0, 0) = {12 13}', 288 '(7, 0, 0) = {14 15}', 289 '(8, 0, 0) = {16 17}', 290 '(9, 0, 0) = {18 19}', 291 '(10, 0, 0) = {20 21}', 292 '(11, 0, 0) = {22 23}']) 293 294 def test_dump_long3(self): 295 self.try_command('language renderscript allocation dump 17', 296 ['(0, 0, 0) = {0 1 2}', 297 '(1, 0, 0) = {4 5 6}', 298 '(2, 0, 0) = {8 9 10}', 299 '(3, 0, 0) = {12 13 14}', 300 '(4, 0, 0) = {16 17 18}', 301 '(5, 0, 0) = {20 21 22}']) 302 303 def test_dump_long4(self): 304 self.try_command('language renderscript allocation dump 18', 305 ['(0, 0, 0) = {0 1 2 3}', 306 '(0, 1, 0) = {4 5 6 7}', 307 '(0, 2, 0) = {8 9 10 11}', 308 '(0, 3, 0) = {12 13 14 15}', 309 '(0, 4, 0) = {16 17 18 19}', 310 '(0, 5, 0) = {20 21 22 23}']) 311 312 def test_dump_bool(self): 313 self.try_command('language renderscript allocation dump 19', 314 ['(0, 0, 0) = false', 315 '(1, 0, 0) = true', 316 '(2, 0, 0) = false', 317 '(3, 0, 0) = true', 318 '(4, 0, 0) = false', 319 '(5, 0, 0) = true', 320 '(6, 0, 0) = false', 321 '(7, 0, 0) = true', 322 '(8, 0, 0) = false', 323 '(9, 0, 0) = true', 324 '(10, 0, 0) = false', 325 '(11, 0, 0) = true', 326 '(12, 0, 0) = false', 327 '(13, 0, 0) = true', 328 '(14, 0, 0) = false', 329 '(15, 0, 0) = true', 330 '(16, 0, 0) = false', 331 '(17, 0, 0) = true', 332 '(18, 0, 0) = false', 333 '(19, 0, 0) = true', 334 '(20, 0, 0) = false', 335 '(21, 0, 0) = true', 336 '(22, 0, 0) = false', 337 '(23, 0, 0) = true']) 338 339 @ordered_test('last') 340 @cpp_only_test() 341 def test_cpp_cleanup_breakpoints(self): 342 self.try_command('breakpoint delete 1', ['1 breakpoints deleted']) 343 344 self.try_command('breakpoint delete 2', ['1 breakpoints deleted']) 345 346 self.try_command('breakpoint delete 3', ['1 breakpoints deleted']) 347 348 self.try_command('process continue', ['exited with status = 0']) 349