1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-01 10:52:33 +01:00

Adding Antutu BDP class for cli automation

Fixing linting errors

Fixing linting errors

Fixing linting errors

Fixing pep8 errors

Fixing pep8 errors

Fixing pep8 line indent errors
This commit is contained in:
scojac01
2025-04-08 15:10:49 +01:00
committed by Marc Bonnici
parent 82033b6d04
commit 24f9af84af

View File

@@ -13,8 +13,9 @@
# limitations under the License.
#
import re
from wa import ApkUiautoWorkload, WorkloadError, Parameter
import os
import time
from wa import ApkUiautoWorkload, Workload, WorkloadError, Parameter, ApkFile, File
class Antutu(ApkUiautoWorkload):
@@ -65,6 +66,26 @@ class Antutu(ApkUiautoWorkload):
re.compile(r'ROM Sequential Read Score (.+)'),
re.compile(r'ROM Sequential Write Score (.+)'),
re.compile(r'ROM Random Access Score (.+)')]
regex_matches_v10 = [re.compile(r'CPU Mathematical Operations Score (.+)'),
re.compile(r'CPU Common Algorithms Score (.+)'),
re.compile(r'CPU Multi-Core Score (.+)'),
re.compile(r'GPU Seasons Score (.+)'),
re.compile(r'GPU Coastline2 Score (.+)'),
re.compile(r'RAM Bandwidth Score (.+)'),
re.compile(r'RAM Latency Score (.+)'),
re.compile(r'ROM APP IO Score (.+)'),
re.compile(r'ROM Sequential Read Score (.+)'),
re.compile(r'ROM Sequential Write Score (.+)'),
re.compile(r'ROM Random Access Score (.+)'),
re.compile(r'Data Security Score (.+)'),
re.compile(r'Data Processing Score (.+)'),
re.compile(r'Document Processing Score (.+)'),
re.compile(r'Image Decoding Score (.+)'),
re.compile(r'Image Processing Score (.+)'),
re.compile(r'User Experience Score (.+)'),
re.compile(r'Video CTS Score (.+)'),
re.compile(r'Video Decoding Score (.+)'),
re.compile(r'Video Editing Score (.+)')]
description = '''
Executes Antutu 3D, UX, CPU and Memory tests
@@ -75,7 +96,10 @@ class Antutu(ApkUiautoWorkload):
Known working APK version: 8.0.4
'''
supported_versions = ['7.0.4', '7.2.0', '8.0.4', '8.1.9', '9.1.6']
supported_versions = ['7.0.4', '7.2.0',
'8.0.4', '8.1.9', '8.4.5',
'9.1.6', '9.2.9',
'10.0.1-OB1', '10.0.6-OB6', '10.1.9', '10.2.1', '10.4.3']
parameters = [
Parameter('version', kind=str, allowed_values=supported_versions, override=True,
@@ -90,12 +114,24 @@ class Antutu(ApkUiautoWorkload):
super(Antutu, self).__init__(device, **kwargs)
self.gui.timeout = 1200
def initialize(self, context):
super(Antutu, self).initialize(context)
#Install the supporting benchmark
supporting_apk = context.get_resource(ApkFile(self, package='com.antutu.benchmark.full'))
self.target.install(supporting_apk)
#Ensure the orientation is set to portrait
self.target.set_rotation(0)
def setup(self, context):
self.gui.uiauto_params['version'] = self.version
super(Antutu, self).setup(context)
def extract_scores(self, context, regex_version):
#pylint: disable=no-self-use
#pylint: disable=no-self-use, too-many-locals
cpu = []
gpu = []
ux = []
mem = []
expected_results = len(regex_version)
logcat_file = context.get_artifact_path('logcat')
with open(logcat_file, errors='replace') as fh:
@@ -109,16 +145,98 @@ class Antutu(ApkUiautoWorkload):
result = float('NaN')
entry = regex.pattern.rsplit(None, 1)[0]
context.add_metric(entry, result, lower_is_better=False)
#Calculate group scores if 'CPU' in entry:
if 'CPU' in entry:
cpu.append(result)
cpu_result = sum(cpu)
if 'GPU' in entry:
gpu.append(result)
gpu_result = sum(gpu)
if any([i in entry for i in ['Data', 'Document', 'Image', 'User', 'Video']]):
ux.append(result)
ux_result = sum(ux)
if any([i in entry for i in ['RAM', 'ROM']]):
mem.append(result)
mem_result = sum(mem)
expected_results -= 1
if expected_results > 0:
msg = "The Antutu workload has failed. Expected {} scores, Detected {} scores."
raise WorkloadError(msg.format(len(regex_version), expected_results))
context.add_metric('CPU Total Score', cpu_result, lower_is_better=False)
context.add_metric('GPU Total Score', gpu_result, lower_is_better=False)
context.add_metric('UX Total Score', ux_result, lower_is_better=False)
context.add_metric('MEM Total Score', mem_result, lower_is_better=False)
#Calculate overall scores
overall_result = float(cpu_result + gpu_result + ux_result + mem_result)
context.add_metric('Overall Score', overall_result, lower_is_better=False)
def update_output(self, context):
super(Antutu, self).update_output(context)
if self.version.startswith('10'):
self.extract_scores(context, self.regex_matches_v10)
if self.version.startswith('9'):
self.extract_scores(context, self.regex_matches_v9)
if self.version.startswith('8'):
self.extract_scores(context, self.regex_matches_v8)
if self.version.startswith('7'):
self.extract_scores(context, self.regex_matches_v7)
class AntutuBDP(Workload):
name = "antutu_bdp"
description = '''
Workload for executing the BDP versions of the Antutu APK.
This will only work with specific APKS provided by Antutu but does
unlock command line automation and the capturing of a result file
as opposed to using UiAuto and Regex.
Known working version: 10.4.3-domesticAndroidFullBdp
'''
package_name = 'com.antutu.ABenchMark'
test_dir = '/sdcard/Android/data/com.antutu/ABenchMark/files/.antutu/'
result_file = '/sdcard/Documents/antutu/last_result.json'
def initialize(self, context):
super(AntutuBDP, self).initialize(context)
#Install the supporting benchmark
supporting_apk = context.get_resource(ApkFile(self, package='com.antutu.benchmark.full'))
self.target.install(supporting_apk)
#Launch the apk to initialize the test dir, then kill it
self.target.execute('am start {}/com.android.module.app.ui.test.activity.ActivityScoreBench'.format(self.package_name))
self.target.execute('am force-stop {}'.format(self.package_name))
#Copy the settings.xml to the test dir
settings_xml = context.get_resource(File(self, 'settings.xml'))
self.target.push(settings_xml, self.test_dir)
#Ensure the orientation is set to portrait
self.target.set_rotation(0)
#Remove any pre-existing test results
self.target.execute('rm {}'.format(self.result_file))
def run(self, context):
super(AntutuBDP, self).run(context)
#Launch the tests
activity = 'com.android.module.app.ui.start.ABenchMarkStart --ez isExternal true --es whereTo "test"'
self.target.execute('am start -n {}/{}'.format(self.package_name, activity))
#Wait 10 minutres, then begin polling every 30s for the test result to appear
self.logger.debug("Waiting 10 minutes before starting to poll for the results file.")
time.sleep(600)
#Poll for another 15 minutes, 20 minutes total before timing out
end_time = time.time() + 900
while time.time() < end_time:
if self.target.file_exists(self.result_file):
self.logger.debug("Result file found.")
return True
time.sleep(30)
self.logger.debug("File not found yet. Continuing polling.")
self.logger.warning("File not found within the configured timeout period. Exiting test.")
return False
def update_output(self, context):
super(AntutuBDP, self).update_output(context)
output_file = os.path.join(context.output_directory, 'antutu_results.json')
self.target.pull(self.result_file, output_file)
context.add_artifact('antutu_result', output_file, kind='data', description='Antutu output from target')