From 7de2b01fb950d0bf084d7c2c5cf2308aa4efb418 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Mon, 12 Apr 2021 16:02:52 +0800 Subject: [PATCH 1/2] Remove check for /var/run/hw-management/config/suspend since it is not used in SONiC --- tests/platform_tests/mellanox/check_hw_mgmt_service.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/platform_tests/mellanox/check_hw_mgmt_service.py b/tests/platform_tests/mellanox/check_hw_mgmt_service.py index 9b0af538999..ac936eb421f 100644 --- a/tests/platform_tests/mellanox/check_hw_mgmt_service.py +++ b/tests/platform_tests/mellanox/check_hw_mgmt_service.py @@ -13,10 +13,6 @@ def check_hw_management_service(dut): assert hw_mgmt_service_state["ActiveState"] == "active", "The hw-management service is not active" assert hw_mgmt_service_state["SubState"] == "exited", "The hw-management service is not exited" - logging.info("Check thermal control status") - tc_suspend = dut.command("cat /var/run/hw-management/config/suspend") - assert tc_suspend["stdout"] == "1", "Thermal control is not suspended" - logging.info("Check dmesg") dmesg = dut.command("sudo dmesg") error_keywords = ["crash", "Out of memory", "Call Trace", "Exception", "panic"] From 149565f2e3a243666d118f54f6a141786c25c866 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Mon, 26 Apr 2021 14:15:24 +0800 Subject: [PATCH 2/2] [Mellanox] Fixed issue: failed to recover mock file --- .../mellanox_thermal_control_test_helper.py | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/tests/platform_tests/mellanox/mellanox_thermal_control_test_helper.py b/tests/platform_tests/mellanox/mellanox_thermal_control_test_helper.py index 08375984df4..3b67ede16a4 100644 --- a/tests/platform_tests/mellanox/mellanox_thermal_control_test_helper.py +++ b/tests/platform_tests/mellanox/mellanox_thermal_control_test_helper.py @@ -193,13 +193,14 @@ def mock_value(self, file_path, value): :param value: Value to write to sys fs file. :return: """ - out = self.dut.stat(path=file_path) - if not out['stat']['exists']: - raise SysfsNotExistError('{} not exist'.format(file_path)) - if out['stat']['islnk']: - self._unlink(file_path) - else: - self._cache_file_value(file_path) + if file_path not in self.regular_file_list and file_path not in self.unlink_file_list: + out = self.dut.stat(path=file_path) + if not out['stat']['exists']: + raise SysfsNotExistError('{} not exist'.format(file_path)) + if out['stat']['islnk']: + self._unlink(file_path) + else: + self._cache_file_value(file_path) self.dut.shell('echo \'{}\' > {}'.format(value, file_path)) def read_thermal_value(self, file_path): @@ -242,13 +243,12 @@ def _cache_file_value(self, file_path): :param file_path: Regular file path. :return: """ - if file_path not in self.regular_file_list: - try: - output = self.dut.command("cat %s" % file_path) - value = output["stdout"] - self.regular_file_list[file_path] = value.strip() - except Exception as e: - assert 0, "Get content from %s failed, exception: %s" % (file_path, repr(e)) + try: + output = self.dut.command("cat %s" % file_path) + value = output["stdout"] + self.regular_file_list[file_path] = value.strip() + except Exception as e: + assert 0, "Get content from %s failed, exception: %s" % (file_path, repr(e)) def _unlink(self, file_path): """ @@ -256,12 +256,11 @@ def _unlink(self, file_path): :param file_path: Sys fs file path. :return: """ - if file_path not in self.unlink_file_list: - readlink_output = self.dut.command('readlink {}'.format(file_path)) - self.unlink_file_list[file_path] = readlink_output["stdout"] - self.dut.command('unlink {}'.format(file_path)) - self.dut.command('touch {}'.format(file_path)) - self.dut.command('chown admin {}'.format(file_path)) + readlink_output = self.dut.command('readlink {}'.format(file_path)) + self.unlink_file_list[file_path] = readlink_output["stdout"] + self.dut.command('unlink {}'.format(file_path)) + self.dut.command('touch {}'.format(file_path)) + self.dut.command('chown admin {}'.format(file_path)) def deinit(self): """