-
Notifications
You must be signed in to change notification settings - Fork 209
[202012] Refactor Pcied and add unittest #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [pytest] | ||
| addopts = --cov=scripts --cov-report html --cov-report term --cov-report xml --junitxml=test-results.xml -vv |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,31 +5,62 @@ | |||||
| PCIe device monitoring daemon for SONiC | ||||||
| """ | ||||||
|
|
||||||
| try: | ||||||
| import os | ||||||
| import signal | ||||||
| import sys | ||||||
| import threading | ||||||
|
|
||||||
| import swsssdk | ||||||
| from sonic_py_common import daemon_base, device_info | ||||||
| from swsscommon import swsscommon | ||||||
| except ImportError as e: | ||||||
| raise ImportError(str(e) + " - required module not found") | ||||||
| import os | ||||||
| import signal | ||||||
| import sys | ||||||
| import threading | ||||||
|
|
||||||
| from sonic_py_common import daemon_base, device_info | ||||||
| from swsscommon import swsscommon | ||||||
|
|
||||||
| # | ||||||
| # Constants ==================================================================== | ||||||
| # | ||||||
|
|
||||||
| # TODO: Once we no longer support Python 2, we can eliminate this and get the | ||||||
| # name using the 'name' field (e.g., `signal.SIGINT.name`) starting with Python 3.5 | ||||||
| SIGNALS_TO_NAMES_DICT = dict((getattr(signal, n), n) | ||||||
| for n in dir(signal) if n.startswith('SIG') and '_' not in n) | ||||||
|
|
||||||
| SYSLOG_IDENTIFIER = "pcied" | ||||||
|
|
||||||
| PCIE_RESULT_REGEX = "PCIe Device Checking All Test" | ||||||
| PCIE_TABLE_NAME = "PCIE_STATUS" | ||||||
| PCIE_DEVICE_TABLE_NAME = "PCIE_DEVICE" | ||||||
|
|
||||||
| PCIE_CONF_FILE = 'pcie.yaml' | ||||||
| PCIE_STATUS_TABLE_NAME = "PCIE_DEVICES" | ||||||
|
|
||||||
| PCIED_MAIN_THREAD_SLEEP_SECS = 60 | ||||||
| REDIS_HOSTIP = "127.0.0.1" | ||||||
|
|
||||||
| PCIEUTIL_CONF_FILE_ERROR = 1 | ||||||
| PCIEUTIL_LOAD_ERROR = 2 | ||||||
|
|
||||||
| platform_pcieutil = None | ||||||
|
|
||||||
| exit_code = 0 | ||||||
|
|
||||||
| # wrapper functions to call the platform api | ||||||
| def load_platform_pcieutil(): | ||||||
| _platform_pcieutil = None | ||||||
| (platform_path, _) = device_info.get_paths_to_platform_and_hwsku_dirs() | ||||||
| try: | ||||||
| from sonic_platform.pcie import Pcie | ||||||
| _platform_pcieutil = Pcie(platform_path) | ||||||
| except ImportError as e: | ||||||
| self.log_error("Failed to load platform Pcie module. Error : {}".format(str(e)), True) | ||||||
|
||||||
| self.log_error("Failed to load platform Pcie module. Error : {}".format(str(e)), True) | |
| log.log_notice("Failed to load platform Pcie module. Error : {}, Fallback to default module".format(str(e)), True) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| self.log_error("Failed to load default PcieUtil module. Error : {}".format(str(e)), True) | |
| log.log_error("Failed to load default PcieUtil module. Error : {}".format(str(e)), True) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [aliases] | ||
| test=pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is needed for the fixes on line 48 & 53 to run