xref: /aosp_15_r20/tools/asuite/aidegen/lib/native_util_unittest.py (revision c2e18aaa1096c836b086f94603d04f4eb9cf37f5)
1*c2e18aaaSAndroid Build Coastguard Worker#!/usr/bin/env python3
2*c2e18aaaSAndroid Build Coastguard Worker#
3*c2e18aaaSAndroid Build Coastguard Worker# Copyright 2019, The Android Open Source Project
4*c2e18aaaSAndroid Build Coastguard Worker#
5*c2e18aaaSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
6*c2e18aaaSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
7*c2e18aaaSAndroid Build Coastguard Worker# You may obtain a copy of the License at
8*c2e18aaaSAndroid Build Coastguard Worker#
9*c2e18aaaSAndroid Build Coastguard Worker#     http://www.apache.org/licenses/LICENSE-2.0
10*c2e18aaaSAndroid Build Coastguard Worker#
11*c2e18aaaSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
12*c2e18aaaSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
13*c2e18aaaSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*c2e18aaaSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
15*c2e18aaaSAndroid Build Coastguard Worker# limitations under the License.
16*c2e18aaaSAndroid Build Coastguard Worker
17*c2e18aaaSAndroid Build Coastguard Worker"""Unittests for native_util."""
18*c2e18aaaSAndroid Build Coastguard Worker
19*c2e18aaaSAndroid Build Coastguard Workerimport os
20*c2e18aaaSAndroid Build Coastguard Workerimport unittest
21*c2e18aaaSAndroid Build Coastguard Workerfrom unittest import mock
22*c2e18aaaSAndroid Build Coastguard Worker
23*c2e18aaaSAndroid Build Coastguard Workerfrom aidegen import unittest_constants
24*c2e18aaaSAndroid Build Coastguard Workerfrom aidegen.lib import common_util
25*c2e18aaaSAndroid Build Coastguard Workerfrom aidegen.lib import native_module_info
26*c2e18aaaSAndroid Build Coastguard Workerfrom aidegen.lib import native_util
27*c2e18aaaSAndroid Build Coastguard Workerfrom aidegen.lib import project_info
28*c2e18aaaSAndroid Build Coastguard Worker
29*c2e18aaaSAndroid Build Coastguard Worker
30*c2e18aaaSAndroid Build Coastguard Worker# pylint: disable=protected-access
31*c2e18aaaSAndroid Build Coastguard Worker# pylint: disable=too-many-arguments
32*c2e18aaaSAndroid Build Coastguard Workerclass AidegenNativeUtilUnittests(unittest.TestCase):
33*c2e18aaaSAndroid Build Coastguard Worker    """Unit tests for native_util.py"""
34*c2e18aaaSAndroid Build Coastguard Worker
35*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(native_util, '_check_native_project_exists')
36*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(common_util, 'check_java_or_kotlin_file_exists')
37*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(common_util, 'get_related_paths')
38*c2e18aaaSAndroid Build Coastguard Worker    def test_analyze_native_and_java_projects(
39*c2e18aaaSAndroid Build Coastguard Worker            self, mock_get_related, mock_check_java, mock_check_native):
40*c2e18aaaSAndroid Build Coastguard Worker        """Test analyze_native_and_java_projects function."""
41*c2e18aaaSAndroid Build Coastguard Worker        mock_get_related.return_value = None, None
42*c2e18aaaSAndroid Build Coastguard Worker        mock_check_java.return_value = True
43*c2e18aaaSAndroid Build Coastguard Worker        mock_check_native.return_value = True
44*c2e18aaaSAndroid Build Coastguard Worker        targets = ['a']
45*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual((targets, targets),
46*c2e18aaaSAndroid Build Coastguard Worker                         native_util._analyze_native_and_java_projects(
47*c2e18aaaSAndroid Build Coastguard Worker                             None, None, targets))
48*c2e18aaaSAndroid Build Coastguard Worker        mock_check_native.return_value = False
49*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual((targets, []),
50*c2e18aaaSAndroid Build Coastguard Worker                         native_util._analyze_native_and_java_projects(
51*c2e18aaaSAndroid Build Coastguard Worker                             None, None, targets))
52*c2e18aaaSAndroid Build Coastguard Worker        mock_check_java.return_value = False
53*c2e18aaaSAndroid Build Coastguard Worker        mock_check_native.return_value = True
54*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(([], targets),
55*c2e18aaaSAndroid Build Coastguard Worker                         native_util._analyze_native_and_java_projects(
56*c2e18aaaSAndroid Build Coastguard Worker                             None, None, targets))
57*c2e18aaaSAndroid Build Coastguard Worker
58*c2e18aaaSAndroid Build Coastguard Worker    def test_check_native_project_exists(self):
59*c2e18aaaSAndroid Build Coastguard Worker        """Test _check_native_project_exists function."""
60*c2e18aaaSAndroid Build Coastguard Worker        rel_path = 'a/b'
61*c2e18aaaSAndroid Build Coastguard Worker        path_to_module_info = {'a/b/c': {}}
62*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(
63*c2e18aaaSAndroid Build Coastguard Worker            native_util._check_native_project_exists(path_to_module_info,
64*c2e18aaaSAndroid Build Coastguard Worker                                                     rel_path))
65*c2e18aaaSAndroid Build Coastguard Worker        rel_path = 'a/b/c/d'
66*c2e18aaaSAndroid Build Coastguard Worker        self.assertFalse(
67*c2e18aaaSAndroid Build Coastguard Worker            native_util._check_native_project_exists(path_to_module_info,
68*c2e18aaaSAndroid Build Coastguard Worker                                                     rel_path))
69*c2e18aaaSAndroid Build Coastguard Worker
70*c2e18aaaSAndroid Build Coastguard Worker    def test_find_parent(self):
71*c2e18aaaSAndroid Build Coastguard Worker        """Test _find_parent function with conditions."""
72*c2e18aaaSAndroid Build Coastguard Worker        current_parent = None
73*c2e18aaaSAndroid Build Coastguard Worker        abs_path = 'a/b/c/d'
74*c2e18aaaSAndroid Build Coastguard Worker        expected = abs_path
75*c2e18aaaSAndroid Build Coastguard Worker        result = native_util._find_parent(abs_path, current_parent)
76*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(result, expected)
77*c2e18aaaSAndroid Build Coastguard Worker        current_parent = 'a/b/c/d/e'
78*c2e18aaaSAndroid Build Coastguard Worker        result = native_util._find_parent(abs_path, current_parent)
79*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(result, expected)
80*c2e18aaaSAndroid Build Coastguard Worker        current_parent = 'a/b/c'
81*c2e18aaaSAndroid Build Coastguard Worker        expected = current_parent
82*c2e18aaaSAndroid Build Coastguard Worker        result = native_util._find_parent(abs_path, current_parent)
83*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(result, expected)
84*c2e18aaaSAndroid Build Coastguard Worker        current_parent = 'a/b/f'
85*c2e18aaaSAndroid Build Coastguard Worker        expected = 'a/b'
86*c2e18aaaSAndroid Build Coastguard Worker        result = native_util._find_parent(abs_path, current_parent)
87*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(result, expected)
88*c2e18aaaSAndroid Build Coastguard Worker
89*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(native_module_info.NativeModuleInfo,
90*c2e18aaaSAndroid Build Coastguard Worker                       '_load_module_info_file')
91*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(native_util, '_find_parent')
92*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(common_util, 'get_related_paths')
93*c2e18aaaSAndroid Build Coastguard Worker    def test_get_merged_native_target_is_module(
94*c2e18aaaSAndroid Build Coastguard Worker            self, mock_get_related, mock_find_parent, mock_load_info):
95*c2e18aaaSAndroid Build Coastguard Worker        """Test _get_merged_native_target function if the target is a module."""
96*c2e18aaaSAndroid Build Coastguard Worker        mock_get_related.return_value = 'c/d', 'a/b/c/d'
97*c2e18aaaSAndroid Build Coastguard Worker        parent = 'a/b'
98*c2e18aaaSAndroid Build Coastguard Worker        mock_find_parent.return_value = parent
99*c2e18aaaSAndroid Build Coastguard Worker        targets = ['multiarch']
100*c2e18aaaSAndroid Build Coastguard Worker        expected = (parent, targets)
101*c2e18aaaSAndroid Build Coastguard Worker        mock_load_info.return_value = (
102*c2e18aaaSAndroid Build Coastguard Worker            None, unittest_constants.CC_NAME_TO_MODULE_INFO)
103*c2e18aaaSAndroid Build Coastguard Worker        cc_mod_info = native_module_info.NativeModuleInfo()
104*c2e18aaaSAndroid Build Coastguard Worker        new_parent, new_targets = native_util._get_merged_native_target(
105*c2e18aaaSAndroid Build Coastguard Worker            cc_mod_info, targets)
106*c2e18aaaSAndroid Build Coastguard Worker        result = (new_parent, new_targets)
107*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(result, expected)
108*c2e18aaaSAndroid Build Coastguard Worker
109*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(native_module_info.NativeModuleInfo,
110*c2e18aaaSAndroid Build Coastguard Worker                       '_load_module_info_file')
111*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(native_util, '_find_parent')
112*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(common_util, 'get_related_paths')
113*c2e18aaaSAndroid Build Coastguard Worker    def test_get_merged_native_target_is_path(self, mock_get_related,
114*c2e18aaaSAndroid Build Coastguard Worker                                              mock_find_parent, mock_load_info):
115*c2e18aaaSAndroid Build Coastguard Worker        """Test _get_merged_native_target function if the target is a path."""
116*c2e18aaaSAndroid Build Coastguard Worker        parent = 'a/b'
117*c2e18aaaSAndroid Build Coastguard Worker        rel_path = 'shared/path/to/be/used2'
118*c2e18aaaSAndroid Build Coastguard Worker        mock_get_related.return_value = rel_path, os.path.join(parent, rel_path)
119*c2e18aaaSAndroid Build Coastguard Worker        mock_find_parent.return_value = parent
120*c2e18aaaSAndroid Build Coastguard Worker        mock_load_info.return_value = (
121*c2e18aaaSAndroid Build Coastguard Worker            None, unittest_constants.CC_NAME_TO_MODULE_INFO)
122*c2e18aaaSAndroid Build Coastguard Worker        targets = [rel_path]
123*c2e18aaaSAndroid Build Coastguard Worker        result_targets = unittest_constants.TESTABLE_MODULES_WITH_SHARED_PATH
124*c2e18aaaSAndroid Build Coastguard Worker        expected = (parent, result_targets)
125*c2e18aaaSAndroid Build Coastguard Worker        cc_mod_info = native_module_info.NativeModuleInfo()
126*c2e18aaaSAndroid Build Coastguard Worker        new_parent, new_targets = native_util._get_merged_native_target(
127*c2e18aaaSAndroid Build Coastguard Worker            cc_mod_info, targets)
128*c2e18aaaSAndroid Build Coastguard Worker        result = (new_parent, new_targets)
129*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(result, expected)
130*c2e18aaaSAndroid Build Coastguard Worker
131*c2e18aaaSAndroid Build Coastguard Worker    def test_filter_out_modules(self):
132*c2e18aaaSAndroid Build Coastguard Worker        """Test _filter_out_modules with conditions."""
133*c2e18aaaSAndroid Build Coastguard Worker        targets = ['shared/path/to/be/used2']
134*c2e18aaaSAndroid Build Coastguard Worker        result = ([], targets)
135*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(
136*c2e18aaaSAndroid Build Coastguard Worker            result, native_util._filter_out_modules(targets, lambda x: False))
137*c2e18aaaSAndroid Build Coastguard Worker        targets = ['multiarch']
138*c2e18aaaSAndroid Build Coastguard Worker        result = (targets, [])
139*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(
140*c2e18aaaSAndroid Build Coastguard Worker            result, native_util._filter_out_modules(targets, lambda x: True))
141*c2e18aaaSAndroid Build Coastguard Worker
142*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(native_util, '_filter_out_rust_projects')
143*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(native_util, '_analyze_native_and_java_projects')
144*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(native_util, '_filter_out_modules')
145*c2e18aaaSAndroid Build Coastguard Worker    def test_get_java_cc_and_rust_projects(self, mock_fil, mock_ana,
146*c2e18aaaSAndroid Build Coastguard Worker                                           mock_fil_rust):
147*c2e18aaaSAndroid Build Coastguard Worker        """Test get_java_cc_and_rust_projects handling."""
148*c2e18aaaSAndroid Build Coastguard Worker        targets = ['multiarch']
149*c2e18aaaSAndroid Build Coastguard Worker        mock_fil_rust.return_value = []
150*c2e18aaaSAndroid Build Coastguard Worker        mock_fil.return_value = [], targets
151*c2e18aaaSAndroid Build Coastguard Worker        cc_mod_info = mock.Mock()
152*c2e18aaaSAndroid Build Coastguard Worker        cc_mod_info.is_module = mock.Mock()
153*c2e18aaaSAndroid Build Coastguard Worker        cc_mod_info.is_module.return_value = True
154*c2e18aaaSAndroid Build Coastguard Worker        at_mod_info = mock.Mock()
155*c2e18aaaSAndroid Build Coastguard Worker        at_mod_info.is_module = mock.Mock()
156*c2e18aaaSAndroid Build Coastguard Worker        at_mod_info.is_module.return_value = True
157*c2e18aaaSAndroid Build Coastguard Worker        mock_ana.return_value = [], targets
158*c2e18aaaSAndroid Build Coastguard Worker        native_util.get_java_cc_and_rust_projects(
159*c2e18aaaSAndroid Build Coastguard Worker            at_mod_info, cc_mod_info, targets)
160*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(mock_fil.call_count, 2)
161*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(mock_ana.call_count, 1)
162*c2e18aaaSAndroid Build Coastguard Worker
163*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(native_util, '_get_rust_targets')
164*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(common_util, 'get_json_dict')
165*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch('builtins.print')
166*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch('os.path.isfile')
167*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch('os.path.join')
168*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(common_util, 'get_blueprint_json_path')
169*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(common_util, 'get_android_root_dir')
170*c2e18aaaSAndroid Build Coastguard Worker    def test_filter_out_rust_projects(self, mock_get_root, mock_get_json,
171*c2e18aaaSAndroid Build Coastguard Worker                                      mock_join, mock_is_file, mock_print,
172*c2e18aaaSAndroid Build Coastguard Worker                                      mock_get_dict, mock_get_rust):
173*c2e18aaaSAndroid Build Coastguard Worker        """Test _filter_out_rust_projects with conditions."""
174*c2e18aaaSAndroid Build Coastguard Worker        mock_is_file.return_value = False
175*c2e18aaaSAndroid Build Coastguard Worker        native_util._filter_out_rust_projects(['a/b/rust'])
176*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_get_root.called)
177*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_get_json.called)
178*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_join.called)
179*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_print.called)
180*c2e18aaaSAndroid Build Coastguard Worker        self.assertFalse(mock_get_dict.called)
181*c2e18aaaSAndroid Build Coastguard Worker        self.assertFalse(mock_get_rust.called)
182*c2e18aaaSAndroid Build Coastguard Worker
183*c2e18aaaSAndroid Build Coastguard Worker        mock_get_root.mock_reset()
184*c2e18aaaSAndroid Build Coastguard Worker        mock_get_json.mock_reset()
185*c2e18aaaSAndroid Build Coastguard Worker        mock_join.mock_reset()
186*c2e18aaaSAndroid Build Coastguard Worker        mock_print.mock_reset()
187*c2e18aaaSAndroid Build Coastguard Worker        mock_get_dict.mock_reset()
188*c2e18aaaSAndroid Build Coastguard Worker        mock_get_rust.mock_reset()
189*c2e18aaaSAndroid Build Coastguard Worker        mock_is_file.return_value = True
190*c2e18aaaSAndroid Build Coastguard Worker        mock_get_dict.return_value = {}
191*c2e18aaaSAndroid Build Coastguard Worker        native_util._filter_out_rust_projects(['a/b/rust'])
192*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_get_root.called)
193*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_get_json.called)
194*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_join.called)
195*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_print.called)
196*c2e18aaaSAndroid Build Coastguard Worker        self.assertFalse(mock_get_rust.called)
197*c2e18aaaSAndroid Build Coastguard Worker
198*c2e18aaaSAndroid Build Coastguard Worker        mock_get_root.mock_reset()
199*c2e18aaaSAndroid Build Coastguard Worker        mock_get_json.mock_reset()
200*c2e18aaaSAndroid Build Coastguard Worker        mock_join.mock_reset()
201*c2e18aaaSAndroid Build Coastguard Worker        mock_print.mock_reset()
202*c2e18aaaSAndroid Build Coastguard Worker        mock_get_rust.mock_reset()
203*c2e18aaaSAndroid Build Coastguard Worker        mock_is_file.return_value = True
204*c2e18aaaSAndroid Build Coastguard Worker        crates = [{native_util._ROOT_MODULE: 'a/b/rust/src'}]
205*c2e18aaaSAndroid Build Coastguard Worker        mock_get_dict.return_value = {native_util._CRATES_KEY: crates}
206*c2e18aaaSAndroid Build Coastguard Worker        mock_get_root.return_value = 'a/b'
207*c2e18aaaSAndroid Build Coastguard Worker        native_util._filter_out_rust_projects(['a/b/rust'])
208*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_get_json.called)
209*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_join.called)
210*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(mock_get_rust.called)
211*c2e18aaaSAndroid Build Coastguard Worker        mock_get_rust.assert_called_with(['a/b/rust'], crates, 'a/b')
212*c2e18aaaSAndroid Build Coastguard Worker
213*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(project_info, 'batch_build_dependencies')
214*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch.object(common_util, 'is_source_under_relative_path')
215*c2e18aaaSAndroid Build Coastguard Worker    @mock.patch('os.path.isdir')
216*c2e18aaaSAndroid Build Coastguard Worker    def test_get_rust_targets(self, mock_is_dir, mock_is_under, mock_rebuilds):
217*c2e18aaaSAndroid Build Coastguard Worker        """Test _get_rust_targets with conditions."""
218*c2e18aaaSAndroid Build Coastguard Worker        mock_is_dir.return_value = True
219*c2e18aaaSAndroid Build Coastguard Worker        mock_is_under.return_value = True
220*c2e18aaaSAndroid Build Coastguard Worker        display_name = 'rust_module'
221*c2e18aaaSAndroid Build Coastguard Worker        mod_info = [
222*c2e18aaaSAndroid Build Coastguard Worker            {
223*c2e18aaaSAndroid Build Coastguard Worker                native_util._DISPLAY_NAME: display_name,
224*c2e18aaaSAndroid Build Coastguard Worker                native_util._ROOT_MODULE: 'a/b/rust/src'
225*c2e18aaaSAndroid Build Coastguard Worker            }
226*c2e18aaaSAndroid Build Coastguard Worker        ]
227*c2e18aaaSAndroid Build Coastguard Worker        targets = ['a/b/rust']
228*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(
229*c2e18aaaSAndroid Build Coastguard Worker            targets,
230*c2e18aaaSAndroid Build Coastguard Worker            native_util._get_rust_targets(targets, mod_info, 'a/b'))
231*c2e18aaaSAndroid Build Coastguard Worker        mock_rebuilds.assert_called_with({display_name})
232*c2e18aaaSAndroid Build Coastguard Worker
233*c2e18aaaSAndroid Build Coastguard Worker    def test_get_relative_path(self):
234*c2e18aaaSAndroid Build Coastguard Worker        """Test _get_relative_path with conditions."""
235*c2e18aaaSAndroid Build Coastguard Worker        root = common_util.get_android_root_dir()
236*c2e18aaaSAndroid Build Coastguard Worker        cwd = os.getcwd()
237*c2e18aaaSAndroid Build Coastguard Worker        rel_target = os.path.relpath(cwd, root)
238*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(rel_target, native_util._get_relative_path('.', root))
239*c2e18aaaSAndroid Build Coastguard Worker
240*c2e18aaaSAndroid Build Coastguard Worker        root = 'a/b'
241*c2e18aaaSAndroid Build Coastguard Worker        target = 'a/b/rust'
242*c2e18aaaSAndroid Build Coastguard Worker        rel_target = 'rust'
243*c2e18aaaSAndroid Build Coastguard Worker        self.assertEqual(
244*c2e18aaaSAndroid Build Coastguard Worker            rel_target, native_util._get_relative_path(target, root))
245*c2e18aaaSAndroid Build Coastguard Worker
246*c2e18aaaSAndroid Build Coastguard Worker    def test_is_target_relative_module(self):
247*c2e18aaaSAndroid Build Coastguard Worker        """Test _is_target_relative_module with conditions."""
248*c2e18aaaSAndroid Build Coastguard Worker        path = 'a/b'
249*c2e18aaaSAndroid Build Coastguard Worker        target = 'a/b'
250*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(
251*c2e18aaaSAndroid Build Coastguard Worker            native_util._is_target_relative_module(path, target))
252*c2e18aaaSAndroid Build Coastguard Worker
253*c2e18aaaSAndroid Build Coastguard Worker        path = 'a/b/c'
254*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(
255*c2e18aaaSAndroid Build Coastguard Worker            native_util._is_target_relative_module(path, target))
256*c2e18aaaSAndroid Build Coastguard Worker
257*c2e18aaaSAndroid Build Coastguard Worker        path = 'out/a/b/c'
258*c2e18aaaSAndroid Build Coastguard Worker        self.assertTrue(
259*c2e18aaaSAndroid Build Coastguard Worker            native_util._is_target_relative_module(path, target))
260*c2e18aaaSAndroid Build Coastguard Worker
261*c2e18aaaSAndroid Build Coastguard Worker        target = 'a/bc'
262*c2e18aaaSAndroid Build Coastguard Worker        self.assertFalse(
263*c2e18aaaSAndroid Build Coastguard Worker            native_util._is_target_relative_module(path, target))
264*c2e18aaaSAndroid Build Coastguard Worker
265*c2e18aaaSAndroid Build Coastguard Worker
266*c2e18aaaSAndroid Build Coastguard Workerif __name__ == '__main__':
267*c2e18aaaSAndroid Build Coastguard Worker    unittest.main()
268