From bea84e169718c21a78dfa98a0e5dc6a40a39b4f2 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Sun, 19 Sep 2021 08:09:55 +0800 Subject: [PATCH] [Mellanox] Enhance check_sysfs to ignore expected broken symbol links (#4279) With the Mellanox new hw-managenet package release V.7.0010.3134, some symbol links are expected to be broken after boot up, they should be excluded from the broken symbol link check. Add a function to match these expected broken symbol links and remove them from the check list. --- tests/platform_tests/mellanox/check_sysfs.py | 31 ++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/platform_tests/mellanox/check_sysfs.py b/tests/platform_tests/mellanox/check_sysfs.py index 232bf23d839..c7ced758804 100644 --- a/tests/platform_tests/mellanox/check_sysfs.py +++ b/tests/platform_tests/mellanox/check_sysfs.py @@ -4,12 +4,38 @@ This script contains re-usable functions for checking status of hw-management related sysfs. """ import logging +import re from tests.common.mellanox_data import get_platform_data from tests.common.utilities import wait_until MAX_FAN_SPEED_THRESHOLD = 0.15 +def skip_ignored_broken_symbolinks(broken_symbolinks): + """ + @summary: Check all the broken symbol links found, remove the expected ones + examples for the expected broken symbol links: + /var/run/hw-management/led/led_psu2_green_delay_off + /var/run/hw-management/led/led_uid_blue_delay_on + /var/run/hw-management/led/led_fan_green_delay_on + /var/run/hw-management/led/led_status_red_delay_on + """ + # Currently some led blinking related sysfs are expected to be broken after system boot up, + # so skip and remove them from the check list. + broken_symbolinks_updated = [] + pattern = re.compile(".*led_.*_delay_(off|on)") + + logging.info("broken_symbolinks: {}".format(broken_symbolinks)) + + for symbolink in broken_symbolinks.splitlines(): + if not pattern.match(symbolink): + broken_symbolinks_updated.append(symbolink) + else: + logging.info("ignore expected broken link: {}".format(symbolink)) + + return broken_symbolinks_updated + + def check_sysfs(dut): """ @summary: Check various hw-management related sysfs under /var/run/hw-management @@ -21,8 +47,9 @@ def check_sysfs(dut): logging.info("Check broken symbolinks") broken_symbolinks = sysfs_facts['symbolink_info']['broken_links'] - assert len(broken_symbolinks) == 0, \ - "Found some broken symbolinks: {}".format(str(broken_symbolinks)) + broken_symbolinks_updated = skip_ignored_broken_symbolinks(broken_symbolinks) + assert len(broken_symbolinks_updated) == 0, \ + "Found some broken symbolinks: {}".format(str(broken_symbolinks_updated)) logging.info("Check ASIC related sysfs") try: