def get_testcase_path(self): """Get the testcase path.""" android.adb_shell('rm -rf %s' % ANDROID_TESTCASE_DIR) android_testcase_dir = '%s/%s' % (ANDROID_TESTCASE_DIR, self.testcase.id) testcase_relative_path = os.path.relpath( self.testcase.get_testcase_path(), self.testcase.testcase_dir_path) android.adb('push %s %s' % (self.testcase.testcase_dir_path, android_testcase_dir)) return '%s/%s' % (android_testcase_dir, testcase_relative_path)
def run_monkey_gestures_if_needed(package_name, gestures): """Runs monkey gestures if gestures isn't empty.""" if not gestures: return gestures = gestures[0].split(',') if gestures[0] != 'monkey': return seed = gestures[-1] android.adb_shell( 'monkey -p %s -s %s --throttle %s --ignore-security-exceptions %s' % (package_name, seed, MONKEY_THROTTLE_DELAY, NUM_MONKEY_EVENTS)) time.sleep(10)
def reproduce_crash(self): """Reproduce crash on Android.""" android.reset(self.testcase.android_package_name) android.reboot() android.ensure_active() android.clear_log() ret_value, _ = android.adb_shell( 'am start -a android.intent.action.MAIN ' "-n {package_name}/{class_name} '{testcase_url}'".format( package_name=self.testcase.android_package_name, class_name=self.testcase.android_main_class_name, testcase_url=self.get_testcase_url()), redirect_stderr_to_stdout=True, stdout_transformer=output_transformer.Identity()) time.sleep(TEST_TIMEOUT) run_monkey_gestures_if_needed(self.testcase.android_package_name, self.testcase.gestures) output = android.get_log() android.kill(self.testcase.android_package_name) lib_tmp_dir_path = tempfile.mkdtemp(dir=common.CLUSTERFUZZ_TMP_DIR) symbolized_output = symbolize( output=android.fix_lib_path( content=android.filter_log(output), search_paths=[ self.binary_provider.get_unstripped_lib_dir_path(), self.binary_provider.get_android_libclang_dir_path() ], lib_tmp_dir_path=lib_tmp_dir_path), source_dir_path=self.binary_provider.get_source_dir_path()) common.delete_if_exists(lib_tmp_dir_path) return ret_value, symbolized_output
def install(self): """Install webview.""" android.adb_shell('setprop persist.sys.webview.vmsize %s' % SYSTEM_WEBVIEW_VMSIZE_BYTES) android.adb_shell('stop') android.adb_shell('rm -rf %s' % ' '.join(SYSTEM_WEBVIEW_DIRS)) android.adb_shell('start') android.uninstall(SYSTEM_WEBVIEW_PACKAGE) android.uninstall(self.testcase.android_package_name) android.install( os.path.join(os.path.dirname(self.binary_path), SYSTEM_WEBVIEW_APK)) android.install(self.binary_path)