@@ -677,7 +677,9 @@ def _run_android_test(testapp_dir, package_name, app_path, helper_project, retry
677677 logging .info ("Running android helper test: %s, %s, %s" , package_name , app_path , helper_project )
678678 _install_android_app (app_path )
679679 video_name = "video-%s-%s-%s.mp4" % (package_name , retry , FLAGS .logfile_name )
680+ logcat_name = "logcat-%s-%s-%s.txt" % (package_name , retry , FLAGS .logfile_name )
680681 record_process = _record_android_tests (video_name )
682+ _clear_android_logcat ()
681683 _run_instrumented_test ()
682684 _stop_recording (record_process )
683685 log = _get_android_test_log (package_name )
@@ -686,6 +688,7 @@ def _run_android_test(testapp_dir, package_name, app_path, helper_project, retry
686688 result = test_validation .validate_results (log , test_validation .CPP )
687689 if not result .complete or (FLAGS .test_type == "uitest" and result .fails > 0 ):
688690 _save_recorded_android_video (video_name , testapp_dir )
691+ _save_android_logcat (logcat_name , testapp_dir )
689692 if retry > 1 :
690693 logging .info ("Retry _run_android_test. Remaining retry: %s" , retry - 1 )
691694 return _run_android_test (testapp_dir , package_name , app_path , helper_project , retry = retry - 1 )
@@ -734,6 +737,20 @@ def _save_recorded_android_video(video_name, summary_dir):
734737 subprocess .run (args = args , capture_output = True , text = True , check = False )
735738
736739
740+ def _save_android_logcat (logcat_name , summary_dir ):
741+ logcat_file = os .path .join (summary_dir , logcat_name )
742+ args = ["adb" , "logcat" , "-d" ]
743+ logging .info ("Save logcat to %s: %s" , logcat_file , " " .join (args ))
744+ with open (logcat_file , "wb" ) as f :
745+ subprocess .run (args = args , stdout = f , check = False )
746+
747+
748+ def _clear_android_logcat ():
749+ args = ["adb" , "logcat" , "-c" ]
750+ logging .info ("Clear logcat: %s" , " " .join (args ))
751+ subprocess .run (args = args , check = False )
752+
753+
737754def _run_instrumented_test ():
738755 """Run the helper app.
739756 This helper app can run integration_test app automatically.
0 commit comments