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 TestBacktrace.''' 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 25 26class TestBacktrace(TestBaseRemote): 27 '''Tests breaking on a kernel and a function, and viewing the call stack.''' 28 29 bundle_target = { 30 'java': 'BranchingFunCalls', 31 'jni': 'JNIBranchingFunCalls', 32 'cpp': 'CppBranchingFunCalls' 33 } 34 35 def test_kernel_backtrace(self): 36 # pylint: disable=line-too-long 37 self.try_command('language renderscript status', 38 ['Runtime Library discovered', 39 'Runtime Driver discovered']) 40 41 self.try_command('language renderscript kernel breakpoint set simple_kernel', 42 ['Breakpoint(s) created', 43 '(pending)']) 44 45 self.try_command('process continue', 46 ['resuming', 47 'stopped', 48 'stop reason = breakpoint']) 49 50 self.try_command('bt', 51 ['stop reason = breakpoint', 52 # We should be able to see three functions in bt: 53 # libRSCpuRef, kernel.expand and the kernel 54 'frame #2:', 55 'librs.scalars.so', 56 'simple_kernel'], 57 [r'scalars\.rs:6[123]']) 58 59 self.try_command('breakpoint delete 1', 60 ['1 breakpoints deleted']) 61 62 self.try_command('b set_i', 63 ['Breakpoint 2', 64 'set_i'], 65 [r'scalars\.rs:3[678]']) 66 67 self.try_command('breakpoint list', 68 ['set_i', 'resolved']) 69 70 self.try_command('process continue', 71 ['resuming', 72 'stopped', 73 'stop reason = breakpoint']) 74 75 self.try_command('bt', 76 ['stop reason = breakpoint', 77 # We should be able to see five functions in bt: 78 # libRSCpuRef, kernel.expand, kernel and two functions 79 'frame #4:', 80 'librs.scalars.so', 81 'modify_i', 82 'set_i'], 83 [r'scalars\.rs:3[678]']) 84 85 @ordered_test('last') 86 @cpp_only_test() 87 def test_cpp_cleanup(self): 88 self.try_command('breakpoint delete 2', 89 ['1 breakpoints deleted']) 90 91 self.try_command('process continue', 92 ['exited with status = 0']) 93