def test_tracing(self): TRACE_BUFFER_SIZE = '16384' TRACE_TIME = '5' devices = device_utils.DeviceUtils.HealthyDevices() package_info = util.get_supported_browsers()['stable'] device = devices[0] with tempfile_ext.TemporaryFileName() as output_file_name: # Launch the browser before tracing. device.StartActivity( intent.Intent(activity=package_info.activity, package=package_info.package, data='about:blank', extras={'create_new_tab': True}), blocking=True, force_stop=True) # Run atrace agent. run_systrace.main_impl(['./run_systrace.py', '-b', TRACE_BUFFER_SIZE, '-t', TRACE_TIME, '-o', output_file_name, '-e', str(device), '--atrace-categories=gfx,input,view']) # Verify results. with open(output_file_name, 'r') as f: full_trace = f.read() self.assertTrue('CPU#' in full_trace)
def test_tracing(self): TRACE_BUFFER_SIZE = '16384' TRACE_TIME = '5' devices = device_utils.DeviceUtils.HealthyDevices() package_info = util.get_supported_browsers()['stable'] presentation.device = devices[0] output_file_name = util.generate_random_filename_for_test() try: # Launch the browser before tracing. presentation.device.StartActivity(intent.Intent( activity=package_info.activity, package=package_info.package, data='about:blank', extras={'create_new_tab': True}), blocking=True, force_stop=True) # Run atrace agent. run_systrace.main_impl([ './run_systrace.py', '-b', TRACE_BUFFER_SIZE, '-t', TRACE_TIME, '-o', output_file_name, '-e', str(presentation.device), '--atrace-categories=gfx,input,view' ]) # Verify results. with open(output_file_name, 'r') as f: full_trace = f.read() self.assertTrue('CPU#' in full_trace) except: raise finally: if os.path.exists(output_file_name): os.remove(output_file_name)
def test_missing_file(self): try: run_systrace.main_impl( ['./run_systrace.py', '--from-file', NON_EXISTENT_DATA]) self.fail('should not get here') except IOError: pass
def test_from_file(self): update_systrace_trace_viewer.update(force_update=True) self.assertTrue( os.path.exists( update_systrace_trace_viewer.SYSTRACE_TRACE_VIEWER_HTML_FILE)) output_file_name = util.generate_random_filename_for_test() try: # use from-file to create a specific expected output run_systrace.main_impl([ './run_systrace.py', '--from-file', COMPRESSED_ATRACE_DATA, '-o', output_file_name ]) # and verify file contents with contextlib.nested(open(output_file_name, 'r'), open(DECOMPRESSED_ATRACE_DATA, 'r')) as (f1, f2): full_trace = f1.read() expected_contents = f2.read() self.assertTrue(expected_contents in full_trace) except: raise finally: os.remove( update_systrace_trace_viewer.SYSTRACE_TRACE_VIEWER_HTML_FILE) if os.path.exists(output_file_name): os.remove(output_file_name)
def test_tracing(self): TRACE_BUFFER_SIZE = '16384' TRACE_TIME = '5' devices = device_utils.DeviceUtils.HealthyDevices() package_info = util.get_supported_browsers()['stable'] device = devices[0] with tempfile_ext.TemporaryFileName() as output_file_name: # Launch the browser before tracing. device.StartActivity(intent.Intent(activity=package_info.activity, package=package_info.package, data='about:blank', extras={'create_new_tab': True}), blocking=True, force_stop=True) # Run atrace agent. run_systrace.main_impl([ './run_systrace.py', '-b', TRACE_BUFFER_SIZE, '-t', TRACE_TIME, '-o', output_file_name, '-e', str(device), '--atrace-categories=gfx,input,view' ]) # Verify results. with open(output_file_name, 'r') as f: full_trace = f.read() self.assertTrue('CPU#' in full_trace)
def test_missing_file(self): try: run_systrace.main_impl(['./run_systrace.py', '--from-file', NON_EXISTENT_DATA]) self.fail('should not get here') except IOError: pass
def test_from_file(self): update_systrace_trace_viewer.update(force_update=True) self.assertTrue(os.path.exists( update_systrace_trace_viewer.SYSTRACE_TRACE_VIEWER_HTML_FILE)) try: with tempfile_ext.TemporaryFileName() as output_file_name: # use from-file to create a specific expected output run_systrace.main_impl(['./run_systrace.py', '--from-file', COMPRESSED_ATRACE_DATA, '-o', output_file_name]) # and verify file contents with contextlib.nested(open(output_file_name, 'r'), open(DECOMPRESSED_ATRACE_DATA, 'r')) as (f1, f2): full_trace = f1.read() expected_contents = f2.read() self.assertTrue(expected_contents in full_trace) finally: os.remove(update_systrace_trace_viewer.SYSTRACE_TRACE_VIEWER_HTML_FILE)
def test_from_file(self): output_file_name = util.generate_random_filename_for_test() try: # use from-file to create a specific expected output run_systrace.main_impl(['./run_systrace.py', '--from-file', COMPRESSED_ATRACE_DATA, '-o', output_file_name]) # and verify file contents with contextlib.nested(open(output_file_name, 'r'), open(DECOMPRESSED_ATRACE_DATA, 'r')) as (f1, f2): full_trace = f1.read() expected_contents = f2.read() self.assertTrue(expected_contents in full_trace) except: raise finally: if os.path.exists(output_file_name): os.remove(output_file_name)
def test_default_output_filename(self): update_systrace_trace_viewer.update(force_update=True) self.assertTrue(os.path.exists( update_systrace_trace_viewer.SYSTRACE_TRACE_VIEWER_HTML_FILE)) output_file_name = os.path.join(TEST_DIR, 'compressed_atrace_data.html') try: # use from-file to create a specific expected output run_systrace.main_impl(['./run_systrace.py', '--from-file', COMPRESSED_ATRACE_DATA]) # and verify file contents with contextlib.nested(open(output_file_name, 'r'), open(DECOMPRESSED_ATRACE_DATA, 'r')) as (f1, f2): full_trace = f1.read() expected_contents = f2.read() self.assertTrue(expected_contents in full_trace) except: raise finally: os.remove(update_systrace_trace_viewer.SYSTRACE_TRACE_VIEWER_HTML_FILE) if os.path.exists(output_file_name): os.remove(output_file_name)