class Fan(unittest.TestCase): def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.data_files = shell_command("ls Thermal_data_*.csv")[1] self.thermal = Thermal() def tearDown(self): print "[Teardown]: %s" % self._test_name def check_fan_status(self, temp1, temp2): for data_file in self.data_files: data_file = data_file.strip() lines = read_file_by_line(data_file) lines.next() for line in lines: line_arr = line.split(",") tcpu, tskn, tamb, fan = tuple( [int(item) for item in line_arr[0:4]]) if temp1 <= tamb <= temp2: status = self.thermal.map_fan_percent( tcpu, tskn, tamb, fan) if status: print "tcpu:", tcpu print "tskn:", tskn print "tamb:", tamb print "fan:", fan return True else: return False def test_fan_max_temp_of_two_base_board_thermistors_between_30_to_35_degrees( self): print "[RunTest]: %s" % self.__str__() assert self.check_fan_status(30, 35) def test_fan_max_temp_of_two_base_board_thermistors_between_35_to_40_degrees( self): print "[RunTest]: %s" % self.__str__() assert self.check_fan_status(35, 40) def test_fan_max_temp_of_two_base_board_thermistors_between_40_to_45_degrees( self): print "[RunTest]: %s" % self.__str__() assert self.check_fan_status(40, 45) def test_fan_max_temp_of_two_base_board_thermistors_between_45_to_50_degrees( self): print "[RunTest]: %s" % self.__str__() assert self.check_fan_status(45, 50) def test_fan_max_temp_of_two_base_board_thermistors_more_than_50_degrees( self): print "[RunTest]: %s" % self.__str__() assert self.check_fan_status(50, 60) print "--------------" assert self.check_fan_status(65, 70)
class MonitorFan(unittest.TestCase): def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.thermal = Thermal() self.thermal.adb_root() def tearDown(self): print "[Teardown]: %s" % self._test_name def test_monitor_fan_status_ioc_uart_log(self): print "[RunTest]: %s" % self.__str__() board_temp, ambient_temp, fan_percent = self.thermal.get_fan_status() print "board_temp:", board_temp print "ambient_temp:", ambient_temp print "fan_percent:", fan_percent def check_fan_status(self, retry=10): for _ in range(retry): cpu_temp = self.thermal.ivi_get_cpu_temp() / 1000 board_temp, ambient_temp, fan_real = self.thermal.get_fan_status() print "cpu_temp:", cpu_temp print "board_temp:", board_temp print "ambient_temp:", ambient_temp print "fan_real:", fan_real status = self.thermal.map_fan_percent(cpu_temp, board_temp, ambient_temp, fan_real) if status: return True time.sleep(3) else: return False def test_fan_max_temp_of_two_base_board_thermistors_less_than_30(self): print "[RunTest]: %s" % self.__str__() board_temp, ambient_temp, _ = self.thermal.get_fan_status() temp = max(board_temp, ambient_temp) assert temp < 30 assert self.check_fan_status(2)