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
=== 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-24 06:01:19 +0000
@@ -19,18 +19,23 @@
19import os19import os
20import base6420import base64
21import urlparse21import urlparse
22from uuid import uuid4
22import versiontools23import versiontools
2324
25from tempfile import mkdtemp
26
24from lava_tool.interface import Command as LAVACommand27from lava_tool.interface import Command as LAVACommand
25from lava_tool.interface import LavaCommandError28from lava_tool.interface import LavaCommandError
26from linaro_dashboard_bundle.io import DocumentIO29from linaro_dashboard_bundle.io import DocumentIO
2730
28from lava_android_test.adb import ADB31from lava_android_test.adb import ADB
29from lava_android_test.config import get_config32from lava_android_test.config import get_config
33from lava_android_test.repository import GitRepository
30from lava_android_test.testdef import testloader, AndroidTest34from lava_android_test.testdef import testloader, AndroidTest
31from lava_android_test.testdef import AndroidTestRunner, \35from lava_android_test.testdef import AndroidTestRunner, \
32 AndroidTestInstaller, \36 AndroidTestInstaller, \
33 AndroidTestParser37 AndroidTestParser
38from lava_android_test import utils
3439
3540
36class Command(LAVACommand):41class Command(LAVACommand):
@@ -146,6 +151,15 @@
146 test_dir = os.path.join(self.config.installdir_android, test_id)151 test_dir = os.path.join(self.config.installdir_android, test_id)
147 return self.adb.exists(test_dir)152 return self.adb.exists(test_dir)
148153
154 def get_device_serial(self):
155 if not self.args.serial:
156 serial_ary = ADB().run_cmd_host('adb get-serialno')[1]
157 serial = serial_ary[0].strip()
158 if not serial or serial == 'unknown':
159 return ''
160 else:
161 return serial
162
149 def assertDeviceIsConnected(self):163 def assertDeviceIsConnected(self):
150 if not self.adb.isDeviceConnected():164 if not self.adb.isDeviceConnected():
151 if self.adb.serial:165 if self.adb.serial:
@@ -163,7 +177,7 @@
163177
164 self.invoke_sub()178 self.invoke_sub()
165179
166 def invoke_sub():180 def invoke_sub(self):
167 raise NotImplementedError181 raise NotImplementedError
168182
169183
@@ -344,7 +358,7 @@
344class run_custom(AndroidCommand):358class run_custom(AndroidCommand):
345 """359 """
346 Run the command(s) that specified by the -c option in the command line360 Run the command(s) that specified by the -c option in the command line
347361
348 program:: lava-android-test run-custom -c 'command1' -c 'command2' -p 'parse-regex1'362 program:: lava-android-test run-custom -c 'cm1' -c 'cmd2' -p 'parse-regex1'
349 program:: lava-android-test run test-id -s device_serial363 program:: lava-android-test run test-id -s device_serial
350 program:: lava-android-test run test-id -s device_serial -o outputfile364 program:: lava-android-test run test-id -s device_serial -o outputfile
351 """365 """
@@ -453,6 +467,139 @@
453 self.say_end(tip_msg)467 self.say_end(tip_msg)
454468
455469
470class run_monkeyrunner(AndroidCommand):
471 """
472 Run the monkeyrunner scripts that stored in the specified git repository
456473
474 program:: lava-android-test run-monkeyrunner -g giturl -r resultfilelist
475 """
476
477 @classmethod
478 def register_arguments(cls, parser):
479 super(run_monkeyrunner, cls).register_arguments(parser)
480 parser.add_argument("url",
481 help="The repository url of the test scripts")
482 parser.add_argument('-t', '--repo-type',
483 default='git',
484 help=("Specify the type of the repository"))
485 group = parser.add_argument_group("specify the bundle output file")
486 group.add_argument("-o", "--output",
487 default=None,
488 metavar="FILE",
489 help=("After running the test parse the result"
490 " artefacts, fuse them with the initial"
491 " bundle and finally save the complete bundle"
492 " to the specified FILE."))
493
494 def invoke(self):
495 config = get_config()
496 if self.args.serial:
497 serial = self.args.serial
498 else:
499 serial = self.get_device_serial()
500 if not serial:
501 raise LavaCommandError("No device attached")
502 self.adb = ADB(serial)
503
504 if self.args.repo_type == 'git':
505 target_dir = mkdtemp(prefix='git_repo', dir=config.tempdir_host)
506 os.chmod(target_dir, 0755)
507 GitRepository(self.args.url).checkout(target_dir)
508 else:
509 raise LavaCommandError("The repository type(%s) is not supported"
510 % self.args.repo_type)
511
512 script_list = utils.find_files(target_dir, '.py')
513
514 test_id = self.args.url
515 if len(test_id) > 40:
516 test_id = '%s...' % (test_id[:40])
517 test_id = 'monkeyrunner_%s' % test_id
518
519 tip_msg = ("Run monkeyrunner scripts in following url on device(%s):"
520 "\n\turl=%s") % (
521 self.args.serial,
522 self.args.url)
523
524 self.say_begin(tip_msg)
525 bundles = []
526 for script in script_list:
527 sub_bundle = {}
528 from datetime import datetime
529 starttime = datetime.utcnow()
530 test_case_id = script.replace('%s/' % target_dir, '')
531 if len(test_case_id) > 50:
532 test_case_id = '%s...' % (test_case_id[:50])
533 try:
534 sub_bundle = self.run_monkeyrunner_test(script, serial,
535 test_case_id)
536 test_result = {"test_case_id": test_case_id,
537 "result": 'pass'}
538 if sub_bundle:
539 sub_bundle['test_runs'][0]['test_results'].append(
540 test_result)
541 except Exception as strerror:
542 self.say('Failed to run script(%s) with error:\n%s' % (
543 script,
544 strerror))
545
546 test_result = {"test_case_id": test_case_id,
547 "result": 'fail'}
548 TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
549 sub_bundle['test_runs'] = [{'test_results': [test_result],
550 'test_id': 'monkeyrunner(%s)' % test_case_id,
551 'time_check_performed': False,
552 'analyzer_assigned_uuid': str(uuid4()),
553 'analyzer_assigned_date': starttime.strftime(TIMEFORMAT)}]
554 if sub_bundle:
555 bundles.append(sub_bundle)
556
557 if self.args.output:
558 output_dir = os.path.dirname(self.args.output)
559 if output_dir and (not os.path.exists(output_dir)):
560 os.makedirs(output_dir)
561 with open(self.args.output, "wt") as stream:
562 DocumentIO.dump(stream, merge_bundles(bundles))
563
564 self.say_end(tip_msg)
565
566 def run_monkeyrunner_test(self, script, serial, test_case_id=None):
567 config = get_config()
568
569 inst = AndroidTestInstaller()
570 run = AndroidTestRunner(steps_host_pre=[
571 'monkeyrunner %s %s' % (script, serial)])
572 parser = AndroidTestParser()
573 test = AndroidTest(testname='monkeyrunner',
574 installer=inst, runner=run, parser=parser)
575 test.parser.results = {'test_results': []}
576 test.setadb(self.adb)
577
578 ##By calling the install function, we will create the directory
579 ##on the target, and the the output file and error file
580 ##will be pushed there
581 if not self.test_installed(test.testname):
582 test.install()
583
584 ##The png files here are generated to the host by the monkeyrunner
585 ##monkeyrunner is run on host, not on the target
586 bundle = {}
587 org_png_file_list = utils.find_files(config.tempdir_host,
588 '.%s' % 'png')
589 result_id = test.run(quiet=self.args.quiet)
590 if self.args.output:
591 cur_all_png_list = utils.find_files(config.tempdir_host,
592 '.%s' % 'png')
593 new_png_list = set(cur_all_png_list).difference(org_png_file_list)
594 test_id = 'monkeyrunner(%s)' % (test_case_id)
595 bundle = generate_bundle(self.args.serial,
596 result_id, test=test,
597 test_id=test_id,
598 attachments=list(new_png_list))
599 utils.delete_files(new_png_list)
600
601 return bundle
602
603
457class parse(AndroidResultsCommand):604class parse(AndroidResultsCommand):
458 """605 """
459 Parse the results of previous test that run on the specified device606 Parse the results of previous test that run on the specified device
460607
@@ -518,19 +665,30 @@
518 return bundle665 return bundle
519666
520667
521def generate_bundle(serial=None, result_id=None, test=None, test_id=None):668def merge_bundles(bundles=[]):
669 config = get_config()
670 merged_bundles = {"format": config.bundle_format,
671 'test_runs': []}
672 for bundle in bundles:
673 if bundle['test_runs']:
674 merged_bundles['test_runs'].append(bundle['test_runs'][0])
675 return merged_bundles
676
677
678def generate_bundle(serial=None, result_id=None, test=None,
679 test_id=None, attachments=[]):
522 if result_id is None:680 if result_id is None:
523 return {}681 return {}
524 config = get_config()682 config = get_config()
525 adb = ADB(serial)683 adb = ADB(serial)
526 resultdir = os.path.join(config.resultsdir_android, result_id)684 resultdir = os.path.join(config.resultsdir_android, result_id)
527 if not adb.exists(resultdir):685 if not adb.exists(resultdir):
528 raise LavaCommandError("The result (%s) is not existed." % result_id)686 raise Exception("The result (%s) is not existed." % result_id)
529687
530 bundle_text = adb.read_file(os.path.join(resultdir, "testdata.json"))688 bundle_text = adb.read_file(os.path.join(resultdir, "testdata.json"))
531 bundle = DocumentIO.loads(bundle_text)[1]689 bundle = DocumentIO.loads(bundle_text)[1]
532 test_tmp = None690 test_tmp = None
533 if bundle['test_runs'][0]['test_id'] == 'custom':691 if test:
534 test_tmp = test692 test_tmp = test
535 else:693 else:
536 test_tmp = testloader(bundle['test_runs'][0]['test_id'], serial)694 test_tmp = testloader(bundle['test_runs'][0]['test_id'], serial)
@@ -560,6 +718,7 @@
560 "content": base64.standard_b64encode(stderr_text)718 "content": base64.standard_b64encode(stderr_text)
561 }719 }
562 ]720 ]
721
563 screencap_path = os.path.join(resultdir, 'screencap.png')722 screencap_path = os.path.join(resultdir, 'screencap.png')
564 if adb.exists(screencap_path):723 if adb.exists(screencap_path):
565 tmp_path = os.path.join(config.tempdir_host, 'screencap.png')724 tmp_path = os.path.join(config.tempdir_host, 'screencap.png')
@@ -571,7 +730,17 @@
571 "pathname": 'screencap.png',730 "pathname": 'screencap.png',
572 "mime_type": 'image/png',731 "mime_type": 'image/png',
573 "content": base64.standard_b64encode(data)})732 "content": base64.standard_b64encode(data)})
733 os.unlink(tmp_path)
574734
735 for attach in attachments:
736 if os.path.exists(attach):
737 with open(attach, 'rb') as stream:
738 data = stream.read()
739 if data:
740 bundle['test_runs'][0]["attachments"].append({
741 "pathname": os.path.basename(attach),
742 "mime_type": 'image/png',
743 "content": base64.standard_b64encode(data)})
575 return bundle744 return bundle
576745
577746
578747
=== modified file 'lava_android_test/config.py'
--- lava_android_test/config.py 2012-03-08 11:29:09 +0000
+++ lava_android_test/config.py 2012-05-24 06:01:19 +0000
@@ -1,4 +1,4 @@
1# Copyright (c) 2010-2011 Linaro1# Copyright (c) 2010-2012 Linaro
22
3# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>3# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
4#4#
@@ -33,6 +33,8 @@
33 self.tempdir_android = os.path.join(home, 'temp')33 self.tempdir_android = os.path.join(home, 'temp')
34 self.tempdir_host = os.environ.get('ANDROID_TEST_TEMP_HOST',34 self.tempdir_host = os.environ.get('ANDROID_TEST_TEMP_HOST',
35 '/tmp/lava-android-test')35 '/tmp/lava-android-test')
36 self.bundle_format = "Dashboard Bundle Format 1.3"
37
3638
37_config = None39_config = None
3840
3941
=== modified file 'lava_android_test/main.py'
--- lava_android_test/main.py 2012-03-09 03:31:21 +0000
+++ lava_android_test/main.py 2012-05-24 06:01:19 +0000
@@ -1,4 +1,4 @@
1# Copyright (c) 2010 Linaro1# Copyright (c) 2010-2012 Linaro
2#2#
3# This program is free software: you can redistribute it and/or modify3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -14,9 +14,9 @@
14# along with this program. If not, see <http://www.gnu.org/licenses/>.14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15import os15import os
16import sys16import sys
17import subprocess
18import shutil17import shutil
19from tempfile import mkdtemp18from tempfile import mkdtemp
19from lava_android_test import utils
20from lava_android_test.config import get_config, set_config20from lava_android_test.config import get_config, set_config
21from lava_tool.dispatcher import LavaDispatcher, run_with_dispatcher_class21from lava_tool.dispatcher import LavaDispatcher, run_with_dispatcher_class
2222
@@ -33,8 +33,7 @@
3333
3434
35def check_adb_installed():35def check_adb_installed():
36 rc = subprocess.call(["which", "adb"], stdout=open('/dev/null', 'w'))36 return utils.check_command_exist('adb')
37 return rc == 0
3837
3938
40def main():39def main():
4140
=== added file 'lava_android_test/repository.py'
--- lava_android_test/repository.py 1970-01-01 00:00:00 +0000
+++ lava_android_test/repository.py 2012-05-24 06:01:19 +0000
@@ -0,0 +1,83 @@
1# Copyright (C) 2012 Linaro Limited
2#
3# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
4#
5# This file is part of LAVA Android Test.
6
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19import os
20import subprocess
21
22from lava_android_test import utils
23
24
25class RepositoryError(Exception):
26 """
27 Raise this for repository related errors
28 """
29
30
31class Repository(object):
32 '''
33 Base class for all repository class used to checkout files.
34 This class and sub classes are base the repository command.
35 '''
36
37 def __init__(self, url, repo_type, cmds=[]):
38 self.url = url
39 self.repo_type = repo_type
40 self.check_cmds_exist(cmds)
41
42 def checkout(self, target_dir=None):
43 """
44 Checkout this repository to the specified the target_dir directory
45 """
46 raise NotImplementedError()
47
48 def check_cmds_exist(self, cmds=[]):
49 """
50 check whether the necessary commands are existing.
51 """
52 for cmd in cmds:
53 if not utils.check_command_exist(cmd):
54 raise RepositoryError(("The necessary command(%) does not"
55 " exist, Or can't be seen from path")
56 % cmd)
57
58
59class GitRepository(Repository):
60
61 git_cmd = 'git'
62
63 def __init__(self, url):
64 super(GitRepository, self).__init__(url, 'git', [self.git_cmd])
65
66 def checkout(self, target_dir=None):
67 """
68 Checkout this git repository to the specified the target_dir directory
69 """
70 cmds = []
71 if not target_dir:
72 cmds = [self.git_cmd, 'clone', self.url]
73
74 else:
75 if not os.path.exists(target_dir):
76 os.makedirs(target_dir)
77 cmds = [self.git_cmd, 'clone', self.url, target_dir]
78
79 rc = subprocess.call(cmds)
80 if rc != 0:
81 raise RepositoryError(("Failed to clone the specified "
82 "repository() with exist staus=%d")
83 % (self.url, rc))
084
=== modified file 'lava_android_test/test_definitions/tjbench.py'
--- lava_android_test/test_definitions/tjbench.py 2012-04-06 13:14:51 +0000
+++ lava_android_test/test_definitions/tjbench.py 2012-05-24 06:01:19 +0000
@@ -87,7 +87,7 @@
87 if not prefix_hash.get(test_case_preffix):87 if not prefix_hash.get(test_case_preffix):
88 prefix_hash[test_case_preffix] = True88 prefix_hash[test_case_preffix] = True
89 test_case_preffix = '%s_%s' % (test_case_preffix,89 test_case_preffix = '%s_%s' % (test_case_preffix,
90 'scale_half') 90 'scale_half')
91 common_data = {'log_filename': result_filename,91 common_data = {'log_filename': result_filename,
92 'log_lineno': lineno,92 'log_lineno': lineno,
93 'result': 'pass'93 'result': 'pass'
9494
=== modified file 'lava_android_test/test_definitions/v8.py'
--- lava_android_test/test_definitions/v8.py 2012-03-20 14:13:50 +0000
+++ lava_android_test/test_definitions/v8.py 2012-05-24 06:01:19 +0000
@@ -17,7 +17,6 @@
17#17#
18# You should have received a copy of the GNU General Public License18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21import lava_android_test.config20import lava_android_test.config
22import lava_android_test.testdef21import lava_android_test.testdef
2322
2423
=== modified file 'lava_android_test/testdef.py'
--- lava_android_test/testdef.py 2012-05-23 01:22:17 +0000
+++ lava_android_test/testdef.py 2012-05-24 06:01:19 +0000
@@ -131,9 +131,10 @@
131 bundle['test_runs'][0]['attributes']['install_options'] = output[0]131 bundle['test_runs'][0]['attributes']['install_options'] = output[0]
132132
133 def _savetestdata(self, analyzer_assigned_uuid):133 def _savetestdata(self, analyzer_assigned_uuid):
134 config = get_config()
134 TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'135 TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
135 bundle = {136 bundle = {
136 'format': 'Dashboard Bundle Format 1.3',137 'format': config.bundle_format,
137 'test_runs': [138 'test_runs': [
138 {139 {
139 'analyzer_assigned_uuid': analyzer_assigned_uuid,140 'analyzer_assigned_uuid': analyzer_assigned_uuid,
@@ -149,7 +150,6 @@
149 }150 }
150 ]151 ]
151 }152 }
152 config = get_config()
153 self._add_install_options(bundle, config)153 self._add_install_options(bundle, config)
154 filename_host = os.path.join(config.tempdir_host, 'testdata.json')154 filename_host = os.path.join(config.tempdir_host, 'testdata.json')
155 write_file(DocumentIO.dumps(bundle), filename_host)155 write_file(DocumentIO.dumps(bundle), filename_host)
156156
=== modified file 'lava_android_test/utils.py'
--- lava_android_test/utils.py 2012-03-08 11:29:09 +0000
+++ lava_android_test/utils.py 2012-05-24 06:01:19 +0000
@@ -1,4 +1,4 @@
1# Copyright (c) 2010 Linaro1# Copyright (c) 2010-2012 Linaro
2#2#
3# This program is free software: you can redistribute it and/or modify3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -152,3 +152,25 @@
152 if rest is None or rest == '':152 if rest is None or rest == '':
153 return host153 return host
154 return os.path.basename(rest)154 return os.path.basename(rest)
155
156
157def check_command_exist(command):
158 rc = subprocess.call(["which", command], stdout=open('/dev/null', 'w'))
159 return rc == 0
160
161
162def find_files(target_dir, ext):
163 file_list = []
164 for rootdir, dirs, files in os.walk(target_dir):
165 for f in files:
166 if f.upper().endswith(ext.upper()):
167 file_list.append(os.path.join(rootdir, f))
168
169 file_list.sort()
170 return file_list
171
172
173def delete_files(flist=[]):
174 for f in flist:
175 if os.path.exists(f):
176 os.unlink(f)
155177
=== modified file 'setup.py'
--- setup.py 2012-03-07 10:09:01 +0000
+++ setup.py 2012-05-24 06:01:19 +0000
@@ -42,6 +42,7 @@
42 uninstall=lava_android_test.commands:uninstall42 uninstall=lava_android_test.commands:uninstall
43 run=lava_android_test.commands:run43 run=lava_android_test.commands:run
44 run-custom=lava_android_test.commands:run_custom44 run-custom=lava_android_test.commands:run_custom
45 run-monkeyrunner=lava_android_test.commands:run_monkeyrunner
45 parse=lava_android_test.commands:parse46 parse=lava_android_test.commands:parse
46 parse-custom=lava_android_test.commands:parse_custom47 parse-custom=lava_android_test.commands:parse_custom
47 show=lava_android_test.commands:show48 show=lava_android_test.commands:show

Subscribers

People subscribed via source and target branches