Merge lp:~liuyq0307/lava-android-test/methanol into lp:lava-android-test

Proposed by Yongqin Liu
Status: Superseded
Proposed branch: lp:~liuyq0307/lava-android-test/methanol
Merge into: lp:lava-android-test
Diff against target: 582 lines (+509/-5)
6 files modified
MANIFEST.in (+1/-0)
lava_android_test/test_definitions/methanol.py (+66/-0)
lava_android_test/test_definitions/methanol/methanol.sh (+269/-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 (+30/-5)
To merge this branch: bzr merge lp:~liuyq0307/lava-android-test/methanol
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+118313@code.launchpad.net

This proposal has been superseded by a proposal from 2012-08-11.

Description of the change

add test for methanol

To post a comment you must log in.
Revision history for this message
Yongqin Liu (liuyq0307) wrote :

change to use BaseHTTPServer to server the web pages and cgi server

Revision history for this message
Yongqin Liu (liuyq0307) wrote :
Revision history for this message
Andy Doan (doanac) wrote :
Download full text (3.7 KiB)

On 08/09/2012 08:45 AM, Yongqin Liu wrote:
> === added directory 'lava_android_test/test_definitions/methanol'
> === added file 'lava_android_test/test_definitions/methanol.py'
> --- lava_android_test/test_definitions/methanol.py 1970-01-01 00:00:00 +0000
> +++ lava_android_test/test_definitions/methanol.py 2012-08-09 11:16:19 +0000
<snip>
> + def real_parse(self, result_filename=None, output_filename='methanol_result.json',
> + 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_test/test_definitions/methanol/methanol.sh'
> --- lava_android_test/test_definitions/methanol/methanol.sh 1970-01-01 00:00:00 +0000
> +++ lava_android_test/test_definitions/methanol/methanol.sh 2012-08-09 11:16:19 +0000

<snip>

> +#the default ip or domain used by the client to access the server
> +domain_ip='192.168.1.10'

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_dir="/sdcard/methanol"
Remove this line if its not needed anymore

<snip>
> +
> +function deploy(){
> + cur_path=`pwd`
> + target_dir=`mktemp -u --tmpdir=${cur_path} methanol-XXX`
> + 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_test/testdef.py'
> --- lava_android_test/testdef.py 2012-06-28 09:52:29 +0000
> +++ lava_android_test/testdef.py 2012-08-09 11:16:19 +0000

> @@ -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_parse(result_filename=result_filename,
> + output_filename=output_filename, test_name=test_name)
> +
> + self.fixresults(self.fixupdict)
> + if self.appendall:
> + self.appendtoall(self.appendall)
> + self.fixmeasurements()
> + self.fixids(test_name=test_name)
> +
> + def real_parse(self, result_filename='stdout.log',
> + ...

Read more...

200. By Yongqin Liu

modify acording to the review comments that updating doc of real_parse function and typo error

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

> > +#the default ip or domain used by the client to access the server
> > +domain_ip='192.168.1.10'
>
> 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_data.py when using CGIHTTPServer as the server.
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_filename='stdout.log',
> > + output_filename='stdout.log', 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.
> > + """
>
> 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.

201. By Yongqin Liu

delete the source to create directory /tmp/methanol

202. By Yongqin Liu

add support for test on chrome

203. By Yongqin Liu

redirect the log of the simple server to a file

204. By Yongqin Liu

change the way to no login for chrome and decrease the wait time for svg and example

Revision history for this message
Andy Doan (doanac) wrote :

On 08/10/2012 10:18 PM, Yongqin Liu wrote:
>>> > >+#the default ip or domain used by the client to access the server
>>> > >+domain_ip='192.168.1.10'
>> >
>> >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.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

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_ip='192.168.1.10'
>>> >
>>> >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

205. By Yongqin Liu

change to use option to receive the ip address

206. By Yongqin Liu

add default option in methanol.py

207. By Yongqin Liu

add the option to the test_id in result bundle

208. By Yongqin Liu

fix for twice cleanup and kill chrome for the first time

209. By Yongqin Liu

increase the wait for for fire.html and fire-svg.html on chrome

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'MANIFEST.in'
2--- MANIFEST.in 2012-07-10 06:34:06 +0000
3+++ MANIFEST.in 2012-08-11 09:41: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=== added directory 'lava_android_test/test_definitions/methanol'
12=== added file 'lava_android_test/test_definitions/methanol.py'
13--- lava_android_test/test_definitions/methanol.py 1970-01-01 00:00:00 +0000
14+++ lava_android_test/test_definitions/methanol.py 2012-08-11 09:41:19 +0000
15@@ -0,0 +1,66 @@
16+# Copyright (c) 2012 Linaro
17+
18+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
19+#
20+# This file is part of LAVA Android Test.
21+#
22+#
23+# This program is free software: you can redistribute it and/or modify
24+# it under the terms of the GNU General Public License as published by
25+# the Free Software Foundation, either version 3 of the License, or
26+# (at your option) any later version.
27+#
28+# This program is distributed in the hope that it will be useful,
29+# but WITHOUT ANY WARRANTY; without even the implied warranty of
30+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+# GNU General Public License for more details.
32+#
33+# You should have received a copy of the GNU General Public License
34+# along with this program. If not, see <http://www.gnu.org/licenses/>.
35+
36+"""
37+The Methanol is a page load benchmarking engine.
38+The benchmark engine measures the overall page layouting and rendering time of the browser.
39+Only several test cases are attached to the engine, because of licensing issue.
40+
41+**URL:** https://gitorious.org/methanol
42+
43+**Default options:** None
44+"""
45+
46+import os
47+import json
48+
49+import lava_android_test.testdef
50+
51+from lava_android_test.config import get_config
52+
53+curdir = os.path.realpath(os.path.dirname(__file__))
54+config = get_config()
55+
56+result_dir = config.resultsdir_android
57+RUN_STEPS_HOST_PRE = ["bash %s/methanol/methanol.sh $(SERIAL) $(OPTIONS)" % curdir]
58+
59+class MethanolTestParser(lava_android_test.testdef.AndroidTestParser):
60+
61+ def real_parse(self, result_filename=None, output_filename='methanol_result.json',
62+ test_name=''):
63+ """Parse test output to gather results
64+ Use the pattern specified when the class was instantiated to look
65+ through the results line-by-line and find lines that match it.
66+ Results are then stored in self.results. If a fixupdict was supplied
67+ it is used to convert test result strings to a standard format.
68+ """
69+ with open(output_filename) as stream:
70+ test_results_data = stream.read()
71+ test_results_json = json.loads(test_results_data)
72+ self.results['test_results'] = test_results_json
73+
74+
75+inst = lava_android_test.testdef.AndroidTestInstaller()
76+run = lava_android_test.testdef.AndroidTestRunner(steps_host_pre=RUN_STEPS_HOST_PRE)
77+parser = MethanolTestParser()
78+testobj = lava_android_test.testdef.AndroidTest(testname="methanol",
79+ installer=inst, runner=run, parser=parser,
80+ org_ouput_file='/data/local/methanol/methanol_result.json',
81+ default_options='DEFAULT')
82
83=== added file 'lava_android_test/test_definitions/methanol/methanol.sh'
84--- lava_android_test/test_definitions/methanol/methanol.sh 1970-01-01 00:00:00 +0000
85+++ lava_android_test/test_definitions/methanol/methanol.sh 2012-08-11 09:41:19 +0000
86@@ -0,0 +1,269 @@
87+#!/bin/bash
88+# Copyright (c) 2012 Linaro
89+
90+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
91+#
92+# This file is part of LAVA Android Test.
93+#
94+# This program is free software: you can redistribute it and/or modify
95+# it under the terms of the GNU General Public License as published by
96+# the Free Software Foundation, either version 3 of the License, or
97+# (at your option) any later version.
98+#
99+# This program is distributed in the hope that it will be useful,
100+# but WITHOUT ANY WARRANTY; without even the implied warranty of
101+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102+# GNU General Public License for more details.
103+#
104+# You should have received a copy of the GNU General Public License
105+# along with this program. If not, see <http://www.gnu.org/licenses/>.
106+
107+#the default ip or domain used by the client to access the server
108+domain_ip='192.168.1.10'
109+
110+########################################################
111+###### NOT MODIFY SOURCE OF BELOW #####
112+########################################################
113+methanol_git="git://gitorious.org/methanol/methanol.git"
114+chrome_apk_url="http://testdata.validation.linaro.org/chrome/Chrome-latest.apk"
115+server_settings_file="/etc/lava/web_server/settings.conf"
116+result_dir_android="/data/local/methanol"
117+declare -a RESULTS=();
118+methanol_url="/"
119+report_url="/cgi/save_methanol_data.py"
120+report_res_dir="/tmp/methanol"
121+target_dir=""
122+server_pid=""
123+
124+SERIAL=${1-""}
125+ADB_OPTION=""
126+if [ -n "${SERIAL}" ]; then
127+ ADB_OPTION="-s ${SERIAL}"
128+fi
129+
130+## use which browser to test
131+## DEFAULT: the android default stock browser
132+## CHROME: the chrome browser
133+BROWSER=${2-""}
134+
135+function patch_sources(){
136+ src_root_dir=${1}
137+ if [ -z ${src_root_dir} ]; then
138+ return
139+ fi
140+
141+ if [ \! -d ${src_root_dir} ]; then
142+ return
143+ fi
144+
145+ ## The following test case cannot be on android browser, so comment them out
146+ ## Patch the engine.js
147+ sed -i "s% + results;% + results.replace\(new RegExp('/','gm'), '_'\);%" ${src_root_dir}/engine.js
148+
149+ ##Patch svg.js
150+ sed -i s%\"svg/anim/earth.svg\",%\"svg/anim/earth.svg\"/*,% ${src_root_dir}/svg.js
151+ sed -i s%\"svg/anim/svg.svg\"%\"svg/anim/svg.svg\"*/% ${src_root_dir}/svg.js
152+
153+ ##Patch smp.js
154+ sed -i s%\"smp/3d-terrain-demo/single/index.html\",%//\"smp/3d-terrain-demo/single/index.html\",% ${src_root_dir}/smp.js
155+ sed -i s%\"smp/3d-terrain-demo/worker/index.html\",%//\"smp/3d-terrain-demo/worker/index.html\",% ${src_root_dir}/smp.js
156+ sed -i s%\"smp/fire-on-water/worker/index.html\",%//\"smp/fire-on-water/worker/index.html\",% ${src_root_dir}/smp.js
157+}
158+
159+function deploy(){
160+
161+ if [ "${BROWSER}" = "CHROME" ]; then
162+ echo "wget --progress=dot -e dotbytes=1M -np -l 10 --no-check-certificate ${chrome_apk_url} -O ./Chrome-latest.apk"
163+ wget --progress=dot -e dotbytes=1M -np -l 10 --no-check-certificate ${chrome_apk_url} -O ./Chrome-latest.apk
164+ if [ $? -ne 0 ]; then
165+ echo "Failed to download the chrome apk file from ${chrome_apk_url}."
166+ cleanup
167+ exit 1
168+ fi
169+
170+ adb ${ADB_OPTION} uninstall com.android.chrome
171+
172+ echo "adb ${ADB_OPTION} install ./Chrome-latest.apk"
173+ adb ${ADB_OPTION} install ./Chrome-latest.apk
174+ if [ $? -ne 0 ]; then
175+ echo "Failed to install the Chrome browser application."
176+ cleanup
177+ rm -f ./Chrome-latest.apk
178+ exit 1
179+ fi
180+ rm -f ./Chrome-latest.apk
181+ adb ${ADB_OPTION} shell am start com.android.chrome/com.google.android.apps.chrome.Main
182+ sleep 10
183+ adb ${ADB_OPTION} shell input keyevent 20
184+ sleep 2
185+ adb ${ADB_OPTION} shell input keyevent 66
186+ sleep 2
187+ fi
188+
189+ cur_path=`pwd`
190+ target_dir=`mktemp -u --tmpdir=${cur_path} methanol-XXX`
191+ git clone "${methanol_git}" "${target_dir}"
192+ if [ $? -ne 0 ];then
193+ echo "Failed to clone the methanol source from ${methanol_git}"
194+ cleanup
195+ exit 1
196+ fi
197+
198+ #patch just because some test can not be run on android
199+ patch_sources "${target_dir}"
200+
201+ url_file=`mktemp -u --tmpdir=${cur_path} url-XXX`
202+ nohup python `dirname $0`/start_server.py "${domain_ip}" "${target_dir}" "${url_file}" 2>1 1>/dev/null &
203+ server_pid=$!
204+ sleep 5
205+ domain_protocol=`cat ${url_file}`
206+ if [ -z "${domain_protocol}" ]; then
207+ echo "Cannot get the url of the temporary created server."
208+ echo "Failed to deploy the temporary server"
209+ cleanup
210+ exit 1
211+ fi
212+}
213+
214+function check_url(){
215+ if [ -n "${report_url}" ]; then
216+ wget -q "${domain_protocol}/${report_url}" -O /dev/null
217+ if [ $? -ne 0 ]; then
218+ echo "The report url(${domain_protocol}/${report_url}) cannot be accessed"
219+ echo "Please put the save_methanol_data.py to the cgi-bin directory"
220+ echo "of your web server, and make sure it is accessible."
221+ cleanup
222+ exit 1
223+ fi
224+ fi
225+
226+ if [ -n "${methanol_url}" ]; then
227+ wget -q "${domain_protocol}/${methanol_url}" -O /dev/null
228+ if [ $? -ne 0 ]; then
229+ echo "The url(${domain_protocol}/${methanol_url}) cannot be accessed"
230+ echo "Please clone the methanol directory to local via following command"
231+ echo " git clone ${methanol_git}"
232+ echo "and copy the entire directory to some place of your web server"
233+ echo "and make sure it is accessible."
234+ cleanup
235+ exit 1
236+ fi
237+ else
238+ echo "Please speecify the methanol url that will be used for test."
239+ cleanup
240+ exit 1
241+ fi
242+}
243+
244+function wait_result(){
245+ if [ -n "$1" ]; then
246+ file_path="$1"
247+ else
248+ return 0
249+ fi
250+ wait_minutes=${2-1}
251+
252+ for (( i=1; i<=${wait_minutes}; i++ )); do
253+ sleep 60
254+ if [ -f "${file_path}" ]; then
255+ return 0
256+ fi
257+ done
258+ return 1
259+}
260+
261+function test_methanol(){
262+ if [ -n "$1" ]; then
263+ test_type="-${1}"
264+ else
265+ test_type=""
266+ fi
267+
268+ wait_minutes=${2-1}
269+
270+ result_file=`mktemp -u --tmpdir=${report_res_dir} fire${test_type}-XXX.json`
271+ res_basename=`basename ${result_file}`
272+ test_url="${domain_protocol}/${methanol_url}/fire${test_type}.html"
273+ if [ -n "${report_url}" ]; then
274+ test_url="${test_url}?reportToUrl=${report_url}%3Fsave2file=${res_basename}"
275+ fi
276+
277+ component_default="com.android.browser/.BrowserActivity"
278+ component_chrome=" com.android.chrome/com.google.android.apps.chrome.Main"
279+ if [ "${BROWSER}" = "CHROME" ]; then
280+ component=${component_chrome}
281+ else
282+ component=${component_default}
283+ fi
284+ echo "adb ${ADB_OPTION} shell am start -a android.intent.action.VIEW -d ${test_url} -n ${component}"
285+ adb ${ADB_OPTION} shell "am start -a android.intent.action.VIEW -d ${test_url} -n ${component}"
286+ wait_result "${result_file}" ${wait_minutes}
287+ if [ $? -eq 0 ]; then
288+ cur_path=`pwd`
289+ cp -uvf ${result_file} ${cur_path}/${res_basename}
290+ echo "result_file=${cur_path}/${res_basename}"
291+ RESULTS[${#RESULTS[@]}]="${cur_path}/${res_basename}"
292+
293+ rm -f ${result_file}
294+ else
295+ echo "Failed to get the test result of fire${test_type}.html"
296+ #cleanup
297+ #exit 1
298+ fi
299+}
300+
301+function cleanup(){
302+ rm -fr methanol_result.json "${RESULTS[@]}"
303+ if [ -n "${server_pid}" ]; then
304+ kill -9 ${server_pid}
305+ fi
306+ if [ -n "${target_dir}" ]; then
307+ rm -fr "${target_dir}"
308+ fi
309+ if [ "${BROWSER}" = "CHROME" ]; then
310+ adb ${ADB_OPTION} uninstall com.android.chrome
311+ fi
312+}
313+
314+function main(){
315+ trap cleanup EXIT
316+
317+ if [ -n "${WEB_SERVER_SEETINGS_CONF}" ]; then
318+ server_settings_file="${WIFI_DEV_CONF}"
319+ fi
320+
321+ if [ -f "${server_settings_file}" ]; then
322+ echo "Will use ${server_settings_file} as the configuration file for web server"
323+ . "${server_settings_file}"
324+ else
325+ echo "Will use default value as the configuration of web server"
326+ fi
327+
328+ deploy
329+
330+ check_url
331+ echo `date`: starts to test fire.html
332+ test_methanol "" 100
333+ echo `date`: starts to test fire-svg.html
334+ test_methanol "svg" 100
335+ echo `date`: starts to test fire-smp.html
336+ test_methanol "smp" 100
337+ echo `date`: all tests completed
338+
339+ echo "Merge results of file: ${RESULTS[@]}"
340+ `dirname $0`/methanol_merge_results.py methanol_result.json "${RESULTS[@]}"
341+ if [ $? -eq 0 ]; then
342+ adb ${ADB_OPTION} shell mkdir ${result_dir_android}
343+ adb ${ADB_OPTION} push methanol_result.json "${result_dir_android}/methanol_result.json"
344+ for f in "${RESULTS[@]}"; do
345+ adb ${ADB_OPTION} push "${f}" "${result_dir_android}"
346+ done
347+ echo "The result is also push to android: ${result_dir_android}/${res_basename}"
348+ else
349+ echo "Failed to merege the results"
350+ #cleanup
351+ #exit 1
352+ fi
353+ cleanup
354+}
355+main "$@"
356
357=== added file 'lava_android_test/test_definitions/methanol/methanol_merge_results.py'
358--- lava_android_test/test_definitions/methanol/methanol_merge_results.py 1970-01-01 00:00:00 +0000
359+++ lava_android_test/test_definitions/methanol/methanol_merge_results.py 2012-08-11 09:41:19 +0000
360@@ -0,0 +1,81 @@
361+#!/usr/bin/python
362+# Copyright (c) 2012 Linaro
363+
364+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
365+#
366+# This file is part of LAVA Android Test.
367+#
368+#
369+# This program is free software: you can redistribute it and/or modify
370+# it under the terms of the GNU General Public License as published by
371+# the Free Software Foundation, either version 3 of the License, or
372+# (at your option) any later version.
373+#
374+# This program is distributed in the hope that it will be useful,
375+# but WITHOUT ANY WARRANTY; without even the implied warranty of
376+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
377+# GNU General Public License for more details.
378+#
379+# You should have received a copy of the GNU General Public License
380+# along with this program. If not, see <http://www.gnu.org/licenses/>.
381+
382+import os
383+import re
384+import string
385+import sys
386+
387+import simplejson as json
388+
389+if len(sys.argv) < 3:
390+ basename = os.path.basename(sys.argv[0])
391+ print 'Please specified the merge target file and source files like:'
392+ print '\t %s target-result-file source-file1 source-file2 ...'
393+ sys.exit(1)
394+
395+target_file = sys.argv[1]
396+test_results = []
397+for f in sys.argv[2:]:
398+ if not os.path.exists(f):
399+ print "The file(%s) does not exist" % f
400+ continue
401+
402+ with open(f) as stream:
403+ f_basename = os.path.basename(f)
404+ last_hyphen_index = string.rfind(f_basename, '-')
405+ if last_hyphen_index != -1:
406+ file_id = f_basename[:last_hyphen_index]
407+ else:
408+ file_id = ''
409+
410+ jobdata = stream.read()
411+ results_data = json.loads(jobdata)
412+ for res in results_data:
413+ test_case_id = res.get('test_case_id')
414+ average = res.get('average')
415+ avg_dev = res.get('average_deviate')
416+ if file_id and test_case_id == 'summary':
417+ test_case_id = '%s-summary' % file_id
418+ test_case_id = test_case_id.replace('/', '_')
419+ badchars = "[^a-zA-Z0-9\._-]"
420+ test_case_id = re.sub(badchars, "", test_case_id.replace(" ", "_"))
421+ test_results.append({'test_case_id': '%s_avg' % test_case_id,
422+ 'result': 'pass',
423+ 'measurement': average,
424+ 'units': 'ms'})
425+ test_results.append({'test_case_id': '%s_avg_dev' % test_case_id,
426+ 'result': 'pass',
427+ 'measurement': avg_dev,
428+ 'units': '%'})
429+
430+
431+with open(target_file, 'w') as fd:
432+ indent = ' ' * 2
433+ separators = (', ', ': ')
434+ json.dump(test_results, fd,
435+ use_decimal=True,
436+ indent=indent,
437+ separators=separators,
438+ sort_keys=False)
439+
440+print "The result has been merged in file: %s" % target_file
441+sys.exit(0)
442
443=== added file 'lava_android_test/test_definitions/methanol/start_server.py'
444--- lava_android_test/test_definitions/methanol/start_server.py 1970-01-01 00:00:00 +0000
445+++ lava_android_test/test_definitions/methanol/start_server.py 2012-08-11 09:41:19 +0000
446@@ -0,0 +1,62 @@
447+#/usr/bin/python
448+# Copyright (c) 2012 Linaro
449+
450+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
451+#
452+# This file is part of LAVA Android Test.
453+#
454+# This program is free software: you can redistribute it and/or modify
455+# it under the terms of the GNU General Public License as published by
456+# the Free Software Foundation, either version 3 of the License, or
457+# (at your option) any later version.
458+#
459+# This program is distributed in the hope that it will be useful,
460+# but WITHOUT ANY WARRANTY; without even the implied warranty of
461+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
462+# GNU General Public License for more details.
463+#
464+# You should have received a copy of the GNU General Public License
465+# along with this program. If not, see <http://www.gnu.org/licenses/>.
466+
467+import os
468+import sys
469+import CGIHTTPServer
470+import BaseHTTPServer
471+
472+### check parameter
473+if len(sys.argv) < 3:
474+ print 'Please spsecify the ip and directory like this:'
475+ print ' %s domain-or-ip directory-path url-file' % (
476+ os.path.basename(__file__))
477+ sys.exit(1)
478+
479+domain = sys.argv[1]
480+directory = sys.argv[2]
481+if len(sys.argv) == 4:
482+ url_file = sys.argv[3]
483+else:
484+ url_file = ''
485+
486+## change to that directory
487+old_dir = os.getcwd()
488+os.chdir(directory)
489+
490+## set the server configuration before start
491+cgi_handler = CGIHTTPServer.CGIHTTPRequestHandler
492+cgi_handler.cgi_directories.append('/cgi')
493+httpd = BaseHTTPServer.HTTPServer((domain, 0), cgi_handler)
494+url = '%s://%s:%s/' % ('http', httpd.socket.getsockname()[0],
495+ httpd.socket.getsockname()[1])
496+
497+## out put the url information to console and file for other script reference
498+print "serving at url=", url
499+if url_file:
500+ with open(url_file, 'w') as stream:
501+ stream.write(url)
502+ print 'The information of url also have been wirtten into file(%s)' % (
503+ url_file)
504+
505+try:
506+ httpd.serve_forever()
507+finally:
508+ os.chdir(old_dir)
509
510=== modified file 'lava_android_test/testdef.py'
511--- lava_android_test/testdef.py 2012-06-28 09:52:29 +0000
512+++ lava_android_test/testdef.py 2012-08-11 09:41:19 +0000
513@@ -319,6 +319,10 @@
514 cmd = cmd.replace('$(OPTIONS)', option)
515 else:
516 cmd = cmd.replace('$(OPTIONS)', '')
517+ if resultsdir is not None:
518+ cmd = cmd.replace('$(RESULTDIR)', resultsdir)
519+ else:
520+ cmd = cmd.replace('$(RESULTDIR)', '')
521 cmd = cmd.strip()
522 ret_code = self.adb.run_adb_shell_for_test(cmd,
523 stdoutlog,
524@@ -410,6 +414,23 @@
525 Results are then stored in self.results. If a fixupdict was supplied
526 it is used to convert test result strings to a standard format.
527 """
528+
529+ self.real_parse(result_filename=result_filename,
530+ output_filename=output_filename, test_name=test_name)
531+
532+ self.fixresults(self.fixupdict)
533+ if self.appendall:
534+ self.appendtoall(self.appendall)
535+ self.fixmeasurements()
536+ self.fixids(test_name=test_name)
537+
538+ def real_parse(self, result_filename='stdout.log',
539+ output_filename='stdout.log', test_name=''):
540+ """Using the pattern to do the real parse operation
541+
542+ generate the test_results elements from the result file by parsing
543+ with the pattern specified.
544+ """
545 if not self.pattern:
546 return
547
548@@ -448,11 +469,6 @@
549 if data.get('result') is None:
550 data['result'] = test_ok and 'pass' or 'fail'
551 self.results['test_results'].append(data)
552- self.fixresults(self.fixupdict)
553- if self.appendall:
554- self.appendtoall(self.appendall)
555- self.fixmeasurements()
556- self.fixids(test_name=test_name)
557
558 def append(self, testid, entry):
559 """Appends a dict to the test_results entry for a specified testid
560@@ -593,6 +609,11 @@
561 cmd = cmd.replace('$(OPTIONS)', option)
562 else:
563 cmd = cmd.replace('$(OPTIONS)', '')
564+ if resultsdir is not None:
565+ cmd = cmd.replace('$(RESULTDIR)', resultsdir)
566+ else:
567+ cmd = cmd.replace('$(RESULTDIR)', '')
568+
569 cmd = cmd.strip()
570 rc, output = adb.run_cmd_host(cmd, quiet=False)
571 if rc:
572@@ -610,6 +631,10 @@
573 cmd = cmd.replace('$(OPTIONS)', option)
574 else:
575 cmd = cmd.replace('$(OPTIONS)', '')
576+ if resultsdir is not None:
577+ cmd = cmd.replace('$(RESULTDIR)', resultsdir)
578+ else:
579+ cmd = cmd.replace('$(RESULTDIR)', '')
580 cmd = cmd.strip()
581 rc, output = adb.run_adb_cmd(cmd, quiet=False)
582 if rc:

Subscribers

People subscribed via source and target branches