Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mach bootstrap-android and test-android-startup commands #21094

Merged
merged 30 commits into from Jul 2, 2018
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b9d5f11
Add `./mach bootstrap-android`
SimonSapin Jun 21, 2018
510cf1a
boostrap: set executable bits when extracting zip files
SimonSapin Jun 21, 2018
56df7f4
Install complete Android SDK (as much as on Buildbot CI)
SimonSapin Jun 21, 2018
244a332
Use more recent Android tools
SimonSapin Jun 25, 2018
1ee54ab
Create and Android virtual device
SimonSapin Jun 25, 2018
8889742
mach bootstrap-android: configure and show how to start an emulator
SimonSapin Jun 25, 2018
fe24816
mach run --android: show PID
SimonSapin Jun 25, 2018
4cbf3de
mach {package,install} --android: add --emulator and --usb
SimonSapin Jun 25, 2018
eab971c
Android cross-compiled command line hello world
SimonSapin Jun 25, 2018
90ba22b
egl-configs: link to EGL and generate bindings
SimonSapin Jun 25, 2018
89f6c6d
egl-configs: get the number of configs
SimonSapin Jun 25, 2018
7e7316e
egl-configs: print all config attributes
SimonSapin Jun 25, 2018
1f8d04b
egl-configs: print hex too
SimonSapin Jun 25, 2018
6e68705
cargo run into Android/adb: configurable target device
SimonSapin Jun 25, 2018
484eee8
Tidy
SimonSapin Jun 25, 2018
3c992af
Remove debugging println from a year ago
SimonSapin Jun 26, 2018
7d7f202
Fix copy/paste mistake
SimonSapin Jun 26, 2018
b7a8b81
egl-configs: add i686 support
SimonSapin Jun 26, 2018
f4d740f
Typo fixes
SimonSapin Jun 27, 2018
e54ad77
Do not prompt for Android emulator hardware profile
SimonSapin Jun 28, 2018
0e2e9cb
Create emulator images for both ARM and x86
SimonSapin Jun 28, 2018
aa1c3ce
bootstrap-android: use predictable paths for SDK and NDK
SimonSapin Jun 28, 2018
65122b1
bootstrap-android: always run sdkmanager
SimonSapin Jun 28, 2018
fc77db4
Use the bootstraped Android toolchains by default
SimonSapin Jun 28, 2018
b6b9fe0
Add "./mach android-emulator"
SimonSapin Jun 28, 2018
9e544c2
Remove the egl-configs diagnostic program
SimonSapin Jun 29, 2018
8293b29
bootstrap-android: check SHA1 hashes of downloaded archives
SimonSapin Jun 29, 2018
bee3fd0
mach android-emulator: avoid mach error messages for Python exceptions
SimonSapin Jun 29, 2018
eecbe83
Add ./mach test-android-startup
SimonSapin Jun 29, 2018
c0d1b8e
Android: increase emulator disk size, for debug builds
SimonSapin Jul 2, 2018
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add ./mach test-android-startup

  • Loading branch information
SimonSapin committed Jul 2, 2018
commit eecbe837500270f530e943a1b6bb718031156dd6
@@ -623,6 +623,13 @@ def android_adb_path(self, env):
return sdk_adb
return "adb"

def android_emulator_path(self, env):
if "ANDROID_SDK" in env:
sdk_adb = path.join(env["ANDROID_SDK"], "emulator", "emulator")
if path.exists(sdk_adb):
return sdk_adb
return "emulator"

def handle_android_target(self, target):
if target == "arm-linux-androideabi":
self.config["android"]["platform"] = "android-18"
@@ -177,10 +177,8 @@ def run(self, params, release=False, dev=False, android=None, debug=False, debug
help="Command-line arguments to be passed through to the emulator")
def android_emulator(self, args=None):
if not args:
print("Pass at least an AVD name such as @servo-arm or @servo-x86")
return 1
env = self.build_env()
emulator = path.join(env["ANDROID_SDK"], "emulator", "emulator")
print("AVDs created by `./mach bootstrap-android` are servo-arm and servo-x86.")
emulator = self.android_emulator_path(self.build_env())
return subprocess.call([emulator] + args)

