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 TestOnce (unittest .TestCase ):
10
13
"""
11
14
Simple test of ability to obey #pragma once directives.
12
15
"""
@@ -15,17 +18,50 @@ def setUp(self):
15
18
self .rootdir = "./tests/once/"
16
19
logging .getLogger ("codebasin" ).disabled = True
17
20
18
- self .expected_setmap = {frozenset ([]): 4 ,
19
- frozenset (['CPU' , 'GPU' ]): 10 }
21
+ self .expected_setmap = {
22
+ frozenset ([]): 4 ,
23
+ frozenset (["CPU" , "GPU" ]): 10 ,
24
+ }
20
25
21
26
def test_yaml (self ):
22
27
"""once/once.yaml"""
23
- codebase , configuration = config .load ("./tests/once/once.yaml" , self .rootdir )
28
+ codebase = {
29
+ "files" : [
30
+ os .path .realpath (os .path .join (self .rootdir , "main.cpp" )),
31
+ os .path .realpath (os .path .join (self .rootdir , "once.h" )),
32
+ ],
33
+ "platforms" : ["CPU" , "GPU" ],
34
+ "exclude_files" : set (),
35
+ "exclude_patterns" : [],
36
+ "rootdir" : self .rootdir ,
37
+ }
38
+ configuration = {
39
+ "CPU" : [
40
+ {
41
+ "file" : codebase ["files" ][0 ],
42
+ "defines" : ["CPU" ],
43
+ "include_paths" : [],
44
+ "include_files" : [],
45
+ },
46
+ ],
47
+ "GPU" : [
48
+ {
49
+ "file" : codebase ["files" ][0 ],
50
+ "defines" : ["GPU" ],
51
+ "include_paths" : [],
52
+ "include_files" : [],
53
+ },
54
+ ],
55
+ }
24
56
state = finder .find (self .rootdir , codebase , configuration )
25
57
mapper = PlatformMapper (codebase )
26
58
setmap = mapper .walk (state )
27
- self .assertDictEqual (setmap , self .expected_setmap , "Mismatch in setmap" )
59
+ self .assertDictEqual (
60
+ setmap ,
61
+ self .expected_setmap ,
62
+ "Mismatch in setmap" ,
63
+ )
28
64
29
65
30
- if __name__ == ' __main__' :
66
+ if __name__ == " __main__" :
31
67
unittest .main ()
0 commit comments