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 TestDisjointCodebase (unittest .TestCase ):
11
13
"""
12
14
Test of handling for disjoint code bases:
13
15
- Separate file lists for each platform
@@ -18,17 +20,64 @@ def setUp(self):
18
20
self .rootdir = "./tests/disjoint/"
19
21
logging .getLogger ("codebasin" ).disabled = True
20
22
21
- self .expected_setmap = {frozenset (['CPU' ]): 6 ,
22
- frozenset (['GPU' ]): 6 }
23
+ self .expected_setmap = {frozenset (["CPU" ]): 6 , frozenset (["GPU" ]): 6 }
23
24
24
25
def test_yaml (self ):
25
26
"""disjoint/disjoint.yaml"""
26
- codebase , configuration = config .load ("./tests/disjoint/disjoint.yaml" , self .rootdir )
27
+ files = [
28
+ "cpu.cpp" ,
29
+ "gpu.cpp" ,
30
+ "cpu_headers/header.h" ,
31
+ "gpu_headers/header.h" ,
32
+ ]
33
+ codebase = {
34
+ "files" : [
35
+ os .path .realpath (os .path .join (self .rootdir , f )) for f in files
36
+ ],
37
+ "platforms" : ["CPU" , "GPU" ],
38
+ "exclude_files" : set (),
39
+ "exclude_patterns" : [],
40
+ "rootdir" : self .rootdir ,
41
+ }
42
+ configuration = {
43
+ "CPU" : [
44
+ {
45
+ "file" : os .path .realpath (
46
+ os .path .join (self .rootdir , "cpu.cpp" ),
47
+ ),
48
+ "defines" : ["CPU" ],
49
+ "include_paths" : [
50
+ os .path .realpath (
51
+ os .path .join (self .rootdir , "cpu_headers" ),
52
+ ),
53
+ ],
54
+ "include_files" : [],
55
+ },
56
+ ],
57
+ "GPU" : [
58
+ {
59
+ "file" : os .path .realpath (
60
+ os .path .join (self .rootdir , "gpu.cpp" ),
61
+ ),
62
+ "defines" : ["GPU" ],
63
+ "include_paths" : [
64
+ os .path .realpath (
65
+ os .path .join (self .rootdir , "gpu_headers" ),
66
+ ),
67
+ ],
68
+ "include_files" : [],
69
+ },
70
+ ],
71
+ }
27
72
state = finder .find (self .rootdir , codebase , configuration )
28
73
mapper = PlatformMapper (codebase )
29
74
setmap = mapper .walk (state )
30
- self .assertDictEqual (setmap , self .expected_setmap , "Mismatch in setmap" )
75
+ self .assertDictEqual (
76
+ setmap ,
77
+ self .expected_setmap ,
78
+ "Mismatch in setmap" ,
79
+ )
31
80
32
81
33
- if __name__ == ' __main__' :
82
+ if __name__ == " __main__" :
34
83
unittest .main ()
0 commit comments