Beispiel #1
0
    def set_initial_state(self, context):
        # TODO: this does not play well with hotplug but leaving as-is, as this will be changed with
        # the devilib port anyway.
        # Write initial frequencies into the trace.
        # NOTE: this assumes per-cluster DVFS, that is valid for devices that
        # currently exist. This will need to be updated for per-CPU DFS.
        # pylint: disable=attribute-defined-outside-init
        self.logger.debug('Writing initial frequencies into trace...')
        device = context.device
        cluster_freqs = {}
        cluster_max_freqs = {}
        self.max_freq_list = []
        for c in unique(device.core_clusters):
            try:
                cluster_freqs[c] = device.get_cluster_cur_frequency(c)
                cluster_max_freqs[c] = device.get_cluster_max_frequency(c)
            except ValueError:
                cluster_freqs[c] = None
                cluster_max_freqs[c] = None
        for i, c in enumerate(device.core_clusters):
            self.max_freq_list.append(cluster_max_freqs[c])
            entry = 'CPU {} FREQUENCY: {} kHZ'.format(i, cluster_freqs[c])
            device.set_sysfile_value('/sys/kernel/debug/tracing/trace_marker',
                                     entry,
                                     verify=False)

        # Nudge each cpu to force idle state transitions in the trace
        self.logger.debug('Nudging all cores awake...')
        for i in xrange(len(device.core_names)):
            command = device.busybox + ' taskset 0x{:x} {}'
            try:
                device.execute(command.format(1 << i, 'ls'))
            except DeviceError:
                self.logger.warning(
                    "Failed to nudge CPU %s, has it been hot plugged out?", i)
    def set_initial_state(self, context):
        # TODO: this does not play well with hotplug but leaving as-is, as this will be changed with
        # the devilib port anyway.
        # Write initial frequencies into the trace.
        # NOTE: this assumes per-cluster DVFS, that is valid for devices that
        # currently exist. This will need to be updated for per-CPU DFS.
        # pylint: disable=attribute-defined-outside-init
        self.logger.debug('Writing initial frequencies into trace...')
        device = context.device
        cluster_freqs = {}
        cluster_max_freqs = {}
        self.max_freq_list = []
        for c in unique(device.core_clusters):
            cluster_freqs[c] = device.get_cluster_cur_frequency(c)
            cluster_max_freqs[c] = device.get_cluster_max_frequency(c)
        for i, c in enumerate(device.core_clusters):
            self.max_freq_list.append(cluster_max_freqs[c])
            entry = 'CPU {} FREQUENCY: {} kHZ'.format(i, cluster_freqs[c])
            device.set_sysfile_value('/sys/kernel/debug/tracing/trace_marker',
                                     entry, verify=False)

        # Nudge each cpu to force idle state transitions in the trace
        self.logger.debug('Nudging all cores awake...')
        for i in xrange(len(device.core_names)):
            command = device.busybox + ' taskset 0x{:x} {}'
            device.execute(command.format(1 << i, 'ls'))
_env_configs = []
for filename in ['config.py', 'config.yaml']:
    filepath = os.path.join(_env_root, filename)
    if os.path.isfile(filepath):
        _env_configs.append(filepath)

if not os.path.isdir(_env_root):
    init_environment(_env_root, _dep_dir, _extension_paths)
elif not _env_configs:
    filepath = os.path.join(_env_root, 'config.py')
    with open(os.path.join(_this_dir, '..', 'config_example.py')) as f:
        f_text = re.sub(r'""".*?"""', '', f.read(), 1, re.DOTALL)
        with open(filepath, 'w') as f:
            f.write(f_text)
        _env_configs.append(filepath)

settings = ConfigLoader()
settings.environment_root = _env_root
settings.dependencies_directory = _dep_dir
settings.extension_paths = _extension_paths
settings.extensions = _extensions

_packages_file = os.path.join(_env_root, 'packages')
if os.path.isfile(_packages_file):
    with open(_packages_file) as fh:
        settings.extension_packages = unique(fh.read().split())

for config in _env_configs:
    settings.update(config)
