summaryrefslogtreecommitdiff
path: root/automated/android/apk-automation/glbenchmark25.py
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-03-30 18:54:46 +0100
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-04-28 09:50:02 +0000
commitab48dcadc4eb74a126a8d76bece720ab000b1452 (patch)
tree4cf508236cf2cf8d44ff2552bf7b2d7a6fdee58b /automated/android/apk-automation/glbenchmark25.py
parentd92cc5a7e7461e7fe493a3a1be0bbdc7a94f9892 (diff)
automated: android: add refactored apk-automation
Change-Id: I5a81b3c4317dc56f90df37c5a8f83d2547542fab Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
Diffstat (limited to 'automated/android/apk-automation/glbenchmark25.py')
-rwxr-xr-xautomated/android/apk-automation/glbenchmark25.py122
1 files changed, 122 insertions, 0 deletions
diff --git a/automated/android/apk-automation/glbenchmark25.py b/automated/android/apk-automation/glbenchmark25.py
new file mode 100755
index 0000000..657cd01
--- /dev/null
+++ b/automated/android/apk-automation/glbenchmark25.py
@@ -0,0 +1,122 @@
+import time
+import xml.dom.minidom
+from common import ApkTestRunner
+
+
+class ApkRunnerImpl(ApkTestRunner):
+ def __init__(self, config):
+ self.config = config
+ self.config['apk_file_name'] = 'GLBenchmark_2.5.1.apk'
+ self.config['apk_package'] = 'com.glbenchmark.glbenchmark25'
+ self.config['activity'] = 'com.glbenchmark.glbenchmark25/com.glbenchmark.activities.GLBenchmarkDownloaderActivity'
+ super(ApkRunnerImpl, self).__init__(self.config)
+
+ def setUp(self):
+ self.download_apk('main.1.com.glbenchmark.glbenchmark25.obb')
+ self.uninstall_apk(self.config['apk_package'])
+ self.install_apk(self.config['apk_file_name'])
+
+ # Push data and config files.
+ self.logger.info('Pushing main.1.com.glbenchmark.glbenchmark25.obb to target...')
+ self.call_adb('push %s/main.1.com.glbenchmark.glbenchmark25.obb /sdcard/Android/obb/com.glbenchmark.glbenchmark25/main.1.com.glbenchmark.glbenchmark25.obb' % self.config['apk_dir'])
+ self.logger.info('Pushing glbenchmark25-preferences.xml to target...')
+ self.call_adb('push ./glbenchmark25-preferences.xml /data/data/com.glbenchmark.glbenchmark25/shared_prefs/com.glbenchmark.glbenchmark25_preferences.xml')
+
+ # Clear logcat buffer.
+ self.call_adb("logcat -c")
+ self.call_adb("logcat -b events -c")
+ time.sleep(3)
+
+ # Start intent.
+ self.logger.info('Starting %s' % self.config['apk_package'])
+ self.call_adb("shell am start -W -S %s" % self.config['activity'])
+
+ def execute(self):
+ time.sleep(2)
+
+ self.vc.dump(window='-1')
+ test_type = self.vc.findViewWithText("Performance Tests")
+ if test_type:
+ test_type.touch()
+ time.sleep(2)
+
+ # By some reason in order to select all test, a back step is required
+ self.dump_always()
+ test_selection = self.vc.findViewByIdOrRaise("com.glbenchmark.glbenchmark25:id/buttonAll")
+ self.device.press('KEYCODE_BACK')
+ time.sleep(3)
+
+ test_type.touch()
+ time.sleep(2)
+ test_selection.touch()
+ self.logger.info("All selected!")
+ time.sleep(3)
+
+ # Disable crashed test suites
+ self.vc.dump(window='-1')
+ crashed_test_name = "C24Z24MS4"
+ self.logger.info('Test suite %s is going to be disabled!' % crashed_test_name)
+ crashed_test = self.vc.findViewWithText(crashed_test_name)
+ if crashed_test is not None:
+ crashed_test.touch()
+ self.logger.info('Test suite %s has been excluded!' % crashed_test_name)
+ time.sleep(2)
+ else:
+ self.logger.info('Can not find test suite %s, please check the screen!' % crashed_test_name)
+
+ # Start selected test suites
+ start_button = self.vc.findViewByIdOrRaise("com.glbenchmark.glbenchmark25:id/buttonStart")
+ start_button.touch()
+ time.sleep(2)
+
+ finished = False
+ while not finished:
+ time.sleep(120)
+ self.dump_always()
+ flag = self.vc.findViewWithText("Result processing")
+ if flag is not None:
+ self.logger.info('GLBenchmark Test Finished.')
+ finished = True
+ # Give up the result upload
+ cancel_button = self.vc.findViewWithText("Cancel")
+ if cancel_button is not None:
+ cancel_button.touch()
+ time.sleep(5)
+ else:
+ self.logger.error('Can not find cancel button! Please check the pop up window!')
+ else:
+ self.logger.info('GLBenchmark Test is still in progress...')
+
+ def getText(self, node):
+ children = node.childNodes
+ rc = []
+ for node in children:
+ if node.nodeType == node.TEXT_NODE:
+ rc.append(node.data)
+ return ''.join(rc)
+
+ def logparser(self, cached_result_file):
+ run_result = 'pass'
+ dom = xml.dom.minidom.parse(cached_result_file)
+ results = dom.getElementsByTagName('test_result')
+
+ for test in results:
+ title = self.getText(test.getElementsByTagName('title')[0])
+ test_type = self.getText(test.getElementsByTagName('type')[0])
+ score_number = self.getText(test.getElementsByTagName('score')[0])
+ fps = self.getText(test.getElementsByTagName('fps')[0])
+ score_unit = self.getText(test.getElementsByTagName('uom')[0])
+ benchmark_name = title.replace(" ", "-").replace(":", "") + "-" + test_type.replace(" ", "-").replace(":", "")
+ self.report_result(benchmark_name, run_result, score_number, score_unit)
+
+ if fps != "":
+ score_number = fps.split(" ")[0]
+ score_unit = fps.split(" ")[1]
+ self.report_result(benchmark_name, run_result, score_number, score_unit)
+
+ def parseResult(self):
+ cached_result_file = '%s/last-results-2.5.1-itr%s.xml' % (self.config['output'], self.config['itr'])
+ self.logger.info('pull /data/data/com.glbenchmark.glbenchmark25/cache/last_results_2.5.1.xml to output directory...')
+ self.call_adb('pull /data/data/com.glbenchmark.glbenchmark25/cache/last_results_2.5.1.xml %s' % cached_result_file)
+
+ self.logparser(cached_result_file)