Commit 7eed7e0b authored by jbudorick's avatar jbudorick Committed by Commit bot

Revert of [Android] Add zip pushing and refine push mode selection.

Broke telemetry_perf_unittests on Android Tests.

TBR=craigdh@chromium.org,cjhopman@chromium.org,klundberg@chromium.org,tonyg@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=400440

Review URL: https://codereview.chromium.org/645093002

Cr-Commit-Position: refs/heads/master@{#299133}
parent 4bef9dd9
...@@ -64,8 +64,7 @@ def TriggerSymlinkScript(options): ...@@ -64,8 +64,7 @@ def TriggerSymlinkScript(options):
mkdir_cmd = ('if [ ! -e %(dir)s ]; then mkdir -p %(dir)s; fi ' % mkdir_cmd = ('if [ ! -e %(dir)s ]; then mkdir -p %(dir)s; fi ' %
{ 'dir': device_dir }) { 'dir': device_dir })
RunShellCommand(device, mkdir_cmd) RunShellCommand(device, mkdir_cmd)
device.PushChangedFiles([(options.script_host_path, device.PushChangedFiles(options.script_host_path, options.script_device_path)
options.script_device_path)])
trigger_cmd = ( trigger_cmd = (
'APK_LIBRARIES_DIR=%(apk_libraries_dir)s; ' 'APK_LIBRARIES_DIR=%(apk_libraries_dir)s; '
......
...@@ -40,7 +40,7 @@ def DoPush(options): ...@@ -40,7 +40,7 @@ def DoPush(options):
if needs_directory: if needs_directory:
device.RunShellCommand('mkdir -p ' + options.device_dir) device.RunShellCommand('mkdir -p ' + options.device_dir)
needs_directory[:] = [] # = False needs_directory[:] = [] # = False
device.PushChangedFiles([(host_path, device_path)]) device.PushChangedFiles(host_path, device_path)
record_path = '%s.%s.push.md5.stamp' % (host_path, serial_number) record_path = '%s.%s.push.md5.stamp' % (host_path, serial_number)
md5_check.CallAndRecordIfStale( md5_check.CallAndRecordIfStale(
......
...@@ -72,7 +72,7 @@ def PushAndLaunchAdbReboot(device, target): ...@@ -72,7 +72,7 @@ def PushAndLaunchAdbReboot(device, target):
logging.info(' Pushing adb_reboot ...') logging.info(' Pushing adb_reboot ...')
adb_reboot = os.path.join(constants.DIR_SOURCE_ROOT, adb_reboot = os.path.join(constants.DIR_SOURCE_ROOT,
'out/%s/adb_reboot' % target) 'out/%s/adb_reboot' % target)
device.PushChangedFiles([(adb_reboot, '/data/local/tmp/')]) device.PushChangedFiles(adb_reboot, '/data/local/tmp/')
# Launch adb_reboot # Launch adb_reboot
logging.info(' Launching adb_reboot ...') logging.info(' Launching adb_reboot ...')
device.old_interface.GetAndroidToolStatusAndOutput( device.old_interface.GetAndroidToolStatusAndOutput(
......
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'chromium_commands',
'type': 'none',
'variables': {
'java_in_dir': ['java'],
},
'includes': [
'../../../../../build/java.gypi',
],
}
],
}
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
from pylib import constants
BIN_DIR = '%s/bin' % constants.TEST_EXECUTABLE_DIR
_FRAMEWORK_DIR = '%s/framework' % constants.TEST_EXECUTABLE_DIR
_COMMANDS = {
'unzip': 'org.chromium.android.commands.unzip.Unzip',
}
_SHELL_COMMAND_FORMAT = (
"""#!/system/bin/sh
base=%s
export CLASSPATH=$base/framework/chromium_commands.jar
exec app_process $base/bin %s $@
""")
def Installed(device):
return all(device.FileExists('%s/%s' % (BIN_DIR, c)) for c in _COMMANDS)
def InstallCommands(device):
device.RunShellCommand(['mkdir', BIN_DIR, _FRAMEWORK_DIR])
for command, main_class in _COMMANDS.iteritems():
shell_command = _SHELL_COMMAND_FORMAT % (
constants.TEST_EXECUTABLE_DIR, main_class)
shell_file = '%s/%s' % (BIN_DIR, command)
device.WriteTextFile(shell_file, shell_command)
device.RunShellCommand(
['chmod', '755', shell_file], check_return=True)
device.adb.Push(
os.path.join(constants.GetOutDirectory(),
constants.SDK_BUILD_JAVALIB_DIR,
'chromium_commands.dex.jar'),
'%s/chromium_commands.jar' % _FRAMEWORK_DIR)
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.android.commands.unzip;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
* Minimal implementation of the command-line unzip utility for Android.
*/
public class Unzip {
private static final String TAG = "Unzip";
public static void main(String[] args) {
try {
(new Unzip()).run(args);
} catch (RuntimeException e) {
Log.e(TAG, e.toString());
System.exit(1);
}
}
private void showUsage(PrintStream s) {
s.println("Usage:");
s.println("unzip [zipfile]");
}
private void unzip(String[] args) {
ZipInputStream zis = null;
try {
String zipfile = args[0];
zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipfile)));
ZipEntry ze = null;
byte[] bytes = new byte[1024];
while ((ze = zis.getNextEntry()) != null) {
File outputFile = new File(ze.getName());
if (ze.isDirectory()) {
if (!outputFile.exists() && !outputFile.mkdirs()) {
throw new RuntimeException(
"Failed to create directory: " + outputFile.toString());
}
} else {
File parentDir = outputFile.getParentFile();
if (!parentDir.exists() && !parentDir.mkdirs()) {
throw new RuntimeException(
"Failed to create directory: " + parentDir.toString());
}
OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile));
int actual_bytes = 0;
int total_bytes = 0;
while ((actual_bytes = zis.read(bytes)) != -1) {
out.write(bytes, 0, actual_bytes);
total_bytes += actual_bytes;
}
out.close();
}
zis.closeEntry();
}
} catch (IOException e) {
throw new RuntimeException("Error while unzipping: " + e.toString());
} finally {
try {
if (zis != null) zis.close();
} catch (IOException e) {
throw new RuntimeException("Error while closing zip: " + e.toString());
}
}
}
public void run(String[] args) {
if (args.length != 1) {
showUsage(System.err);
throw new RuntimeException("Incorrect usage.");
}
unzip(args);
}
}
This diff is collapsed.
...@@ -288,9 +288,9 @@ class Forwarder(object): ...@@ -288,9 +288,9 @@ class Forwarder(object):
if device_serial in self._initialized_devices: if device_serial in self._initialized_devices:
return return
Forwarder._KillDeviceLocked(device, tool) Forwarder._KillDeviceLocked(device, tool)
device.PushChangedFiles([( device.PushChangedFiles(
self._device_forwarder_path_on_host, self._device_forwarder_path_on_host,
Forwarder._DEVICE_FORWARDER_FOLDER)]) Forwarder._DEVICE_FORWARDER_FOLDER)
cmd = '%s %s' % (tool.GetUtilWrapper(), Forwarder._DEVICE_FORWARDER_PATH) cmd = '%s %s' % (tool.GetUtilWrapper(), Forwarder._DEVICE_FORWARDER_PATH)
(exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput( (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput(
cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER)
......
...@@ -44,9 +44,9 @@ class TestPackageApk(TestPackage): ...@@ -44,9 +44,9 @@ class TestPackageApk(TestPackage):
# GTest expects argv[0] to be the executable path. # GTest expects argv[0] to be the executable path.
command_line_file.write(self.suite_name + ' ' + options) command_line_file.write(self.suite_name + ' ' + options)
command_line_file.flush() command_line_file.flush()
device.PushChangedFiles([( device.PushChangedFiles(
command_line_file.name, command_line_file.name,
self._package_info.cmdline_file)]) self._package_info.cmdline_file)
def _GetFifo(self): def _GetFifo(self):
# The test.fifo path is determined by: # The test.fifo path is determined by:
......
...@@ -105,9 +105,9 @@ class TestPackageExecutable(TestPackage): ...@@ -105,9 +105,9 @@ class TestPackageExecutable(TestPackage):
TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE)) TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE))
sh_script_file.flush() sh_script_file.flush()
cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name]) cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name])
device.PushChangedFiles([( device.PushChangedFiles(
sh_script_file.name, sh_script_file.name,
constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh')]) constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh')
logging.info('Conents of the test runner script: ') logging.info('Conents of the test runner script: ')
for line in open(sh_script_file.name).readlines(): for line in open(sh_script_file.name).readlines():
logging.info(' ' + line.rstrip()) logging.info(' ' + line.rstrip())
...@@ -148,4 +148,4 @@ class TestPackageExecutable(TestPackage): ...@@ -148,4 +148,4 @@ class TestPackageExecutable(TestPackage):
self.suite_name + '_stripped')) self.suite_name + '_stripped'))
test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name
device.PushChangedFiles([(target_name, test_binary)]) device.PushChangedFiles(target_name, test_binary)
...@@ -70,10 +70,10 @@ class TestRunner(base_test_runner.BaseTestRunner): ...@@ -70,10 +70,10 @@ class TestRunner(base_test_runner.BaseTestRunner):
device_dir = constants.TEST_EXECUTABLE_DIR device_dir = constants.TEST_EXECUTABLE_DIR
else: else:
device_dir = self.device.GetExternalStoragePath() device_dir = self.device.GetExternalStoragePath()
self.device.PushChangedFiles( for p in os.listdir(constants.ISOLATE_DEPS_DIR):
[(os.path.join(constants.ISOLATE_DEPS_DIR, p), self.device.PushChangedFiles(
os.path.join(constants.ISOLATE_DEPS_DIR, p),
os.path.join(device_dir, p)) os.path.join(device_dir, p))
for p in os.listdir(constants.ISOLATE_DEPS_DIR)])
def _ParseTestOutput(self, p): def _ParseTestOutput(self, p):
"""Process the test output. """Process the test output.
......
...@@ -99,15 +99,14 @@ class TestRunner(base_test_runner.BaseTestRunner): ...@@ -99,15 +99,14 @@ class TestRunner(base_test_runner.BaseTestRunner):
str(self.device)) str(self.device))
return return
host_device_file_tuples = []
test_data = _GetDataFilesForTestSuite(self.test_pkg.GetApkName()) test_data = _GetDataFilesForTestSuite(self.test_pkg.GetApkName())
if test_data: if test_data:
# Make sure SD card is ready. # Make sure SD card is ready.
self.device.WaitUntilFullyBooted(timeout=20) self.device.WaitUntilFullyBooted(timeout=20)
host_device_file_tuples += [ for p in test_data:
(os.path.join(constants.DIR_SOURCE_ROOT, p), self.device.PushChangedFiles(
os.path.join(self.device.GetExternalStoragePath(), p)) os.path.join(constants.DIR_SOURCE_ROOT, p),
for p in test_data] os.path.join(self.device.GetExternalStoragePath(), p))
# TODO(frankf): Specify test data in this file as opposed to passing # TODO(frankf): Specify test data in this file as opposed to passing
# as command-line. # as command-line.
...@@ -118,14 +117,12 @@ class TestRunner(base_test_runner.BaseTestRunner): ...@@ -118,14 +117,12 @@ class TestRunner(base_test_runner.BaseTestRunner):
host_test_files_path = os.path.join(constants.DIR_SOURCE_ROOT, host_test_files_path = os.path.join(constants.DIR_SOURCE_ROOT,
host_src) host_src)
if os.path.exists(host_test_files_path): if os.path.exists(host_test_files_path):
host_device_file_tuples += [( self.device.PushChangedFiles(
host_test_files_path, host_test_files_path,
'%s/%s/%s' % ( '%s/%s/%s' % (
self.device.GetExternalStoragePath(), self.device.GetExternalStoragePath(),
TestRunner._DEVICE_DATA_DIR, TestRunner._DEVICE_DATA_DIR,
dst_layer))] dst_layer))
if host_device_file_tuples:
self.device.PushChangedFiles(host_device_file_tuples)
self.tool.CopyFiles() self.tool.CopyFiles()
TestRunner._DEVICE_HAS_TEST_FILES[str(self.device)] = True TestRunner._DEVICE_HAS_TEST_FILES[str(self.device)] = True
......
...@@ -24,4 +24,4 @@ class TestPackage(test_jar.TestJar): ...@@ -24,4 +24,4 @@ class TestPackage(test_jar.TestJar):
# Override. # Override.
def Install(self, device): def Install(self, device):
device.PushChangedFiles([(self._jar_path, constants.TEST_EXECUTABLE_DIR)]) device.PushChangedFiles(self._jar_path, constants.TEST_EXECUTABLE_DIR)
...@@ -172,10 +172,10 @@ class ValgrindTool(BaseTool): ...@@ -172,10 +172,10 @@ class ValgrindTool(BaseTool):
'rm -r %s; mkdir %s' % (ValgrindTool.VGLOGS_DIR, 'rm -r %s; mkdir %s' % (ValgrindTool.VGLOGS_DIR,
ValgrindTool.VGLOGS_DIR)) ValgrindTool.VGLOGS_DIR))
files = self.GetFilesForTool() files = self.GetFilesForTool()
self._device.PushChangedFiles( for f in files:
[((os.path.join(DIR_SOURCE_ROOT, f), self._device.PushChangedFiles(
os.path.join(DIR_SOURCE_ROOT, f),
os.path.join(ValgrindTool.VG_DIR, os.path.basename(f))) os.path.join(ValgrindTool.VG_DIR, os.path.basename(f)))
for f in files)])
def SetupEnvironment(self): def SetupEnvironment(self):
"""Sets up device environment.""" """Sets up device environment."""
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
{ {
'dependencies': [ 'dependencies': [
'<(DEPTH)/base/base.gyp:base_java', '<(DEPTH)/base/base.gyp:base_java',
'<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands',
'<(DEPTH)/tools/android/android_tools.gyp:android_tools', '<(DEPTH)/tools/android/android_tools.gyp:android_tools',
], ],
'conditions': [ 'conditions': [
......
...@@ -551,7 +551,6 @@ ...@@ -551,7 +551,6 @@
}], }],
['is_test_apk == 1', { ['is_test_apk == 1', {
'dependencies': [ 'dependencies': [
'<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands',
'<(DEPTH)/tools/android/android_tools.gyp:android_tools', '<(DEPTH)/tools/android/android_tools.gyp:android_tools',
] ]
}], }],
......
...@@ -89,7 +89,7 @@ class ChromeBackendSettings(AndroidBrowserBackendSettings): ...@@ -89,7 +89,7 @@ class ChromeBackendSettings(AndroidBrowserBackendSettings):
profile_base = os.path.basename(profile_parent) profile_base = os.path.basename(profile_parent)
saved_profile_location = '/sdcard/profile/%s' % profile_base saved_profile_location = '/sdcard/profile/%s' % profile_base
adb.device().PushChangedFiles([(new_profile_dir, saved_profile_location)]) adb.device().PushChangedFiles(new_profile_dir, saved_profile_location)
adb.device().old_interface.EfficientDeviceDirectoryCopy( adb.device().old_interface.EfficientDeviceDirectoryCopy(
saved_profile_location, self.profile_dir) saved_profile_location, self.profile_dir)
......
...@@ -26,6 +26,6 @@ def InstallOnDevice(device, profiler_binary): ...@@ -26,6 +26,6 @@ def InstallOnDevice(device, profiler_binary):
return False return False
device_binary_path = GetDevicePath(profiler_binary) device_binary_path = GetDevicePath(profiler_binary)
device.PushChangedFiles([(host_path, device_binary_path)]) device.PushChangedFiles(host_path, device_binary_path)
device.RunShellCommand('chmod 777 ' + device_binary_path) device.RunShellCommand('chmod 777 ' + device_binary_path)
return True return True
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment