1
- # Copyright (C) 2019 Intel Corporation
1
+ # Copyright (C) 2019-2024 Intel Corporation
2
2
# SPDX-License-Identifier: BSD-3-Clause
3
3
4
- import unittest
5
4
import logging
6
- from codebasin import config , finder , walkers
5
+ import os
6
+ import unittest
7
+
8
+ from codebasin import finder
7
9
from codebasin .walkers .platform_mapper import PlatformMapper
8
10
9
- class TestExampleFile (unittest .TestCase ):
11
+
12
+ class TestMultiLine (unittest .TestCase ):
10
13
"""
11
14
Simple test of ability to handle counting of multi-line directives
12
15
"""
@@ -15,17 +18,49 @@ def setUp(self):
15
18
self .rootdir = "./tests/multi_line/"
16
19
logging .getLogger ("codebasin" ).disabled = True
17
20
18
- self .expected_setmap = {frozenset ([]): 4 ,
19
- frozenset (['CPU' , 'GPU' ]): 17 }
21
+ self .expected_setmap = {
22
+ frozenset ([]): 4 ,
23
+ frozenset (["CPU" , "GPU" ]): 17 ,
24
+ }
20
25
21
26
def test_yaml (self ):
22
27
"""multi_line/multi_line.yaml"""
23
- codebase , configuration = config .load ("./tests/multi_line/multi_line.yaml" , self .rootdir )
28
+ codebase = {
29
+ "files" : [
30
+ os .path .realpath (os .path .join (self .rootdir , "main.cpp" )),
31
+ ],
32
+ "platforms" : ["CPU" , "GPU" ],
33
+ "exclude_files" : set (),
34
+ "exclude_patterns" : [],
35
+ "rootdir" : self .rootdir ,
36
+ }
37
+ configuration = {
38
+ "CPU" : [
39
+ {
40
+ "file" : codebase ["files" ][0 ],
41
+ "defines" : ["CPU" ],
42
+ "include_paths" : [],
43
+ "include_files" : [],
44
+ },
45
+ ],
46
+ "GPU" : [
47
+ {
48
+ "file" : codebase ["files" ][0 ],
49
+ "defines" : ["GPU" ],
50
+ "include_paths" : [],
51
+ "include_files" : [],
52
+ },
53
+ ],
54
+ }
24
55
state = finder .find (self .rootdir , codebase , configuration )
25
56
mapper = PlatformMapper (codebase )
26
57
setmap = mapper .walk (state )
27
- self .assertDictEqual (setmap , self .expected_setmap , "Mismatch in setmap" )
58
+ self .assertDictEqual (
59
+ setmap ,
60
+ self .expected_setmap ,
61
+ "Mismatch in setmap" ,
62
+ )
28
63
29
64
30
- if __name__ == ' __main__' :
65
+ if __name__ == " __main__" :
31
66
unittest .main ()
0 commit comments