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

Install android tools r25.2.3 concurrently #639

Merged

Add smoke test that Android SDK is installed properly

The Android SDK installation states often have tricky changes
due to upstream changes by Google,
and additionally often fail silently in various different ways
e.g. because the `android` tool always has a zero exit status.
Additionally, some failures are not evident until Servo builds
themselves start failing.

Add a somke test in saltfs to catch common problems early on,
and automatically run it on Travis.
  • Loading branch information
aneeshusa committed Apr 20, 2017
commit b9fbecd7bb8035585a495322230ee8d9c15255a4
@@ -72,6 +72,9 @@ else
if [[ "${SALT_NODE_ID}" == "servo-master1" ]]; then
./test.py sls.buildbot.master sls.homu sls.nginx
fi
if [[ "${SALT_NODE_ID}" == "servo-linux-cross1" ]]; then
./test.py sls.servo-build-dependencies.android
fi

# Salt doesn't support timezone.system on OSX
# See https://github.com/saltstack/salt/issues/31345
@@ -2,3 +2,4 @@
# (Travis-CI will auto-install them from this file)
flake8 == 2.5.4
toml == 0.9.1 # Please ensure this is in sync with homu/init.sls
jinja2 == 2.9.6 # TODO: sync this with version used by Salt
No changes.
@@ -0,0 +1,88 @@
import os.path

from jinja2 import Template

from tests.util import Failure, Success, project_path

BASE_DIR = '/home/servo/android/sdk'
CHECKS = {
'{}/android-sdk-linux': {'type': 'absent'},
'{}/tools/android': {'type': 'file', 'executable': True},
'{}/platform-tools': {'type': 'directory'},
'{}/platforms/android-{platform}': {'type': 'directory'},
'{}/build-tools/{build_tools}': {'type': 'directory'},
}


def has_perms(perms, stat_info):
return perms == stat_info & perms


def run():
with open(os.path.join(
project_path(),
'servo-build-dependencies',
'map.jinja'
)) as jinja_file:
template = Template(jinja_file.read())

sdk_vars = template.module.android['sdk']
failures = []
checks = {}
for version, sdk in sdk_vars.items():
if version == 'current':
if sdk not in sdk_vars:
failures.append(
'The current SDK is not pointed at any installed SDK'
)
continue
checks[os.path.join(BASE_DIR, 'current')] = {
'type': 'link',
'target': os.path.join(BASE_DIR, sdk)
}
sdk = sdk_vars[sdk]
for path_template, spec in CHECKS.items():
path = path_template.format(os.path.join(BASE_DIR, version), **sdk)
checks[path] = spec

for path, spec in sorted(checks.items(), key=lambda kv: kv[0]):
exists = os.path.lexists(path)
if spec['type'] == 'absent':
if exists:
failures.append('{} should not exist'.format(path))
continue
if not exists:
failures.append('{} does not exist but should'.format(path))
continue
info = os.stat(path).st_mode
if spec['type'] == 'directory':
if not (os.path.isdir(path) and not os.path.islink(path)):
failures.append('{} should be a directory'.format(path))
if not has_perms(0o700, info):
failures.append(
'{} should have at least perms 700'.format(path)
)
elif spec['type'] == 'file':
if not (os.path.isfile(path) and not os.path.islink(path)):
failures.append('{} should be a file'.format(path))
perms = 0o700 if spec['executable'] else 0o600
if not has_perms(perms, info):
failures.append(
'{} should have at least perms {:o}'.format(path, perms)
)
elif spec['type'] == 'link':
if not os.path.islink(path):
failures.append('{} should be a symlink'.format(path))
if not os.path.realpath(path) == spec['target']:
failures.append(
'{} should be a link to {}'.format(path, spec['target'])
)

else:
failures.append('Unknown spec for path {}'.format(path))

if failures:
output = '\n'.join(('- {}'.format(f) for f in failures))
return Failure('Android SDK(s) not installed properly:', output)

return Success('Android SDK(s) are properly installed')
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.