class CheckPowerLimit(UIATestBase): def setUp(self): self._test_name = __name__ self.s0i3 = S0i3() self.s0i3.adb_root() self.s0i3.set_screen_status("on") self.s0i3.unlock_screen() print "[Setup]: %s" % self._test_name self.thermal = Thermal() def tearDown(self): print "[Teardown]: %s" % self._test_name def test_check_power_limit_for_S3(self): """ test check Power limit """ print "[RunTest]: %s" % self.__str__() power_p = self.thermal.ivi_get_power() power_pre = power_p / float(10 ** 6) enter_s3 = self.s0i3.suspend_resume(retry=2) assert enter_s3, "Not enter to S3" power_a = self.thermal.ivi_get_power() power_post = power_a / float(10 ** 6) if power_pre == power_post: print "[Info]--- check Power limit: pre:{}, post:{}".format(power_pre,power_post) else: assert False, "[Info]--- check Power limit: pre:{}, post:{}".format(power_pre,power_post)
def setUp(self): self._test_name = __name__ self.s0i3 = S0i3() self.s0i3.adb_root() self.s0i3.set_screen_status("on") self.s0i3.unlock_screen() print "[Setup]: %s" % self._test_name self.thermal = Thermal()
def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.thermal_file_remote = "/mnt/sdcard/thermal.txt" self.thermal_file_host = "" self.wait_time = 600 self.score_list = [] self.thermal = Thermal() self.thermal.adb_root() self.thermal.unlock_screen() g_common_obj.close_background_apps() super(IVI_DPTF, self).setUp()
class CollectData(unittest.TestCase): def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.thermal = Thermal() self.power = get_power_obj() #self.csv_path = gen_tmp_file_path_by_time("temps.csv") self.csv_name = ("Thermal_data_%s.csv" % time.strftime("%y-%m-%d-%H-%M-%S")) self.csv_file = open(self.csv_name, "wb") self.csv_writer = csv.writer(self.csv_file) #self.reboot_temps = [0, 20, 30, 40, 55, 75] self.reboot_temps = [0, 10, 20, 30, 40, 50, 55, 70, 75, 80] self.thermal.adb_root() self.csv_writer.writerow( ["tcpu", "tskn", "tamb", "fan", "power", "reboot"]) def tearDown(self): print "[Teardown]: %s" % self._test_name self.csv_file.close() def test_collect_data(self): print "[RunTest]: %s" % self.__str__() for temp in self.reboot_temps: print "[Info]------------------- %s" % temp while True: tskn, tamb, fan = self.thermal.get_fan_status() tcpu = self.thermal.ivi_get_cpu_temp() / 1000 power = self.thermal.ivi_get_power() power = power / float(10**6) line = [tcpu, tskn, tamb, fan, power, "No"] if abs(temp - tamb) < 3: if temp in (20, 30): self.power.adb_reboot() self.thermal.adb_root() line[-1] = "Yes" print "tcpu: %s, tskn: %s, tamb: %s, fan: %s, power: %.2f, boot: %s" % tuple( line) self.csv_writer.writerow(line) time.sleep(10) if temp in (0, 20, 40, 55, 75): self.power.power_off_on_os_by_ignition() time.sleep(10) self.thermal.adb_root() line[-1] = "boot_up_completed" print "tcpu: %s, tskn: %s, tamb: %s, fan: %s, power: %.2f, boot: %s" % tuple( line) self.csv_writer.writerow(line) break else: print "tcpu: %s, tskn: %s, tamb: %s, fan: %s, power: %.2f, boot: %s" % tuple( line) self.csv_writer.writerow(line) #time.sleep(30) self.csv_file.flush()
class Temp_Sensor_Board_Temp(UIATestBase): 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_temperature_sensor_board_temp(self): print "[RunTest]: %s" % self.__str__() temp = self.thermal.ivi_get_board_temp() print "[info]--- Current CPU temp:", temp
class Monitor_CPU_Temp(UIATestBase): 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_current_cpu_temp_sysfs(self): print "[RunTest]: %s" % self.__str__() cpu_temp = self.thermal.ivi_get_cpu_temp() print "[info]--- Current CPU temp:", cpu_temp
def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.thermal = Thermal() self.power = get_power_obj() #self.csv_path = gen_tmp_file_path_by_time("temps.csv") self.csv_name = ("Thermal_data_%s.csv" % time.strftime("%y-%m-%d-%H-%M-%S")) self.csv_file = open(self.csv_name, "wb") self.csv_writer = csv.writer(self.csv_file) #self.reboot_temps = [0, 20, 30, 40, 55, 75] self.reboot_temps = [0, 10, 20, 30, 40, 50, 55, 70, 75, 80] self.thermal.adb_root() self.csv_writer.writerow( ["tcpu", "tskn", "tamb", "fan", "power", "reboot"])
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 CheckDPTF(UIATestBase): def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.thermal = Thermal() def tearDown(self): print "[Teardown]: %s" % self._test_name def test_check_DPTF(self): """ test check DPTF """ print "[RunTest]: %s" % self.__str__() pid = self.thermal.get_process_pid("esif_ufd") assert pid, "No esif_ufd process"
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)
def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.thermal = Thermal() self.thermal.adb_root()
class IVI_DPTF(UIATestBase): def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.thermal_file_remote = "/mnt/sdcard/thermal.txt" self.thermal_file_host = "" self.wait_time = 600 self.score_list = [] self.thermal = Thermal() self.thermal.adb_root() self.thermal.unlock_screen() g_common_obj.close_background_apps() super(IVI_DPTF, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name self.thermal.ivi_end_capture_thermal_data() g_common_obj.close_background_apps() super(IVI_DPTF, self).tearDown() def check_glbenchmark_result(self): score = self.glb.get_score() if score or not self.glb.check_running(): if score: self.score_list.append(score) self.glb.clear_data() self.glb.launch() self.glb.select_offscreen_etc1_test() self.glb.run_tests() def keep_running_glbenchmark(self, timeout): stop_time = time.time() + timeout cycle = 1 while time.time() < stop_time: print "Cycle:", cycle self.check_glbenchmark_result() time.sleep(20) cycle += 1 def check_antutu_result(self): score = self.antutu.get_score() if score or not self.antutu.check_running(): if score: self.score_list.append(score) self.antutu.run_test() def keep_running_antutu(self, timeout): stop_time = time.time() + timeout cycle = 1 while time.time() < stop_time: print "Cycle:", cycle self.check_antutu_result() time.sleep(20) cycle += 1 def verify_thermal_in_scenarial(self, scenarial): self.thermal_file_host = gen_tmp_file_path_by_time(scenarial + ".txt") self.thermal_data_result = gen_tmp_file_path_by_time(scenarial + ".xls") self.thermal.ivi_start_capture_thermal_data(self.thermal_file_remote) if scenarial == "Antutu": self.keep_running_antutu(self.wait_time) elif scenarial == "GLBenchmark": self.keep_running_glbenchmark(self.wait_time) else: time.sleep(self.wait_time) self.thermal.ivi_end_capture_thermal_data() g_common_obj.pull_file(self.thermal_file_host, self.thermal_file_remote) self.thermal.ivi_gen_temp_result(self.thermal_data_result, self.thermal_file_host, self.score_list) def ivi_capture_thermal_data(self): cpu_temp = self.thermal.ivi_get_cpu_temp() cpu_freq = self.thermal.ivi_get_cpu_freq() power = self.thermal.ivi_get_power() gpu_freq = self.thermal.get_gpu_freq() if self.thermal.get_product() == BXT_O: return "%s %s %s %s\n" % (cpu_temp, cpu_freq, power, gpu_freq) board_temp = self.thermal.ivi_get_board_temp() return "%s %s %s %s %s\n" % (cpu_temp, board_temp, cpu_freq, power, gpu_freq) def test_ivi_thermal_glbenchmark(self): print "[RunTest]: %s" % self.__str__() from testlib.em.apps import GLBenchmark self.glb = GLBenchmark() self.glb.install() self.ivi_capture_thermal_data() self.verify_thermal_in_scenarial("GLBenchmark") def test_ivi_thermal_antutu(self): print "[RunTest]: %s" % self.__str__() from testlib.em.apps import Antutu4 self.antutu = Antutu4() self.antutu.install() self.antutu.reject_network_access() self.ivi_capture_thermal_data() self.verify_thermal_in_scenarial("Antutu") def test_ivi_thermal_play_video(self): print "[RunTest]: %s" % self.__str__() from testlib.em.apps import VideoPlayer self.player = VideoPlayer() self.player.install() video_file = self.player.push_artifactory_resource( "video", "/mnt/sdcard/Movies") self.ivi_capture_thermal_data() self.player.play_local_video(video_file) self.verify_thermal_in_scenarial("Video_playback") def test_ivi_thermal_video_recording(self): print "[RunTest]: %s" % self.__str__() from testlib.em.apps import Camera self.camera = Camera() self.camera.grant_permissions() self.ivi_capture_thermal_data() self.camera.launch("Video") self.camera.click_shutter_button("Video") self.verify_thermal_in_scenarial("Video_recording") def test_ivi_thermal_video_streaming(self): print "[RunTest]: %s" % self.__str__() from testlib.em.apps import VideoPlayer from testlib.em.settings import WifiSetting WifiSetting().connect_wifi_by_conf("wifi_adb") self.player = VideoPlayer() self.ivi_capture_thermal_data() video_url = "http://" + get_server_ip() + get_config_value( "webpage", "video_streaming") self.player.play_http_video(video_url) self.verify_thermal_in_scenarial("Video_streaming") def test_ivi_thermal_gps_audio_playback(self): print "[RunTest]: %s" % self.__str__() from testlib.em.apps import Maps, CleanMusic audio_file = self.thermal.push_artifactory_resource( "long_music", "/mnt/sdcard/Music") Maps().launch() music = CleanMusic() music.install() self.ivi_capture_thermal_data() music.play_audio("file://" + audio_file) self.verify_thermal_in_scenarial("Maps") def test_ivi_thermal_adb_reboot(self): print "[RunTest]: %s" % self.__str__() from testlib.em.power import get_power_obj power = get_power_obj() self.thermal_file_host = gen_tmp_file_path_by_time("adb_reboot.txt") self.thermal_data_result = gen_tmp_file_path_by_time("adb_reboot.xls") write_to_file("cpu_temp board_temp cpu_freq power gpu_freq\n", self.thermal_file_host, "w") data_list = self.ivi_capture_thermal_data() write_to_file(data_list, self.thermal_file_host, "a") times = 10 for i in range(1, 1 + times): print "Cycle: %d/%d" % (i, times) power.adb_reboot() self.thermal.adb_root() data_list = self.ivi_capture_thermal_data() write_to_file(data_list, self.thermal_file_host, "a") self.thermal.ivi_gen_temp_result(self.thermal_data_result, self.thermal_file_host, self.score_list)
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()