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 TestAllocationDumpStruct.''' 16 17from __future__ import absolute_import 18 19from harness.test_base_remote import TestBaseRemote 20 21 22class TestAllocationDumpStruct(TestBaseRemote): 23 '''Tests printing the contents of a struct allocation.''' 24 25 bundle_target = { 26 'java': 'Allocations' 27 } 28 29 def setup(self, android): 30 '''This test requires to be run on one thread.''' 31 android.push_prop('debug.rs.max-threads', 1) 32 33 def teardown(self, android): 34 '''Reset the number of RS threads to the previous value.''' 35 android.pop_prop('debug.rs.max-threads') 36 37 def test_dump_complex_struct_allocation(self): 38 # Hit struct_kernel on last coordinate, so almost all elements have been initalised 39 self.try_command( 40 'language renderscript kernel breakpoint set struct_kernel -c 23', 41 ['Conditional kernel breakpoint on coordinate (23, 0, 0)', 42 'Breakpoint(s) created']) 43 44 self.try_command('process continue', 45 ['resuming', 46 'stopped', 47 'stop reason = breakpoint']) 48 49 # complex_struct output allocation 50 self.try_command('language renderscript allocation dump 49', 51 ['(0, 0, 0) = (complexStruct) {\n' 52 ' (i = 0, j = 0)\n' 53 ' (0x00, 0x41, 0x42, 0x43)\n' 54 ' ([0] = 0, [1] = 0.5)\n' 55 '}', 56 '(1, 0, 0) = (complexStruct) {\n' 57 ' (i = 1, j = 1)\n' 58 ' (0x01, 0x41, 0x42, 0x43)\n' 59 ' ([0] = 1, [1] = 1.5)\n' 60 '}', 61 '(2, 0, 0) = (complexStruct) {\n' 62 ' (i = 2, j = 2)\n' 63 ' (0x02, 0x41, 0x42, 0x43)\n' 64 ' ([0] = 2, [1] = 2.5)\n' 65 '}', 66 '(3, 0, 0) = (complexStruct) {\n' 67 ' (i = 3, j = 3)\n' 68 ' (0x03, 0x41, 0x42, 0x43)\n' 69 ' ([0] = 3, [1] = 3.5)\n' 70 '}', 71 '(4, 0, 0) = (complexStruct) {\n' 72 ' (i = 4, j = 4)\n' 73 ' (0x04, 0x41, 0x42, 0x43)\n' 74 ' ([0] = 4, [1] = 4.5)\n' 75 '}', 76 '(5, 0, 0) = (complexStruct) {\n' 77 ' (i = 5, j = 5)\n' 78 ' (0x05, 0x41, 0x42, 0x43)\n' 79 ' ([0] = 5, [1] = 5.5)\n' 80 '}', 81 '(6, 0, 0) = (complexStruct) {\n' 82 ' (i = 6, j = 6)\n' 83 ' (0x06, 0x41, 0x42, 0x43)\n' 84 ' ([0] = 6, [1] = 6.5)\n' 85 '}', 86 '(7, 0, 0) = (complexStruct) {\n' 87 ' (i = 7, j = 7)\n' 88 ' (0x07, 0x41, 0x42, 0x43)\n' 89 ' ([0] = 7, [1] = 7.5)\n' 90 '}', 91 '(8, 0, 0) = (complexStruct) {\n' 92 ' (i = 8, j = 8)\n' 93 ' (0x08, 0x41, 0x42, 0x43)\n' 94 ' ([0] = 8, [1] = 8.5)\n' 95 '}', 96 '(9, 0, 0) = (complexStruct) {\n' 97 ' (i = 9, j = 9)\n' 98 ' (0x09, 0x41, 0x42, 0x43)\n' 99 ' ([0] = 9, [1] = 9.5)\n' 100 '}', 101 '(10, 0, 0) = (complexStruct) {\n' 102 ' (i = 10, j = 10)\n' 103 ' (0x0a, 0x41, 0x42, 0x43)\n' 104 ' ([0] = 10, [1] = 10.5)\n' 105 '}', 106 '(11, 0, 0) = (complexStruct) {\n' 107 ' (i = 11, j = 11)\n' 108 ' (0x0b, 0x41, 0x42, 0x43)\n' 109 ' ([0] = 11, [1] = 11.5)\n' 110 '}', 111 '(12, 0, 0) = (complexStruct) {\n' 112 ' (i = 12, j = 12)\n' 113 ' (0x0c, 0x41, 0x42, 0x43)\n' 114 ' ([0] = 12, [1] = 12.5)\n' 115 '}', 116 '(13, 0, 0) = (complexStruct) {\n' 117 ' (i = 13, j = 13)\n' 118 ' (0x0d, 0x41, 0x42, 0x43)\n' 119 ' ([0] = 13, [1] = 13.5)\n' 120 '}', 121 '(14, 0, 0) = (complexStruct) {\n' 122 ' (i = 14, j = 14)\n' 123 ' (0x0e, 0x41, 0x42, 0x43)\n' 124 ' ([0] = 14, [1] = 14.5)\n' 125 '}', 126 '(15, 0, 0) = (complexStruct) {\n' 127 ' (i = 15, j = 15)\n' 128 ' (0x0f, 0x41, 0x42, 0x43)\n' 129 ' ([0] = 15, [1] = 15.5)\n' 130 '}', 131 '(16, 0, 0) = (complexStruct) {\n' 132 ' (i = 16, j = 16)\n' 133 ' (0x10, 0x41, 0x42, 0x43)\n' 134 ' ([0] = 16, [1] = 16.5)\n' 135 '}', 136 '(17, 0, 0) = (complexStruct) {\n' 137 ' (i = 17, j = 17)\n' 138 ' (0x11, 0x41, 0x42, 0x43)\n' 139 ' ([0] = 17, [1] = 17.5)\n' 140 '}', 141 '(18, 0, 0) = (complexStruct) {\n' 142 ' (i = 18, j = 18)\n' 143 ' (0x12, 0x41, 0x42, 0x43)\n' 144 ' ([0] = 18, [1] = 18.5)\n' 145 '}', 146 '(19, 0, 0) = (complexStruct) {\n' 147 ' (i = 19, j = 19)\n' 148 ' (0x13, 0x41, 0x42, 0x43)\n' 149 ' ([0] = 19, [1] = 19.5)\n' 150 '}', 151 '(20, 0, 0) = (complexStruct) {\n' 152 ' (i = 20, j = 20)\n' 153 ' (0x14, 0x41, 0x42, 0x43)\n' 154 ' ([0] = 20, [1] = 20.5)\n' 155 '}', 156 '(21, 0, 0) = (complexStruct) {\n' 157 ' (i = 21, j = 21)\n' 158 ' (0x15, 0x41, 0x42, 0x43)\n' 159 ' ([0] = 21, [1] = 21.5)\n' 160 '}', 161 '(22, 0, 0) = (complexStruct) {\n' 162 ' (i = 22, j = 22)\n' 163 ' (0x16, 0x41, 0x42, 0x43)\n' 164 ' ([0] = 22, [1] = 22.5)\n' 165 '}']) 166