diff options
author | Botao Sun <botao.sun@linaro.org> | 2014-08-13 19:14:40 +1000 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2014-08-13 11:18:09 +0000 |
commit | e610e9f8e9d1306523bad610595e954a0b05a485 (patch) | |
tree | 5fda96a06494f8f49081fbbdeda4f3d2885008f2 /benchmarkpi | |
parent | 1fe5a3aba506c8e32a76b0dde23f9c61757bd8e7 (diff) |
Add BenchmarkPi Test for Linaro Android
Signed-off by: Botao Sun <botao.sun@linaro.org>
Change-Id: If19833f9107fe5195060d0034741f69ec051b9f6
Diffstat (limited to 'benchmarkpi')
-rwxr-xr-x | benchmarkpi/execute.sh | 12 | ||||
-rw-r--r-- | benchmarkpi/session.xml | 3 | ||||
-rwxr-xr-x | benchmarkpi/vc.py | 61 |
3 files changed, 76 insertions, 0 deletions
diff --git a/benchmarkpi/execute.sh b/benchmarkpi/execute.sh new file mode 100755 index 0000000..be4f2a1 --- /dev/null +++ b/benchmarkpi/execute.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#need to be defined for different benchmark apks +activity="gr.androiddev.BenchmarkPi/.BenchmarkPi" +apk_file_name="gr.androiddev.BenchmarkPi-1.apk" +test_method="python vc.py" +apk_package="gr.androiddev.BenchmarkPi" + +#following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +main "$@" diff --git a/benchmarkpi/session.xml b/benchmarkpi/session.xml new file mode 100644 index 0000000..971413d --- /dev/null +++ b/benchmarkpi/session.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="US-ASCII" ?> +<session version="1" title="BenchmarkPi" 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/benchmarkpi/vc.py b/benchmarkpi/vc.py new file mode 100755 index 0000000..f4ff581 --- /dev/null +++ b/benchmarkpi/vc.py @@ -0,0 +1,61 @@ +# Author: Botao Sun <botao.sun@linaro.org> + +import sys +import time +from subprocess import call + +from com.dtmilano.android.viewclient import ViewClient, ViewNotFoundException + +def collect_score(benchmark_name, run_result, score_number, score_unit): + call(['lava-test-case', benchmark_name, '--result', run_result, '--measurement', score_number, '--units', score_unit]) + +benchmark_name = "BenchmarkPi" +kwargs1 = {'verbose': False, 'ignoresecuredevice': False} +device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1) +kwargs2 = {'startviewserver': True, 'forceviewserveruse': False, 'autodump': False, 'ignoreuiautomatorkilled': True} +vc = ViewClient(device, serialno, **kwargs2) + +time.sleep(2) +vc.dump(window='-1') +start_button = vc.findViewByIdOrRaise("gr.androiddev.BenchmarkPi:id/Button01") +start_button.touch() + +finished = False +while (not finished): + time.sleep(1) + try: + vc.dump(window='-1') + vc.findViewByIdOrRaise("android:id/message") + finished = True + except ViewNotFoundException: + pass + except RuntimeError as e: + print e +print "benchmark finished" + +return_text = vc.findViewByIdOrRaise("android:id/message").getText().split(" ") + +flagwordA = "calculated" +flagwordB = "Pi" + +if flagwordA in return_text and flagwordB in return_text: + if return_text.index(flagwordB) == return_text.index(flagwordA) + 1: + print "This is an valid test result" + score_number = return_text[return_text.index(flagwordA) + 3] + score_unit = return_text[return_text.index(flagwordA) + 4].split("!")[0] + print score_number + " " + score_unit + run_result = "pass" + else: + print "Output string changed, parser need to be updated!" + sys.exit(1) +else: + print "Can not find keyword which is supposed to show up!" + sys.exit(1) + +# Submit the test result to LAVA +collect_score(benchmark_name, run_result, score_number, score_unit) + +# Exit the app +vc.dump(window='-1') +exit_button = vc.findViewByIdOrRaise("android:id/button2") +exit_button.touch() |