From 0e946629344a3f8ddc6a6454524b19dbde2e7b5c Mon Sep 17 00:00:00 2001 From: "bin.huang" Date: Fri, 26 Apr 2024 09:57:37 +0000 Subject: [PATCH] add ut case for neoverse/ampere1 build flag detection --- unittest/test_cmake_scanner.py | 12 ++++++++++++ unittest/test_makefile_scanner.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/unittest/test_cmake_scanner.py b/unittest/test_cmake_scanner.py index 00f2312..8fe1856 100644 --- a/unittest/test_cmake_scanner.py +++ b/unittest/test_cmake_scanner.py @@ -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) diff --git a/unittest/test_makefile_scanner.py b/unittest/test_makefile_scanner.py index bc0814a..8e05a72 100644 --- a/unittest/test_makefile_scanner.py +++ b/unittest/test_makefile_scanner.py @@ -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)