diff options
35 files changed, 1791 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..fb152bb --- /dev/null +++ b/Android.mk @@ -0,0 +1,23 @@ +# Author: Linaro Android Team <linaro-dev@lists.linaro.org> +# +# These files are Copyright (C) 2012 Linaro Limited and they +# are licensed under the Apache License, Version 2.0. +# You may obtain a copy of this license at +# http://www.apache.org/licenses/LICENSE-2.0 + +local_target_dir := $(TARGET_OUT_DATA)/local/tmp +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_MODULE_TAGS := optional + +LOCAL_MODULE := linaro.android + +LOCAL_JAVA_LIBRARIES := uiautomator.core + +LOCAL_MODULE_PATH := $(local_target_dir) + +include $(BUILD_JAVA_LIBRARY) @@ -0,0 +1,21 @@ +This project is used to run benchmark applications in: +http://linaro-private.git.linaro.org/git/people/bhoj/benchmarks.git + +1. steps to run the uiautomator script: +* have a fully built Android source tree +* build the test: + mmm external/thirdparty-benchmarks +* deploy the test: + adb push ${OUT}/data/local/tmp/linaro.android.jar /data/local/tmp/ +* run the test: + adb shell uiautomator runtest linaro.android.jar \ + -c org.linaro.benchmarks.BenchmarksTestCase#${test_method} + +Steps to create new tests off it: +* open file src/org/linaro/benchmarks/BenchmarksTestCase.java +* add method like testLinpack + +2. steps to run the scripts in benchmarks-script directory +* checkout this git repository +* run command like "monkeyrunner benchmarks-script/antutu/run.py" for antutu test + diff --git a/benchmarks-script/andebench/run.py b/benchmarks-script/andebench/run.py new file mode 100644 index 0000000..32a2e8a --- /dev/null +++ b/benchmarks-script/andebench/run.py @@ -0,0 +1,52 @@ +import os +import re +import sys +import subprocess + +cur_dir = os.path.realpath(os.path.dirname(__file__)) +log_path = os.path.join(cur_dir, 'logcat_textview.log') +result_path = os.path.join(cur_dir, 'results.txt') + + +def checkResults(): + if not os.path.exists(log_path): + return + log_fd = open(log_path) + output = log_fd.readlines() + log_fd.close() + +# D/TextView( 4338): AndEMark Native: 4327 +# D/TextView( 4338): AndEMark Java: 181 + pat_str = ('^\s*D/TextView\s*\(\s*\d+\s*\)\s*:' + '\s*(?P<key>(AndEMark Native|AndEMark Java))\s*:' + '\s*(?P<value>\d+)\s*$') + pat = re.compile(pat_str) + res_hash = {} + for line in output: + match = pat.search(line) + if match: + data = match.groupdict() + res_hash[data['key']] = data['value'] + + f = open(result_path, "w") + for key, value in res_hash.items(): + f.write("%s=%s\n" % (key, value)) + f.close() + + +def main(): + dev_ids = [] + if len(sys.argv) >= 2: + dev_ids = sys.argv[1:] + else: + dev_ids = [''] + for dev_id in dev_ids: + if os.path.exists(result_path): + os.unlink(result_path) + run_sh = os.path.realpath(os.path.dirname(__file__)) + "/run.sh" + subprocess.call(['/bin/bash', run_sh, dev_id]) + checkResults() + + +if __name__ == '__main__': + main() diff --git a/benchmarks-script/andebench/run.sh b/benchmarks-script/andebench/run.sh new file mode 100755 index 0000000..5522c69 --- /dev/null +++ b/benchmarks-script/andebench/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#need to be defined for different benchmark apks +activity="com.eembc.coremark/.tabs" +apk_file_name="com.eembc.coremark-1.apk" +test_method="testAndEBench" +apk_package="com.eembc.coremark" + +#following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +main "$@" diff --git a/benchmarks-script/andebench/session.xml b/benchmarks-script/andebench/session.xml new file mode 100644 index 0000000..5579d1c --- /dev/null +++ b/benchmarks-script/andebench/session.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="US-ASCII" ?> +<session version="1" title="AndEBench" target_path="@F" call_stack_unwinding="yes" parse_debug_info="yes" high_resolution="no" buffer_mode="streaming" sample_rate="normal" duration="0"> +</session> diff --git a/benchmarks-script/antutu/run.py b/benchmarks-script/antutu/run.py new file mode 100644 index 0000000..1deb16d --- /dev/null +++ b/benchmarks-script/antutu/run.py @@ -0,0 +1,123 @@ +import os +import re +import subprocess +import sys + +cur_dir = os.path.realpath(os.path.dirname(__file__)) +log_path = os.path.join(cur_dir, 'logcat.log') +log_path_canvas = os.path.join(cur_dir, 'logcat_canvas.log') +result_path = os.path.join(cur_dir, 'results.txt') + + +def getResultFromCanvas(): + if not os.path.exists(log_path_canvas): + return + log_fd = open(log_path_canvas) + output = log_fd.readlines() + log_fd.close() + #D/Canvas ( 6368): RAM: + #D/Canvas ( 6368): 727 + #D/Canvas ( 6368): CPU integer: + #D/Canvas ( 6368): 1291 + #D/Canvas ( 6368): CPU float-point: + #D/Canvas ( 6368): 1049 + #D/Canvas ( 6368): 2D graphics: + #D/Canvas ( 6368): 293 + #D/Canvas ( 6368): 3D graphics: + #D/Canvas ( 6368): 1212 + #D/Canvas ( 6368): Database IO: + #D/Canvas ( 6368): 330 + #D/Canvas ( 6368): SD card write: + #D/Canvas ( 6368): 0 + #D/Canvas ( 6368): SD card read: + #D/Canvas ( 6368): 0 + tmp_hash = {'RAM': 'memory', + 'CPU integer': 'integer', + 'CPU float-point': 'float', + '2D graphics': 'score2d', + '3D graphics': 'score3d', + 'Database IO': 'database', + 'SD card write': 'sdwrite', + 'SD card read': 'sdread', + 'Total score': 'score' + } + res_hash = {} + for index in range(len(output)): + tmp_ary = output[index].split(':') + if len(tmp_ary) != 3: + index = index + 1 + continue + key = tmp_ary[1].strip() + if key in tmp_hash.keys(): + value = output[index + 1].split(':')[1].strip() + res_hash[tmp_hash[key]] = value + index = index + 2 + return res_hash + + +def checkResults(): + if not os.path.exists(log_path): + return + log_fd = open(log_path) + output = log_fd.readlines() + log_fd.close() + + #I/Antutu Benchmark( 3373): memory: 789 + #I/Antutu Benchmark( 3373): integer: 1319 + #I/Antutu Benchmark( 3373): float: 1084 + #I/Antutu Benchmark( 3373): score2d: 332 + #I/Antutu Benchmark( 3373): score3d: 1313 + #I/Antutu Benchmark( 3373): database: 260 + #I/Antutu Benchmark( 3373): sdwrite: 0 + #I/Antutu Benchmark( 3373): sdread: 0 + #I/Antutu Benchmark( 3373): score: 5097 + pat_str = ('^\s*I/Antutu Benchmark\s*\(\s*\d+\s*\)\s*:' + '\s*(?P<key>(memory|integer|float|score2d|score3d|' + 'database|sdwrite|sdread|score))\s*:' + '\s*(?P<score>\d+)\s*$' + ) + pat = re.compile(pat_str) + res_hash = {} + for line in output: + match = pat.search(line) + if not match: + continue + data = match.groupdict() + res_hash[data['key'].strip()] = data['score'].strip() + + if len(res_hash) == 0: + res_hash = getResultFromCanvas() + + tmp_hash = {'integer': 'Antutu CPU integer', + 'float': 'Antutu CPU float-point', + 'memory': 'Antutu RAM', + 'score2d': 'Antutu 2D graphics', + 'score3d': 'Antutu 3D graphics', + 'database': 'Antutu Database IO', + 'sdwrite': 'Antutu SD card write', + 'sdread': 'Antutu SD card read', + 'score': 'Antutu Total' + } + f = open(result_path, "w") + for key in res_hash.keys(): + f.write('%s=%s\n' % (tmp_hash[key], res_hash.get(key))) + f.close() + + +def main(): + + dev_ids = [] + if len(sys.argv) >= 2: + dev_ids = sys.argv[1:] + else: + dev_ids = [''] + for dev_id in dev_ids: + if os.path.exists(result_path): + os.unlink(result_path) + run_sh = os.path.realpath(os.path.dirname(__file__)) + "/run.sh" + subprocess.call(['/bin/bash', run_sh, dev_id]) + checkResults() + + +if __name__ == '__main__': + main() diff --git a/benchmarks-script/antutu/run.sh b/benchmarks-script/antutu/run.sh new file mode 100755 index 0000000..66dc194 --- /dev/null +++ b/benchmarks-script/antutu/run.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +#need to be defined for different benchmark apks +activity="com.antutu.ABenchMark/.ABenchMarkStart" +apk_file_name="com.antutu.ABenchMark-1.apk" +test_method="testAntutu" +apk_package="com.antutu.ABenchMark" + +function change_no_update(){ + user=`adb shell ls -l /data/data/|grep com.antutu.ABenchMark|cut -d \ -f 2` + user=`echo ${user}|sed 's/\r//'` + dir_prefs="/data/data/com.antutu.ABenchMark/shared_prefs" + adb push ${parent_dir}/shared_prefs "${dir_prefs}" + adb shell chown ${user}:${user} "${dir_prefs}" + adb shell chmod 700 "${dir_prefs}" + adb shell chown ${user}:${user} "${dir_prefs}/com.antutu.ABenchMark_preferences.xml" + adb shell chmod 660 "${dir_prefs}/com.antutu.ABenchMark_preferences.xml" +} + +#following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +post_install="change_no_update" +main "$@" diff --git a/benchmarks-script/antutu/session.xml b/benchmarks-script/antutu/session.xml new file mode 100644 index 0000000..7843358 --- /dev/null +++ b/benchmarks-script/antutu/session.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="US-ASCII" ?> +<session version="1" title="Antutu" target_path="@F" call_stack_unwinding="yes" parse_debug_info="yes" high_resolution="no" buffer_mode="streaming" sample_rate="normal" duration="0"> +</session> diff --git a/benchmarks-script/antutu/shared_prefs/com.antutu.ABenchMark_preferences.xml b/benchmarks-script/antutu/shared_prefs/com.antutu.ABenchMark_preferences.xml new file mode 100644 index 0000000..e6f0315 --- /dev/null +++ b/benchmarks-script/antutu/shared_prefs/com.antutu.ABenchMark_preferences.xml @@ -0,0 +1,6 @@ +<?xml version='1.0' encoding='utf-8' standalone='yes' ?> +<map> +<int name="lastVersionCode" value="63" /> +<boolean name="frist_start" value="false" /> +<boolean name="setting_update" value="false" /> +</map> diff --git a/benchmarks-script/caffeinemark/run.py b/benchmarks-script/caffeinemark/run.py new file mode 100644 index 0000000..ddd6aa3 --- /dev/null +++ b/benchmarks-script/caffeinemark/run.py @@ -0,0 +1,71 @@ +import os +import re +import sys +import subprocess + +cur_dir = os.path.realpath(os.path.dirname(__file__)) +log_path = os.path.join(cur_dir, 'logcat_textview.log') +result_path = os.path.join(cur_dir, 'results.txt') + + +def checkResults(): + if not os.path.exists(log_path): + return + log_fd = open(log_path) + output = log_fd.readlines() + log_fd.close() + +# D/TextView( 7764): Sieve +# D/TextView( 7764): 8426 +# D/TextView( 7764): Loop +# D/TextView( 7764): 17864 +# D/TextView( 7764): Logic +# D/TextView( 7764): 11095 +# D/TextView( 7764): String +# D/TextView( 7764): 10029 +# D/TextView( 7764): Float +# D/TextView( 7764): 7084 +# D/TextView( 7764): Method +# D/TextView( 7764): 5424 + + key_pat_str = ('^\s*D/TextView\s*\(\s*(?P<pid>\d+)\s*\)\s*:' + '\s*(?P<key>(Sieve|Loop|Logic|String|Float|Method))\s*$') + key_pat = re.compile(key_pat_str) + res_hash = {} + for index in range(len(output)): + line = output[index] + match = key_pat.search(line) + if match: + data = match.groupdict() + key = data['key'] + value = output[index + 1].split(':')[1].strip() + res_hash[key] = value + index = index + 2 + else: + index = index + 1 + + f = open(result_path, "w") + keys = ['Sieve', 'Loop', 'Logic', 'String', 'Float', 'Method'] + for key in keys: + value = res_hash.get(key, '0') + f.write("CaffeineMark %s=%s\n" % (key, value)) + f.close() + + +def main(): + + dev_ids = [] + if len(sys.argv) >= 2: + dev_ids = sys.argv[1:] + else: + dev_ids = [''] + for dev_id in dev_ids: + if os.path.exists(result_path): + os.unlink(result_path) + run_sh = os.path.realpath(os.path.dirname(__file__)) + "/run.sh" + subprocess.call(['/bin/bash', run_sh, dev_id]) + checkResults() + + +if __name__ == '__main__': + main() diff --git a/benchmarks-script/caffeinemark/run.sh b/benchmarks-script/caffeinemark/run.sh new file mode 100755 index 0000000..668917b --- /dev/null +++ b/benchmarks-script/caffeinemark/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#need to be defined for different benchmark apks +activity="com.flexycore.caffeinemark/.Application" +apk_file_name="com.flexycore.caffeinemark-1.apk" +test_method="testCaffeine" +apk_package="com.flexycore.caffeinemark" + +#following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +main "$@" diff --git a/benchmarks-script/caffeinemark/session.xml b/benchmarks-script/caffeinemark/session.xml new file mode 100644 index 0000000..6223cb6 --- /dev/null +++ b/benchmarks-script/caffeinemark/session.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="US-ASCII" ?> +<session version="1" title="CaffeineMark" target_path="@F" call_stack_unwinding="yes" parse_debug_info="yes" high_resolution="no" buffer_mode="streaming" sample_rate="normal" duration="0"> +</session> diff --git a/benchmarks-script/common/common.sh b/benchmarks-script/common/common.sh new file mode 100755 index 0000000..78bc3fa --- /dev/null +++ b/benchmarks-script/common/common.sh @@ -0,0 +1,306 @@ +#!/bin/bash + +#base_url="scp://linaro-lava@mombin.canonical.com/home/yongqinliu/benchmark-apks/" +base_url="ssh://linaro-lava@linaro-private.git.linaro.org/srv/linaro-private.git.linaro.org/people/yongqinliu/benchmark-apks.git" +png_dir_device="/data/local/tmp/" +post_install="" +pre_uninstall="" +do_streamline=false + + +function install_linaro_android_jar(){ + jar_name="linaro.android.jar" + tgt_path="/data/local/tmp/${jar_name}" + jar_url="http://testdata.validation.linaro.org/tools/${jar_name}" + exist=`adb shell "ls ${tgt_path} 2>/dev/null"` + if [ -z "${exist}" ]; then + wget ${jar_url} -O ${jar_name} + adb push ${jar_name} ${tgt_path} + rm -f ${jar_name} + fi +} + +function delete_png_files_on_device(){ + png_dir=${1-$png_dir_device} + png_files=`adb shell "ls ${png_dir}/*.png 2>/dev/null"` + for png_f in ${png_files}; do + png_f=`echo ${png_f}|sed 's/\r//'` + adb shell rm "${png_f}" + done +} + +function pull_png_files_from_device(){ + src_dir_device=${1-"${png_dir_device}"} + tgt_dir_local=${2-"${parent_dir}"} + png_files=`adb shell "ls ${png_dir}/*.png 2>/dev/null"` + for png_f in ${png_files}; do + png_f=`echo ${png_f}|sed 's/\r//'` + adb pull "${png_f}" "${tgt_dir_local}" &>/dev/null + done +} + +function init(){ + + install_linaro_android_jar + + #uninstall the apk application + adb uninstall "${apk_package}" + #clear the logcat information + adb logcat -c + sleep 5 + + rm -fr "${parent_dir}"/*.png 2>/dev/null + delete_png_files_on_device "${png_dir_device}" + + disableRotationapk="${APKS_DIR}/RotationOff.apk" + if [ -f "{$disableRotationapk}" ]; then + echo "The file(${disableRotationapk}) already exists." + else + get_file_with_base_url "RotationOff.apk" + fi + adb install "${disableRotationapk}" + sleep 2 + adb shell am start 'rotation.off/.RotationOff' + sleep 2 + adb shell "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor > /data/governor.txt" + adb shell "echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" + adb shell "echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor" + adb shell logcat -c + adb shell setprop ro.debug.drawtext true + adb shell setprop ro.debug.textview true + adb shell setprop ro.debug.loadDataWithBaseURL true + logcat_file="${parent_dir}/logcat.log" + echo "---------------------------------------------------" + echo "A new test is started:`date`" |tee -a "${logcat_file}" + adb logcat >>${logcat_file} & + export LOGCAT_PID=$! +} + + +function cleanup(){ + adb shell "cat /data/governor.txt > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" + adb shell "cat /data/governor.txt > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor" + adb shell rm /data/governor.txt + adb shell setprop ro.debug.drawtext false + adb shell setprop ro.debug.textview false + adb shell setprop ro.debug.loadDataWithBaseURL false + adb uninstall rotation.off + if [ -n "${LOGCAT_PID}" ]; then + kill -9 ${LOGCAT_PID} + fi +} + +function export_serial(){ + serial="${1}" && shift + if [ -n "${serial}" ]; then + export ANDROID_SERIAL=${serial} + else + serial=`adb get-serialno|sed 's/\r//g'` + if [ "X${serial}" == "Xunknown" ]; then + echo "Can not get the serial number autotically," + echo "Please specify the serial number with the -s option" + exit 1 + else + export ANDROID_SERIAL=${serial} + fi + fi +} + +function export_parent_dir(){ + old_pwd=`pwd` + cd ${parent_dir} + parent_dir=`pwd` + cd ${old_pwd} + export parent_dir=${parent_dir} +} + +function export_apks_dir(){ + export APKS_DIR="${parent_dir}/../benchmark-apks" +} + +function get_file_with_base_url(){ + file_name="${1}" && shift + + if [ -z "${file_name}" ]; then + echo "File name must be passed!" + exit 1 + fi + + if [ -f "${APKS_DIR}/${file_name}" ]; then + echo "The file(${APKS_DIR}/${file_name}) already exists." + return + fi + if [[ "${base_url}" =~ "scp://" ]]; then + mkdir -p "${APKS_DIR}" + apk_url="${base_url}/${file_name}" + url_no_scp=`echo ${apk_url}|sed 's/^\s*scp\:\/\///'|sed 's/\//\:\//'` + scp "${url_no_scp}" "${APKS_DIR}/${file_name}" + if [ $? -ne 0 ]; then + echo "Failed to get the apk(${file_name}) with ${base_url}" + exit 1 + fi + elif [[ "${base_url}" =~ "ssh://" ]]; then + rm -fr "${APKS_DIR}" + git clone "${base_url}" "${APKS_DIR}" + if [ $? -ne 0 ]; then + echo "Failed to get the apks with ${base_url}" + exit 1 + fi + else + echo "Failed to get the file($file_name)." + echo "The schema of the ${base_url} is not supported now!" + exit 1 + fi +} + +function install_run_uninstall(){ + #install the apk files + apk_file="${APKS_DIR}/${apk_file_name}" + adb install "${apk_file}" + if [ $? -ne 0 ]; then + echo "Failed to install ${apk_file}." + exit 1 + fi + if [ -n "${post_install}" ]; then + ${post_install} + fi + adb shell am start "${activity}" + sleep 5 + adb shell am kill-all + sleep 5 + streamline_init_capture + adb shell uiautomator runtest linaro.android.jar -c org.linaro.benchmarks.BenchmarksTestCase#${test_method} + sleep 5 + streamline_end_capture + if [ -n "${pre_uninstall}" ]; then + ${pre_uninstall} + fi + adb uninstall "${apk_package}" +} + +function collect_log(){ + sleep 5 + adb logcat -d -s "TextView" >${parent_dir}/logcat_textview.log + sleep 5 + adb logcat -d -s "Canvas" >${parent_dir}/logcat_canvas.log + sleep 5 + adb logcat -d -s "WebViewClassic.loadDataWithBaseURL" >${parent_dir}/logcat_webview.log + sleep 5 +} + +function streamline_locate(){ + which streamline >&/dev/null + return $? +} + +function streamline_init_capture(){ + if ! ${do_streamline}; then + return + fi + if ! streamline_locate; then + echo "There is no streamline command found." + echo "Please check your environment variable or install it" + return + fi + + echo "Start Streamline Capture.. " + adb shell "rm -r /data/streamline 2>/dev/null" + adb shell mkdir /data/streamline + session_file="${parent_dir}/session.xml" + adb push $session_file /data/streamline + app_name=`basename $parent_dir` + adb shell "gatord -s /data/streamline/session.xml -o /data/streamline/${app_name}.apc &" + adb shell sleep 2 +} + +function streamline_end_capture(){ + if ! ${do_streamline}; then + return + fi + if ! streamline_locate; then + return + fi + + echo "End Streamline Capture.. " + ps_info=`adb shell ps -x | grep -E '\s+gatord\s+'` + ##TODO maybe have multiple lines here + pid=`echo $ps_info|cut -d \ -f 2|sed 's/\r//'` + if [ -n "${pid}" ]; then + adb shell kill $pid + fi + + echo "Start Processing Streamline data." + app_name=`basename $parent_dir` + capture_dir="$parent_dir/${app_name}.apc" + rm -fr ${capture_dir} + adb pull /data/streamline/${app_name}.apc $capture_dir + if [ $? -ne 0 ]; then + echo "Failed to pull the streamline data from android!" + exit 1 + fi + streamline -analyze ${capture_dir} + if [ $? -ne 0 ]; then + echo "Failed to analyze the streamline data!" + exit 1 + fi + apd_f="${app_name}.apd" + streamline -report -function ${apd_f} |tee ${parent_dir}/streamlineReport.txt + if [ $? -ne 0 ]; then + echo "Failed to generate the streamline report!" + exit 1 + fi + ##TODO detail parse should be done in run.py + rm -fr ${capture_dir} + adb shell rm -r /data/streamline +} +function show_usage(){ + echo "`basename $0` [--base-url|-b <base-url>] [<device-serial>] [--streamline]" + echo "`basename $0` --help|-h" +} + +function parse_arguments(){ + while test -n "$1"; do + case "$1" in + --help|-h) + show_usage + exit 1 + ;; + --streamline|-s) + do_streamline=true + shift 1 + ;; + "--base-url"|-b) + if [ -z "$2" ]; then + show_usage + exit 1 + else + base_url="$2" + shift 2 + fi + ;; + *) + if [ -n "${arg_serial}" ]; then + echo "Too many arguments are given!" + show_usage + exit 1 + fi + arg_serial="$1" + shift 1 + ;; + esac + done +} + +function main(){ + arg_serial="" + parse_arguments "$@" + export_serial "${arg_serial}" + export_parent_dir + export_apks_dir + init + get_file_with_base_url "${apk_file_name}" + install_run_uninstall + pull_png_files_from_device "${png_dir_device}" ${parent_dir} + collect_log + cleanup +} diff --git a/benchmarks-script/geekbench/run.py b/benchmarks-script/geekbench/run.py new file mode 100644 index 0000000..173476b --- /dev/null +++ b/benchmarks-script/geekbench/run.py @@ -0,0 +1,87 @@ +import os +import re +import sys +import subprocess + +cur_dir = os.path.realpath(os.path.dirname(__file__)) +log_path = os.path.join(cur_dir, 'logcat_webview.log') +result_path = os.path.join(cur_dir, 'results.txt') + + +def checkResults(): + + if not os.path.exists(log_path): + return + log_fd = open(log_path) + lines = log_fd.readlines() + log_fd.close() + + usefull_info = [] + begin_pat_str = ('^\s*D/WebViewClassic.loadDataWithBaseURL\(\s*\d+\s*\)' + '\s*:\s*(?P<content>\<.*)\s*$') + begin_pat = re.compile(begin_pat_str) + replace_pat = re.compile('<[^>]*>') + found_start_of_integer_perf = False + for line in lines: + + if not found_start_of_integer_perf: + if line.find('overall-score') == -1 and \ + line.find('Geekbench Score') == -1: + if line.find('<h1>Integer Performance</h1>') == -1: + continue + else: + found_start_of_integer_perf = True + + match = begin_pat.search(line) + if not match: + continue + data = match.groupdict() + value = data['content'].strip() + if value.find('<h1>') > -1: + continue + value = re.sub(replace_pat, '', value) + if not value.strip(): + continue + usefull_info.append(value) + + res_ary = [] + index = 0 + while index < len(usefull_info): + line = usefull_info[index].strip() + if line.find("Score") > -1: + res_ary.append({'key': line, + 'value': usefull_info[index + 1].strip()}) + index = index + 2 + else: + key = "%s_%s" % (line, usefull_info[index + 1].strip()) + res_ary.append({'key': "%s Score" % key, + 'value': usefull_info[index + 2].strip()}) + res_ary.append({'key': key, + 'value': usefull_info[index + 3].strip()}) + index = index + 4 + + result_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), + 'results.txt') + res_fd = open(result_path, 'w') + for test_hash in res_ary: + res_fd.write('%s=%s\n' % (test_hash.get('key'), + test_hash.get('value'))) + res_fd.close() + + +def main(): + + dev_ids = [] + if len(sys.argv) >= 2: + dev_ids = sys.argv[1:] + else: + dev_ids = [''] + for dev_id in dev_ids: + if os.path.exists(result_path): + os.unlink(result_path) + run_sh = os.path.realpath(os.path.dirname(__file__)) + "/run.sh" + subprocess.call(['/bin/bash', run_sh, dev_id]) + checkResults() + +if __name__ == '__main__': + main() diff --git a/benchmarks-script/geekbench/run.sh b/benchmarks-script/geekbench/run.sh new file mode 100755 index 0000000..e06c610 --- /dev/null +++ b/benchmarks-script/geekbench/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#need to be defined for different benchmark apks +activity="ca.primatelabs.geekbench2/.HomeActivity" +apk_file_name="ca.primatelabs.geekbench2-1.apk" +test_method="testGeekbench" +apk_package="ca.primatelabs.geekbench2" + +#following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +main "$@" diff --git a/benchmarks-script/geekbench/session.xml b/benchmarks-script/geekbench/session.xml new file mode 100644 index 0000000..a3fb1b0 --- /dev/null +++ b/benchmarks-script/geekbench/session.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="US-ASCII" ?> +<session version="1" title="GeekBench" target_path="@F" call_stack_unwinding="yes" parse_debug_info="yes" high_resolution="no" buffer_mode="streaming" sample_rate="normal" duration="0"> +</session> diff --git a/benchmarks-script/glbenchmark/run.py b/benchmarks-script/glbenchmark/run.py new file mode 100644 index 0000000..426a856 --- /dev/null +++ b/benchmarks-script/glbenchmark/run.py @@ -0,0 +1,66 @@ +import os +import sys +import subprocess +import xml.dom.minidom + +parent_dir = os.path.realpath(os.path.dirname(__file__)) +res_path = os.path.join(parent_dir, 'results.txt') +result_f = os.path.join(parent_dir, 'last_results_2.5.1.xml') + + +def getText(node): + children = node.childNodes + rc = [] + for node in children: + if node.nodeType == node.TEXT_NODE: + rc.append(node.data) + return ''.join(rc) + + +def parseLog(res_file=result_f): + if not res_file: + return [] + if not os.path.exists(res_file): + print "File(%s) does not exist" % res_file + return [] + + result_list = [] + try: + dom = xml.dom.minidom.parse(res_file) + results = dom.getElementsByTagName('test_result') + for test in results: + title = getText(test.getElementsByTagName('title')[0]) + test_type = getText(test.getElementsByTagName('type')[0]) + score = getText(test.getElementsByTagName('score')[0]) + fps = getText(test.getElementsByTagName('fps')[0]) + uom = getText(test.getElementsByTagName('uom')[0]) + test_case_id = "%s_%s" % (title, test_type) + result_list.append("%s=%s %s" % (test_case_id, score, uom)) + if fps: + result_list.append("%s_fps=%s" % (test_case_id, fps)) + except Exception, e: + print "Has exception to parse the xml filei: %s" % res_file + print "Exception: %s" % e + + res_fd = open(res_path, 'w') + for line in result_list: + res_fd.write('%s\n' % line) + res_fd.close() + + +def main(): + dev_ids = [] + if len(sys.argv) >= 2: + dev_ids = sys.argv[1:] + else: + dev_ids = [''] + for dev_id in dev_ids: + if os.path.exists(res_path): + os.unlink(res_path) + run_sh = os.path.realpath(os.path.dirname(__file__)) + "/run.sh" + subprocess.call(['/bin/bash', run_sh, dev_id]) + parseLog() + + +if __name__ == '__main__': + main() diff --git a/benchmarks-script/glbenchmark/run.sh b/benchmarks-script/glbenchmark/run.sh new file mode 100755 index 0000000..2c6f838 --- /dev/null +++ b/benchmarks-script/glbenchmark/run.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +#need to be defined for different benchmark apks +activity="com.glbenchmark.glbenchmark25/com.glbenchmark.activities.GLBenchmarkDownloaderActivity" +#apk_file_name="GLBenchmark_v2.5.apk" +apk_file_name="GLBenchmark_2.5.1.apk" +test_method="testGLBenchmark" +apk_package="com.glbenchmark.glbenchmark25" + +function func_post_install(){ + #get the obb file and push it into android + mkdir -p "${parent_dir}/Android/obb/com.glbenchmark.glbenchmark25" + obb_file_name="main.1.com.glbenchmark.glbenchmark25.obb" + obb_file_path="${parent_dir}/Android/obb/com.glbenchmark.glbenchmark25/${obb_file_name}" + if [ ! -f "${obb_file_path}" ]; then + get_file_with_base_url "${obb_file_name}" + cp -uvf "${APKS_DIR}/${obb_file_name}" "${parent_dir}/Android/obb/com.glbenchmark.glbenchmark25/${obb_file_name}" + fi + adb push ${parent_dir}/Android /storage/sdcard0/Android + + user=`adb shell ls -l /data/data/|grep com.glbenchmark.glbenchmark25|cut -d \ -f 2` + user=`echo ${user}|sed 's/\r//'` + dir_prefs="/data/data/com.glbenchmark.glbenchmark25/shared_prefs" + adb push ${parent_dir}/shared_prefs "${dir_prefs}" + adb shell chown ${user}:${user} "${dir_prefs}" + adb shell chmod 771 "${dir_prefs}" + adb shell chown ${user}:${user} "${dir_prefs}/com.glbenchmark.glbenchmark25_preferences.xml" + adb shell chmod 660 "${dir_prefs}/com.glbenchmark.glbenchmark25_preferences.xml" +} + +#following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +post_install="func_post_install" +pre_uninstall="adb pull /data/data/com.glbenchmark.glbenchmark25/cache/last_results_2.5.1.xml $parent_dir/last_results_2.5.1.xml" +main "$@" diff --git a/benchmarks-script/glbenchmark/session.xml b/benchmarks-script/glbenchmark/session.xml new file mode 100644 index 0000000..dd85cbd --- /dev/null +++ b/benchmarks-script/glbenchmark/session.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="US-ASCII" ?> +<session version="1" title="GLBenchMark" target_path="@F" call_stack_unwinding="yes" parse_debug_info="yes" high_resolution="no" buffer_mode="streaming" sample_rate="normal" duration="0"> +</session> diff --git a/benchmarks-script/glbenchmark/shared_prefs/com.glbenchmark.glbenchmark25_preferences.xml b/benchmarks-script/glbenchmark/shared_prefs/com.glbenchmark.glbenchmark25_preferences.xml new file mode 100644 index 0000000..1315e4c --- /dev/null +++ b/benchmarks-script/glbenchmark/shared_prefs/com.glbenchmark.glbenchmark25_preferences.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='utf-8' standalone='yes' ?> +<map> +<string name="edition">COMMUNITY</string> +<string name="username">androidcommunityuser</string> +<string name="customoffscreenresolution">1920x1080</string> +<boolean name="batterytest" value="false" /> +<boolean name="dontshowdialogregisterwarning" value="true" /> +<string name="customresolution">0x0</string> +<boolean name="offscreenbutton" value="true" /> +<string name="devicename">pandaboard</string> +<boolean name="disableupload" value="true" /> +<string name="password">asdojavmdthjwejgasogaouhgaufiuadxfoafgaosdcjaocaod</string> +<boolean name="onscreenbutton" value="true" /> +</map> diff --git a/benchmarks-script/linpack/run.py b/benchmarks-script/linpack/run.py new file mode 100644 index 0000000..7b396b7 --- /dev/null +++ b/benchmarks-script/linpack/run.py @@ -0,0 +1,53 @@ +import os +import sys +import subprocess + +cur_dir = os.path.realpath(os.path.dirname(__file__)) +log_path = os.path.join(cur_dir, 'logcat.log') +result_path = os.path.join(cur_dir, 'results.txt') + + +def checkResults(): + if not os.path.exists(log_path): + return + log_fd = open(log_path) + output = log_fd.readlines() + log_fd.close() + + linpack_st = 0 + linpack_mt = 0 + for index in range(len(output)): + line = output[index] + if line.find("D/TextView(") == -1: + continue + if (line.find('Inaccurate Result') > 0): + words = output[index - 3].split() + linpack_st = words[len(words) - 1].strip() + + if (line.find('Inconsistent Result') > 0): + words = output[index - 3].split() + linpack_mt = words[len(words) - 1].strip() + break + + f = open(result_path, "w") + f.write("LinPack_ST=" + str(linpack_st) + "\n") + f.write("LinPack_MT=" + str(linpack_mt) + "\n") + f.close() + + +def main(): + + dev_ids = [] + if len(sys.argv) >= 2: + dev_ids = sys.argv[1:] + else: + dev_ids = [''] + for dev_id in dev_ids: + if os.path.exists(result_path): + os.unlink(result_path) + run_sh = os.path.realpath(os.path.dirname(__file__)) + "/run.sh" + subprocess.call(['/bin/bash', run_sh, dev_id]) + checkResults() + +if __name__ == '__main__': + main() diff --git a/benchmarks-script/linpack/run.sh b/benchmarks-script/linpack/run.sh new file mode 100755 index 0000000..0d71c73 --- /dev/null +++ b/benchmarks-script/linpack/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#need to be defined for different benchmark apks +activity="com.greenecomputing.linpack/.Linpack" +apk_file_name="com.greenecomputing.linpack-1.apk" +test_method="testLinpack" +apk_package="com.greenecomputing.linpack" + +#following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +main "$@" diff --git a/benchmarks-script/linpack/session.xml b/benchmarks-script/linpack/session.xml new file mode 100644 index 0000000..8db25ba --- /dev/null +++ b/benchmarks-script/linpack/session.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="US-ASCII" ?> +<session version="1" title="LinPack" target_path="@F" call_stack_unwinding="yes" parse_debug_info="yes" high_resolution="no" buffer_mode="streaming" sample_rate="normal" duration="0"> +</session> diff --git a/benchmarks-script/nbench/run.py b/benchmarks-script/nbench/run.py new file mode 100644 index 0000000..e777573 --- /dev/null +++ b/benchmarks-script/nbench/run.py @@ -0,0 +1,54 @@ +import os +import re +import sys +import subprocess + +cur_dir = os.path.realpath(os.path.dirname(__file__)) +log_path = os.path.join(cur_dir, 'logcat_textview.log') +result_path = os.path.join(cur_dir, 'results.txt') + +def parseLog(log_file=log_path): + test_ids = ['NUMERIC SORT', + 'STRING SORT', + 'BITFIELD', + 'FP EMULATION', + 'FOURIER', + 'ASSIGNMENT', + 'IDEA', + 'HUFFMAN', + 'NEURAL NET', + 'LU DECOMPOSITION'] + results = {} + if not os.path.exists(log_file): + return + + log_fd = open(log_file) + for line in log_fd.readlines(): + for test_id in test_ids: + if line.find(test_id) >= 0: + elements = line.split(':') + results[test_id] = elements[2].strip() + log_fd.close() + + res_fd = open(result_path, "w") + for test_id in results.keys(): + res_fd.write('%s=%s\n' % (test_id, results[test_id])) + res_fd.close() + + +def main(): + dev_ids = [] + if len(sys.argv) >= 2: + dev_ids = sys.argv[1:] + else: + dev_ids = [''] + for dev_id in dev_ids: + if os.path.exists(result_path): + os.unlink(result_path) + run_sh = os.path.realpath(os.path.dirname(__file__)) + "/run.sh" + subprocess.call(['/bin/bash', run_sh, dev_id]) + parseLog() + + +if __name__ == '__main__': + main() diff --git a/benchmarks-script/nbench/run.sh b/benchmarks-script/nbench/run.sh new file mode 100755 index 0000000..a96c77f --- /dev/null +++ b/benchmarks-script/nbench/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#need to be defined for different benchmark apks +activity="com.drolez.nbench/.MainActivity" +apk_file_name="com.drolez.nbench-1.apk" +test_method="testNBench" +apk_package="com.drolez.nbench" + +#following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +main "$@" diff --git a/benchmarks-script/nbench/session.xml b/benchmarks-script/nbench/session.xml new file mode 100644 index 0000000..7f5cb6d --- /dev/null +++ b/benchmarks-script/nbench/session.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="US-ASCII" ?> +<session version="1" title="nBench" target_path="@F" call_stack_unwinding="yes" parse_debug_info="yes" high_resolution="no" buffer_mode="streaming" sample_rate="normal" duration="0"> +</session> diff --git a/benchmarks-script/quadrant/run.py b/benchmarks-script/quadrant/run.py new file mode 100644 index 0000000..4615304 --- /dev/null +++ b/benchmarks-script/quadrant/run.py @@ -0,0 +1,56 @@ +import os +import re +import sys +import subprocess + +cur_dir = os.path.realpath(os.path.dirname(__file__)) +log_path = os.path.join(cur_dir, 'logcat_canvas.log') +result_path = os.path.join(cur_dir, 'results.txt') + + +def parseLog(log_file=log_path): + if not os.path.exists(log_file): + return + res_f = open(log_file) + lines = res_f.readlines() + res_f.close() + + pat_str = ( + '^\s*D/Canvas\s*\(\s*\d+\s*\)\s*:' + '\s*(?P<key>(Total|CPU|Mem|I/O|2D|3D))\s*:' + '\s*(?P<score>\d+)\s*$' + ) + pat = re.compile(pat_str) + res_hash = {} + for line in lines: + match = pat.search(line) + if not match: + continue + data = match.groupdict() + res_hash[data['key'].strip()] = data['score'].strip() + + result_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), + 'results.txt') + res_fd = open(result_path, 'w') + for key in res_hash.keys(): + res_fd.write('%s=%s\n' % (key, + res_hash.get(key))) + res_fd.close() + + +def main(): + dev_ids = [] + if len(sys.argv) >= 2: + dev_ids = sys.argv[1:] + else: + dev_ids = [''] + for dev_id in dev_ids: + if os.path.exists(result_path): + os.unlink(result_path) + run_sh = os.path.realpath(os.path.dirname(__file__)) + "/run.sh" + subprocess.call(['/bin/bash', run_sh, dev_id]) + parseLog() + + +if __name__ == '__main__': + main() diff --git a/benchmarks-script/quadrant/run.sh b/benchmarks-script/quadrant/run.sh new file mode 100755 index 0000000..d436618 --- /dev/null +++ b/benchmarks-script/quadrant/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#need to be defined for different benchmark apks +activity="com.aurorasoftworks.quadrant.ui.standard/.QuadrantStandardLauncherActivity" +apk_file_name="com.aurorasoftworks.quadrant.ui.standard-1.apk" +test_method="testQuadrant" +apk_package="com.aurorasoftworks.quadrant.ui.standard" + +#following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +main "$@" diff --git a/benchmarks-script/quadrant/session.xml b/benchmarks-script/quadrant/session.xml new file mode 100644 index 0000000..d7ce585 --- /dev/null +++ b/benchmarks-script/quadrant/session.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="US-ASCII" ?> +<session version="1" title="Quadrant" target_path="@F" call_stack_unwinding="yes" parse_debug_info="yes" high_resolution="no" buffer_mode="streaming" sample_rate="normal" duration="0"> +</session> diff --git a/benchmarks-script/vellamo/run.py b/benchmarks-script/vellamo/run.py new file mode 100644 index 0000000..1cdc4f7 --- /dev/null +++ b/benchmarks-script/vellamo/run.py @@ -0,0 +1,72 @@ +import os +import sys +import subprocess + +parent_dir = os.path.realpath(os.path.dirname(__file__)) +res_path = os.path.join(parent_dir, 'results.txt') + + +sub_items_count_hash = { + "Total Score": 0, + "See The Sun Canvas": 7, + "Deep Sea Canvas": 3, + "Aquarium Canvas": 5, + "Pixel Blender": 5, + "Surf Wax Binder": 5, + "Sun Spider (Online)": 3, + "V8 Benchmark (Online)": 3, + "Ocean Flinger": 10, + "Image Flinger": 10, + "Text Flinger": 10, + "Networking Loader": 10, + "HTML5 Video (Online)": 2, + "WebGL (Online)": 2, + "Page Loader & Reloader (Online)": 3 +} + + +def parseLog(): + if not os.path.exists(res_path): + return + + res_f = open(res_path) + contents = res_f.readlines() + res_f.close() + + index = 0 + while index < len(contents): + line = contents[index].strip() + if line.find("' ") > -1: + line = line.replace("' ", '.').replace('"', "'") + contents[index] = '%s\n' % line + for key in sub_items_count_hash.keys(): + if line.find(key) > -1: + count = sub_items_count_hash.get(key) + for i in range(1, count + 1): + contents[index + i] = "%s %s\n" % (key, + contents[index + i].strip()) + index = index + count + 1 + break + + res_f = open(res_path, 'w') + for line in contents: + res_f.write(line) + res_f.close() + + +def main(): + dev_ids = [] + if len(sys.argv) >= 2: + dev_ids = sys.argv[1:] + else: + dev_ids = [''] + for dev_id in dev_ids: + if os.path.exists(res_path): + os.unlink(res_path) + run_sh = os.path.realpath(os.path.dirname(__file__)) + "/run.sh" + subprocess.call(['/bin/bash', run_sh, dev_id]) + parseLog() + + +if __name__ == '__main__': + main() diff --git a/benchmarks-script/vellamo/run.sh b/benchmarks-script/vellamo/run.sh new file mode 100755 index 0000000..f7cf105 --- /dev/null +++ b/benchmarks-script/vellamo/run.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +#need to be defined for different benchmark apks +activity="com.quicinc.vellamo/.Vellamo" +apk_file_name="com.quicinc.vellamo-1.apk" +test_method="testVellamo" +apk_package="com.quicinc.vellamo" + +#following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +pre_uninstall="${parent_dir}/vellamo_getres.sh" +main "$@" diff --git a/benchmarks-script/vellamo/session.xml b/benchmarks-script/vellamo/session.xml new file mode 100644 index 0000000..8b1102a --- /dev/null +++ b/benchmarks-script/vellamo/session.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="US-ASCII" ?> +<session version="1" title="Vellamo" target_path="@F" call_stack_unwinding="yes" parse_debug_info="yes" high_resolution="no" buffer_mode="streaming" sample_rate="normal" duration="0"> +</session> diff --git a/benchmarks-script/vellamo/vellamo_getres.sh b/benchmarks-script/vellamo/vellamo_getres.sh new file mode 100755 index 0000000..a1bafc9 --- /dev/null +++ b/benchmarks-script/vellamo/vellamo_getres.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +path_dir=`dirname $0` +old_pwd=`pwd` +cd ${path_dir} +if [ -n "${1}" ]; then + adb -s "${1}" pull /data/data/com.quicinc.vellamo/files files +else + adb pull /data/data/com.quicinc.vellamo/files files +fi +if [ $? -ne 0 ]; then + echo "Failed to get the result of vellamo test" + exit 1 +fi + +sed 's/<[^>]*>//g' files/latest_result.html |grep -v '^[ ]*$'|sed 's/ /:/g'|sed 's/"/ "/g'|sed 's/:/=/g'|grep '=' >results.txt +rm -fr files +cd "${old_pwd}" diff --git a/src/org/linaro/SettingsTestCase.java b/src/org/linaro/SettingsTestCase.java new file mode 100644 index 0000000..b9a9f22 --- /dev/null +++ b/src/org/linaro/SettingsTestCase.java @@ -0,0 +1,110 @@ +/* + * Author: Linaro Android Team <linaro-dev@lists.linaro.org> + * + * These files are Copyright (C) 2012 Linaro Limited and they + * are licensed under the Apache License, Version 2.0. + * You may obtain a copy of this license at + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.linaro; + +import java.io.File; + +import android.app.Activity; +import android.graphics.Point; +import android.os.Bundle; +import android.util.Log; +import android.view.KeyEvent; + +import com.android.uiautomator.core.UiDevice; +import com.android.uiautomator.core.UiObject; +import com.android.uiautomator.core.UiSelector; +import com.android.uiautomator.core.UiScrollable; +import com.android.uiautomator.testrunner.UiAutomatorTestCase; +import com.android.uiautomator.core.UiObjectNotFoundException; + +public class SettingsTestCase extends UiAutomatorTestCase { + + public void clickText(String text)throws UiObjectNotFoundException{ + UiSelector selector = new UiSelector(); + UiObject obj = new UiObject(selector.text(text) + .className("android.widget.TextView")); + obj.click(); + } + public void openSettingsApp() throws UiObjectNotFoundException{ + getUiDevice().pressHome(); + getUiDevice().pressMenu(); + UiSelector selector = new UiSelector(); + UiObject btn_setting = new UiObject(selector.text("System settings") + .className("android.widget.TextView") + .packageName("com.android.launcher")); + btn_setting.click(); + + } + + public void testSetSleep30Minutes() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //application related + openSettingsApp(); + UiScrollable settingsItem = new UiScrollable(new UiSelector() + .className("android.widget.ListView")); + UiObject item = settingsItem.getChildByText(new UiSelector() + .className("android.widget.LinearLayout"), "Display"); + item.click(); + + clickText("Sleep"); + UiSelector selector = new UiSelector(); + UiObject checkText = new UiObject(selector.text("30 minutes") + .className("android.widget.CheckedTextView")); + checkText.click(); + } + + public void testSetScreenLockNone() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //application related + openSettingsApp(); + UiScrollable settingsItem = new UiScrollable(new UiSelector() + .className("android.widget.ListView")); + UiObject item = settingsItem.getChildByText(new UiSelector() + .className("android.widget.LinearLayout"), "Security"); + item.click(); + + clickText("Screen lock"); + clickText("None"); + } + + public void testSetStayAwake() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //application related + openSettingsApp(); + UiScrollable settingsItem = new UiScrollable(new UiSelector() + .className("android.widget.ListView")); + UiObject item = settingsItem.getChildByText(new UiSelector() + .className("android.widget.LinearLayout"), "Developer options"); + item.click(); + + UiScrollable item_items = new UiScrollable(new UiSelector() + .className("android.widget.ListView").instance(1)); + UiObject stayawake_item = item_items.getChildByText(new UiSelector() + .className("android.widget.RelativeLayout"), "Stay awake"); + + UiObject check_box = stayawake_item.getFromParent(new UiSelector() + .className("android.widget.CheckBox")); + if (! check_box.isChecked()){ + check_box.click(); + } + } +} diff --git a/src/org/linaro/benchmarks/BenchmarksTestCase.java b/src/org/linaro/benchmarks/BenchmarksTestCase.java new file mode 100644 index 0000000..07205a3 --- /dev/null +++ b/src/org/linaro/benchmarks/BenchmarksTestCase.java @@ -0,0 +1,487 @@ +/* + * Author: Linaro Android Team <linaro-dev@lists.linaro.org> + * + * These files are Copyright (C) 2012 Linaro Limited and they + * are licensed under the Apache License, Version 2.0. + * You may obtain a copy of this license at + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.linaro.benchmarks; + +import java.io.File; + +import android.app.Activity; +import android.graphics.Point; +import android.os.Bundle; +import android.util.Log; +import android.view.KeyEvent; + +import com.android.uiautomator.core.UiDevice; +import com.android.uiautomator.core.UiObject; +import com.android.uiautomator.core.UiSelector; +import com.android.uiautomator.testrunner.UiAutomatorTestCase; +import com.android.uiautomator.core.UiObjectNotFoundException; + +public class BenchmarksTestCase extends UiAutomatorTestCase { + + String TAG = "BenchmarksTestCase"; + + String png_dir = "/data/local/tmp/"; + + public boolean takeScreenshot(String name){ + try{ + //only avaliable for 4.2 + return getUiDevice().takeScreenshot( + new File(png_dir + name + ".png")); + }catch(NoSuchMethodError e){ + return true; + } + } + + public void sleep(int second){ + super.sleep(second * 1000); + } + + public void waitText(String text) throws UiObjectNotFoundException{ + waitText(text, 600); + } + + public void waitText(String text, int second) + throws UiObjectNotFoundException{ + UiSelector selector = new UiSelector(); + UiObject text_obj = new UiObject(selector.text(text) + .className("android.widget.TextView")); + waitObject(text_obj, second); + } + + public void waitObject(UiObject obj) throws UiObjectNotFoundException{ + waitObject(obj, 600); + } + + public void waitObject(UiObject obj, int second) + throws UiObjectNotFoundException{ + if (! obj.waitForExists(second * 1000)){ + throw new UiObjectNotFoundException("UiObject is not found: " + + obj.getSelector().toString()); + } + } + + public boolean waitUntilNoObject(UiObject obj, int second){ + return obj.waitUntilGone(second * 1000); + } + + public void testOrientationNatural() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //Application specific + getUiDevice().setOrientationNatural(); + getUiDevice().freezeRotation(); + + getUiDevice().unfreezeRotation(); + getAutomationSupport().sendStatus(Activity.RESULT_OK, status); + } + + public void testGeekbench() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //application related + UiSelector selector = new UiSelector(); + UiObject btn_run = new UiObject(selector.text("Run Benchmarks") + .className("android.widget.Button")); + btn_run.click(); + try{ + UiObject res_webview = new UiObject(selector.className( + "android.webkit.WebView")); + waitObject(res_webview); + takeScreenshot("geekbench-0"); + sleep(2); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_PAGE_DOWN); + takeScreenshot("geekbench-1"); + sleep(2); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_PAGE_DOWN); + takeScreenshot("geekbench-2"); + sleep(2); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_PAGE_DOWN); + takeScreenshot("geekbench-3"); + sleep(2); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_PAGE_DOWN); + takeScreenshot("geekbench-4"); + + }catch(UiObjectNotFoundException e){ + takeScreenshot("geekbench-error"); + } + getAutomationSupport().sendStatus(Activity.RESULT_OK, status); + } + + public void testLinpack() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + UiSelector selector = new UiSelector(); + UiObject btn_st = new UiObject(selector.text("Run Single Thread")); + btn_st.click(); + sleep(10); + takeScreenshot("linpack-st"); + UiObject btn_mt = new UiObject(selector.text("Run Multi-Thread")); + btn_mt.click(); + sleep(10); + takeScreenshot("linpack-mt"); + getAutomationSupport().sendStatus(Activity.RESULT_OK, status); + } + + public void testAntutu() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + UiSelector selector = new UiSelector(); + // + //click the Test test + UiObject text_scores = new UiObject(selector.text("Scores") + .className("android.widget.TextView")); + text_scores.click(); + sleep(2); + + //click the Test test + UiObject text_detail = new UiObject(selector.text("Detailed Scores") + .className("android.widget.TextView")); + text_detail.click(); + sleep(2); + + //click the Test test + UiObject text_test = new UiObject(selector.text("Test") + .className("android.widget.TextView")); + text_test.click(); + sleep(2); + + Log.v(TAG, "Start the test"); + //begin the test + UiObject btn_test = new UiObject(selector.text("Start Test") + .className("android.widget.Button")); + btn_test.click(); + try{ + UiObject submit = new UiObject(selector + .text("Submit Scores") + .className("android.widget.TextView")); + UiObject detail = new UiObject(selector + .text("Detailed Scores") + .className("android.widget.TextView")); + for(int i = 0; i < 60; i++){ + if (detail.exists() || submit.exists()){ + break; + } + sleep(10); + } + }finally{ + takeScreenshot("antutu"); + } + getAutomationSupport().sendStatus(Activity.RESULT_OK, status); + } + + public void testCaffeine() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //Application specific + UiSelector selector = new UiSelector(); + UiObject btn_run = new UiObject(selector.text("Run benchmark") + .className("android.widget.Button")); + btn_run.click(); + + try{ + waitText("CaffeineMark results"); + takeScreenshot("caffeine-0"); + UiObject btn_details = new UiObject(selector.text("Details") + .className("android.widget.Button")); + btn_details.click(); + sleep(2); + takeScreenshot("caffeine-1"); + }catch(UiObjectNotFoundException e){ + takeScreenshot("caffeine-error"); + } + + getAutomationSupport().sendStatus(Activity.RESULT_OK, status); + } + + public void testAndEBench() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //Application specific + getUiDevice().setOrientationNatural(); + UiSelector selector = new UiSelector(); + UiObject btn_start = new UiObject(selector + .className("android.widget.ImageButton") + .packageName("com.eembc.coremark")); + btn_start.click(); + + try{ + UiObject running_text = new UiObject(selector + .textContains("Running...") + .className("android.widget.TextView") + .packageName("com.eembc.coremark")); + waitUntilNoObject(running_text, 600); + + UiObject result_text = new UiObject(selector + .textContains("Results in Iterations/sec:") + .className("android.widget.TextView") + .packageName("com.eembc.coremark")); + waitObject(result_text); + sleep(2); + takeScreenshot("AndEBench-0"); + }catch(UiObjectNotFoundException e){ + takeScreenshot("AndEBench-error"); + } + + getAutomationSupport().sendStatus(Activity.RESULT_OK, status); + } + + public void testNBench() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //Application specific + getUiDevice().setOrientationNatural(); + UiSelector selector = new UiSelector(); + UiObject btn_start = new UiObject(selector.text("Start the benchmark") + .className("android.widget.Button") + .packageName("com.drolez.nbench")); + btn_start.click(); + + try{ + + UiObject running_text = new UiObject(selector + .textContains("Benchmark running.") + .className("android.widget.TextView") + .packageName("com.drolez.nbench")); + waitUntilNoObject(running_text, 600); + + UiObject result_text = new UiObject(selector + .textContains("Last run:") + .className("android.widget.TextView") + .packageName("com.drolez.nbench")); + waitObject(result_text); + sleep(2); + takeScreenshot("NBench-0"); + }catch(UiObjectNotFoundException e){ + takeScreenshot("NBench-error"); + } + + getAutomationSupport().sendStatus(Activity.RESULT_OK, status); + } + + public void testQuadrant() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //Application specific + getUiDevice().setOrientationNatural(); + UiSelector selector = new UiSelector(); + try{ + waitText("Information"); + UiObject btn_ok = new UiObject(selector.text("OK") + .className("android.widget.Button") + .packageName("com.aurorasoftworks.quadrant.ui.standard")); + if (btn_ok.exists()){ + btn_ok.click(); + } + }catch(UiObjectNotFoundException e){ + //do nothing + } + + + UiObject text_run = new UiObject(selector.text("Run full benchmark") + .className("android.widget.TextView") + .packageName("com.aurorasoftworks.quadrant.ui.standard")); + text_run.click(); + waitText("Benchmark result"); + UiObject btn_yes = new UiObject(selector.text("Yes") + .className("android.widget.Button") + .packageName("com.aurorasoftworks.quadrant.ui.standard")); + if (btn_yes.exists()){ + btn_yes.click(); + } + UiObject text_sending = new UiObject(selector + .text("Sending benchmark results...") + .className("android.widget.TextView")); + try{ + waitObject(text_sending); + }catch(UiObjectNotFoundException e){ + takeScreenshot("quadrant-no-sending"); + } + + waitUntilNoObject(text_sending, 600); + sleep(3); + takeScreenshot("quadrant"); + + getAutomationSupport().sendStatus(Activity.RESULT_OK, status); + } + + public void testVellamo() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //Application specific + getUiDevice().setOrientationNatural(); + UiSelector selector = new UiSelector(); + try{ + waitText("Vellamo EULA"); + UiObject btn_accept = new UiObject(selector.text("Accept") + .className("android.widget.Button") + .packageName("com.quicinc.vellamo")); + if (btn_accept.exists()){ + btn_accept.click(); + } + }catch(UiObjectNotFoundException e){ + //do nothing + } + + UiObject btn_no = new UiObject(selector.text("No") + .className("android.widget.Button") + .packageName("com.quicinc.vellamo")); + try{ + waitText( + "Would you like to edit the list of websites Vellamo accesses?"); + if (btn_no.exists()){ + btn_no.click(); + } + }catch(UiObjectNotFoundException e){ + //do nothing + } + + UiObject text_start = new UiObject(selector.text("Start") + .className("android.widget.TextView") + .packageName("com.quicinc.vellamo")); + text_start.click(); + + waitText("Enable Tutorial?"); + btn_no.click(); + try{ + waitText("Vellamo Score"); + btn_no.click(); + sleep(3); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_BACK); + takeScreenshot("vellamo-0"); + sleep(2); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_PAGE_DOWN); + takeScreenshot("vellamo-1"); + sleep(2); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_PAGE_DOWN); + takeScreenshot("vellamo-2"); + sleep(2); + }catch(UiObjectNotFoundException e){ + takeScreenshot("vellamo-error"); + throw e; + } + + getAutomationSupport().sendStatus(Activity.RESULT_OK, status); + } + + public void testGLBenchmark() throws Exception{ + Bundle status = new Bundle(); + status.putString("product", getUiDevice().getProductName()); + Point p = getUiDevice().getDisplaySizeDp(); + status.putInt("dp-width", p.x); + status.putInt("dp-height", p.y); + //Application specific + getUiDevice().setOrientationNatural(); + UiSelector selector = new UiSelector(); + + UiObject download_fail = new UiObject(selector.text("Retry Download") + .className("android.widget.Button")); + if (download_fail.exists()){ + takeScreenshot("glbenchmark-retry"); + throw new Exception( + "Download failed because the resources could not be found"); + } + UiObject text_perf_test = new UiObject(selector + .text("Performance Tests") + .className("android.widget.TextView")); + text_perf_test.click(); + sleep(3); + + UiObject btn_all = new UiObject(selector.text("All") + .className("android.widget.Button")); + btn_all.click(); + sleep(1); + //uncheck the crash item + UiObject crash_item = new UiObject(selector + .text("C24Z24MS4") + .className("android.widget.TextView")); + crash_item.click(); + + UiObject btn_start= new UiObject(selector.text("Start") + .className("android.widget.Button")); + btn_start.click(); + try{ + UiObject error = new UiObject(selector + .text("Error during network communication!") + .className("android.widget.TextView")); + UiObject processing = new UiObject(selector + .text("Processing results...") + .className("android.widget.TextView")); + UiObject results = new UiObject(selector + .text("Results") + .className("android.widget.TextView")); + for(int i = 0; i < 360; i++){ + if (results.exists()){ + break; + } + if (processing.exists()){ + continue; + } + + if (error.exists()){ + UiObject btn_retry= new UiObject(selector.text("Retry") + .className("android.widget.Button")); + btn_retry.click(); + } + sleep(10); + } + waitText("Results"); + sleep(2); + takeScreenshot("glbenchmark-0"); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN); + takeScreenshot("glbenchmark-1"); + sleep(1); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN); + sleep(1); + takeScreenshot("glbenchmark-2"); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN); + sleep(1); + takeScreenshot("glbenchmark-3"); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN); + getUiDevice().pressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN); + sleep(1); + takeScreenshot("glbenchmark-4"); + }catch(UiObjectNotFoundException e){ + takeScreenshot("glbenchmark-error"); + throw e; + } + + getAutomationSupport().sendStatus(Activity.RESULT_OK, status); + } +} |