Skip to content

Commit 237d475

Browse files
committed
Rewrite basic assembly test without YAML
Signed-off-by: John Pennycook <john.pennycook@intel.com>
1 parent 9cc7dda commit 237d475

File tree

3 files changed

+58
-26
lines changed

3 files changed

+58
-26
lines changed

tests/basic_asm/basic_asm.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/basic_asm/basic_asm_ptx.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/basic_asm/test_basic_asm.py

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,83 @@
1-
# Copyright (C) 2021 Intel Corporation
1+
# Copyright (C) 2021-2024 Intel Corporation
22
# SPDX-License-Identifier: BSD-3-Clause
33

4-
import unittest
54
import logging
6-
from codebasin import config, finder, walkers
5+
import os
6+
import unittest
7+
8+
from codebasin import finder
79
from codebasin.walkers.platform_mapper import PlatformMapper
810

911

10-
class TestExampleFile(unittest.TestCase):
12+
class TestBasicAsm(unittest.TestCase):
1113
"""
12-
Simple test of ability to handle directives in Fortran code.
14+
Simple test of ability to handle assembly files.
1315
"""
1416

1517
def setUp(self):
1618
self.rootdir = "./tests/basic_asm/"
1719
logging.getLogger("codebasin").disabled = True
1820

19-
self.expected_setmap = {frozenset(['CPU']): 24}
21+
self.expected_setmap = {frozenset(["CPU"]): 24}
2022

2123
def test_yaml(self):
2224
"""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}
2546
state = finder.find(self.rootdir, codebase, configuration)
2647
mapper = PlatformMapper(codebase)
2748
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+
)
2954

3055
def test_ptx(self):
3156
"""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+
)
3680

3781

38-
if __name__ == '__main__':
82+
if __name__ == "__main__":
3983
unittest.main()

0 commit comments

Comments
 (0)