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 TestMultipleRSFiles.''' 16 17from __future__ import absolute_import 18 19from harness.test_base_remote import TestBaseRemote 20from harness.decorators import ( 21 ordered_test, 22 cpp_only_test, 23) 24 25class TestMultipleRSFiles(TestBaseRemote): 26 '''Tests some commands on an apk which has two rs files.''' 27 28 bundle_target = { 29 'java': 'MultipleRSFiles', 30 'jni': 'JNIMultipleRSFiles', 31 'cpp': 'CppMultipleRSFiles' 32 } 33 34 def _binary_name(self): 35 return { 36 'java': 'multiplersfiles', 37 'jni': 'multiplersfiles', 38 'cpp': 'CppMultipleRSFi' 39 }[self.app_type] 40 41 def _pkg_name(self): 42 return { 43 'java': 'com.android.rs.multiplersfiles', 44 'jni': 'com.android.rs.jnimultiplersfiles', 45 'cpp': 'com.android.rs.cppmultiplersfiles' 46 }[self.app_type] 47 48 def test_multiple_rs_files(self): 49 self.try_command('language renderscript status', 50 ['Runtime Library discovered', 51 'Runtime Driver discovered', 52 'Runtime functions hooked']) 53 54 self.try_command('breakpoint set --file first.rs --line 28', 55 ['(pending)']) 56 57 self.try_command('process continue', 58 ['stopped', 59 'librs.first.so`first_kernel', 60 'at first.rs:28', 61 "name = '%s'" % self._binary_name(), 62 'stop reason = breakpoint 1']) 63 64 self.try_command('language renderscript kernel list', 65 ['RenderScript Kernels', 66 "Resource 'first'", 67 "Resource 'second'", 68 'root', 69 'first_kernel', 70 'second_kernel']) 71 72 self.try_command('language renderscript context dump', 73 ['Inferred RenderScript Contexts', 74 '2 script instances']) 75 76 self.try_command('language renderscript module dump', 77 ['RenderScript Modules:', 78 'librs.first.so', 79 'librs.second.so', 80 'Debug info loaded', 81 'Globals: 1', 82 'gColor - float4', 83 'Kernels: 2', 84 'root', 85 'first_kernel', 86 'second_kernel', 87 'java_package_name: %s' % self._pkg_name(), 88 'version:']) 89 90 @ordered_test('last') 91 @cpp_only_test() 92 def test_cpp_cleanup(self): 93 self.try_command('breakpoint delete 1', ['1 breakpoints deleted']) 94 95 self.try_command('process continue', ['exited with status = 0']) 96