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 TestBreakpointFileLineMultipleRSFiles.'''
16
17from __future__ import absolute_import
18
19from harness.test_base_remote import TestBaseRemote
20from harness.decorators import (
21    cpp_only_test,
22    ordered_test
23)
24
25
26class TestBreakpointFileLineMultipleRSFiles(TestBaseRemote):
27    '''Tests the setting of a breakpoint on one of multiple RS files.'''
28
29    bundle_target = {
30        'java': 'MultipleRSFiles',
31        'jni': 'JNIMultipleRSFiles',
32        'cpp': 'CppMultipleRSFiles'
33    }
34
35    def _binary_name(self):
36        return {
37            'java': 'multiplersfiles',
38            'jni': 'multiplersfiles',
39            'cpp': 'CppMultipleRSFi'
40        }[self.app_type]
41
42    @ordered_test(0)
43    def test_breakpoint_fileline_multiple_files(self):
44        self.try_command('language renderscript status',
45                         ['Runtime Library discovered',
46                          'Runtime Driver discovered'])
47
48        self.try_command('breakpoint set --file first.rs --line 28',
49                         ['(pending)'])
50
51        self.try_command('process continue',
52                         ['stopped',
53                          'librs.first.so`first_kernel',
54                          'at first.rs:28',
55                          "name = '%s'" % self._binary_name(),
56                          'stop reason = breakpoint 1'])
57
58        self.try_command('breakpoint set --file second.rs --line 23',
59                         ['Breakpoint 2',
60                          'librs.second.so`second_kernel',
61                          'second.rs:23'])
62
63        self.try_command('breakpoint list',
64                         ['first.rs',
65                          'second.rs',
66                          'resolved = 1',
67                          'first.rs:28',
68                          'second.rs:23'])
69
70        self.try_command('breakpoint delete 1',
71                         ['1 breakpoints deleted'])
72
73        self.try_command('process continue',
74                         ['stopped',
75                          'librs.second.so`second_kernel',
76                          'at second.rs:23',
77                          "name = '%s'" % self._binary_name(),
78                          'stop reason = breakpoint 2'])
79
80        self.try_command('process status',
81                         ['stopped',
82                          'stop reason = breakpoint'])
83
84    @cpp_only_test()
85    @ordered_test('last')
86    def test_cpp_cleanup(self):
87        self.try_command('breakpoint delete 2', ['1 breakpoints deleted'])
88
89        self.try_command('process continue', ['exited with status = 0'])
90