Merge lp:~liuyq0307/lava-android-test/support-monkeyrunner into lp:lava-android-test

Proposed by Yongqin Liu
Status: Merged
Merged at revision: 158
Proposed branch: lp:~liuyq0307/lava-android-test/support-monkeyrunner
Merge into: lp:lava-android-test
Diff against target: 496 lines (+290/-15)
9 files modified
lava_android_test/commands.py (+174/-5)
lava_android_test/config.py (+3/-1)
lava_android_test/main.py (+3/-4)
lava_android_test/repository.py (+83/-0)
lava_android_test/test_definitions/tjbench.py (+1/-1)
lava_android_test/test_definitions/v8.py (+0/-1)
lava_android_test/testdef.py (+2/-2)
lava_android_test/utils.py (+23/-1)
setup.py (+1/-0)
To merge this branch: bzr merge lp:~liuyq0307/lava-android-test/support-monkeyrunner
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+106942@code.launchpad.net

This proposal supersedes a proposal from 2012-04-25.

Description of the change

add run-monkeyrunner sub command to make support monkeyrunner test easily.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote : Posted in a previous version of this proposal

It's pretty hard to review this as I'm not that fluent in the android parts of lava.

287 === added file 'lava_android_test/repository.py'

We already have lava-vcs which supports git and bzr through single API. Perhaps it would be better to use that instead?

Revision history for this message
Yongqin Liu (liuyq0307) wrote : Posted in a previous version of this proposal

On 25 April 2012 21:17, Zygmunt Krynicki <email address hidden>wrote:

> It's pretty hard to review this as I'm not that fluent in the android
> parts of lava.
>
> 287 === added file 'lava_android_test/repository.py'
>
> We already have lava-vcs which supports git and bzr through single API.
> Perhaps it would be better to use that instead?
>
This component is great.

Can it be used now?
And just one look, it has many files, seems a little complicate.
(Maybe it is easy to be used)

I'd like to change to use it after we merged it to lava-core

Revision history for this message
Zygmunt Krynicki (zyga) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

W dniu 25.04.2012 16:08, Yongqin Liu pisze:
> On 25 April 2012 21:17, Zygmunt Krynicki
> <email address hidden>wrote:
>
>> It's pretty hard to review this as I'm not that fluent in the
>> android parts of lava.
>>
>> 287 === added file 'lava_android_test/repository.py'
>>
>> We already have lava-vcs which supports git and bzr through
>> single API. Perhaps it would be better to use that instead?
>>
> This component is great.
>
> Can it be used now?

Yes

> And just one look, it has many files, seems a little complicate.
> (Maybe it is easy to be used)

It's pretty easy. The abstraction has three objects: IVCS (like git
and bzr), IRemoteBranch which has limited functionality but allows you
to create a local copy / branch / clone and ILocalBranch that gives
you extra stuff that I needed to work on lava. If you need more then
we can easily extend it.

PS: look at lava/vcs/interfaces.py - this is what you can do on both
git and bzr.

from lava.vcs.adapters import get_vcs
git = get_vcs("git")
remote_branch = git.open_remote("git://...")
local_branch = remote_branch.sprout_to_pathname("some-place")
print local_branch.get_revision_id()

> I'd like to change to use it after we merged it to lava-core

Ok

