|
1 |
| -# Copyright (C) 2021 Intel Corporation |
| 1 | +# Copyright (C) 2021-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 TestBasicAsm(unittest.TestCase): |
11 | 13 | """
|
12 |
| - Simple test of ability to handle directives in Fortran code. |
| 14 | + Simple test of ability to handle assembly files. |
13 | 15 | """
|
14 | 16 |
|
15 | 17 | def setUp(self):
|
16 | 18 | self.rootdir = "./tests/basic_asm/"
|
17 | 19 | logging.getLogger("codebasin").disabled = True
|
18 | 20 |
|
19 |
| - self.expected_setmap = {frozenset(['CPU']): 24} |
| 21 | + self.expected_setmap = {frozenset(["CPU"]): 24} |
20 | 22 |
|
21 | 23 | def test_yaml(self):
|
22 | 24 | """basic_asm/basic_asm.yaml"""
|
23 |
| - codebase, configuration = config.load( |
24 |
| - "./tests/basic_asm/basic_asm.yaml", self.rootdir) |
| 25 | + files = ["test.s", "test.S", "test.asm"] |
| 26 | + codebase = { |
| 27 | + "files": [ |
| 28 | + os.path.realpath(os.path.join(self.rootdir, f)) for f in files |
| 29 | + ], |
| 30 | + "platforms": ["CPU"], |
| 31 | + "exclude_files": set(), |
| 32 | + "exclude_patterns": [], |
| 33 | + "rootdir": self.rootdir, |
| 34 | + } |
| 35 | + entries = [] |
| 36 | + for f in codebase["files"]: |
| 37 | + entries.append( |
| 38 | + { |
| 39 | + "file": f, |
| 40 | + "defines": [], |
| 41 | + "include_paths": [], |
| 42 | + "include_files": [], |
| 43 | + }, |
| 44 | + ) |
| 45 | + configuration = {"CPU": entries} |
25 | 46 | state = finder.find(self.rootdir, codebase, configuration)
|
26 | 47 | mapper = PlatformMapper(codebase)
|
27 | 48 | setmap = mapper.walk(state)
|
28 |
| - self.assertDictEqual(setmap, self.expected_setmap, "Mismatch in setmap") |
| 49 | + self.assertDictEqual( |
| 50 | + setmap, |
| 51 | + self.expected_setmap, |
| 52 | + "Mismatch in setmap", |
| 53 | + ) |
29 | 54 |
|
30 | 55 | def test_ptx(self):
|
31 | 56 | """basic_asm/basic_asm_ptx.yaml"""
|
32 |
| - codebase, configuration = config.load( |
33 |
| - "./tests/basic_asm/basic_asm_ptx.yaml", self.rootdir) |
34 |
| - self.assertRaises(RuntimeError, finder.find, self.rootdir, codebase, configuration) |
35 |
| - |
| 57 | + codebase = { |
| 58 | + "files": [ |
| 59 | + os.path.realpath(os.path.join(self.rootdir, "test.ptx")), |
| 60 | + ], |
| 61 | + "platforms": ["GPU"], |
| 62 | + "exclude_files": set(), |
| 63 | + "exclude_patterns": [], |
| 64 | + "rootdir": self.rootdir, |
| 65 | + } |
| 66 | + entry = { |
| 67 | + "file": codebase["files"][0], |
| 68 | + "defines": [], |
| 69 | + "include_paths": [], |
| 70 | + "include_files": [], |
| 71 | + } |
| 72 | + configuration = {"GPU": [entry]} |
| 73 | + self.assertRaises( |
| 74 | + RuntimeError, |
| 75 | + finder.find, |
| 76 | + self.rootdir, |
| 77 | + codebase, |
| 78 | + configuration, |
| 79 | + ) |
36 | 80 |
|
37 | 81 |
|
38 |
| -if __name__ == '__main__': |
| 82 | +if __name__ == "__main__": |
39 | 83 | unittest.main()
|
0 commit comments