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
11
10
- class TestExampleFile (unittest .TestCase ):
12
+ class TestDefine (unittest .TestCase ):
11
13
"""
12
14
Simple test of ability to recognize #define directives within files.
13
15
"""
@@ -16,17 +18,49 @@ def setUp(self):
16
18
self .rootdir = "./tests/define/"
17
19
logging .getLogger ("codebasin" ).disabled = True
18
20
19
- self .expected_setmap = {frozenset ([]): 4 ,
20
- frozenset (['CPU' , 'GPU' ]): 10 }
21
+ self .expected_setmap = {
22
+ frozenset ([]): 4 ,
23
+ frozenset (["CPU" , "GPU" ]): 10 ,
24
+ }
21
25
22
26
def test_yaml (self ):
23
27
"""define/define.yaml"""
24
- codebase , configuration = config .load ("./tests/define/define.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
+ }
25
55
state = finder .find (self .rootdir , codebase , configuration )
26
56
mapper = PlatformMapper (codebase )
27
57
setmap = mapper .walk (state )
28
- self .assertDictEqual (setmap , self .expected_setmap , "Mismatch in setmap" )
58
+ self .assertDictEqual (
59
+ setmap ,
60
+ self .expected_setmap ,
61
+ "Mismatch in setmap" ,
62
+ )
29
63
30
64
31
- if __name__ == ' __main__' :
65
+ if __name__ == " __main__" :
32
66
unittest .main ()
0 commit comments