• Home
  • Raw
  • Download

Lines Matching refs:self

63     def setUp(self):  argument
64 super(TestExampleBase, self).setUp()
66 'ExampleJava' in self.id() or 'ExampleKotlin' in self.id()):
67 self.skipTest('Profiling java code needs wrap.sh on Android O (8.x)')
68 if 'TraceOffCpu' in self.id() and not TestHelper.is_trace_offcpu_supported():
69 self.skipTest('trace-offcpu is not supported on device')
72 if not os.path.isdir(self.testcase_dir):
73 os.makedirs(self.testcase_dir)
74 os.chdir(self.testcase_dir)
75 self.run_app_profiler(compile_java_code=self.use_compiled_java_code)
76 os.chdir(self.test_dir)
78 for name in os.listdir(self.testcase_dir):
79 path = os.path.join(self.testcase_dir, name)
81 shutil.copy(path, self.test_dir)
83 shutil.copytree(path, os.path.join(self.test_dir, name))
85 def run(self, result=None): argument
86 self.__class__.test_result = result
87 super(TestExampleBase, self).run(result)
89 def run_app_profiler(self, record_arg="-g --duration 10", build_binary_cache=True, argument
91 args = ['app_profiler.py', '--app', self.package_name, '-r', record_arg, '-o', 'perf.data']
97 args += ["-a", self.activity_name]
98 args += ["-lib", self.example_path]
99 if not self.adb_root:
101 self.run_cmd(args)
102 self.check_exist(filename="perf.data")
104 self.check_exist(dirname="binary_cache")
106 def check_file_under_dir(self, dirname, filename): argument
107 self.check_exist(dirname=dirname)
112 self.fail("Failed to call check_file_under_dir(dir=%s, file=%s)" % (dirname, filename))
115 self, summary_file: str, check_entries: List[Tuple[str, float, float]]): argument
120 self.check_exist(filename=summary_file)
135 self.check_fulfilled_entries(fulfilled, check_entries)
137 def check_inferno_report_html(self, check_entries, filename="report.html"): argument
138 self.check_exist(filename=filename)
151 self.check_fulfilled_entries(fulfilled, check_entries)
153 def common_test_app_profiler(self): argument
154 self.run_cmd(["app_profiler.py", "-h"])
156 self.run_app_profiler(build_binary_cache=False)
157 self.assertFalse(os.path.isdir("binary_cache"))
159 if not self.adb_root:
161 self.run_cmd(args)
162 self.check_exist(dirname="binary_cache")
164 self.run_app_profiler(build_binary_cache=True)
165 self.run_app_profiler()
166 self.run_app_profiler(start_activity=False)
168 def common_test_report(self): argument
169 self.run_cmd(["report.py", "-h"])
170 self.run_cmd(["report.py"])
171 self.run_cmd(["report.py", "-i", "perf.data"])
172 self.run_cmd(["report.py", "-g"])
173 self.run_cmd(["report.py", "--self-kill-for-testing", "-g", "--gui"])
175 def common_test_annotate(self): argument
176 self.run_cmd(["annotate.py", "-h"])
178 self.run_cmd(["annotate.py", "-s", self.example_path, '--summary-width', '1000'])
179 self.check_exist(dirname="annotated_files")
181 def common_test_report_sample(self, check_strings): argument
182 self.run_cmd(["report_sample.py", "-h"])
183 self.run_cmd(["report_sample.py"])
184 output = self.run_cmd(["report_sample.py", "-i", "perf.data"], return_output=True)
185 self.check_strings_in_content(output, check_strings)
187 def common_test_pprof_proto_generator(self, check_strings_with_lines, argument
189 self.run_cmd(["pprof_proto_generator.py", "-h"])
190 self.run_cmd(["pprof_proto_generator.py"])
192 self.run_cmd(["pprof_proto_generator.py", "-i", "perf.data", "-o", "pprof.profile"])
193 self.check_exist(filename="pprof.profile")
194 self.run_cmd(["pprof_proto_generator.py", "--show"])
195 output = self.run_cmd(["pprof_proto_generator.py", "--show", "pprof.profile"],
197 self.check_strings_in_content(output, check_strings_with_lines + ["has_line_numbers: True"])
199 self.run_cmd(["pprof_proto_generator.py"])
200 output = self.run_cmd(["pprof_proto_generator.py", "--show", "pprof.profile"],
202 self.check_strings_in_content(output, check_strings_without_lines +
205 def common_test_inferno(self): argument
206 self.run_cmd([INFERNO_SCRIPT, "-h"])
208 append_args = [] if self.adb_root else ["--disable_adb_root"]
209 self.run_cmd([INFERNO_SCRIPT, "-p", self.package_name, "-t", "3"] + append_args)
210 self.check_exist(filename="perf.data")
211 self.run_cmd([INFERNO_SCRIPT, "-p", self.package_name, "-f", "1000", "-du", "-t", "1"] +
213 self.run_cmd([INFERNO_SCRIPT, "-p", self.package_name, "-e", "100000 cpu-cycles",
215 self.run_cmd([INFERNO_SCRIPT, "-sc"])
217 def common_test_report_html(self): argument
218 self.run_cmd(['report_html.py', '-h'])
219 self.run_cmd(['report_html.py'])
220 self.run_cmd(['report_html.py', '--add_source_code', '--source_dirs', 'testdata'])
221 self.run_cmd(['report_html.py', '--add_disassembly'])
224 self.run_app_profiler(record_arg='-g -f 1000 --duration 3 -e task-clock:u')
225 self.run_cmd(['report_html.py', '-i', 'perf.data', 'perf2.data'])
229 def setUp(self): argument
230 super(TestRecordingRealApps, self).setUp()
231 self.adb = TestHelper.adb
232 self.installed_packages = []
234 def tearDown(self): argument
235 for package in self.installed_packages:
236 self.adb.run(['shell', 'pm', 'uninstall', package])
237 super(TestRecordingRealApps, self).tearDown()
239 def install_apk(self, apk_path, package_name): argument
240 self.adb.run(['uninstall', package_name])
241 self.adb.run(['install', '-t', apk_path])
242 self.installed_packages.append(package_name)
244 def start_app(self, start_cmd): argument
245 subprocess.Popen(self.adb.adb_path + ' ' + start_cmd, shell=True,
248 def record_data(self, package_name, record_arg): argument
249 self.run_cmd(['app_profiler.py', '--app', package_name, '-r', record_arg])
251 def check_symbol_in_record_file(self, symbol_name): argument
252 self.run_cmd(['report.py', '--children', '-o', 'report.txt'])
253 self.check_strings_in_file('report.txt', [symbol_name])
255 def test_recording_displaybitmaps(self): argument
256 self.install_apk(TestHelper.testdata_path('DisplayBitmaps.apk'),
258 self.install_apk(TestHelper.testdata_path('DisplayBitmapsTest.apk'),
260 self.start_app('shell am instrument -w -r -e debug false -e class ' +
264 self.record_data('com.example.android.displayingbitmaps', '-e cpu-clock -g --duration 10')
266 self.check_symbol_in_record_file('androidx.test.espresso')
268 def test_recording_endless_tunnel(self): argument
269 self.install_apk(TestHelper.testdata_path(
271 self.start_app('shell am start -n com.google.sample.tunnel/android.app.NativeActivity -a ' +
273 self.record_data('com.google.sample.tunnel', '-e cpu-clock -g --duration 10')
274 self.check_symbol_in_record_file('PlayScene::DoFrame')