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

Ensure preemptive hosts only run fuzz tasks for android #3808

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/clusterfuzz/_internal/platforms/android/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,14 @@ def initialize_environment():
environment.set_value('BUILD_VERSION', settings.get_build_version())
environment.set_value('DEVICE_CODENAME', settings.get_device_codename())
environment.set_value('DEVICE_PATH', adb.get_device_path())
environment.set_value('LOG_TASK_TIMES', True)
environment.set_value('PLATFORM_ID', settings.get_platform_id())
environment.set_value('PREEMPTIBLE', settings.using_preemptible_host())
environment.set_value('PRODUCT_BRAND', settings.get_product_brand())
environment.set_value('SANITIZER_TOOL_NAME',
settings.get_sanitizer_tool_name())
environment.set_value('SECURITY_PATCH_LEVEL',
settings.get_security_patch_level())
environment.set_value('LOG_TASK_TIMES', True)


def install_application_if_needed(apk_path, force_update):
Expand Down
5 changes: 5 additions & 0 deletions src/clusterfuzz/_internal/platforms/android/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ def is_mte_build():
return 'mte' in build_flavor


def using_preemptible_host():
"""Return True if using a peemptible host."""
return '-pre-' in environment.get_value('DOCKER_HOST', '')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my question on the other internal CL :)

I would've expected the hostname to propagate to inside the container, as that's what we expect in our other environments.

DOCKER_HOST also seems like it's leaking abstraction a bit (the fact that this is running in a docker container). Perhaps we could just call this HOSTNAME if we do end up needing an env var?



def get_security_patch_level():
"""Return the security patch level reported by the device."""
return adb.get_property('ro.build.version.security_patch')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class InitializeEnvironmentTest(android_helpers.AndroidTest):
"""Tests for """
"""Tests for initializing the device environment."""

def test(self):
"""Ensure that initialize_environment throws no exceptions."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest

from clusterfuzz._internal.platforms.android import settings
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.tests.test_libs import helpers as test_helpers

DATA_PATH = os.path.join(
Expand Down Expand Up @@ -47,3 +48,15 @@ def test_by_usb(self):
"""Ensure that we report the correct codename for a usb device."""
os.environ['ANDROID_SERIAL'] = 'usb:2-4.2'
self.assertEqual(settings.get_device_codename(), 'device2')


class DockerLauncherTests(unittest.TestCase):
"""Tests to ensure docker launcher command is clean."""

def setUp(self):
test_helpers.patch_environ(self)

def test_docker_host_is_pre(self):
"""Ensure that we report the correct preemptible status."""
environment.set_value('DOCKER_HOST', 'clusterfuzz-android-pre-0123')
self.assertEqual(settings.using_preemptible_host(), True)
Loading