Thanks
ZK

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPmDD6AAoJEOvx/vtfL8ZXadQP/0ga6sQg+vojuR6+ZSxzD78t
JtPKaRfWPlKrK7FazNjZLVXl/M390bxR/fWbHP9VMCsf9ZgXXL2t8whA0wk4sxnB
tHeaGjqgc21S2XdwGMbQ/XHI9cdSKvwvzpdOTD0ClqcjCBCOhVzQcylZLGAXapiW
TQo6ZrEvHBJwI62soSxk4xTO1ry5POYy8ZoVreYlhrPuYYE0SH7wnLj/Q/hvodmk
MWV5wfxgsGjeUTykKtNSZ7GQV1bWo8Cq60BG8xrUIlI2QEtcahFL2LsvKU/kV3PG
3Ul3QYj+zNv/TYMgA2qkyK7xYG0Rd0Gk8vxMEfId2nndcXTgo8MCue/vn8eU2Q5d
XdLHN+KzwDT6tY2QnxwYIfYIejUyWIPxBIXVI1DTO7xiJyjNpT/WESugC2MHZdGx
0k6KFXEYiGpze9INgnFp55aanfCDWUd+TY6vW4I754CtTIxOpvmMRIzxghVNjNLT
PNglV3y3nLy22N7+XBf0yKl2n9mh0f8te4DYNtjckKi1/lUyY8F4rDkPdhBkYj/J
b4zfGuw1E50fZ1nc+VDGFD+MS7Odj1Kmu5aRTppRobuOFVlsOSqvd1mkZ0t/WMj9
5cq78RBcXboFQF9beZJowrK6pI+koHzM8n55sicdySUSPhh24KtXHgo2T2TBajyA
3rI4BWQy+2v9tuxRFSw8
=xea1
-----END PGP SIGNATURE-----

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote : Posted in a previous version of this proposal
Download full text (12.6 KiB)

Yongqin Liu <email address hidden> writes:

> Yongqin Liu has proposed merging lp:~liuyq0307/lava-android-test/support-monkeyrunner into lp:lava-android-test.
>
> Requested reviews:
> Linaro Validation Team (linaro-validation)
>
> For more details, see:
> https://code.launchpad.net/~liuyq0307/lava-android-test/support-monkeyrunner/+merge/103452
>
> add run-monkeyrunner sub command to make support monkeyrunner test easily.

It has to be said, this whole approach feels like a way for the android
team to get out of the chore of having to define their tests
properly... but if that's what they want, they can have it I guess.

I have quite a lot of Python coding issues, please see inline comments.

