Skip to content

Commit

Permalink
add ut case for neoverse/ampere1 build flag detection
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-ampere committed Apr 26, 2024
1 parent 54fffea commit 0e94662
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions unittest/test_cmake_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,15 @@ def test_continuation(self):
cmake_scanner.scan_file_object(
'CMakeLists.txt', io_object, report)
self.assertEqual(len(report.issues), 1)

def test_neoverse_specific_opts_line_re(self):
match = CMakeScanner.NEOVERSE_SPECIFIC_OPTS_RE_PROG.search('ADD_CXX_FLAGS("-mtune=ampere1a")')
self.assertIsNone(match)
match = CMakeScanner.NEOVERSE_SPECIFIC_OPTS_RE_PROG.search('ADD_CXX_FLAGS("-mtune=neoverse-n2")')
self.assertIsNotNone(match)

def test_ampereone_specific_opts_line_re(self):
match = CMakeScanner.AMPEREONE_SPECIFIC_OPTS_RE_PROG.search('ADD_CXX_FLAGS("-mcpu=neoverse-v2")')
self.assertIsNone(match)
match = CMakeScanner.AMPEREONE_SPECIFIC_OPTS_RE_PROG.search('ADD_CXX_FLAGS("-mcpu=ampere1b")')
self.assertIsNotNone(match)
12 changes: 12 additions & 0 deletions unittest/test_makefile_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,15 @@ def test_continuation(self):
makefile_scanner.scan_file_object(
'Makefile', io_object, report)
self.assertEqual(len(report.issues), 1)

def test_neoverse_specific_opts_line_re(self):
match = MakefileScanner.NEOVERSE_SPECIFIC_OPTS_RE_PROG.search('CFLAGS = -mtune=ampere1a')
self.assertIsNone(match)
match = MakefileScanner.NEOVERSE_SPECIFIC_OPTS_RE_PROG.search('CFLAGS = -mtune=neoverse-n2')
self.assertIsNotNone(match)

def test_ampereone_specific_opts_line_re(self):
match = MakefileScanner.AMPEREONE_SPECIFIC_OPTS_RE_PROG.search('CFLAGS = -mcpu=neoverse-v2')
self.assertIsNone(match)
match = MakefileScanner.AMPEREONE_SPECIFIC_OPTS_RE_PROG.search('CFLAGS = -mcpu=ampere1b')
self.assertIsNotNone(match)

0 comments on commit 0e94662

Please sign in to comment.