From 6e40b140a21762878b06c7d17e9d6bf046406e84 Mon Sep 17 00:00:00 2001 From: Jeremiah Leary Date: Tue, 17 Oct 2023 20:13:55 -0500 Subject: [PATCH] Issue#27: Added parsing of Synplify Pro log files. --- docs/source/vendors/synopsys/synopsys.rst | 5 ++ docs/source/vendors/synopsys/synplify_pro.rst | 28 ++++++++++ docs/source/vendors/vendors.rst | 1 + elfws/vendor/synopsys/__init__.py | 0 elfws/vendor/synopsys/synplify_pro.py | 34 +++++++++++++ tests/utils/test_functions.py | 3 +- tests/vendor/synopsys/__init__.py | 0 .../vendor/synopsys/synplify_pro/__init__.py | 0 .../synopsys/synplify_pro/test_functions.py | 51 +++++++++++++++++++ 9 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 docs/source/vendors/synopsys/synopsys.rst create mode 100644 docs/source/vendors/synopsys/synplify_pro.rst create mode 100644 elfws/vendor/synopsys/__init__.py create mode 100644 elfws/vendor/synopsys/synplify_pro.py create mode 100644 tests/vendor/synopsys/__init__.py create mode 100644 tests/vendor/synopsys/synplify_pro/__init__.py create mode 100644 tests/vendor/synopsys/synplify_pro/test_functions.py diff --git a/docs/source/vendors/synopsys/synopsys.rst b/docs/source/vendors/synopsys/synopsys.rst new file mode 100644 index 0000000..8c2614c --- /dev/null +++ b/docs/source/vendors/synopsys/synopsys.rst @@ -0,0 +1,5 @@ +Synopsys +-------- + +.. include:: synplify_pro.rst + diff --git a/docs/source/vendors/synopsys/synplify_pro.rst b/docs/source/vendors/synopsys/synplify_pro.rst new file mode 100644 index 0000000..e66c7a2 --- /dev/null +++ b/docs/source/vendors/synopsys/synplify_pro.rst @@ -0,0 +1,28 @@ +Synplify Pro +~~~~~~~~~~~~ + +Synplify Pro provides warnings on a single line with the line starting with :code:`@W`. + + : : + +where: + ++-------------------------------+-------------------------------------------------+ +| Item | Regular Expression Match | ++===============================+=================================================+ +| warning keyword | @W | ++-------------------------------+-------------------------------------------------+ +| ID | \\W+ | ++-------------------------------+-------------------------------------------------+ +| message | .*$ | ++-------------------------------+-------------------------------------------------+ + +Extracting Warnings +^^^^^^^^^^^^^^^^^^^ + +Extraction of warnings from the logfile will follow this process: + +1. Search for lines starting with **@W** +2. Extract warning keyword +3. Extract message + diff --git a/docs/source/vendors/vendors.rst b/docs/source/vendors/vendors.rst index b795a51..294c623 100644 --- a/docs/source/vendors/vendors.rst +++ b/docs/source/vendors/vendors.rst @@ -8,4 +8,5 @@ The following sections contain information about each vendor tool supported by E mentor_graphics/mentor_graphics.rst microsemi/microsemi.rst + synopsys/synopsys.rst xilinx/xilinx.rst diff --git a/elfws/vendor/synopsys/__init__.py b/elfws/vendor/synopsys/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/elfws/vendor/synopsys/synplify_pro.py b/elfws/vendor/synopsys/synplify_pro.py new file mode 100644 index 0000000..5cf8fd9 --- /dev/null +++ b/elfws/vendor/synopsys/synplify_pro.py @@ -0,0 +1,34 @@ + +from elfws import warning +from elfws import warning_list + + +def get_vendor(): + return ['Synopsys'] + + +def get_tool_name(): + return 'Synplify Pro' + + +def is_logfile(lFile): + for iLineNumber, sLine in enumerate(lFile): + if sLine.startswith('#Build: Synplify Pro (R)'): + return True + if iLineNumber == 5: + return False + return False + + +def extract_warnings(lFile): + oReturn = warning_list.create() + + for iLineNumber, sLine in enumerate(lFile): + if sLine.startswith('@W'): + iColon1Index = sLine.find(':') + iColon2Index = sLine.find(':', iColon1Index+1) + sID = sLine[iColon1Index+1:iColon2Index].strip() + sMessage = sLine[iColon2Index+1:].strip() + oWarning = warning.create(sID, sMessage, None, iLineNumber + 1) + oReturn.add_warning(oWarning) + return oReturn diff --git a/tests/utils/test_functions.py b/tests/utils/test_functions.py index c4f9d40..101cc43 100644 --- a/tests/utils/test_functions.py +++ b/tests/utils/test_functions.py @@ -242,9 +242,10 @@ def test_import_vendor_module(self): def test_get_vendors(self): lActual = utils.get_vendors() - self.assertEqual(3, len(lActual)) + self.assertEqual(4, len(lActual)) self.assertTrue('mentor_graphics' in lActual) self.assertTrue('microsemi' in lActual) + self.assertTrue('synopsys' in lActual) self.assertTrue('xilinx' in lActual) def test_get_tools(self): diff --git a/tests/vendor/synopsys/__init__.py b/tests/vendor/synopsys/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/vendor/synopsys/synplify_pro/__init__.py b/tests/vendor/synopsys/synplify_pro/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/vendor/synopsys/synplify_pro/test_functions.py b/tests/vendor/synopsys/synplify_pro/test_functions.py new file mode 100644 index 0000000..facd23f --- /dev/null +++ b/tests/vendor/synopsys/synplify_pro/test_functions.py @@ -0,0 +1,51 @@ + +import os +import unittest + +from elfws.vendor.synopsys import synplify_pro +from tests import test_utils + +lLogFile = test_utils.read_file(os.path.join(os.path.dirname(__file__), 'warning_messages.log')) + +class testFunctions(unittest.TestCase): + + def test_extract_warnings(self): + oWarningList = synplify_pro.extract_warnings(lLogFile) + + oWarning = oWarningList.warnings[0] + self.assertEqual('ID1', oWarning.get_id()) + self.assertEqual('"file name" some message', oWarning.get_message()) + self.assertEqual(None, oWarning.get_filename()) + self.assertEqual(7, oWarning.get_linenumber()) + + oWarning = oWarningList.warnings[1] + self.assertEqual('ID1', oWarning.get_id()) + self.assertEqual('"file name" some other message', oWarning.get_message()) + self.assertEqual(None, oWarning.get_filename()) + self.assertEqual(10, oWarning.get_linenumber()) + + oWarning = oWarningList.warnings[2] + self.assertEqual('ID2', oWarning.get_id()) + self.assertEqual('Some message without a file', oWarning.get_message()) + self.assertEqual(None, oWarning.get_filename()) + self.assertEqual(11, oWarning.get_linenumber()) + + def test_is_logfile(self): + lLogFile = [] + lLogFile.append('#Build: Synplify Pro (R)') + lLogFile.append('#OS:') + + self.assertTrue(synplify_pro.is_logfile(lLogFile)) + + lLogFile = [] + lLogFile.append('#OS: ') + lLogFile.append('#install') + + self.assertFalse(synplify_pro.is_logfile(lLogFile)) + + lLogFile = [] + lLogFile.append('#Build: Synplify (R)') + lLogFile.append('#OS:') + + self.assertFalse(synplify_pro.is_logfile(lLogFile)) +