class Googlephotos(AndroidUxPerfWorkload):

    name = 'googlephotos'
    package = 'com.google.android.apps.photos'
    activity = 'com.google.android.apps.photos.home.HomeActivity'
    view = [package + '/com.google.android.apps.consumerphotoeditor.fragments.ConsumerPhotoEditorActivity',
            package + '/com.google.android.apps.photos.home.HomeActivity',
            package + '/com.google.android.apps.photos.localmedia.ui.LocalPhotosActivity',
            package + '/com.google.android.apps.photos.onboarding.AccountPickerActivity',
            package + '/com.google.android.apps.photos.onboarding.IntroActivity']
    description = '''
    A workload to perform standard productivity tasks with Google Photos. The workload carries out
    various tasks, such as browsing images, performing zooms, and post-processing the image.

    Test description:

    1. Four images are copied to the device
    2. The application is started in offline access mode
    3. Gestures are performed to pinch zoom in and out of the selected image
    4. The colour of a selected image is edited by selecting the colour menu, incrementing the
       colour, resetting the colour and decrementing the colour using the seek bar.
    5. A crop test is performed on a selected image.  UiAutomator does not allow the selection of
       the crop markers so the image is tilted positively, reset and then tilted negatively to get a
       similar cropping effect.
    6. A rotate test is performed on a selected image, rotating anticlockwise 90 degrees, 180
       degrees and 270 degrees.

    Known working APK version: 1.21.0.123444480
    '''

    default_test_images = [
        'uxperf_1200x1600.png', 'uxperf_1600x1200.jpg',
        'uxperf_2448x3264.png', 'uxperf_3264x2448.jpg',
    ]

    parameters = [
        Parameter('test_images', kind=list_of_strings, default=default_test_images,
                  constraint=lambda x: len(unique(x)) == 4,
                  description='''
                  A list of four JPEG and/or PNG files to be pushed to the device.
                  Absolute file paths may be used but tilde expansion must be escaped.
                  '''),
    ]

    def __init__(self, device, **kwargs):
        super(Googlephotos, self).__init__(device, **kwargs)
        self.deployable_assets = self.test_images

    def validate(self):
        super(Googlephotos, self).validate()
        # Only accept certain image formats
        for image in self.test_images:
            if os.path.splitext(image.lower())[1] not in ['.jpg', '.jpeg', '.png']:
                raise ValidationError('{} must be a JPEG or PNG file'.format(image))

    def setup(self, context):
        super(Googlephotos, self).setup(context)
        # Create a subfolder for each test_image named ``wa-[1-4]``
        # Move each image into its subfolder
        # This is to guarantee ordering and allows the workload to select a specific
        # image by subfolder, as filenames are not shown easily within the app
        d = self.device.working_directory
        file_list = []
        for i, f in enumerate(self.test_images):
            self.device.execute('mkdir -p {0}/wa-{1}'.format(d, i + 1))
            self.device.execute('mv {0}/{2} {0}/wa-{1}/{2}'.format(d, i + 1, f))
            file_list.append('{0}/wa-{1}/{2}'.format(d, i + 1, f))
        # Force rescan
        self.device.refresh_device_files(file_list)

    def teardown(self, context):
        super(Googlephotos, self).teardown(context)
        # Remove the subfolders and its content
        d = self.device.working_directory
        file_list = []
        for i in xrange(len(self.test_images)):
            f = '{0}/wa-{1}'.format(d, i + 1)
            self.device.execute('rm -rf {}'.format(f))
            file_list.append(f)
        # Force rescan
        self.device.refresh_device_files(file_list)
Beispiel #5
0
_env_configs = []
for filename in ['config.py', 'config.yaml']:
    filepath = os.path.join(_env_root, filename)
    if os.path.isfile(filepath):
        _env_configs.append(filepath)

if not os.path.isdir(_env_root):
    init_environment(_env_root, _dep_dir, _extension_paths)
elif not _env_configs:
    filepath = os.path.join(_env_root, 'config.py')
    with open(os.path.join(_this_dir, '..', 'config_example.py')) as f:
        f_text = re.sub(r'""".*?"""', '', f.read(), 1, re.DOTALL)
        with open(filepath, 'w') as f:
            f.write(f_text)
        _env_configs.append(filepath)

settings = ConfigLoader()
settings.environment_root = _env_root
settings.dependencies_directory = _dep_dir
settings.extension_paths = _extension_paths
settings.extensions = _extensions

_packages_file = os.path.join(_env_root, 'packages')
if os.path.isfile(_packages_file):
    with open(_packages_file) as fh:
        settings.extension_packages = unique(fh.read().split())

for config in _env_configs:
    settings.update(config)