Merge lp:~liuyq0307/lava-android-test/methanol into lp:lava-android-test
- methanol
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 193 |
Proposed branch: | lp:~liuyq0307/lava-android-test/methanol |
Merge into: | lp:lava-android-test |
Diff against target: |
676 lines (+568/-8) 7 files modified
MANIFEST.in (+1/-0) lava_android_test/commands.py (+8/-0) lava_android_test/test_definitions/methanol.py (+66/-0) lava_android_test/test_definitions/methanol/methanol.sh (+317/-0) lava_android_test/test_definitions/methanol/methanol_merge_results.py (+81/-0) lava_android_test/test_definitions/methanol/start_server.py (+62/-0) lava_android_test/testdef.py (+33/-8) |
To merge this branch: | bzr merge lp:~liuyq0307/lava-android-test/methanol |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Yongqin Liu | Approve | ||
Review via email: mp+119978@code.launchpad.net |
This proposal supersedes a proposal from 2012-08-11.
Commit message
Description of the change
add test for methanol
update according to the review comment
Add the support for running on chrome browser
Updated to support passing the IP address from option of lava-android-test that android will use that IP to access the test web pages and report the test result
And this branch has been run successfully on staging, the job url is :
http://
Yongqin Liu (liuyq0307) wrote : Posted in a previous version of this proposal | # |
Yongqin Liu (liuyq0307) wrote : Posted in a previous version of this proposal | # |
This branch has been tested on staging. Please see the following jobs:
http://
http://
Andy Doan (doanac) wrote : Posted in a previous version of this proposal | # |
On 08/09/2012 08:45 AM, Yongqin Liu wrote:
> === added directory 'lava_android_
> === added file 'lava_android_
> --- lava_android_
> +++ lava_android_
<snip>
> + def real_parse(self, result_
> + test_name=''):
> + """Parse test output to gather results
> + Use the pattern specified when the class was instantiated to look
> + through the results line-by-line and find lines that match it.
> + Results are then stored in self.results. If a fixupdict was supplied
> + it is used to convert test result strings to a standard format.
> + """
Seems like this comment should go in the parent's implementation rather
than this one.
> === added file 'lava_android_
> --- lava_android_
> +++ lava_android_
<snip>
> +#the default ip or domain used by the client to access the server
> +domain_
Why should we have to have a default. We can figure out our own IP
address. Actually the python server you wrote figures it out, so maybe
we should just get it from the file it creates for us.
> +######
> +###### NOT MODIFY SOURCE OF BELOW #####
> +######
> +#android_
Remove this line if its not needed anymore
<snip>
> +
> +function deploy(){
> + cur_path=`pwd`
> + target_dir=`mktemp -u --tmpdir=
> + git clone "${methanol_git}" "${target_dir}"
> + if [ $? -ne 0 ];then
> + echo "Faile to clone the methanol source from ${methanol_git}"
typo "Faile" should be "Failed"
> + cleanup
> + exit 1
> + fi
> +function test_methanol(){
> + if [ -n "$1" ]; then
> + test_type="-${1}"
> + else
> + test_type=""
> + fi
> +
> + wait_minutes=${2-1}
> +
> + mkdir -p/tmp/methanol/
> + sudo chmod -R 777 /tmp/methanol
Do we really need /tmp/methanol? this is just something we'll create and
never clean up.
> === modified file 'lava_android_
> --- lava_android_
> +++ lava_android_
> @@ -410,6 +414,25 @@
> Results are then stored in self.results. If a fixupdict was supplied
> it is used to convert test result strings to a standard format.
> """
> +
> + self.real_
> + output_
> +
> + self.fixresults
> + if self.appendall:
> + self.appendtoal
> + self.fixmeasure
> + self.fixids(
> +
> + def real_parse(self, result_
> + ...
Yongqin Liu (liuyq0307) wrote : Posted in a previous version of this proposal | # |
> > +#the default ip or domain used by the client to access the server
> > +domain_
>
> Why should we have to have a default. We can figure out our own IP
> address. Actually the python server you wrote figures it out, so maybe
> we should just get it from the file it creates for us.
Sorry, could you show me how to figure out the available IP?
Using the ifconfig command to get the IP of eth0 is possible, but if the server has more than 2 IPs,
then we can't know which one is the right.
and if we pass 0.0.0.0, then all the IP address will be opened,
and this will cause security problems I think.
> > + mkdir -p/tmp/methanol/
> > + sudo chmod -R 777 /tmp/methanol
>
> Do we really need /tmp/methanol? this is just something we'll create and
> never clean up.
we can't pass a path(including /) to the save_methanol_
so we passed only the file name and get the result file from the default directory /tmp/methanol.
I delete the above two sentence, but the "/tmp/methanol" directory will still exist and won't be deleted.
> > + def real_parse(self, result_
> > + output_
> > + """Parse test output to gather results
> > +
> > + Use the pattern specified when the class was instantiated to look
> > + through the results line-by-line and find lines that match it.
> > + Results are then stored in self.results. If a fixupdict was
> supplied
> > + it is used to convert test result strings to a standard format.
> > + """
>
> There are a few other places in code that could use this function. I
> think: tjbench.py, skia.py, and 0xbench.py. We should fix those up as well.
yes, they are the same type, but here I'd like to leave them as they are now, not to touch them here.
we can update them when we need to update them in the future using this function,
and use this function when add new similar type test.
Thanks,
Yongqin Liu.
Andy Doan (doanac) wrote : Posted in a previous version of this proposal | # |
On 08/10/2012 10:18 PM, Yongqin Liu wrote:
>>> > >+#the default ip or domain used by the client to access the server
>>> > >+domain_
>> >
>> >Why should we have to have a default. We can figure out our own IP
>> >address. Actually the python server you wrote figures it out, so maybe
>> >we should just get it from the file it creates for us.
> Sorry, could you show me how to figure out the available IP?
> Using the ifconfig command to get the IP of eth0 is possible, but if the server has more than 2 IPs,
> then we can't know which one is the right.
> and if we pass 0.0.0.0, then all the IP address will be opened,
> and this will cause security problems I think.
>
I think 0.0.0.0 is okay, we have firewalls to prevent access to the port
it will open.
Michael Hudson-Doyle (mwhudson) wrote : Posted in a previous version of this proposal | # |
Andy Doan <email address hidden> writes:
> On 08/10/2012 10:18 PM, Yongqin Liu wrote:
>>>> > >+#the default ip or domain used by the client to access the server
>>>> > >+domain_
>>> >
>>> >Why should we have to have a default. We can figure out our own IP
>>> >address. Actually the python server you wrote figures it out, so maybe
>>> >we should just get it from the file it creates for us.
>> Sorry, could you show me how to figure out the available IP?
>> Using the ifconfig command to get the IP of eth0 is possible, but if the server has more than 2 IPs,
>> then we can't know which one is the right.
>> and if we pass 0.0.0.0, then all the IP address will be opened,
>> and this will cause security problems I think.
>>
>
> I think 0.0.0.0 is okay, we have firewalls to prevent access to the port
> it will open.
That still doesn't help the test know which IP address to give to the
browser on the DUT...
Cheers,
mwh
Yongqin Liu (liuyq0307) wrote : | # |
Tested on staging.
http://
Preview Diff
1 | === modified file 'MANIFEST.in' |
2 | --- MANIFEST.in 2012-07-10 06:34:06 +0000 |
3 | +++ MANIFEST.in 2012-08-16 16:08:19 +0000 |
4 | @@ -13,4 +13,5 @@ |
5 | include lava_android_test/test_definitions/pm-qa/* |
6 | include lava_android_test/test_definitions/shells/* |
7 | include lava_android_test/test_definitions/hostshells/* |
8 | +include lava_android_test/test_definitions/methanol/* |
9 | |
10 | |
11 | === modified file 'lava_android_test/commands.py' |
12 | --- lava_android_test/commands.py 2012-08-07 02:28:47 +0000 |
13 | +++ lava_android_test/commands.py 2012-08-16 16:08:19 +0000 |
14 | @@ -751,6 +751,14 @@ |
15 | serial) |
16 | if test_id: |
17 | bundle['test_runs'][0]['test_id'] = test_id |
18 | + else: |
19 | + attrs = bundle['test_runs'][0].get('attributes') |
20 | + if attrs: |
21 | + run_options = attrs.get('run_options') |
22 | + if run_options: |
23 | + test_id = '%s(%s)' % (bundle['test_runs'][0]['test_id'], |
24 | + run_options) |
25 | + bundle['test_runs'][0]['test_id'] = test_id |
26 | |
27 | test_tmp.parse(result_id) |
28 | stdout_text = adb.read_file(os.path.join(resultdir, |
29 | |
30 | === added directory 'lava_android_test/test_definitions/methanol' |
31 | === added file 'lava_android_test/test_definitions/methanol.py' |
32 | --- lava_android_test/test_definitions/methanol.py 1970-01-01 00:00:00 +0000 |
33 | +++ lava_android_test/test_definitions/methanol.py 2012-08-16 16:08:19 +0000 |
34 | @@ -0,0 +1,66 @@ |
35 | +# Copyright (c) 2012 Linaro |
36 | + |
37 | +# Author: Linaro Validation Team <linaro-dev@lists.linaro.org> |
38 | +# |
39 | +# This file is part of LAVA Android Test. |
40 | +# |
41 | +# |
42 | +# This program is free software: you can redistribute it and/or modify |
43 | +# it under the terms of the GNU General Public License as published by |
44 | +# the Free Software Foundation, either version 3 of the License, or |
45 | +# (at your option) any later version. |
46 | +# |
47 | +# This program is distributed in the hope that it will be useful, |
48 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
49 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
50 | +# GNU General Public License for more details. |
51 | +# |
52 | +# You should have received a copy of the GNU General Public License |
53 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
54 | + |
55 | +""" |
56 | +The Methanol is a page load benchmarking engine. |
57 | +The benchmark engine measures the overall page layouting and rendering time of the browser. |
58 | +Only several test cases are attached to the engine, because of licensing issue. |
59 | + |
60 | +**URL:** https://gitorious.org/methanol |
61 | + |
62 | +**Default options:** None |
63 | +""" |
64 | + |
65 | +import os |
66 | +import json |
67 | + |
68 | +import lava_android_test.testdef |
69 | + |
70 | +from lava_android_test.config import get_config |
71 | + |
72 | +curdir = os.path.realpath(os.path.dirname(__file__)) |
73 | +config = get_config() |
74 | + |
75 | +result_dir = config.resultsdir_android |
76 | +RUN_STEPS_HOST_PRE = ["bash %s/methanol/methanol.sh $(SERIAL) $(OPTIONS)" % curdir] |
77 | + |
78 | +class MethanolTestParser(lava_android_test.testdef.AndroidTestParser): |
79 | + |
80 | + def real_parse(self, result_filename=None, output_filename='methanol_result.json', |
81 | + test_name=''): |
82 | + """Parse test output to gather results |
83 | + Use the pattern specified when the class was instantiated to look |
84 | + through the results line-by-line and find lines that match it. |
85 | + Results are then stored in self.results. If a fixupdict was supplied |
86 | + it is used to convert test result strings to a standard format. |
87 | + """ |
88 | + with open(output_filename) as stream: |
89 | + test_results_data = stream.read() |
90 | + test_results_json = json.loads(test_results_data) |
91 | + self.results['test_results'] = test_results_json |
92 | + |
93 | + |
94 | +inst = lava_android_test.testdef.AndroidTestInstaller() |
95 | +run = lava_android_test.testdef.AndroidTestRunner(steps_host_pre=RUN_STEPS_HOST_PRE) |
96 | +parser = MethanolTestParser() |
97 | +testobj = lava_android_test.testdef.AndroidTest(testname="methanol", |
98 | + installer=inst, runner=run, parser=parser, |
99 | + org_ouput_file='/data/local/methanol/methanol_result.json', |
100 | + default_options='-b DEFAULT -d 192.168.1.10') |
101 | |
102 | === added file 'lava_android_test/test_definitions/methanol/methanol.sh' |
103 | --- lava_android_test/test_definitions/methanol/methanol.sh 1970-01-01 00:00:00 +0000 |
104 | +++ lava_android_test/test_definitions/methanol/methanol.sh 2012-08-16 16:08:19 +0000 |
105 | @@ -0,0 +1,317 @@ |
106 | +#!/bin/bash |
107 | +# Copyright (c) 2012 Linaro |
108 | + |
109 | +# Author: Linaro Validation Team <linaro-dev@lists.linaro.org> |
110 | +# |
111 | +# This file is part of LAVA Android Test. |
112 | +# |
113 | +# This program is free software: you can redistribute it and/or modify |
114 | +# it under the terms of the GNU General Public License as published by |
115 | +# the Free Software Foundation, either version 3 of the License, or |
116 | +# (at your option) any later version. |
117 | +# |
118 | +# This program is distributed in the hope that it will be useful, |
119 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
120 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
121 | +# GNU General Public License for more details. |
122 | +# |
123 | +# You should have received a copy of the GNU General Public License |
124 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
125 | + |
126 | +#the default ip or domain used by the client to access the server |
127 | +DEFAULT_DOMAIN_IP='192.168.1.10' |
128 | +DEFAULT_BROWSER='DEFAULT' |
129 | + |
130 | +######################################################## |
131 | +###### NOT MODIFY SOURCE OF BELOW ##### |
132 | +######################################################## |
133 | +THIS_FILE="$0" |
134 | +methanol_git="git://gitorious.org/methanol/methanol.git" |
135 | +chrome_apk_url="http://testdata.validation.linaro.org/chrome/Chrome-latest.apk" |
136 | +server_settings_file="/etc/lava/web_server/settings.conf" |
137 | +result_dir_android="/data/local/methanol" |
138 | +declare -a RESULTS=(); |
139 | +methanol_url="/" |
140 | +report_url="/cgi/save_methanol_data.py" |
141 | +report_res_dir="/tmp/methanol" |
142 | +target_dir="" |
143 | +server_pid="" |
144 | + |
145 | +ADB_OPTION="" |
146 | +domain_ip="${DEFAULT_DOMAIN_IP}" |
147 | +browser="${DEFAULT_BROWSER}" |
148 | + |
149 | +function parse_arg(){ |
150 | + serial="" |
151 | + while test -n "$1"; do |
152 | + case "$1" in |
153 | + --browser|-b) |
154 | + if [ "x$2" = "x" ]; then |
155 | + echo "Error: $1 requires an argument which should be DEFAULT or CHROME" |
156 | + exit 1 |
157 | + fi |
158 | + browser="$2" |
159 | + if [ "X${browser}" != "XDEFAULT" ] && [ "X${browser}" != "XCHROME" ]; then |
160 | + echo "Error: $1 requires an argument which should be DEFAULT or CHROME" |
161 | + exit 1 |
162 | + fi |
163 | + shift 2 |
164 | + ;; |
165 | + --domain|-d) |
166 | + if [ "x$2" = "x" ]; then |
167 | + echo "Error: $1 requires an argument" |
168 | + exit 1 |
169 | + fi |
170 | + domain_ip="$2" |
171 | + shift 2 |
172 | + ;; |
173 | + --help|-h) |
174 | + show_usage |
175 | + exit 0 |
176 | + ;; |
177 | + *) |
178 | + if [ -n "${serial}" ]; then |
179 | + show_usage |
180 | + echo "Too many arguments, see --help for details" |
181 | + exit 1 |
182 | + else |
183 | + serial="$1" |
184 | + shift |
185 | + fi |
186 | + ;; |
187 | + esac |
188 | + done |
189 | + |
190 | + if [ -n "${serial}" ]; then |
191 | + ADB_OPTION="-s ${serial}" |
192 | + fi |
193 | +} |
194 | + |
195 | +function show_usage(){ |
196 | + echo "`basename ${THIS_FILE}` [serial_no] [-b DEFAULT|CHROME] [-d domain_ip]" |
197 | +} |
198 | + |
199 | +function patch_sources(){ |
200 | + src_root_dir=${1} |
201 | + if [ -z ${src_root_dir} ]; then |
202 | + return |
203 | + fi |
204 | + |
205 | + if [ \! -d ${src_root_dir} ]; then |
206 | + return |
207 | + fi |
208 | + |
209 | + ## The following test case cannot be on android browser, so comment them out |
210 | + ## Patch the engine.js |
211 | + sed -i "s% + results;% + results.replace\(new RegExp('/','gm'), '_'\);%" ${src_root_dir}/engine.js |
212 | + |
213 | + ##Patch svg.js |
214 | + sed -i s%\"svg/anim/earth.svg\",%\"svg/anim/earth.svg\"/*,% ${src_root_dir}/svg.js |
215 | + sed -i s%\"svg/anim/svg.svg\"%\"svg/anim/svg.svg\"*/% ${src_root_dir}/svg.js |
216 | + |
217 | + ##Patch smp.js |
218 | + sed -i s%\"smp/3d-terrain-demo/single/index.html\",%//\"smp/3d-terrain-demo/single/index.html\",% ${src_root_dir}/smp.js |
219 | + sed -i s%\"smp/3d-terrain-demo/worker/index.html\",%//\"smp/3d-terrain-demo/worker/index.html\",% ${src_root_dir}/smp.js |
220 | + sed -i s%\"smp/fire-on-water/worker/index.html\",%//\"smp/fire-on-water/worker/index.html\",% ${src_root_dir}/smp.js |
221 | +} |
222 | + |
223 | +function deploy(){ |
224 | + |
225 | + if [ "${browser}" = "CHROME" ]; then |
226 | + echo "wget --progress=dot -e dotbytes=1M -np -l 10 --no-check-certificate ${chrome_apk_url} -O ./Chrome-latest.apk" |
227 | + wget --progress=dot -e dotbytes=1M -np -l 10 --no-check-certificate ${chrome_apk_url} -O ./Chrome-latest.apk |
228 | + if [ $? -ne 0 ]; then |
229 | + echo "Failed to download the chrome apk file from ${chrome_apk_url}." |
230 | + cleanup |
231 | + exit 1 |
232 | + fi |
233 | + |
234 | + adb ${ADB_OPTION} uninstall com.android.chrome |
235 | + |
236 | + echo "adb ${ADB_OPTION} install ./Chrome-latest.apk" |
237 | + adb ${ADB_OPTION} install ./Chrome-latest.apk |
238 | + if [ $? -ne 0 ]; then |
239 | + echo "Failed to install the Chrome browser application." |
240 | + cleanup |
241 | + rm -f ./Chrome-latest.apk |
242 | + exit 1 |
243 | + fi |
244 | + rm -f ./Chrome-latest.apk |
245 | + adb ${ADB_OPTION} shell am start com.android.chrome/com.google.android.apps.chrome.Main |
246 | + sleep 10 |
247 | + f_preferences='/data/data/com.android.chrome/shared_prefs/com.android.chrome_preferences.xml' |
248 | + f_preferences_base=`basename ${f_preferences}` |
249 | + owner_grp=`adb ${ADB_OPTION} shell ls -l ${f_preferences}|cut -d \ -f2` |
250 | + if [ -z "${owner_grp}" ]; then |
251 | + echo "Failed to get the user/group infromation of chrome preferences file." |
252 | + cleanup |
253 | + rm -f ./Chrome-latest.apk |
254 | + exit 1 |
255 | + fi |
256 | + adb ${ADB_OPTION} pull ${f_preferences} ./${f_preferences_base} |
257 | + sed -i '/<map>/ a\<boolean name="first_run_flow" value="true" />' ./${f_preferences_base} |
258 | + adb ${ADB_OPTION} push ./${f_preferences_base} ${f_preferences} |
259 | + adb ${ADB_OPTION} shell chown ${owner_grp}:${owner_grp} ${f_preferences} |
260 | + chrome_pid=`adb ${ADB_OPTION} shell ps |grep -P 'chrome\s*$'|tr -s ' '|cut -d \ -f2` |
261 | + if [ -n "${chrome_pid}" ]; then |
262 | + adb ${ADB_OPTION} shell kill ${chrome_pid} |
263 | + fi |
264 | + rm -f ./${f_preferences_base} |
265 | + fi |
266 | + |
267 | + cur_path=`pwd` |
268 | + target_dir=`mktemp -u --tmpdir=${cur_path} methanol-XXX` |
269 | + git clone "${methanol_git}" "${target_dir}" |
270 | + if [ $? -ne 0 ];then |
271 | + echo "Failed to clone the methanol source from ${methanol_git}" |
272 | + cleanup |
273 | + exit 1 |
274 | + fi |
275 | + |
276 | + #patch just because some test can not be run on android |
277 | + patch_sources "${target_dir}" |
278 | + |
279 | + url_file=`mktemp -u --tmpdir=${cur_path} url-XXX` |
280 | + nohup python `dirname $0`/start_server.py "${domain_ip}" "${target_dir}" "${url_file}" &>server.log & |
281 | + server_pid=$! |
282 | + sleep 5 |
283 | + domain_protocol=`cat ${url_file}` |
284 | + if [ -z "${domain_protocol}" ]; then |
285 | + echo "Cannot get the url of the temporary created server." |
286 | + echo "Failed to deploy the temporary server" |
287 | + cleanup |
288 | + exit 1 |
289 | + fi |
290 | +} |
291 | + |
292 | +function check_url(){ |
293 | + if [ -n "${report_url}" ]; then |
294 | + wget -q "${domain_protocol}/${report_url}" -O /dev/null |
295 | + if [ $? -ne 0 ]; then |
296 | + echo "The report url(${domain_protocol}/${report_url}) cannot be accessed" |
297 | + echo "Please put the save_methanol_data.py to the cgi-bin directory" |
298 | + echo "of your web server, and make sure it is accessible." |
299 | + cleanup |
300 | + exit 1 |
301 | + fi |
302 | + fi |
303 | + |
304 | + if [ -n "${methanol_url}" ]; then |
305 | + wget -q "${domain_protocol}/${methanol_url}" -O /dev/null |
306 | + if [ $? -ne 0 ]; then |
307 | + echo "The url(${domain_protocol}/${methanol_url}) cannot be accessed" |
308 | + echo "Please clone the methanol directory to local via following command" |
309 | + echo " git clone ${methanol_git}" |
310 | + echo "and copy the entire directory to some place of your web server" |
311 | + echo "and make sure it is accessible." |
312 | + cleanup |
313 | + exit 1 |
314 | + fi |
315 | + else |
316 | + echo "Please speecify the methanol url that will be used for test." |
317 | + cleanup |
318 | + exit 1 |
319 | + fi |
320 | +} |
321 | + |
322 | +function wait_result(){ |
323 | + if [ -n "$1" ]; then |
324 | + file_path="$1" |
325 | + else |
326 | + return 0 |
327 | + fi |
328 | + wait_minutes=${2-1} |
329 | + |
330 | + for (( i=1; i<=${wait_minutes}; i++ )); do |
331 | + sleep 60 |
332 | + if [ -f "${file_path}" ]; then |
333 | + return 0 |
334 | + fi |
335 | + done |
336 | + return 1 |
337 | +} |
338 | + |
339 | +function test_methanol(){ |
340 | + if [ -n "$1" ]; then |
341 | + test_type="-${1}" |
342 | + else |
343 | + test_type="" |
344 | + fi |
345 | + |
346 | + wait_minutes=${2-1} |
347 | + |
348 | + result_file=`mktemp -u --tmpdir=${report_res_dir} fire${test_type}-XXX.json` |
349 | + res_basename=`basename ${result_file}` |
350 | + test_url="${domain_protocol}/${methanol_url}/fire${test_type}.html" |
351 | + if [ -n "${report_url}" ]; then |
352 | + test_url="${test_url}?reportToUrl=${report_url}%3Fsave2file=${res_basename}" |
353 | + fi |
354 | + |
355 | + component_default="com.android.browser/.BrowserActivity" |
356 | + component_chrome=" com.android.chrome/com.google.android.apps.chrome.Main" |
357 | + if [ "${browser}" = "CHROME" ]; then |
358 | + component=${component_chrome} |
359 | + else |
360 | + component=${component_default} |
361 | + fi |
362 | + echo "adb ${ADB_OPTION} shell am start -a android.intent.action.VIEW -d ${test_url} -n ${component}" |
363 | + adb ${ADB_OPTION} shell "am start -a android.intent.action.VIEW -d ${test_url} -n ${component}" |
364 | + wait_result "${result_file}" ${wait_minutes} |
365 | + if [ $? -eq 0 ]; then |
366 | + cur_path=`pwd` |
367 | + cp -uvf ${result_file} ${cur_path}/${res_basename} |
368 | + echo "result_file=${cur_path}/${res_basename}" |
369 | + RESULTS[${#RESULTS[@]}]="${cur_path}/${res_basename}" |
370 | + |
371 | + rm -f ${result_file} |
372 | + else |
373 | + echo "Failed to get the test result of fire${test_type}.html" |
374 | + #cleanup |
375 | + #exit 1 |
376 | + fi |
377 | +} |
378 | + |
379 | +function cleanup(){ |
380 | + echo "DO CLEAN UP" |
381 | + rm -fr methanol_result.json "${RESULTS[@]}" |
382 | + if [ -n "${server_pid}" ]; then |
383 | + kill -9 ${server_pid} |
384 | + fi |
385 | + if [ -n "${target_dir}" ]; then |
386 | + rm -fr "${target_dir}" |
387 | + fi |
388 | + if [ "${browser}" = "CHROME" ]; then |
389 | + adb ${ADB_OPTION} uninstall com.android.chrome |
390 | + fi |
391 | +} |
392 | + |
393 | +function main(){ |
394 | + parse_arg "$@" |
395 | + |
396 | + trap cleanup EXIT |
397 | + |
398 | + deploy |
399 | + |
400 | + check_url |
401 | + echo `date`: starts to test fire.html |
402 | + test_methanol "" 30 |
403 | + echo `date`: starts to test fire-svg.html |
404 | + test_methanol "svg" 150 |
405 | + echo `date`: starts to test fire-smp.html |
406 | + test_methanol "smp" 100 |
407 | + echo `date`: all tests completed |
408 | + |
409 | + echo "Merge results of file: ${RESULTS[@]}" |
410 | + `dirname $0`/methanol_merge_results.py methanol_result.json "${RESULTS[@]}" |
411 | + if [ $? -eq 0 ]; then |
412 | + adb ${ADB_OPTION} shell mkdir ${result_dir_android} |
413 | + adb ${ADB_OPTION} push methanol_result.json "${result_dir_android}/methanol_result.json" |
414 | + for f in "${RESULTS[@]}"; do |
415 | + adb ${ADB_OPTION} push "${f}" "${result_dir_android}" |
416 | + done |
417 | + echo "The result is also push to android: ${result_dir_android}/${res_basename}" |
418 | + else |
419 | + echo "Failed to merge the results" |
420 | + fi |
421 | +} |
422 | +main "$@" |
423 | |
424 | === added file 'lava_android_test/test_definitions/methanol/methanol_merge_results.py' |
425 | --- lava_android_test/test_definitions/methanol/methanol_merge_results.py 1970-01-01 00:00:00 +0000 |
426 | +++ lava_android_test/test_definitions/methanol/methanol_merge_results.py 2012-08-16 16:08:19 +0000 |
427 | @@ -0,0 +1,81 @@ |
428 | +#!/usr/bin/python |
429 | +# Copyright (c) 2012 Linaro |
430 | + |
431 | +# Author: Linaro Validation Team <linaro-dev@lists.linaro.org> |
432 | +# |
433 | +# This file is part of LAVA Android Test. |
434 | +# |
435 | +# |
436 | +# This program is free software: you can redistribute it and/or modify |
437 | +# it under the terms of the GNU General Public License as published by |
438 | +# the Free Software Foundation, either version 3 of the License, or |
439 | +# (at your option) any later version. |
440 | +# |
441 | +# This program is distributed in the hope that it will be useful, |
442 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
443 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
444 | +# GNU General Public License for more details. |
445 | +# |
446 | +# You should have received a copy of the GNU General Public License |
447 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
448 | + |
449 | +import os |
450 | +import re |
451 | +import string |
452 | +import sys |
453 | + |
454 | +import simplejson as json |
455 | + |
456 | +if len(sys.argv) < 3: |
457 | + basename = os.path.basename(sys.argv[0]) |
458 | + print 'Please specified the merge target file and source files like:' |
459 | + print '\t %s target-result-file source-file1 source-file2 ...' |
460 | + sys.exit(1) |
461 | + |
462 | +target_file = sys.argv[1] |
463 | +test_results = [] |
464 | +for f in sys.argv[2:]: |
465 | + if not os.path.exists(f): |
466 | + print "The file(%s) does not exist" % f |
467 | + continue |
468 | + |
469 | + with open(f) as stream: |
470 | + f_basename = os.path.basename(f) |
471 | + last_hyphen_index = string.rfind(f_basename, '-') |
472 | + if last_hyphen_index != -1: |
473 | + file_id = f_basename[:last_hyphen_index] |
474 | + else: |
475 | + file_id = '' |
476 | + |
477 | + jobdata = stream.read() |
478 | + results_data = json.loads(jobdata) |
479 | + for res in results_data: |
480 | + test_case_id = res.get('test_case_id') |
481 | + average = res.get('average') |
482 | + avg_dev = res.get('average_deviate') |
483 | + if file_id and test_case_id == 'summary': |
484 | + test_case_id = '%s-summary' % file_id |
485 | + test_case_id = test_case_id.replace('/', '_') |
486 | + badchars = "[^a-zA-Z0-9\._-]" |
487 | + test_case_id = re.sub(badchars, "", test_case_id.replace(" ", "_")) |
488 | + test_results.append({'test_case_id': '%s_avg' % test_case_id, |
489 | + 'result': 'pass', |
490 | + 'measurement': average, |
491 | + 'units': 'ms'}) |
492 | + test_results.append({'test_case_id': '%s_avg_dev' % test_case_id, |
493 | + 'result': 'pass', |
494 | + 'measurement': avg_dev, |
495 | + 'units': '%'}) |
496 | + |
497 | + |
498 | +with open(target_file, 'w') as fd: |
499 | + indent = ' ' * 2 |
500 | + separators = (', ', ': ') |
501 | + json.dump(test_results, fd, |
502 | + use_decimal=True, |
503 | + indent=indent, |
504 | + separators=separators, |
505 | + sort_keys=False) |
506 | + |
507 | +print "The result has been merged in file: %s" % target_file |
508 | +sys.exit(0) |
509 | |
510 | === added file 'lava_android_test/test_definitions/methanol/start_server.py' |
511 | --- lava_android_test/test_definitions/methanol/start_server.py 1970-01-01 00:00:00 +0000 |
512 | +++ lava_android_test/test_definitions/methanol/start_server.py 2012-08-16 16:08:19 +0000 |
513 | @@ -0,0 +1,62 @@ |
514 | +#/usr/bin/python |
515 | +# Copyright (c) 2012 Linaro |
516 | + |
517 | +# Author: Linaro Validation Team <linaro-dev@lists.linaro.org> |
518 | +# |
519 | +# This file is part of LAVA Android Test. |
520 | +# |
521 | +# This program is free software: you can redistribute it and/or modify |
522 | +# it under the terms of the GNU General Public License as published by |
523 | +# the Free Software Foundation, either version 3 of the License, or |
524 | +# (at your option) any later version. |
525 | +# |
526 | +# This program is distributed in the hope that it will be useful, |
527 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
528 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
529 | +# GNU General Public License for more details. |
530 | +# |
531 | +# You should have received a copy of the GNU General Public License |
532 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
533 | + |
534 | +import os |
535 | +import sys |
536 | +import CGIHTTPServer |
537 | +import BaseHTTPServer |
538 | + |
539 | +### check parameter |
540 | +if len(sys.argv) < 3: |
541 | + print 'Please spsecify the ip and directory like this:' |
542 | + print ' %s domain-or-ip directory-path url-file' % ( |
543 | + os.path.basename(__file__)) |
544 | + sys.exit(1) |
545 | + |
546 | +domain = sys.argv[1] |
547 | +directory = sys.argv[2] |
548 | +if len(sys.argv) == 4: |
549 | + url_file = sys.argv[3] |
550 | +else: |
551 | + url_file = '' |
552 | + |
553 | +## change to that directory |
554 | +old_dir = os.getcwd() |
555 | +os.chdir(directory) |
556 | + |
557 | +## set the server configuration before start |
558 | +cgi_handler = CGIHTTPServer.CGIHTTPRequestHandler |
559 | +cgi_handler.cgi_directories.append('/cgi') |
560 | +httpd = BaseHTTPServer.HTTPServer((domain, 0), cgi_handler) |
561 | +url = '%s://%s:%s/' % ('http', httpd.socket.getsockname()[0], |
562 | + httpd.socket.getsockname()[1]) |
563 | + |
564 | +## out put the url information to console and file for other script reference |
565 | +print "serving at url=", url |
566 | +if url_file: |
567 | + with open(url_file, 'w') as stream: |
568 | + stream.write(url) |
569 | + print 'The information of url also have been wirtten into file(%s)' % ( |
570 | + url_file) |
571 | + |
572 | +try: |
573 | + httpd.serve_forever() |
574 | +finally: |
575 | + os.chdir(old_dir) |
576 | |
577 | === modified file 'lava_android_test/testdef.py' |
578 | --- lava_android_test/testdef.py 2012-06-28 09:52:29 +0000 |
579 | +++ lava_android_test/testdef.py 2012-08-16 16:08:19 +0000 |
580 | @@ -131,7 +131,7 @@ |
581 | output = self.adb.run_adb_cmd('shell cat %s' % optionfile)[1] |
582 | bundle['test_runs'][0]['attributes']['install_options'] = output[0] |
583 | |
584 | - def _savetestdata(self, analyzer_assigned_uuid): |
585 | + def _savetestdata(self, analyzer_assigned_uuid, run_options=""): |
586 | config = get_config() |
587 | TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ' |
588 | bundle = { |
589 | @@ -142,7 +142,7 @@ |
590 | 'analyzer_assigned_date': |
591 | self.runner.starttime.strftime(TIMEFORMAT), |
592 | 'time_check_performed': False, |
593 | - 'attributes':{}, |
594 | + 'attributes':{'run_options': run_options}, |
595 | 'test_id': self.testname, |
596 | 'test_results':[], |
597 | 'attachments':[], |
598 | @@ -176,7 +176,7 @@ |
599 | self.runner.run(self.resultsdir, run_options=run_options) |
600 | self._copyorgoutputfile(self.resultsdir) |
601 | self._screencap(self.resultsdir) |
602 | - self._savetestdata(str(uuid4())) |
603 | + self._savetestdata(str(uuid4()), run_options=run_options) |
604 | result_id = os.path.basename(self.resultsdir) |
605 | print("ANDROID TEST RUN COMPLETE: Result id is '%s'" % result_id) |
606 | os.chdir(self.origdir) |
607 | @@ -319,6 +319,10 @@ |
608 | cmd = cmd.replace('$(OPTIONS)', option) |
609 | else: |
610 | cmd = cmd.replace('$(OPTIONS)', '') |
611 | + if resultsdir is not None: |
612 | + cmd = cmd.replace('$(RESULTDIR)', resultsdir) |
613 | + else: |
614 | + cmd = cmd.replace('$(RESULTDIR)', '') |
615 | cmd = cmd.strip() |
616 | ret_code = self.adb.run_adb_shell_for_test(cmd, |
617 | stdoutlog, |
618 | @@ -410,6 +414,23 @@ |
619 | Results are then stored in self.results. If a fixupdict was supplied |
620 | it is used to convert test result strings to a standard format. |
621 | """ |
622 | + |
623 | + self.real_parse(result_filename=result_filename, |
624 | + output_filename=output_filename, test_name=test_name) |
625 | + |
626 | + self.fixresults(self.fixupdict) |
627 | + if self.appendall: |
628 | + self.appendtoall(self.appendall) |
629 | + self.fixmeasurements() |
630 | + self.fixids(test_name=test_name) |
631 | + |
632 | + def real_parse(self, result_filename='stdout.log', |
633 | + output_filename='stdout.log', test_name=''): |
634 | + """Using the pattern to do the real parse operation |
635 | + |
636 | + generate the test_results elements from the result file by parsing |
637 | + with the pattern specified. |
638 | + """ |
639 | if not self.pattern: |
640 | return |
641 | |
642 | @@ -448,11 +469,6 @@ |
643 | if data.get('result') is None: |
644 | data['result'] = test_ok and 'pass' or 'fail' |
645 | self.results['test_results'].append(data) |
646 | - self.fixresults(self.fixupdict) |
647 | - if self.appendall: |
648 | - self.appendtoall(self.appendall) |
649 | - self.fixmeasurements() |
650 | - self.fixids(test_name=test_name) |
651 | |
652 | def append(self, testid, entry): |
653 | """Appends a dict to the test_results entry for a specified testid |
654 | @@ -593,6 +609,11 @@ |
655 | cmd = cmd.replace('$(OPTIONS)', option) |
656 | else: |
657 | cmd = cmd.replace('$(OPTIONS)', '') |
658 | + if resultsdir is not None: |
659 | + cmd = cmd.replace('$(RESULTDIR)', resultsdir) |
660 | + else: |
661 | + cmd = cmd.replace('$(RESULTDIR)', '') |
662 | + |
663 | cmd = cmd.strip() |
664 | rc, output = adb.run_cmd_host(cmd, quiet=False) |
665 | if rc: |
666 | @@ -610,6 +631,10 @@ |
667 | cmd = cmd.replace('$(OPTIONS)', option) |
668 | else: |
669 | cmd = cmd.replace('$(OPTIONS)', '') |
670 | + if resultsdir is not None: |
671 | + cmd = cmd.replace('$(RESULTDIR)', resultsdir) |
672 | + else: |
673 | + cmd = cmd.replace('$(RESULTDIR)', '') |
674 | cmd = cmd.strip() |
675 | rc, output = adb.run_adb_cmd(cmd, quiet=False) |
676 | if rc: |
change to use BaseHTTPServer to server the web pages and cgi server