diff --git a/screenshot32/resource/app_capture_screen_test_config.json b/screenshot32/resource/app_capture_screen_test_config.json index 6fa7ee50e381bb920f52f46e15b4526625df738a..a52d9c51c93381270c9605dc1ab13948885ab4d5 100644 --- a/screenshot32/resource/app_capture_screen_test_config.json +++ b/screenshot32/resource/app_capture_screen_test_config.json @@ -53,11 +53,14 @@ "entry": "", "start_screenshot": ["aa start -a com.ohos.screenshot.ServiceExtAbility -b com.ohos.screenshot"], "start_photos": ["aa start -a com.ohos.photos.MainAbility -b com.ohos.photos"], + "start_photo_log":["rm /data/log/hilog/* && hilog -r && hilog -w start -l 400000000 -m none"], + "compress_log":["cd /data/log/hilog && tar -cf photo_log.tar *"], "cp_db": ["cp /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/rdb/media_library.db /data/photo.db"], "kill_photos": ["killall com.ohos.photos"], "all_actions": [ - [8, "start_screenshot"], [8, "start_screenshot"], [5, "start_photos"], [2, "album_click-x-y"], [2, "last_photos-x-y"], [2, "last_photos-x-y"], [2, "shot_cmd"], [1, "cmp_cmd-level"], - [1, "cp_db"], [1, "get_file_from_dev", "/data/photo.db"], [2, "photo_check"], [1, "process_check", "com.ohos.medialibrary.medialibrarydata"], [1, "kill_photos"] + [1, "start_photo_log"], [8, "start_screenshot"], [8, "start_screenshot"], [5, "start_photos"], [2, "album_click-x-y"], [2, "last_photos-x-y"], [2, "last_photos-x-y"], [2, "shot_cmd"], + [1, "cmp_cmd-level"], [1, "cp_db"], [1, "get_file_from_dev", "/data/photo.db"], [2, "photo_check"], [1, "process_check", "com.ohos.medialibrary.medialibrarydata"], [5, "check_sandbox_path"], + [1, "stop_hilog"], [1, "compress_log"], [1, "get_file_from_dev", "/data/log/hilog/photo_log.tar"], [1, "kill_photos"] ] }, { diff --git a/screenshot32/resource/capturescreentest.py b/screenshot32/resource/capturescreentest.py index 0472db57be9eeccf528f1efb5e4e35c6af0f50a4..e38f7a189c5b1fb67d3c0ee56d4e58a78d518679 100644 --- a/screenshot32/resource/capturescreentest.py +++ b/screenshot32/resource/capturescreentest.py @@ -138,7 +138,7 @@ def ImageCheck(str, testnum=1): def ConnectionJudgment(): connection_status = EnterCmd("hdc_std list targets", 2) connection_cnt = 0 - while "7001005458323933328a" not in connection_status and connection_cnt < 15: + while args.device_num not in connection_status and connection_cnt < 15: connection_status = EnterCmd("hdc_std list targets", 2) connection_cnt += 1 if connection_cnt == 15: @@ -146,6 +146,25 @@ def ConnectionJudgment(): PrintToLog("SmokeTest:: End of check, test failed!") sys.exit(101) +def check_sandbox_path(): + PrintToLog("SmokeTest:: start to check sandbox path") + medialibrarydata_pidnum = EnterShellCmd("pgrep -f com.ohos.medialibrary.medialibrarydata", 1) + medialibrarydata_pidnum = medialibrarydata_pidnum.strip() + sandboxf = EnterShellCmd("echo \"ls /storage/media/local/\"|nsenter -t {} -m sh".format(medialibrarydata_pidnum), 1) + if "files" not in sandboxf: + PrintToLog("SmokeTest:: error: can not find sandbox path : /storage/media/local/files") + return -1 + else: + PrintToLog("SmokeTest:: success: find sandbox path : /storage/media/local/files") + return 1 + +def crash_pack(): + EnterShellCmd("cd /data/log/faultlog/temp && tar -cf after_test_crash_log_{}.tar cppcrash*".format(args.device_num)) + GetFileFromDev("/data/log/faultlog/temp/after_test_crash_log_{}.tar".format(args.device_num), \ + os.path.normpath(args.save_path)) + EnterShellCmd("cd /data/log/faultlog/temp && find . -name cppcrash*", 2) + EnterShellCmd("cd /data/log/faultlog/temp && grep \"Process name\" -rnw ./", 2) + def ConnectToWifi(tools_path): EnterShellCmd("mkdir /data/l2tool", 1) SendFileToDev(os.path.normpath(os.path.join(tools_path, "l2tool/busybox")), "/data/l2tool/") @@ -314,7 +333,6 @@ if __name__ == "__main__": testcnt = 3 while testcnt: testok = 0 - checkok = 1 if testcnt != 3: PrintToLog("SmokeTest:: this testcase try again >>>>>>:\n") with open(os.path.join(args.save_path, 'test_{}.bat'.format(args.device_num)),\ @@ -388,6 +406,12 @@ if __name__ == "__main__": elif type(single_action[1]) == str and single_action[1] == 'connect_wifi': next_cmd = "" ConnectToWifi(args.tools_path) + elif type(single_action[1]) == str and single_action[1] == 'check_sandbox_path': + next_cmd = "" + if check_sandbox_path() == 1 and testok == 1: + testok == 1 + else: + testok = -1 elif type(single_action[1]) == str and single_action[1] == 'camera_photo_check': next_cmd = "" if ImageCheck("{}\\camera_photo.db".format(os.path.normpath(args.save_path)),\ @@ -408,11 +432,9 @@ if __name__ == "__main__": result = "".join(p) findsome = result.find(single_action[2], 0, len(result)) if findsome != -1: - checkok = 1 PrintToLog("SmokeTest:: \"{}\" is ok, find process \"{}\"!".format(single_action[1],\ single_action[2])) else: - checkok = -1 PrintToLog("SmokeTest:: \"{}\" failed, not find process \"{}\"!".format(single_action[1],\ single_action[2])) sys.stdout.flush() @@ -459,16 +481,9 @@ if __name__ == "__main__": next_cmd = "uinput -M -m {} {} -c 0".format(single_action[1], single_action[2]) EnterShellCmd(next_cmd, single_action[0]) - if testok == 1 and checkok == 1: + if testok == 1: PrintToLog("SmokeTest:: testcase {}, {} is ok!".format(idx, single_app['app_name'])) testcnt = 0 - elif testok == 1 and checkok == -1: - if testcnt == 1: - fail_idx_list.append(idx) - fail_name_list.append(single_app['app_name']) - smoke_first_failed = single_app['app_name'] - PrintToLog("SmokeTest:: error:testcase {}, {} is failed!".format(idx, single_app['app_name'])) - testcnt -= 1 elif testok == -1 and smoke_first_failed == '': if testcnt == 1: fail_idx_list.append(idx) @@ -485,16 +500,6 @@ if __name__ == "__main__": testcnt = 0 ConnectionJudgment() - PrintToLog("SmokeTest:: start to check sandbox path") - medialibrarydata_pidnum = EnterShellCmd("pgrep -f com.ohos.medialibrary.medialibrarydata", 1) - medialibrarydata_pidnum = medialibrarydata_pidnum.strip() - sandboxf = EnterShellCmd("echo \"ls /storage/media/local/\"|nsenter -t {} -m sh".format(medialibrarydata_pidnum), 1) - if "files" not in sandboxf: - PrintToLog("SmokeTest:: error: can not find sandbox path : /storage/media/local/files") - SysExit() - else: - PrintToLog("SmokeTest:: success: find sandbox path : /storage/media/local/files") - PrintToLog("\nSmokeTest:: ########## Second check key processes start ##############") second_check_lose_process = [] for pname in two_check_process_list: @@ -524,17 +529,20 @@ if __name__ == "__main__": pr_analysis = args.pr_url PrintToLog("SmokeTest:: get pr: {}".format(args.pr_url)) - if "openharmony" in pr_analysis: + if args.test_num == "1/2" or args.test_num == "2/2": EnterShellCmd("param set persist.ace.testmode.enabled 1", 1) PrintToLog("SmokeTest:: close selinux") EnterShellCmd("mount -o rw,remount /", 1) EnterShellCmd("sed -i 's/enforcing/permissive/g' /system/etc/selinux/config", 1) EnterShellCmd("cat /system/etc/selinux/config | grep SELINUX=", 1) EnterShellCmd("reboot") - for i in range(6): - EnterCmd("hdc_std list targets", 5) - unlockcnt = 3 + hdc_list = EnterCmd("hdc_std list targets", 3) + waitcnt = 0 + while args.device_num not in hdc_list and waitcnt < 15: + hdc_list = EnterCmd("hdc_std list targets", 3) + waitcnt += 1 PrintToLog("SmokeTest:: start remove lock") + unlockcnt = 3 while unlockcnt: EnterShellCmd("uinput -T -m 425 1000 425 400;power-shell wakeup;\ uinput -T -m 425 400 425 1000;power-shell setmode 602;uinput -T -m 425 1000 425 400;", 1) @@ -550,6 +558,10 @@ if __name__ == "__main__": PrintToLog("SmokeTest:: error: name {}, index {}, these testcase is failed".format(fail_name_list,\ fail_idx_list)) SysExit() + if ping_cnt == 60: + PrintToLog("SmokeTest:: Ping failed, timeout of 5 minutes") + PrintToLog("SmokeTest:: please check the testcase {}".format(fail_name_list)) + SysExit() elif args.test_num == "2/2": EnterShellCmd("ifconfig eth0 192.168.0.2", 1) ping_result = EnterShellCmd("ping 192.168.0.1 -i 1 -c 2", 3) @@ -557,9 +569,14 @@ if __name__ == "__main__": while "2 packets transmitted, 2 received" not in ping_result and ping_cnt < 60: ping_result = EnterShellCmd("ping 192.168.0.1 -i 1 -c 2", 5) ping_cnt += 1 + if ping_cnt == 60: + PrintToLog("SmokeTest:: Ping failed, timeout of 5 minutes") + PrintToLog("SmokeTest:: please check the testcase {}".format(fail_name_list)) + SysExit() PrintToLog("SmokeTest:: ##### case 13 : distributed test start #####") execute_path = os.path.normpath(os.path.join(args.tools_path, "DistributedTest")) PrintToLog("SmokeTest:: execute_path {}".format(execute_path)) + EnterShellCmd("rm /data/log/hilog/*;hilog -r;hilog -w start -l 400000000 -m none", 1) os.system("cd {} && python main.py run -l DistributedTest".format(execute_path)) report_path = os.path.normpath(os.path.join(args.tools_path, "DistributedTest\\reports")) PrintToLog("SmokeTest:: report_path {}".format(report_path)) @@ -599,13 +616,11 @@ if __name__ == "__main__": PrintToLog("SmokeTest:: error: name {}, index {}, these testcase is failed".format(fail_name_list,\ fail_idx_list)) SysExit() + EnterShellCmd("hilog -w stop", 1) + EnterShellCmd("cd /data/log/hilog && tar -cf distributed_log.tar *", 1) + GetFileFromDev("/data/log/hilog/distributed_log.tar", args.save_path) - EnterShellCmd("cd /data/log/faultlog/temp && tar -cf after_test_crash_log_{}.tar cppcrash*".format(args.device_num)) - GetFileFromDev("/data/log/faultlog/temp/after_test_crash_log_{}.tar".format(args.device_num), \ - os.path.normpath(args.save_path)) - EnterShellCmd("cd /data/log/faultlog/temp && find . -name cppcrash*", 2) - EnterShellCmd("cd /data/log/faultlog/temp && grep \"Process name\" -rnw ./", 2) - + crash_pack() fail_str_list = [str(x) for x in fail_idx_list] reboot_test_num = " ".join(fail_str_list) if len(fail_idx_list) != 0: