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 TestBasicFortran (unittest .TestCase ):
11
13
"""
12
14
Simple test of ability to handle directives in Fortran code.
13
15
"""
@@ -16,19 +18,50 @@ def setUp(self):
16
18
self .rootdir = "./tests/basic_fortran/"
17
19
logging .getLogger ("codebasin" ).disabled = True
18
20
19
- self .expected_setmap = {frozenset (['CPU' ]): 2 ,
20
- frozenset (['GPU' ]): 3 ,
21
- frozenset (['CPU' , 'GPU' ]): 8 }
21
+ self .expected_setmap = {
22
+ frozenset (["CPU" ]): 2 ,
23
+ frozenset (["GPU" ]): 3 ,
24
+ frozenset (["CPU" , "GPU" ]): 8 ,
25
+ }
22
26
23
27
def test_yaml (self ):
24
28
"""basic_fortran/basic_fortran.yaml"""
25
- codebase , configuration = config .load (
26
- "./tests/basic_fortran/basic_fortran.yaml" , self .rootdir )
29
+ codebase = {
30
+ "files" : [
31
+ os .path .realpath (os .path .join (self .rootdir , "test.f90" )),
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
+ }
27
56
state = finder .find (self .rootdir , codebase , configuration )
28
57
mapper = PlatformMapper (codebase )
29
58
setmap = mapper .walk (state )
30
- self .assertDictEqual (setmap , self .expected_setmap , "Mismatch in setmap" )
59
+ self .assertDictEqual (
60
+ setmap ,
61
+ self .expected_setmap ,
62
+ "Mismatch in setmap" ,
63
+ )
31
64
32
65
33
- if __name__ == ' __main__' :
66
+ if __name__ == " __main__" :
34
67
unittest .main ()
0 commit comments