@@ -677,7 +677,9 @@ def _run_android_test(testapp_dir, package_name, app_path, helper_project, retry
677
677
logging .info ("Running android helper test: %s, %s, %s" , package_name , app_path , helper_project )
678
678
_install_android_app (app_path )
679
679
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 )
680
681
record_process = _record_android_tests (video_name )
682
+ _clear_android_logcat ()
681
683
_run_instrumented_test ()
682
684
_stop_recording (record_process )
683
685
log = _get_android_test_log (package_name )
@@ -686,6 +688,7 @@ def _run_android_test(testapp_dir, package_name, app_path, helper_project, retry
686
688
result = test_validation .validate_results (log , test_validation .CPP )
687
689
if not result .complete or (FLAGS .test_type == "uitest" and result .fails > 0 ):
688
690
_save_recorded_android_video (video_name , testapp_dir )
691
+ _save_android_logcat (logcat_name , testapp_dir )
689
692
if retry > 1 :
690
693
logging .info ("Retry _run_android_test. Remaining retry: %s" , retry - 1 )
691
694
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):
734
737
subprocess .run (args = args , capture_output = True , text = True , check = False )
735
738
736
739
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
+
737
754
def _run_instrumented_test ():
738
755
"""Run the helper app.
739
756
This helper app can run integration_test app automatically.
0 commit comments