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 TestSourceStep.''' 16 17from __future__ import absolute_import 18 19import os 20from harness.test_base_remote import TestBaseRemote 21from harness.decorators import ( 22 ordered_test, 23 cpp_only_test, 24) 25 26 27class TestSourceStep(TestBaseRemote): 28 '''Test stepping through the source using step-in, -over and -out.''' 29 30 bundle_target = { 31 'java': 'BranchingFunCalls', 32 'jni': 'JNIBranchingFunCalls', 33 'cpp': 'CppBranchingFunCalls' 34 35 } 36 37 def script_dir(self): 38 file_dir = os.path.dirname(os.path.realpath(__file__)) 39 app_root = os.path.join(file_dir, '..', '..') 40 41 return { 42 'java': os.path.join(app_root, 'java', 'BranchingFunCalls', 'src', 'rs'), 43 'cpp': os.path.join(app_root, 'cpp', 'BranchingFunCalls'), 44 'jni': os.path.join(app_root, 'jni', 'BranchingFunCalls', 'jnibranchingfuncalls') 45 }[self.app_type] 46 47 def setup(self, android): 48 '''This test requires to be run on one thread.''' 49 android.push_prop('debug.rs.max-threads', 1) 50 51 def teardown(self, android): 52 '''Reset the number of RS threads to the previous value.''' 53 android.pop_prop('debug.rs.max-threads') 54 55 def test_source_thread_step_in_out(self): 56 self.try_command('language renderscript status', 57 ['Runtime Library discovered', 58 'Runtime Driver discovered']) 59 60 self.try_command('b -f scalars.rs -l 63', 61 ['(pending)']) 62 63 self.try_command('process continue', 64 ['stopped', 65 'stop reason = breakpoint', 66 'scalars.rs:63']) 67 68 # set the source mapping 69 self.set_src_map('scalars.rs', self.script_dir()) 70 71 self.try_command('process status', 72 ['-> 63', 73 'int i = in;']) 74 75 #63 int i = in; 76 self.try_command('thread step-in', 77 ['-> 64']) 78 #64 float f = (float) i; 79 self.try_command('thread step-in', 80 ['-> 65']) 81 #49 modify_f(&f); 82 self.try_command('thread step-over', 83 ['-> 66']) 84 #50 modify_i(&i); 85 self.try_command('thread step-in', 86 ['-> 49']) 87 #49 int j = *i; 88 self.try_command('b -f scalars.rs -l 54', 89 ['librs.scalars.so`modify_i', 90 'scalars.rs:54']) 91 self.try_command('c', 92 ['stop reason = breakpoint', 93 'scalars.rs:54', 94 '-> 54']) 95 #54 set_i(i, 0); 96 # For the line number anything between #37 and #38 is fine 97 self.try_command('thread step-in', 98 [], 99 [r'-> 3[678]']) 100 #38 int tmp = b; 101 self.try_command('thread step-out', 102 ['-> 54']) 103 104 @cpp_only_test() 105 @ordered_test('last') 106 def test_cpp_cleanup(self): 107 self.try_command('breakpoint delete 1', ['1 breakpoints deleted']) 108 109 self.try_command('breakpoint delete 2', ['1 breakpoints deleted']) 110 111 self.try_command('process continue', 112 ['exited with status = 0']) 113 114