> === modified file 'lava_android_test/commands.py'
> --- lava_android_test/commands.py 2012-04-11 05:58:13 +0000
> +++ lava_android_test/commands.py 2012-04-25 12:02:22 +0000
> @@ -21,16 +21,20 @@
> import urlparse
> import versiontools
>
> +from tempfile import mkdtemp
> +
> from lava_tool.interface import Command as LAVACommand
> from lava_tool.interface import LavaCommandError
> from linaro_dashboard_bundle.io import DocumentIO
>
> from lava_android_test.adb import ADB
> from lava_android_test.config import get_config
> +from lava_android_test.repository import GitRepository
> from lava_android_test.testdef import testloader, AndroidTest
> from lava_android_test.testdef import AndroidTestRunner, \
> AndroidTestInstaller, \
> AndroidTestParser
> +from lava_android_test import utils
>
>
> class Command(LAVACommand):
> @@ -146,6 +150,17 @@
> test_dir = os.path.join(self.config.installdir_android, test_id)
> return self.adb.exists(test_dir)
>
> + def get_device_serial(self):
> + if not self.args.serial:
> + serial_ary = ADB().run_cmd_host('adb get-serialno')[1]
> + serial = serial_ary[0].strip()
> + if not serial or serial == 'unknown':
> + return ''
> + else:
> + return serial
> + else:
> + return self.args.serial
> +
>
> class AndroidTestCommand(AndroidCommand):
> @classmethod
> @@ -435,6 +450,136 @@
> self.say_end(tip_msg)
>
>
> +class run_monkeyrunner(AndroidCommand):
> + """
> + Run the monkeyrunner scripts that stored in the specified git repository

> + program:: lava-android-test run-monkeyrunner -g giturl -r resultfilelist
> + """
> +
> + @classmethod
> + def register_arguments(cls, parser):
> + super(run_monkeyrunner, cls).register_arguments(parser)
> + parser.add_argument("url",
> + help="The repository url of the test scripts")
> + parser.add_argument('-t', '--repo-type',
> + default='git',
> + help=("Specify the type of the repository"))
> + group = parser.add_argument_group("specify the bundle output file")
> + group.add_argument("-o", "--output",
> + default=None,
> + metavar="FILE",
> + he...

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

>> + if not self.test_installed(test.testname):
>> + test.install()
>
>The need to do this seems a bit strange, given that test.install()
>doesn't really seem to do anything? I guess given the way things work
>today it's needed.

The install function will create directory in the target, it is there for store some file.
But in this time, not really use.

Here used to keep the consistency with other tests.

>> + bundle = {}
>> + org_png_file_list = utils.find_files(config.tempdir_host,
>> + '.%s' % 'png')
>> + result_id = test.run(quiet=self.args.quiet)
>> + if self.args.output:
>> + cur_all_png_list = utils.find_files(config.tempdir_host,
>> + '.%s' % 'png')
>> + new_png_list = set(cur_all_png_list).difference(org_png_file_list)
>> + test_id = 'monkeyrunner(%s)' % (test_case_id)
>> + bundle = generate_bundle(self.args.serial,
>> + result_id, test=test,
>> + test_id=test_id,
>> + attachments=list(new_png_list))
>> + utils.delete_files(new_png_list)
>> + return bundle

>I can't find the code which will copy the pngs from the device to the
>host. Can you tell me where it is?

The png files are generate on the host by the monkeyrunner script, so there is no need to pull them form device.
And it is suggested to generated on the same directory of the monkeyrunner script file

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :
Download full text (13.1 KiB)

Thanks for fixing the things I complained about, however there seem to
be some new, unrelated changes that really belong in another branch...

Yongqin Liu <email address hidden> writes:

> Yongqin Liu has proposed merging lp:~liuyq0307/lava-android-test/support-monkeyrunner into lp:lava-android-test.
>
> Requested reviews:
> Linaro Validation Team (linaro-validation)
>
> For more details, see:
> https://code.launchpad.net/~liuyq0307/lava-android-test/support-monkeyrunner/+merge/106942
>
> add run-monkeyrunner sub command to make support monkeyrunner test easily.
> --
> https://code.launchpad.net/~liuyq0307/lava-android-test/support-monkeyrunner/+merge/106942
> Your team Linaro Validation Team is requested to review the proposed merge of lp:~liuyq0307/lava-android-test/support-monkeyrunner into lp:lava-android-test.
> === modified file 'lava_android_test/commands.py'
> --- lava_android_test/commands.py 2012-05-08 05:32:19 +0000
> +++ lava_android_test/commands.py 2012-05-23 06:49:24 +0000
> @@ -19,18 +19,23 @@
> import os
> import base64
> import urlparse
> +from uuid import uuid4
> import versiontools
>
> +from tempfile import mkdtemp
> +
> from lava_tool.interface import Command as LAVACommand
> from lava_tool.interface import LavaCommandError
> from linaro_dashboard_bundle.io import DocumentIO
>
> from lava_android_test.adb import ADB
> from lava_android_test.config import get_config
> +from lava_android_test.repository import GitRepository
> from lava_android_test.testdef import testloader, AndroidTest
> from lava_android_test.testdef import AndroidTestRunner, \
> AndroidTestInstaller, \
> AndroidTestParser
> +from lava_android_test import utils
>
>
> class Command(LAVACommand):
> @@ -146,6 +151,13 @@
> test_dir = os.path.join(self.config.installdir_android, test_id)
> return self.adb.exists(test_dir)
>
> + def get_device_serial(self):
> + if not self.args.serial:
> + serial_ary = ADB().run_cmd_host('adb get-serialno')[1]
> + serial = serial_ary[0].strip()
> + if not serial or serial == 'unknown':
> + return ''

This looks wrong -- I guess a 'return serial' has been dropped?

> def assertDeviceIsConnected(self):
> if not self.adb.isDeviceConnected():
> if self.adb.serial:
> @@ -163,7 +175,7 @@
>
> self.invoke_sub()
>
> - def invoke_sub():
> + def invoke_sub(self):
> raise NotImplementedError
>
>
> @@ -344,7 +356,7 @@
> class run_custom(AndroidCommand):
> """
> Run the command(s) that specified by the -c option in the command line

> - program:: lava-android-test run-custom -c 'command1' -c 'command2' -p 'parse-regex1'
> + program:: lava-android-test run-custom -c 'cm1' -c 'cmd2' -p 'parse-regex1'
> program:: lava-android-test run test-id -s device_serial
> program:: lava-android-test run test-id -s device_serial -o outputfile
> """
> @@ -453,6 +465,139 @@
> self.say_end(tip_msg)
>
>
> +class run_monkeyrunner(AndroidCommand):
> + """
> + Run the monkeyrun...

154. By Yongqin Liu

update the typo of bundle

155. By Yongqin Liu

revert project files

156. By Yongqin Liu

add return serial for get_device_serial according to review comment

157. By Yongqin Liu

modify bundle_format definition bug that using os.environ.get to define

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

206 - parser.add_argument('-p', '--parse-regex',
207 + parser.add_argument(' - p', ' - -parse - regex',

I still don't understand what this is for.

All else looks good, so if you can revert the above, please merge.

158. By Yongqin Liu

modify the auto rewriting error

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_android_test/commands.py'
2--- lava_android_test/commands.py 2012-05-08 05:32:19 +0000
3+++ lava_android_test/commands.py 2012-05-24 06:01:19 +0000
4@@ -19,18 +19,23 @@
5 import os
6 import base64
7 import urlparse
8+from uuid import uuid4
9 import versiontools
10
11+from tempfile import mkdtemp
12+
13 from lava_tool.interface import Command as LAVACommand
14 from lava_tool.interface import LavaCommandError
15 from linaro_dashboard_bundle.io import DocumentIO
16
17 from lava_android_test.adb import ADB
18 from lava_android_test.config import get_config
19+from lava_android_test.repository import GitRepository
20 from lava_android_test.testdef import testloader, AndroidTest
21 from lava_android_test.testdef import AndroidTestRunner, \
22 AndroidTestInstaller, \
23 AndroidTestParser
24+from lava_android_test import utils
25
26
27 class Command(LAVACommand):
28@@ -146,6 +151,15 @@
29 test_dir = os.path.join(self.config.installdir_android, test_id)
30 return self.adb.exists(test_dir)
31
32+ def get_device_serial(self):
33+ if not self.args.serial:
34+ serial_ary = ADB().run_cmd_host('adb get-serialno')[1]
35+ serial = serial_ary[0].strip()
36+ if not serial or serial == 'unknown':
37+ return ''
38+ else:
39+ return serial
40+
41 def assertDeviceIsConnected(self):
42 if not self.adb.isDeviceConnected():
43 if self.adb.serial:
44@@ -163,7 +177,7 @@
45
46 self.invoke_sub()
47
48- def invoke_sub():
49+ def invoke_sub(self):
50 raise NotImplementedError
51
52
53@@ -344,7 +358,7 @@
54 class run_custom(AndroidCommand):
55 """
56 Run the command(s) that specified by the -c option in the command line
57
58- program:: lava-android-test run-custom -c 'command1' -c 'command2' -p 'parse-regex1'
59+ program:: lava-android-test run-custom -c 'cm1' -c 'cmd2' -p 'parse-regex1'
60 program:: lava-android-test run test-id -s device_serial
61 program:: lava-android-test run test-id -s device_serial -o outputfile
62 """
63@@ -453,6 +467,139 @@
64 self.say_end(tip_msg)
65
66
67+class run_monkeyrunner(AndroidCommand):
68+ """
69+ Run the monkeyrunner scripts that stored in the specified git repository
70
71+ program:: lava-android-test run-monkeyrunner -g giturl -r resultfilelist
72+ """
73+
74+ @classmethod
75+ def register_arguments(cls, parser):
76+ super(run_monkeyrunner, cls).register_arguments(parser)
77+ parser.add_argument("url",
78+ help="The repository url of the test scripts")
79+ parser.add_argument('-t', '--repo-type',
80+ default='git',
81+ help=("Specify the type of the repository"))
82+ group = parser.add_argument_group("specify the bundle output file")
83+ group.add_argument("-o", "--output",
84+ default=None,
85+ metavar="FILE",
86+ help=("After running the test parse the result"
87+ " artefacts, fuse them with the initial"
88+ " bundle and finally save the complete bundle"
89+ " to the specified FILE."))
90+
91+ def invoke(self):
92+ config = get_config()
93+ if self.args.serial:
94+ serial = self.args.serial
95+ else:
96+ serial = self.get_device_serial()
97+ if not serial:
98+ raise LavaCommandError("No device attached")
99+ self.adb = ADB(serial)
100+
101+ if self.args.repo_type == 'git':
102+ target_dir = mkdtemp(prefix='git_repo', dir=config.tempdir_host)
103+ os.chmod(target_dir, 0755)
104+ GitRepository(self.args.url).checkout(target_dir)
105+ else:
106+ raise LavaCommandError("The repository type(%s) is not supported"
107+ % self.args.repo_type)
108+
109+ script_list = utils.find_files(target_dir, '.py')
110+
111+ test_id = self.args.url
112+ if len(test_id) > 40:
113+ test_id = '%s...' % (test_id[:40])
114+ test_id = 'monkeyrunner_%s' % test_id
115+
116+ tip_msg = ("Run monkeyrunner scripts in following url on device(%s):"
117+ "\n\turl=%s") % (
118+ self.args.serial,
119+ self.args.url)
120+
121+ self.say_begin(tip_msg)
122+ bundles = []
123+ for script in script_list:
124+ sub_bundle = {}
125+ from datetime import datetime
126+ starttime = datetime.utcnow()
127+ test_case_id = script.replace('%s/' % target_dir, '')
128+ if len(test_case_id) > 50:
129+ test_case_id = '%s...' % (test_case_id[:50])
130+ try:
131+ sub_bundle = self.run_monkeyrunner_test(script, serial,
132+ test_case_id)
133+ test_result = {"test_case_id": test_case_id,
134+ "result": 'pass'}
135+ if sub_bundle:
136+ sub_bundle['test_runs'][0]['test_results'].append(
137+ test_result)
138+ except Exception as strerror:
139+ self.say('Failed to run script(%s) with error:\n%s' % (
140+ script,
141+ strerror))
142+
143+ test_result = {"test_case_id": test_case_id,
144+ "result": 'fail'}
145+ TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
146+ sub_bundle['test_runs'] = [{'test_results': [test_result],
147+ 'test_id': 'monkeyrunner(%s)' % test_case_id,
148+ 'time_check_performed': False,
149+ 'analyzer_assigned_uuid': str(uuid4()),
150+ 'analyzer_assigned_date': starttime.strftime(TIMEFORMAT)}]
151+ if sub_bundle:
152+ bundles.append(sub_bundle)
153+
154+ if self.args.output:
155+ output_dir = os.path.dirname(self.args.output)
156+ if output_dir and (not os.path.exists(output_dir)):
157+ os.makedirs(output_dir)
158+ with open(self.args.output, "wt") as stream:
159+ DocumentIO.dump(stream, merge_bundles(bundles))
160+
161+ self.say_end(tip_msg)
162+
163+ def run_monkeyrunner_test(self, script, serial, test_case_id=None):
164+ config = get_config()
165+
166+ inst = AndroidTestInstaller()
167+ run = AndroidTestRunner(steps_host_pre=[
168+ 'monkeyrunner %s %s' % (script, serial)])
169+ parser = AndroidTestParser()
170+ test = AndroidTest(testname='monkeyrunner',
171+ installer=inst, runner=run, parser=parser)
172+ test.parser.results = {'test_results': []}
173+ test.setadb(self.adb)
174+
175+ ##By calling the install function, we will create the directory
176+ ##on the target, and the the output file and error file
177+ ##will be pushed there
178+ if not self.test_installed(test.testname):
179+ test.install()
180+
181+ ##The png files here are generated to the host by the monkeyrunner
182+ ##monkeyrunner is run on host, not on the target
183+ bundle = {}
184+ org_png_file_list = utils.find_files(config.tempdir_host,
185+ '.%s' % 'png')
186+ result_id = test.run(quiet=self.args.quiet)
187+ if self.args.output:
188+ cur_all_png_list = utils.find_files(config.tempdir_host,
189+ '.%s' % 'png')
190+ new_png_list = set(cur_all_png_list).difference(org_png_file_list)
191+ test_id = 'monkeyrunner(%s)' % (test_case_id)
192+ bundle = generate_bundle(self.args.serial,
193+ result_id, test=test,
194+ test_id=test_id,
195+ attachments=list(new_png_list))
196+ utils.delete_files(new_png_list)
197+
198+ return bundle
199+
200+
201 class parse(AndroidResultsCommand):
202 """
203 Parse the results of previous test that run on the specified device
204
205@@ -518,19 +665,30 @@
206 return bundle
207
208
209-def generate_bundle(serial=None, result_id=None, test=None, test_id=None):
210+def merge_bundles(bundles=[]):
211+ config = get_config()
212+ merged_bundles = {"format": config.bundle_format,
213+ 'test_runs': []}
214+ for bundle in bundles:
215+ if bundle['test_runs']:
216+ merged_bundles['test_runs'].append(bundle['test_runs'][0])
217+ return merged_bundles
218+
219+
220+def generate_bundle(serial=None, result_id=None, test=None,
221+ test_id=None, attachments=[]):
222 if result_id is None:
223 return {}
224 config = get_config()
225 adb = ADB(serial)
226 resultdir = os.path.join(config.resultsdir_android, result_id)
227 if not adb.exists(resultdir):
228- raise LavaCommandError("The result (%s) is not existed." % result_id)
229+ raise Exception("The result (%s) is not existed." % result_id)
230
231 bundle_text = adb.read_file(os.path.join(resultdir, "testdata.json"))
232 bundle = DocumentIO.loads(bundle_text)[1]
233 test_tmp = None
234- if bundle['test_runs'][0]['test_id'] == 'custom':
235+ if test:
236 test_tmp = test
237 else:
238 test_tmp = testloader(bundle['test_runs'][0]['test_id'], serial)
239@@ -560,6 +718,7 @@
240 "content": base64.standard_b64encode(stderr_text)
241 }
242 ]
243+
244 screencap_path = os.path.join(resultdir, 'screencap.png')
245 if adb.exists(screencap_path):
246 tmp_path = os.path.join(config.tempdir_host, 'screencap.png')
247@@ -571,7 +730,17 @@
248 "pathname": 'screencap.png',
249 "mime_type": 'image/png',
250 "content": base64.standard_b64encode(data)})
251+ os.unlink(tmp_path)
252
253+ for attach in attachments:
254+ if os.path.exists(attach):
255+ with open(attach, 'rb') as stream:
256+ data = stream.read()
257+ if data:
258+ bundle['test_runs'][0]["attachments"].append({
259+ "pathname": os.path.basename(attach),
260+ "mime_type": 'image/png',
261+ "content": base64.standard_b64encode(data)})
262 return bundle
263
264
265
266=== modified file 'lava_android_test/config.py'
267--- lava_android_test/config.py 2012-03-08 11:29:09 +0000
268+++ lava_android_test/config.py 2012-05-24 06:01:19 +0000
269@@ -1,4 +1,4 @@
270-# Copyright (c) 2010-2011 Linaro
271+# Copyright (c) 2010-2012 Linaro
272
273 # Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
274 #
275@@ -33,6 +33,8 @@
276 self.tempdir_android = os.path.join(home, 'temp')
277 self.tempdir_host = os.environ.get('ANDROID_TEST_TEMP_HOST',
278 '/tmp/lava-android-test')
279+ self.bundle_format = "Dashboard Bundle Format 1.3"
280+
281
282 _config = None
283
284
285=== modified file 'lava_android_test/main.py'
286--- lava_android_test/main.py 2012-03-09 03:31:21 +0000
287+++ lava_android_test/main.py 2012-05-24 06:01:19 +0000
288@@ -1,4 +1,4 @@
289-# Copyright (c) 2010 Linaro
290+# Copyright (c) 2010-2012 Linaro
291 #
292 # This program is free software: you can redistribute it and/or modify
293 # it under the terms of the GNU General Public License as published by
294@@ -14,9 +14,9 @@
295 # along with this program. If not, see <http://www.gnu.org/licenses/>.
296 import os
297 import sys
298-import subprocess
299 import shutil
300 from tempfile import mkdtemp
301+from lava_android_test import utils
302 from lava_android_test.config import get_config, set_config
303 from lava_tool.dispatcher import LavaDispatcher, run_with_dispatcher_class
304
305@@ -33,8 +33,7 @@
306
307
308 def check_adb_installed():
309- rc = subprocess.call(["which", "adb"], stdout=open('/dev/null', 'w'))
310- return rc == 0
311+ return utils.check_command_exist('adb')
312
313
314 def main():
315
316=== added file 'lava_android_test/repository.py'
317--- lava_android_test/repository.py 1970-01-01 00:00:00 +0000
318+++ lava_android_test/repository.py 2012-05-24 06:01:19 +0000
319@@ -0,0 +1,83 @@
320+# Copyright (C) 2012 Linaro Limited
321+#
322+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
323+#
324+# This file is part of LAVA Android Test.
325+
326+# This program is free software: you can redistribute it and/or modify
327+# it under the terms of the GNU General Public License as published by
328+# the Free Software Foundation, either version 3 of the License, or
329+# (at your option) any later version.
330+#
331+# This program is distributed in the hope that it will be useful,
332+# but WITHOUT ANY WARRANTY; without even the implied warranty of
333+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
334+# GNU General Public License for more details.
335+#
336+# You should have received a copy of the GNU General Public License
337+# along with this program. If not, see <http://www.gnu.org/licenses/>.
338+import os
339+import subprocess
340+
341+from lava_android_test import utils
342+
343+
344+class RepositoryError(Exception):
345+ """
346+ Raise this for repository related errors
347+ """
348+
349+
350+class Repository(object):
351+ '''
352+ Base class for all repository class used to checkout files.
353+ This class and sub classes are base the repository command.
354+ '''
355+
356+ def __init__(self, url, repo_type, cmds=[]):
357+ self.url = url
358+ self.repo_type = repo_type
359+ self.check_cmds_exist(cmds)
360+
361+ def checkout(self, target_dir=None):
362+ """
363+ Checkout this repository to the specified the target_dir directory
364+ """
365+ raise NotImplementedError()
366+
367+ def check_cmds_exist(self, cmds=[]):
368+ """
369+ check whether the necessary commands are existing.
370+ """
371+ for cmd in cmds:
372+ if not utils.check_command_exist(cmd):
373+ raise RepositoryError(("The necessary command(%) does not"
374+ " exist, Or can't be seen from path")
375+ % cmd)
376+
377+
378+class GitRepository(Repository):
379+
380+ git_cmd = 'git'
381+
382+ def __init__(self, url):
383+ super(GitRepository, self).__init__(url, 'git', [self.git_cmd])
384+
385+ def checkout(self, target_dir=None):
386+ """
387+ Checkout this git repository to the specified the target_dir directory
388+ """
389+ cmds = []
390+ if not target_dir:
391+ cmds = [self.git_cmd, 'clone', self.url]
392+
393+ else:
394+ if not os.path.exists(target_dir):
395+ os.makedirs(target_dir)
396+ cmds = [self.git_cmd, 'clone', self.url, target_dir]
397+
398+ rc = subprocess.call(cmds)
399+ if rc != 0:
400+ raise RepositoryError(("Failed to clone the specified "
401+ "repository() with exist staus=%d")
402+ % (self.url, rc))
403
404=== modified file 'lava_android_test/test_definitions/tjbench.py'
405--- lava_android_test/test_definitions/tjbench.py 2012-04-06 13:14:51 +0000
406+++ lava_android_test/test_definitions/tjbench.py 2012-05-24 06:01:19 +0000
407@@ -87,7 +87,7 @@
408 if not prefix_hash.get(test_case_preffix):
409 prefix_hash[test_case_preffix] = True
410 test_case_preffix = '%s_%s' % (test_case_preffix,
411- 'scale_half')
412+ 'scale_half')
413 common_data = {'log_filename': result_filename,
414 'log_lineno': lineno,
415 'result': 'pass'
416
417=== modified file 'lava_android_test/test_definitions/v8.py'
418--- lava_android_test/test_definitions/v8.py 2012-03-20 14:13:50 +0000
419+++ lava_android_test/test_definitions/v8.py 2012-05-24 06:01:19 +0000
420@@ -17,7 +17,6 @@
421 #
422 # You should have received a copy of the GNU General Public License
423 # along with this program. If not, see <http://www.gnu.org/licenses/>.
424-
425 import lava_android_test.config
426 import lava_android_test.testdef
427
428
429=== modified file 'lava_android_test/testdef.py'
430--- lava_android_test/testdef.py 2012-05-23 01:22:17 +0000
431+++ lava_android_test/testdef.py 2012-05-24 06:01:19 +0000
432@@ -131,9 +131,10 @@
433 bundle['test_runs'][0]['attributes']['install_options'] = output[0]
434
435 def _savetestdata(self, analyzer_assigned_uuid):
436+ config = get_config()
437 TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
438 bundle = {
439- 'format': 'Dashboard Bundle Format 1.3',
440+ 'format': config.bundle_format,
441 'test_runs': [
442 {
443 'analyzer_assigned_uuid': analyzer_assigned_uuid,
444@@ -149,7 +150,6 @@
445 }
446 ]
447 }
448- config = get_config()
449 self._add_install_options(bundle, config)
450 filename_host = os.path.join(config.tempdir_host, 'testdata.json')
451 write_file(DocumentIO.dumps(bundle), filename_host)
452
453=== modified file 'lava_android_test/utils.py'
454--- lava_android_test/utils.py 2012-03-08 11:29:09 +0000
455+++ lava_android_test/utils.py 2012-05-24 06:01:19 +0000
456@@ -1,4 +1,4 @@
457-# Copyright (c) 2010 Linaro
458+# Copyright (c) 2010-2012 Linaro
459 #
460 # This program is free software: you can redistribute it and/or modify
461 # it under the terms of the GNU General Public License as published by
462@@ -152,3 +152,25 @@
463 if rest is None or rest == '':
464 return host
465 return os.path.basename(rest)
466+
467+
468+def check_command_exist(command):
469+ rc = subprocess.call(["which", command], stdout=open('/dev/null', 'w'))
470+ return rc == 0
471+
472+
473+def find_files(target_dir, ext):
474+ file_list = []
475+ for rootdir, dirs, files in os.walk(target_dir):
476+ for f in files:
477+ if f.upper().endswith(ext.upper()):
478+ file_list.append(os.path.join(rootdir, f))
479+
480+ file_list.sort()
481+ return file_list
482+
483+
484+def delete_files(flist=[]):
485+ for f in flist:
486+ if os.path.exists(f):
487+ os.unlink(f)
488
489=== modified file 'setup.py'
490--- setup.py 2012-03-07 10:09:01 +0000
491+++ setup.py 2012-05-24 06:01:19 +0000
492@@ -42,6 +42,7 @@
493 uninstall=lava_android_test.commands:uninstall
494 run=lava_android_test.commands:run
495 run-custom=lava_android_test.commands:run_custom
496+ run-monkeyrunner=lava_android_test.commands:run_monkeyrunner
497 parse=lava_android_test.commands:parse
498 parse-custom=lava_android_test.commands:parse_custom
499 show=lava_android_test.commands:show

Subscribers

People subscribed via source and target branches