@Command('rr-record',
@@ -17,7 +17,7 @@
import platform
import copy
from collections import OrderedDict
from time import time
import time
import json
import urllib2
import urllib
@@ -157,7 +157,7 @@ def test(self, params, render_mode=DEFAULT_RENDER_MODE, release=False, tidy_all=
print("%s is not a valid test path or suite name" % arg)
return 1

test_start = time()
test_start = time.time()
for suite, tests in selected_suites.iteritems():
props = suites[suite]
kwargs = props.get("kwargs", {})
@@ -166,7 +166,7 @@ def test(self, params, render_mode=DEFAULT_RENDER_MODE, release=False, tidy_all=

Registrar.dispatch("test-%s" % suite, context=self.context, **kwargs)

elapsed = time() - test_start
elapsed = time.time() - test_start

print("Tests completed in %0.2fs" % elapsed)

@@ -551,6 +551,87 @@ def filter_intermittents(self, summary, log_filteredsummary, log_intermittents,
output.close()
return 1

@Command('test-android-startup',
description='Extremely minimal testing of Servo for Android',
category='testing')
@CommandArgument('--release', '-r', action='store_true',
help='Run the release build')
@CommandArgument('--dev', '-d', action='store_true',
help='Run the dev build')
def test_android_startup(self, release, dev):
if (release and dev) or not (release or dev):
print("Please specify one of --dev or --release.")
return 1
target = "i686-linux-android"
print("Assuming --target " + target)
env = self.build_env(target=target)
assert self.handle_android_target(target)

emulator_port = "5580"
adb = [self.android_adb_path(env), "-s", "emulator-" + emulator_port]
emulator_process = subprocess.Popen([
self.android_emulator_path(env),
"@servo-x86",
"-no-window",
"-gpu", "guest",
"-port", emulator_port,
])
try:
# This is hopefully enough time for the emulator to exit
# if it cannot start because of a configuration problem,
# and probably more time than it needs to boot anyway
time.sleep(1)
if emulator_process.poll() is not None:
# The process has terminated already, wait-for-device would block indefinitely
return 1

subprocess.call(adb + ["wait-for-device"])

# https://stackoverflow.com/a/38896494/1162888
while 1:
stdout, stderr = subprocess.Popen(
adb + ["shell", "getprop", "sys.boot_completed"],
stdout=subprocess.PIPE,
).communicate()
if "1" in stdout:
break
print("Waiting for the emulator to boot")
time.sleep(1)

binary_path = self.get_binary_path(release, dev, android=True)
result = subprocess.call(adb + ["install", "-r", binary_path + ".apk"])
if result != 0:
return result

html = """
<script>
console.log("JavaScript is running!")
</script>
"""
url = "data:text/html;base64," + html.encode("base64").replace("\n", "")
result = subprocess.call(adb + ["shell", """
mkdir -p /sdcard/Android/data/com.mozilla.servo/files/
echo 'servo' > /sdcard/Android/data/com.mozilla.servo/files/android_params
echo '%s' >> /sdcard/Android/data/com.mozilla.servo/files/android_params
am start com.mozilla.servo/com.mozilla.servo.MainActivity
""" % url])
if result != 0:
return result

logcat = adb + ["logcat", "RustAndroidGlueStdouterr:D", "*:S", "-v", "raw"]
logcat_process = subprocess.Popen(logcat, stdout=subprocess.PIPE)
while 1:
line = logcat_process.stdout.readline()
if "JavaScript is running!" in line:
print(line)
break
logcat_process.kill()
finally:
try:
emulator_process.kill()
except OSError:
pass

@Command('test-jquery',
description='Run the jQuery test suite',
category='testing')
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.