@@ -38,6 +38,7 @@ class TestThermal:
38
38
@mock .patch ('os.path.exists' , mock .MagicMock (return_value = True ))
39
39
@mock .patch ('sonic_platform.device_data.DeviceDataManager.get_gearbox_count' , mock .MagicMock (return_value = 2 ))
40
40
@mock .patch ('sonic_platform.device_data.DeviceDataManager.get_cpu_thermal_count' , mock .MagicMock (return_value = 2 ))
41
+ @mock .patch ('sonic_platform.device_data.DeviceDataManager.get_sodimm_thermal_count' , mock .MagicMock (return_value = 2 ))
41
42
@mock .patch ('sonic_platform.device_data.DeviceDataManager.get_platform_name' , mock .MagicMock (return_value = 'x86_64-mlnx_msn2700-r0' ))
42
43
def test_chassis_thermal (self ):
43
44
from sonic_platform .thermal import THERMAL_NAMING_RULE
@@ -48,6 +49,7 @@ def test_chassis_thermal(self):
48
49
thermal_dict = {thermal .get_name (): thermal for thermal in thermal_list }
49
50
gearbox_thermal_rule = None
50
51
cpu_thermal_rule = None
52
+ sodimm_thermal_rule = None
51
53
for rule in THERMAL_NAMING_RULE ['chassis thermals' ]:
52
54
thermal_type = rule .get ('type' , 'single' )
53
55
if thermal_type == 'single' :
@@ -69,9 +71,12 @@ def test_chassis_thermal(self):
69
71
gearbox_thermal_rule = rule
70
72
elif 'CPU Core' in rule ['name' ]:
71
73
cpu_thermal_rule = rule
74
+ elif 'SODIMM' in rule ['name' ]:
75
+ sodimm_thermal_rule = rule
72
76
73
77
gearbox_thermal_count = 0
74
78
cpu_thermal_count = 0
79
+ sodimm_thermal_count = 0
75
80
for thermal in thermal_list :
76
81
if 'Gearbox' in thermal .get_name ():
77
82
start_index = gearbox_thermal_rule .get ('start_index' , 1 )
@@ -89,21 +94,32 @@ def test_chassis_thermal(self):
89
94
assert cpu_thermal_rule ['high_threshold' ].format (start_index ) in thermal .high_threshold
90
95
assert cpu_thermal_rule ['high_critical_threshold' ].format (start_index ) in thermal .high_critical_threshold
91
96
cpu_thermal_count += 1
97
+ elif 'SODIMM' in thermal .get_name ():
98
+ start_index = sodimm_thermal_rule .get ('start_index' , 1 )
99
+ start_index += sodimm_thermal_count
100
+ assert thermal .get_name () == sodimm_thermal_rule ['name' ].format (start_index )
101
+ assert sodimm_thermal_rule ['temperature' ].format (start_index ) in thermal .temperature
102
+ assert sodimm_thermal_rule ['high_threshold' ].format (start_index ) in thermal .high_threshold
103
+ assert sodimm_thermal_rule ['high_critical_threshold' ].format (start_index ) in thermal .high_critical_threshold
104
+ sodimm_thermal_count += 1
92
105
93
106
assert gearbox_thermal_count == 2
94
107
assert cpu_thermal_count == 2
108
+ assert sodimm_thermal_count == 2
95
109
96
110
@mock .patch ('sonic_platform.device_data.DeviceDataManager.get_platform_name' , mock .MagicMock (return_value = 'x86_64-nvidia_sn2201-r0' ))
97
- @mock .patch ('sonic_platform.device_data.DeviceDataManager.get_thermal_capability' , mock . MagicMock ( return_value = { 'comex_amb' : False , 'cpu_amb' : True , 'swb_amb' : True }) )
98
- def test_chassis_thermal_includes (self ):
111
+ @mock .patch ('sonic_platform.device_data.DeviceDataManager.get_thermal_capability' )
112
+ def test_chassis_thermal_includes (self , mock_capability ):
99
113
from sonic_platform .thermal import THERMAL_NAMING_RULE
114
+ thermal_capability = {'comex_amb' : False , 'cpu_amb' : True , 'swb_amb' : True }
115
+ mock_capability .return_value = thermal_capability
100
116
chassis = Chassis ()
101
117
thermal_list = chassis .get_all_thermals ()
102
118
assert thermal_list
103
119
thermal_dict = {thermal .get_name (): thermal for thermal in thermal_list }
104
120
for rule in THERMAL_NAMING_RULE ['chassis thermals' ]:
105
121
default_present = rule .get ('default_present' , True )
106
- if not default_present :
122
+ if not default_present and thermal_capability . get ( rule [ 'temperature' ]) :
107
123
thermal_name = rule ['name' ]
108
124
assert thermal_name in thermal_dict
109
125
0 commit comments