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 config , finder
7
9
from codebasin .walkers .platform_mapper import PlatformMapper
8
10
9
11
10
- class TestExampleFile (unittest .TestCase ):
12
+ class TestInclude (unittest .TestCase ):
11
13
"""
12
14
Simple test of ability to follow #include directives to additional
13
15
files.
@@ -17,26 +19,42 @@ def setUp(self):
17
19
self .rootdir = "./tests/include/"
18
20
logging .getLogger ("codebasin" ).disabled = True
19
21
20
- self .expected_setmap = {frozenset (['CPU' ]): 11 ,
21
- frozenset (['GPU' ]): 12 ,
22
- frozenset (['CPU' , 'GPU' ]): 16 }
22
+ self .expected_setmap = {
23
+ frozenset (["CPU" ]): 11 ,
24
+ frozenset (["GPU" ]): 12 ,
25
+ frozenset (["CPU" , "GPU" ]): 16 ,
26
+ }
23
27
24
- def test_yaml (self ):
28
+ def test_include (self ):
25
29
"""include/include.yaml"""
26
- codebase , configuration = config .load ("./tests/include/include.yaml" , self .rootdir )
27
- state = finder .find (self .rootdir , codebase , configuration )
28
- mapper = PlatformMapper (codebase )
29
- setmap = mapper .walk (state )
30
- self .assertDictEqual (setmap , self .expected_setmap , "Mismatch in setmap" )
30
+ codebase = {
31
+ "files" : [],
32
+ "platforms" : ["CPU" , "GPU" ],
33
+ "exclude_files" : set (),
34
+ "exclude_patterns" : [],
35
+ "rootdir" : os .path .realpath (self .rootdir ),
36
+ }
37
+
38
+ cpu_path = os .path .realpath (
39
+ os .path .join (self .rootdir , "cpu_commands.json" ),
40
+ )
41
+ gpu_path = os .path .realpath (
42
+ os .path .join (self .rootdir , "gpu_commands.json" ),
43
+ )
44
+ configuration = {
45
+ "CPU" : config .load_database (cpu_path , self .rootdir ),
46
+ "GPU" : config .load_database (gpu_path , self .rootdir ),
47
+ }
31
48
32
- def test_db (self ):
33
- """include/include-db.yaml"""
34
- codebase , configuration = config .load ("./tests/include/include-db.yaml" , self .rootdir )
35
49
state = finder .find (self .rootdir , codebase , configuration )
36
50
mapper = PlatformMapper (codebase )
37
51
setmap = mapper .walk (state )
38
- self .assertDictEqual (setmap , self .expected_setmap , "Mismatch in setmap" )
52
+ self .assertDictEqual (
53
+ setmap ,
54
+ self .expected_setmap ,
55
+ "Mismatch in setmap" ,
56
+ )
39
57
40
58
41
- if __name__ == ' __main__' :
59
+ if __name__ == " __main__" :
42
60
unittest .main ()
0 commit comments