Fix dynamic minimum fan table issue caused by python3 (#6690)

**- 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
This commit is contained in:
Junchao-Mellanox 2021-02-07 17:21:44 +08:00 committed by GitHub
parent 834347b8f7
commit 6d4c20efb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -85,7 +85,7 @@ class MinCoolingLevelChangeCondition(ThermalPolicyConditionBase):
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:

View File

@ -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
@ -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