Skip to content

Commit e118644

Browse files
authored
remove time counting message in functions because function running time could be difficult to predict in unit tests (#241)
1 parent 07e75bc commit e118644

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

sonic_platform_base/sonic_xcvr/api/public/cmis.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ def get_module_fw_upgrade_feature(self, verbose = False):
10551055
txt += 'Reply payload check code error\n'
10561056
return {'status': False, 'info': txt, 'result': None}
10571057
elapsedtime = time.time()-starttime
1058-
txt += 'Get module FW upgrade features time: %.2f s\n' %elapsedtime
1058+
logger.info('Get module FW upgrade features time: %.2f s\n' %elapsedtime)
10591059
logger.info(txt)
10601060
return {'status': True, 'info': txt, 'result': (startLPLsize, maxblocksize, lplonly_flag, autopaging_flag, writelength)}
10611061

@@ -1125,7 +1125,7 @@ def get_module_fw_info(self):
11251125
txt += 'Reply payload check code error\n'
11261126
return {'status': False, 'info': txt, 'result': None}
11271127
elapsedtime = time.time()-starttime
1128-
txt += 'Get module FW info time: %.2f s\n' %elapsedtime
1128+
logger.info('Get module FW info time: %.2f s\n' %elapsedtime)
11291129
logger.info(txt)
11301130
return {'status': True, 'info': txt, 'result': (ImageA, ImageARunning, ImageACommitted, ImageAValid, ImageB, ImageBRunning, ImageBCommitted, ImageBValid)}
11311131

@@ -1168,7 +1168,7 @@ def module_fw_run(self, mode = 0x01):
11681168
txt += 'FW_run_status %d\n' %fw_run_status
11691169
return False, txt
11701170
elapsedtime = time.time()-starttime
1171-
txt += 'Module FW run time: %.2f s\n' %elapsedtime
1171+
logger.info('Module FW run time: %.2f s\n' %elapsedtime)
11721172
logger.info(txt)
11731173
return True, txt
11741174

@@ -1203,7 +1203,7 @@ def module_fw_commit(self):
12031203
txt += 'FW_commit_status %d\n' %fw_commit_status
12041204
return False, txt
12051205
elapsedtime = time.time()-starttime
1206-
txt += 'Module FW commit time: %.2f s\n' %elapsedtime
1206+
logger.info('Module FW commit time: %.2f s\n' %elapsedtime)
12071207
logger.info(txt)
12081208
return True, txt
12091209

tests/sonic_xcvr/test_cmis.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -922,13 +922,13 @@ def test_get_module_level_flag(self, mock_response, expected):
922922
False,
923923
[0x77, 0xff],
924924
[18, 35, (0, 7, 112, 255, 255, 16, 0, 0, 19, 136, 0, 100, 3, 232, 19, 136, 58, 152)],
925-
{'status':True, 'info': 'Auto page support: True\nMax write length: 2048\nStart payload size 112\nMax block size 2048\nWrite to EPL supported\nAbort CMD102h supported True\nGet module FW upgrade features time: 0.00 s\n', 'result': (112, 2048, False, True, 2048)}
925+
{'status':True, 'info': 'Auto page support: True\nMax write length: 2048\nStart payload size 112\nMax block size 2048\nWrite to EPL supported\nAbort CMD102h supported True\n', 'result': (112, 2048, False, True, 2048)}
926926
),
927927
(
928928
False,
929929
[0x77, 0xff],
930930
[18, 35, (0, 7, 112, 255, 255, 1, 0, 0, 19, 136, 0, 100, 3, 232, 19, 136, 58, 152)],
931-
{'status':True, 'info': 'Auto page support: True\nMax write length: 2048\nStart payload size 112\nMax block size 2048\nWrite to LPL supported\nAbort CMD102h supported True\nGet module FW upgrade features time: 0.00 s\n', 'result': (112, 2048, True, True, 2048)}
931+
{'status':True, 'info': 'Auto page support: True\nMax write length: 2048\nStart payload size 112\nMax block size 2048\nWrite to LPL supported\nAbort CMD102h supported True\n', 'result': (112, 2048, True, True, 2048)}
932932
),
933933
])
934934
def test_get_module_fw_upgrade_feature(self, input_param, mock_response1, mock_response2, expected):
@@ -945,11 +945,11 @@ def test_get_module_fw_upgrade_feature(self, input_param, mock_response1, mock_r
945945
@pytest.mark.parametrize("mock_response, expected", [
946946
(
947947
[110, 26, (3, 3, 0, 0, 0, 1, 1, 4, 3, 0, 0, 100, 3, 232, 19, 136, 58, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)],
948-
{'status':True, 'info': 'Get module FW info\nImage A Version: 0.0.1\nImage B Version: 0.0.0\nRunning Image: A; Committed Image: A\nGet module FW info time: 0.00 s\n', 'result': ('0.0.1', 1, 1, 0, '0.0.0', 0, 0, 0)}
948+
{'status':True, 'info': 'Get module FW info\nImage A Version: 0.0.1\nImage B Version: 0.0.0\nRunning Image: A; Committed Image: A\n', 'result': ('0.0.1', 1, 1, 0, '0.0.0', 0, 0, 0)}
949949
),
950950
(
951951
[110, 26, (48, 3, 0, 0, 0, 1, 1, 4, 3, 0, 0, 100, 3, 232, 19, 136, 58, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)],
952-
{'status':True, 'info': 'Get module FW info\nImage A Version: 0.0.1\nImage B Version: 0.0.0\nRunning Image: B; Committed Image: B\nGet module FW info time: 0.00 s\n', 'result': ('0.0.1', 0, 0, 0, '0.0.0', 1, 1, 0)}
952+
{'status':True, 'info': 'Get module FW info\nImage A Version: 0.0.1\nImage B Version: 0.0.0\nRunning Image: B; Committed Image: B\n', 'result': ('0.0.1', 0, 0, 0, '0.0.0', 1, 1, 0)}
953953
),
954954
])
955955
def test_get_module_fw_info(self, mock_response, expected):
@@ -962,7 +962,7 @@ def test_get_module_fw_info(self, mock_response, expected):
962962
assert result == expected
963963

964964
@pytest.mark.parametrize("input_param, mock_response, expected", [
965-
(1, 1, (True, 'Module FW run: Success\nModule FW run time: 0.00 s\n')),
965+
(1, 1, (True, 'Module FW run: Success\n')),
966966
(1, 64, (False, 'Module FW run: Fail\nFW_run_status 64\n')),
967967
])
968968
def test_module_fw_run(self, input_param, mock_response, expected):
@@ -973,7 +973,7 @@ def test_module_fw_run(self, input_param, mock_response, expected):
973973
assert result == expected
974974

975975
@pytest.mark.parametrize("mock_response, expected", [
976-
(1, (True, 'Module FW commit: Success\nModule FW commit time: 0.00 s\n')),
976+
(1, (True, 'Module FW commit: Success\n')),
977977
(64, (False, 'Module FW commit: Fail\nFW_commit_status 64\n')),
978978
])
979979
def test_module_fw_commit(self, mock_response, expected):

0 commit comments

Comments
 (0)