Skip to content

Commit

Permalink
Fix dynamic minimum fan table issue caused by python3 (#6690)
Browse files Browse the repository at this point in the history
**- Why I did it**
After migrating to python3, the operator '/' always get a float result, but it gets integer result in python2. Need fix this in thermal_conditions.

**- How I did it**
1. cast float value to int
2. change the unit test case to cover this situation

**- How to verify it**
Manually test and regression test
  • Loading branch information
Junchao-Mellanox authored Feb 7, 2021
1 parent 834347b commit 6d4c20e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def is_match(self, thermal_info_dict):

trust_state = Thermal.check_module_temperature_trustable()
temperature = Thermal.get_min_amb_temperature()
temperature = temperature / 1000
temperature = int(temperature / 1000)

change_cooling_level = False
if trust_state != MinCoolingLevelChangeCondition.trust_state:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def test_dynamic_minimum_policy(thermal_manager):
condition = policy.conditions[MinCoolingLevelChangeCondition]
action = policy.actions[ChangeMinCoolingLevelAction]
Thermal.check_module_temperature_trustable = MagicMock(return_value='trust')
Thermal.get_min_amb_temperature = MagicMock(return_value=35000)
Thermal.get_min_amb_temperature = MagicMock(return_value=35001)
assert condition.is_match(None)
assert MinCoolingLevelChangeCondition.trust_state == 'trust'
assert MinCoolingLevelChangeCondition.temperature == 35
Expand All @@ -492,7 +492,7 @@ def test_dynamic_minimum_policy(thermal_manager):
assert condition.is_match(None)
assert MinCoolingLevelChangeCondition.trust_state == 'untrust'

Thermal.get_min_amb_temperature = MagicMock(return_value=25000)
Thermal.get_min_amb_temperature = MagicMock(return_value=25999)
assert condition.is_match(None)
assert MinCoolingLevelChangeCondition.temperature == 25

Expand Down

0 comments on commit 6d4c20e

Please sign in to comment.