Merge lp:~le-chi-thu/lava-test/using-lava-tool-2 into lp:lava-test/0.0
- using-lava-tool-2
- Merge into trunk
Proposed by
Le Chi Thu
Status: | Merged |
---|---|
Merged at revision: | 93 |
Proposed branch: | lp:~le-chi-thu/lava-test/using-lava-tool-2 |
Merge into: | lp:lava-test/0.0 |
Diff against target: |
7538 lines (+3730/-2909) 79 files modified
.bzrignore (+1/-0) MANIFEST.in (+0/-1) README (+3/-11) abrek/api.py (+0/-76) abrek/builtins.py (+0/-175) abrek/bundle.py (+0/-44) abrek/cache.py (+0/-73) abrek/command.py (+0/-171) abrek/config.py (+0/-93) abrek/dashboard.py (+0/-206) abrek/hwprofile.py (+0/-216) abrek/providers.py (+0/-145) abrek/results.py (+0/-111) abrek/swprofile.py (+0/-65) abrek/testdef.py (+0/-435) bin/lava-test (+0/-31) doc/changes.rst (+25/-0) doc/conf.py (+211/-0) doc/index.rst (+81/-0) doc/installation.rst (+66/-0) doc/reference.rst (+107/-0) doc/todo.rst (+4/-0) doc/usage.rst (+195/-0) examples/power-management-tests.json (+1/-1) examples/stream.json (+1/-1) lava_test/__init__.py (+1/-1) lava_test/api/__init__.py (+24/-0) lava_test/api/core.py (+164/-0) lava_test/api/delegates.py (+119/-0) lava_test/api/observers.py (+120/-0) lava_test/commands.py (+383/-0) lava_test/core/artifacts.py (+277/-0) lava_test/core/config.py (+97/-0) lava_test/core/hwprofile.py (+223/-0) lava_test/core/installers.py (+105/-0) lava_test/core/loader.py (+83/-0) lava_test/core/parsers.py (+147/-0) lava_test/core/providers.py (+165/-0) lava_test/core/runners.py (+66/-0) lava_test/core/swprofile.py (+72/-0) lava_test/core/tests.py (+166/-0) lava_test/extcmd.py (+108/-0) lava_test/main.py (+33/-16) lava_test/test_definitions/bootchart.py (+9/-6) lava_test/test_definitions/firefox.py (+10/-5) lava_test/test_definitions/glmemperf.py (+11/-6) lava_test/test_definitions/gmpbench.py (+11/-6) lava_test/test_definitions/gtkperf.py (+11/-6) lava_test/test_definitions/ltp.py (+11/-6) lava_test/test_definitions/peacekeeper.py (+11/-6) lava_test/test_definitions/posixtestsuite.py (+11/-6) lava_test/test_definitions/pwrmgmt.py (+25/-29) lava_test/test_definitions/pybench.py (+11/-6) lava_test/test_definitions/smem.py (+10/-6) lava_test/test_definitions/stream.py (+11/-6) lava_test/test_definitions/tiobench.py (+11/-6) lava_test/test_definitions/x11perf.py (+11/-6) lava_test/test_definitions/xrestop.py (+9/-6) lava_test/utils.py (+126/-40) setup.py (+25/-5) tests/__init__.py (+6/-10) tests/fixtures.py (+1/-1) tests/imposters.py (+11/-10) tests/test_abrekcmd.py (+0/-137) tests/test_abrektest.py (+0/-48) tests/test_abrektestinstaller.py (+0/-60) tests/test_abrektestparser.py (+0/-65) tests/test_abrektestrunner.py (+0/-104) tests/test_builtins.py (+0/-66) tests/test_dashboard.py (+0/-213) tests/test_hwprofile.py (+13/-13) tests/test_lavatest_commands.py (+62/-0) tests/test_lavatest_test.py (+55/-0) tests/test_lavatest_testinstaller.py (+63/-0) tests/test_lavatest_testparser.py (+70/-0) tests/test_lavatest_testrunner.py (+73/-0) tests/test_main.py (+0/-32) tests/test_results.py (+0/-117) tests/test_swprofile.py (+4/-4) |
To merge this branch: | bzr merge lp:~le-chi-thu/lava-test/using-lava-tool-2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Linaro Validation Team | Pending | ||
Review via email: mp+75272@code.launchpad.net |
Commit message
Description of the change
This is the update from review using-lava-tool pm.
I synced changes in trunk.
* Added register-test, unregister-test commands
* Renamed artefacts to artifacts
* Updated Copyright 2011
* Load the configuration if python logging configuration exist.
To post a comment you must log in.
- 96. By Le Chi Thu <email address hidden> <email address hidden>
-
Fixed type error. get_config()
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2011-06-21 19:38:29 +0000 | |||
3 | +++ .bzrignore 2011-09-13 22:44:36 +0000 | |||
4 | @@ -5,3 +5,4 @@ | |||
5 | 5 | *~ | 5 | *~ |
6 | 6 | *.tmp | 6 | *.tmp |
7 | 7 | *.py[co] | 7 | *.py[co] |
8 | 8 | build | ||
9 | 8 | 9 | ||
10 | === modified file 'MANIFEST.in' | |||
11 | --- MANIFEST.in 2011-06-21 19:38:29 +0000 | |||
12 | +++ MANIFEST.in 2011-09-13 22:44:36 +0000 | |||
13 | @@ -1,4 +1,3 @@ | |||
14 | 1 | include COPYING | 1 | include COPYING |
15 | 2 | include README | 2 | include README |
16 | 3 | include .testr.conf | 3 | include .testr.conf |
17 | 4 | include bin/lava-test | ||
18 | 5 | \ No newline at end of file | 4 | \ No newline at end of file |
19 | 6 | 5 | ||
20 | === modified file 'README' | |||
21 | --- README 2011-08-03 14:11:26 +0000 | |||
22 | +++ README 2011-09-13 22:44:36 +0000 | |||
23 | @@ -3,20 +3,11 @@ | |||
24 | 3 | automatically installed, executed, and the results can be parsed and | 3 | automatically installed, executed, and the results can be parsed and |
25 | 4 | uploaded to an external server. | 4 | uploaded to an external server. |
26 | 5 | 5 | ||
27 | 6 | External dependency | ||
28 | 7 | ------------------- | ||
29 | 8 | The following debian packages are needed: | ||
30 | 9 | * python-setuptools | ||
31 | 10 | * python-apt | ||
32 | 11 | * usbutils | ||
33 | 12 | * python-testrepository - for running unit tests | ||
34 | 13 | |||
35 | 14 | How to install from the source code | 6 | How to install from the source code |
36 | 15 | =================================== | 7 | =================================== |
37 | 16 | 8 | ||
38 | 17 | 1. Run: ./setup.py install | 9 | 1. Run: ./setup.py install |
39 | 18 | 10 | ||
40 | 19 | |||
41 | 20 | How to setup from the source code for development | 11 | How to setup from the source code for development |
42 | 21 | ================================================= | 12 | ================================================= |
43 | 22 | 13 | ||
44 | @@ -32,7 +23,7 @@ | |||
45 | 32 | 3. Add <home>/.local.bin in your PATH | 23 | 3. Add <home>/.local.bin in your PATH |
46 | 33 | 24 | ||
47 | 34 | 25 | ||
49 | 35 | To install build-in tests | 26 | To install built-in tests |
50 | 36 | ========================= | 27 | ========================= |
51 | 37 | 1. Run: lava-test list-tests | 28 | 1. Run: lava-test list-tests |
52 | 38 | 2. Run: lava-test install <test> | 29 | 2. Run: lava-test install <test> |
53 | @@ -47,4 +38,5 @@ | |||
54 | 47 | To install test define with a json file | 38 | To install test define with a json file |
55 | 48 | ======================================= | 39 | ======================================= |
56 | 49 | 1. Run: lava-test register-test file://localhost/<..>/examples/stream.json | 40 | 1. Run: lava-test register-test file://localhost/<..>/examples/stream.json |
57 | 50 | 2. Run: lava-test list-tests | ||
58 | 51 | \ No newline at end of file | 41 | \ No newline at end of file |
59 | 42 | 2. Run: lava-test list-tests | ||
60 | 43 | |||
61 | 52 | 44 | ||
62 | === removed file 'abrek/api.py' | |||
63 | --- abrek/api.py 2011-06-28 12:51:57 +0000 | |||
64 | +++ abrek/api.py 1970-01-01 00:00:00 +0000 | |||
65 | @@ -1,76 +0,0 @@ | |||
66 | 1 | """ | ||
67 | 2 | Public API for extending Abrek | ||
68 | 3 | """ | ||
69 | 4 | from abc import abstractmethod, abstractproperty | ||
70 | 5 | |||
71 | 6 | class ITestProvider(object): | ||
72 | 7 | """ | ||
73 | 8 | Abrek test provider. | ||
74 | 9 | |||
75 | 10 | Abstract source of abrek tests. | ||
76 | 11 | """ | ||
77 | 12 | |||
78 | 13 | @abstractmethod | ||
79 | 14 | def __init__(self, config): | ||
80 | 15 | """ | ||
81 | 16 | Initialize test provider with the specified configuration object. The | ||
82 | 17 | configuration object is obtained from the abrek providers registry. | ||
83 | 18 | """ | ||
84 | 19 | |||
85 | 20 | @abstractmethod | ||
86 | 21 | def __iter__(self): | ||
87 | 22 | """ | ||
88 | 23 | Iterates over instances of ITest exposed by this provider | ||
89 | 24 | """ | ||
90 | 25 | |||
91 | 26 | @abstractmethod | ||
92 | 27 | def __getitem__(self, test_name): | ||
93 | 28 | """ | ||
94 | 29 | Return an instance of ITest with the specified name | ||
95 | 30 | """ | ||
96 | 31 | |||
97 | 32 | @abstractproperty | ||
98 | 33 | def description(self): | ||
99 | 34 | """ | ||
100 | 35 | The description string used by abrek list-tests | ||
101 | 36 | """ | ||
102 | 37 | |||
103 | 38 | |||
104 | 39 | class ITest(object): | ||
105 | 40 | """ | ||
106 | 41 | Abrek test. | ||
107 | 42 | |||
108 | 43 | Something that can be installed and invoked by abre. | ||
109 | 44 | """ | ||
110 | 45 | |||
111 | 46 | @abstractmethod | ||
112 | 47 | def install(self): | ||
113 | 48 | """ | ||
114 | 49 | Install the test suite. | ||
115 | 50 | |||
116 | 51 | This creates an install directory under the user's XDG_DATA_HOME | ||
117 | 52 | directory to mark that the test is installed. The installer's | ||
118 | 53 | install() method is then called from this directory to complete any | ||
119 | 54 | test specific install that may be needed. | ||
120 | 55 | """ | ||
121 | 56 | |||
122 | 57 | @abstractmethod | ||
123 | 58 | def uninstall(self): | ||
124 | 59 | """ | ||
125 | 60 | Uninstall the test suite. | ||
126 | 61 | |||
127 | 62 | Uninstalling just recursively removes the test specific directory under | ||
128 | 63 | the user's XDG_DATA_HOME directory. This will both mark the test as | ||
129 | 64 | removed, and clean up any files that were downloaded or installed under | ||
130 | 65 | that directory. Dependencies are intentionally not removed by this. | ||
131 | 66 | """ | ||
132 | 67 | |||
133 | 68 | @abstractmethod | ||
134 | 69 | def run(self, quiet=False): | ||
135 | 70 | # TODO: Document me | ||
136 | 71 | pass | ||
137 | 72 | |||
138 | 73 | @abstractmethod | ||
139 | 74 | def parse(self, resultname): | ||
140 | 75 | # TODO: Document me | ||
141 | 76 | pass | ||
142 | 77 | 0 | ||
143 | === removed file 'abrek/builtins.py' | |||
144 | --- abrek/builtins.py 2011-08-03 14:25:13 +0000 | |||
145 | +++ abrek/builtins.py 1970-01-01 00:00:00 +0000 | |||
146 | @@ -1,175 +0,0 @@ | |||
147 | 1 | # Copyright (c) 2010 Linaro | ||
148 | 2 | # | ||
149 | 3 | # This program is free software: you can redistribute it and/or modify | ||
150 | 4 | # it under the terms of the GNU General Public License as published by | ||
151 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
152 | 6 | # (at your option) any later version. | ||
153 | 7 | # | ||
154 | 8 | # This program is distributed in the hope that it will be useful, | ||
155 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
156 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
157 | 11 | # GNU General Public License for more details. | ||
158 | 12 | # | ||
159 | 13 | # You should have received a copy of the GNU General Public License | ||
160 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
161 | 15 | |||
162 | 16 | import os | ||
163 | 17 | import sys | ||
164 | 18 | from optparse import make_option | ||
165 | 19 | |||
166 | 20 | import abrek.command | ||
167 | 21 | import abrek.testdef | ||
168 | 22 | from abrek.config import get_config | ||
169 | 23 | |||
170 | 24 | |||
171 | 25 | class cmd_version(abrek.command.AbrekCmd): | ||
172 | 26 | """ | ||
173 | 27 | Show the version of abrek | ||
174 | 28 | """ | ||
175 | 29 | def run(self): | ||
176 | 30 | import abrek | ||
177 | 31 | print abrek.__version__ | ||
178 | 32 | |||
179 | 33 | |||
180 | 34 | class cmd_help(abrek.command.AbrekCmd): | ||
181 | 35 | """ Get help on abrek commands | ||
182 | 36 | |||
183 | 37 | If the command name is ommited, calling the help command will return a | ||
184 | 38 | list of valid commands. | ||
185 | 39 | """ | ||
186 | 40 | arglist = ['command', 'subcommand'] | ||
187 | 41 | def run(self): | ||
188 | 42 | if len(self.args) < 1: | ||
189 | 43 | print "Available commands:" | ||
190 | 44 | for cmd in abrek.command.get_all_cmds(): | ||
191 | 45 | print " %s" % cmd | ||
192 | 46 | |||
193 | 47 | print "To access extended help on a command use 'abrek help " \ | ||
194 | 48 | "[command]'" | ||
195 | 49 | return | ||
196 | 50 | command_name = self.args.pop(0) | ||
197 | 51 | cmd = abrek.command.get_command(command_name) | ||
198 | 52 | if not cmd: | ||
199 | 53 | print "No command found for '%s'" % command_name | ||
200 | 54 | return | ||
201 | 55 | while self.args: | ||
202 | 56 | subcommand_name = self.args.pop(0) | ||
203 | 57 | cmd = cmd.get_subcommand(subcommand_name) | ||
204 | 58 | if not cmd: | ||
205 | 59 | print "No sub-command of '%s' found for '%s'" % ( | ||
206 | 60 | command_name, subcommand_name) | ||
207 | 61 | return | ||
208 | 62 | command_name += ' ' + subcommand_name | ||
209 | 63 | print cmd.help() | ||
210 | 64 | |||
211 | 65 | |||
212 | 66 | class cmd_install(abrek.command.AbrekCmd): | ||
213 | 67 | """ | ||
214 | 68 | Install a test | ||
215 | 69 | """ | ||
216 | 70 | arglist = ['*testname'] | ||
217 | 71 | |||
218 | 72 | def run(self): | ||
219 | 73 | self.checkroot() | ||
220 | 74 | if len(self.args) != 1: | ||
221 | 75 | print "please specify the name of the test to install" | ||
222 | 76 | sys.exit(1) | ||
223 | 77 | test = abrek.testdef.testloader(self.args[0]) | ||
224 | 78 | try: | ||
225 | 79 | test.install() | ||
226 | 80 | except RuntimeError as strerror: | ||
227 | 81 | print "Test installation error: %s" % strerror | ||
228 | 82 | sys.exit(1) | ||
229 | 83 | |||
230 | 84 | |||
231 | 85 | class cmd_run(abrek.command.AbrekCmd): | ||
232 | 86 | """ | ||
233 | 87 | Run tests | ||
234 | 88 | """ | ||
235 | 89 | arglist = ['*testname'] | ||
236 | 90 | options = [make_option('-q', '--quiet', action='store_true', | ||
237 | 91 | default=False, dest='quiet'), | ||
238 | 92 | make_option('-o', '--output', action='store', | ||
239 | 93 | default=None, metavar="FILE", | ||
240 | 94 | help="Store processed test output to FILE")] | ||
241 | 95 | |||
242 | 96 | def run(self): | ||
243 | 97 | self.checkroot() | ||
244 | 98 | if len(self.args) != 1: | ||
245 | 99 | print "please specify the name of the test to run" | ||
246 | 100 | sys.exit(1) | ||
247 | 101 | test = abrek.testdef.testloader(self.args[0]) | ||
248 | 102 | try: | ||
249 | 103 | result_id = test.run(quiet=self.opts.quiet) | ||
250 | 104 | if self.opts.output: | ||
251 | 105 | from abrek.dashboard import generate_bundle | ||
252 | 106 | import json | ||
253 | 107 | bundle = generate_bundle(result_id) | ||
254 | 108 | with open(self.opts.output, "wt") as stream: | ||
255 | 109 | json.dump(bundle, stream) | ||
256 | 110 | except Exception as strerror: | ||
257 | 111 | print "Test execution error: %s" % strerror | ||
258 | 112 | sys.exit(1) | ||
259 | 113 | |||
260 | 114 | |||
261 | 115 | class cmd_uninstall(abrek.command.AbrekCmd): | ||
262 | 116 | """ | ||
263 | 117 | Uninstall a test | ||
264 | 118 | """ | ||
265 | 119 | arglist = ['*testname'] | ||
266 | 120 | |||
267 | 121 | def run(self): | ||
268 | 122 | if len(self.args) != 1: | ||
269 | 123 | print "please specify the name of the test to uninstall" | ||
270 | 124 | sys.exit(1) | ||
271 | 125 | test = abrek.testdef.testloader(self.args[0]) | ||
272 | 126 | try: | ||
273 | 127 | test.uninstall() | ||
274 | 128 | except Exception as strerror: | ||
275 | 129 | print "Test uninstall error: %s" % strerror | ||
276 | 130 | sys.exit(1) | ||
277 | 131 | |||
278 | 132 | |||
279 | 133 | class cmd_list_installed(abrek.command.AbrekCmd): | ||
280 | 134 | """ | ||
281 | 135 | List tests that are currently installed | ||
282 | 136 | """ | ||
283 | 137 | def run(self): | ||
284 | 138 | config = get_config() | ||
285 | 139 | print "Installed tests:" | ||
286 | 140 | try: | ||
287 | 141 | for dir in os.listdir(config.installdir): | ||
288 | 142 | print dir | ||
289 | 143 | except OSError: | ||
290 | 144 | print "No tests installed" | ||
291 | 145 | |||
292 | 146 | |||
293 | 147 | class cmd_list_tests(abrek.command.AbrekCmd): | ||
294 | 148 | """ | ||
295 | 149 | List all known tests | ||
296 | 150 | """ | ||
297 | 151 | def run(self): | ||
298 | 152 | from abrek.testdef import TestLoader | ||
299 | 153 | for provider in TestLoader().get_providers(): | ||
300 | 154 | print provider.description | ||
301 | 155 | for test in provider: | ||
302 | 156 | print " - %s" % test | ||
303 | 157 | |||
304 | 158 | |||
305 | 159 | class cmd_register_test(abrek.command.AbrekCmd): | ||
306 | 160 | """ | ||
307 | 161 | Register declarative tests | ||
308 | 162 | """ | ||
309 | 163 | |||
310 | 164 | arglist = ['test_url'] | ||
311 | 165 | |||
312 | 166 | def run(self): | ||
313 | 167 | if len(self.args) != 1: | ||
314 | 168 | self.parser.error("You need to provide an URL to a test definition file") | ||
315 | 169 | test_url = self.args[0] | ||
316 | 170 | from abrek.providers import RegistryProvider | ||
317 | 171 | try: | ||
318 | 172 | RegistryProvider.register_remote_test(test_url) | ||
319 | 173 | except ValueError as exc: | ||
320 | 174 | print "Unable to register test: %s" % exc | ||
321 | 175 | sys.exit(1) | ||
322 | 176 | 0 | ||
323 | === removed file 'abrek/bundle.py' | |||
324 | --- abrek/bundle.py 2011-04-19 16:56:01 +0000 | |||
325 | +++ abrek/bundle.py 1970-01-01 00:00:00 +0000 | |||
326 | @@ -1,44 +0,0 @@ | |||
327 | 1 | # Copyright (c) 2011 Linaro | ||
328 | 2 | # | ||
329 | 3 | # This program is free software: you can redistribute it and/or modify | ||
330 | 4 | # it under the terms of the GNU General Public License as published by | ||
331 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
332 | 6 | # (at your option) any later version. | ||
333 | 7 | # | ||
334 | 8 | # This program is distributed in the hope that it will be useful, | ||
335 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
336 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
337 | 11 | # GNU General Public License for more details. | ||
338 | 12 | # | ||
339 | 13 | # You should have received a copy of the GNU General Public License | ||
340 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
341 | 15 | |||
342 | 16 | """ | ||
343 | 17 | This module attempts to use the linaro-dashboard-bundle package, if possible. | ||
344 | 18 | |||
345 | 19 | Using that package adds proper support for loading and saving bundle | ||
346 | 20 | documents. In particular it supports loosles decimals, better, more stable | ||
347 | 21 | load-modify-write cycles, data validation, transparent migration and many | ||
348 | 22 | other features. | ||
349 | 23 | |||
350 | 24 | It is not a hard dependency to make it possible to run abrek from a checkout | ||
351 | 25 | without having to install (too many) dependencies. | ||
352 | 26 | """ | ||
353 | 27 | |||
354 | 28 | try: | ||
355 | 29 | from linaro_dashboard_bundle import DocumentIO | ||
356 | 30 | except ImportError: | ||
357 | 31 | import json | ||
358 | 32 | |||
359 | 33 | class DocumentIO(object): | ||
360 | 34 | """ Bare replacement DocumentIO without any fancy features """ | ||
361 | 35 | |||
362 | 36 | @classmethod | ||
363 | 37 | def dumps(cls, doc): | ||
364 | 38 | return json.dumps(doc, indent=2) | ||
365 | 39 | |||
366 | 40 | @classmethod | ||
367 | 41 | def loads(cls, text): | ||
368 | 42 | doc = json.loads(text) | ||
369 | 43 | fmt = doc.get("format") | ||
370 | 44 | return fmt, doc | ||
371 | 45 | \ No newline at end of file | 0 | \ No newline at end of file |
372 | 46 | 1 | ||
373 | === removed file 'abrek/cache.py' | |||
374 | --- abrek/cache.py 2011-08-16 19:18:30 +0000 | |||
375 | +++ abrek/cache.py 1970-01-01 00:00:00 +0000 | |||
376 | @@ -1,73 +0,0 @@ | |||
377 | 1 | """ | ||
378 | 2 | Cache module for Abrek | ||
379 | 3 | """ | ||
380 | 4 | import contextlib | ||
381 | 5 | import hashlib | ||
382 | 6 | import os | ||
383 | 7 | import urllib2 | ||
384 | 8 | |||
385 | 9 | |||
386 | 10 | class AbrekCache(object): | ||
387 | 11 | """ | ||
388 | 12 | Cache class for Abrek | ||
389 | 13 | """ | ||
390 | 14 | |||
391 | 15 | _instance = None | ||
392 | 16 | |||
393 | 17 | def __init__(self): | ||
394 | 18 | home = os.environ.get('HOME', '/') | ||
395 | 19 | basecache = os.environ.get('XDG_CACHE_HOME', | ||
396 | 20 | os.path.join(home, '.cache')) | ||
397 | 21 | self.cache_dir = os.path.join(basecache, 'abrek') | ||
398 | 22 | |||
399 | 23 | @classmethod | ||
400 | 24 | def get_instance(cls): | ||
401 | 25 | if cls._instance is None: | ||
402 | 26 | cls._instance = cls() | ||
403 | 27 | return cls._instance | ||
404 | 28 | |||
405 | 29 | def open_cached(self, key, mode="r"): | ||
406 | 30 | """ | ||
407 | 31 | Acts like open() but the pathname is relative to the | ||
408 | 32 | abrek-specific cache directory. | ||
409 | 33 | """ | ||
410 | 34 | if "w" in mode and not os.path.exists(self.cache_dir): | ||
411 | 35 | os.makedirs(self.cache_dir) | ||
412 | 36 | if os.path.isabs(key): | ||
413 | 37 | raise ValueError("key cannot be an absolute path") | ||
414 | 38 | try: | ||
415 | 39 | stream = open(os.path.join(self.cache_dir, key), mode) | ||
416 | 40 | yield stream | ||
417 | 41 | finally: | ||
418 | 42 | stream.close() | ||
419 | 43 | |||
420 | 44 | def _key_for_url(self, url): | ||
421 | 45 | return hashlib.sha1(url).hexdigest() | ||
422 | 46 | |||
423 | 47 | def _refresh_url_cache(self, key, url): | ||
424 | 48 | with contextlib.nested( | ||
425 | 49 | contextlib.closing(urllib2.urlopen(url)), | ||
426 | 50 | self.open_cached(key, "wb")) as (in_stream, out_stream): | ||
427 | 51 | out_stream.write(in_stream.read()) | ||
428 | 52 | |||
429 | 53 | @contextlib.contextmanager | ||
430 | 54 | def open_cached_url(self, url): | ||
431 | 55 | """ | ||
432 | 56 | Like urlopen.open() but the content may be cached. | ||
433 | 57 | """ | ||
434 | 58 | # Do not cache local files, this is not what users would expect | ||
435 | 59 | |||
436 | 60 | # workaround - not using cache at all. | ||
437 | 61 | # TODO: fix this and use the cache | ||
438 | 62 | # if url.startswith("file://"): | ||
439 | 63 | if True: | ||
440 | 64 | stream = urllib2.urlopen(url) | ||
441 | 65 | else: | ||
442 | 66 | key = self._key_for_url(url) | ||
443 | 67 | try: | ||
444 | 68 | stream = self.open_cached(key, "rb") | ||
445 | 69 | except IOError as exc: | ||
446 | 70 | self._refresh_url_cache(key, url) | ||
447 | 71 | stream = self.open_cached(key, "rb") | ||
448 | 72 | yield stream | ||
449 | 73 | stream.close() | ||
450 | 74 | 0 | ||
451 | === removed file 'abrek/command.py' | |||
452 | --- abrek/command.py 2011-08-03 14:25:13 +0000 | |||
453 | +++ abrek/command.py 1970-01-01 00:00:00 +0000 | |||
454 | @@ -1,171 +0,0 @@ | |||
455 | 1 | # Copyright (c) 2010 Linaro | ||
456 | 2 | # | ||
457 | 3 | # This program is free software: you can redistribute it and/or modify | ||
458 | 4 | # it under the terms of the GNU General Public License as published by | ||
459 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
460 | 6 | # (at your option) any later version. | ||
461 | 7 | # | ||
462 | 8 | # This program is distributed in the hope that it will be useful, | ||
463 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
464 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
465 | 11 | # GNU General Public License for more details. | ||
466 | 12 | # | ||
467 | 13 | # You should have received a copy of the GNU General Public License | ||
468 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
469 | 15 | |||
470 | 16 | from optparse import OptionParser | ||
471 | 17 | import os | ||
472 | 18 | import sys | ||
473 | 19 | |||
474 | 20 | |||
475 | 21 | class _AbrekOptionParser(OptionParser): | ||
476 | 22 | """ | ||
477 | 23 | This is just to override the epilog formatter to allow newlines | ||
478 | 24 | """ | ||
479 | 25 | def format_epilog(self, formatter): | ||
480 | 26 | return self.epilog | ||
481 | 27 | |||
482 | 28 | |||
483 | 29 | class AbrekCmd(object): | ||
484 | 30 | """ Base class for commands that can be passed to Abrek. | ||
485 | 31 | |||
486 | 32 | Commands added to abrek should inherit from AbrekCmd. To allow for | ||
487 | 33 | autodiscovery, the name of the class should begin with cmd_. | ||
488 | 34 | |||
489 | 35 | Arguments allowed by the command can be specified in the 'arglist'. | ||
490 | 36 | These arguments will automatically be listed in the help for that | ||
491 | 37 | command. Required arguments should begin with a '*'. For example: | ||
492 | 38 | arglist = ['*requiredarg', 'optionalarg'] | ||
493 | 39 | |||
494 | 40 | Options may also be specified by using the 'options' list. To add | ||
495 | 41 | arguments, you must use the make_option() function from optparse. | ||
496 | 42 | For example: | ||
497 | 43 | options = [make_option("-b", "--bar", dest="bar")] | ||
498 | 44 | |||
499 | 45 | Commands also support subcommands. A subcommand is similar to a | ||
500 | 46 | command in abrek, and it should also inherit from AbrekCmd. However, | ||
501 | 47 | a subcommand class should not begin with cmd_. Instead, it should | ||
502 | 48 | be tied to the command that uses it, using the 'subcmds' dict. | ||
503 | 49 | For example: | ||
504 | 50 | class subcmd_bar(AbrekCmd): | ||
505 | 51 | pass | ||
506 | 52 | class cmd_foo(AbrekCmd): | ||
507 | 53 | subcmds = {'bar':subcmd_bar()} | ||
508 | 54 | pass | ||
509 | 55 | """ | ||
510 | 56 | options = [] | ||
511 | 57 | arglist = [] | ||
512 | 58 | |||
513 | 59 | def __init__(self, name_prefix=''): | ||
514 | 60 | self._name_prefix = name_prefix | ||
515 | 61 | self.parser = _AbrekOptionParser(usage=self._usage(), | ||
516 | 62 | epilog=self._desc()) | ||
517 | 63 | for opt in self.options: | ||
518 | 64 | self.parser.add_option(opt) | ||
519 | 65 | |||
520 | 66 | def main(self, argv): | ||
521 | 67 | (self.opts, self.args) = self.parser.parse_args(argv) | ||
522 | 68 | return self.run() | ||
523 | 69 | |||
524 | 70 | def name(self): | ||
525 | 71 | return self._name_prefix + _convert_command_name(self.__class__.__name__) | ||
526 | 72 | |||
527 | 73 | def run(self): | ||
528 | 74 | raise NotImplementedError("%s: command defined but not implemented!" % | ||
529 | 75 | self.name()) | ||
530 | 76 | |||
531 | 77 | def _usage(self): | ||
532 | 78 | usagestr = "Usage: lava-test %s" % self.name() | ||
533 | 79 | for arg in self.arglist: | ||
534 | 80 | if arg[0] == '*': | ||
535 | 81 | usagestr += " %s" % arg[1:].upper() | ||
536 | 82 | else: | ||
537 | 83 | usagestr += " [%s]" % arg.upper() | ||
538 | 84 | return usagestr | ||
539 | 85 | |||
540 | 86 | def _desc(self): | ||
541 | 87 | from inspect import getdoc | ||
542 | 88 | docstr = getdoc(self) | ||
543 | 89 | if not docstr: | ||
544 | 90 | return "" | ||
545 | 91 | description = "\nDescription:\n" | ||
546 | 92 | description += docstr + "\n" | ||
547 | 93 | return description | ||
548 | 94 | |||
549 | 95 | def help(self): | ||
550 | 96 | #For some reason, format_help includes an extra \n | ||
551 | 97 | return self.parser.format_help()[:-1] | ||
552 | 98 | |||
553 | 99 | def get_subcommand(self, name): | ||
554 | 100 | return None | ||
555 | 101 | |||
556 | 102 | def checkroot(self): | ||
557 | 103 | if os.getuid() != 0: | ||
558 | 104 | print >> sys.stderr, ("**** WARNING: ROOT PERMISSIONS ARE OFTEN" | ||
559 | 105 | "REQUIRED FOR THIS OPERATION ****") | ||
560 | 106 | |||
561 | 107 | |||
562 | 108 | class AbrekCmdWithSubcommands(AbrekCmd): | ||
563 | 109 | |||
564 | 110 | arglist = ['subcommand'] | ||
565 | 111 | |||
566 | 112 | def main(self, argv): | ||
567 | 113 | if not argv: | ||
568 | 114 | print "Missing sub-command." + self._list_subcmds() | ||
569 | 115 | else: | ||
570 | 116 | subcmd = self.get_subcommand(argv[0]) | ||
571 | 117 | if subcmd is None: | ||
572 | 118 | # This line might print the help and raise SystemExit if | ||
573 | 119 | # --help is passed or if an invalid option was passed. | ||
574 | 120 | opts, args = self.parser.parse_args(argv) | ||
575 | 121 | # If it didn't, complain. | ||
576 | 122 | print "'%s' not found as a sub-command of '%s'" % ( | ||
577 | 123 | args[0], self.name()) + self._list_subcmds() | ||
578 | 124 | else: | ||
579 | 125 | return subcmd.main(argv[1:]) | ||
580 | 126 | |||
581 | 127 | def get_subcommand(self, name): | ||
582 | 128 | subcmd_cls = getattr(self, 'cmd_' + name.replace('_', '-'), None) | ||
583 | 129 | if subcmd_cls is None: | ||
584 | 130 | return None | ||
585 | 131 | return subcmd_cls(self.name() + ' ') | ||
586 | 132 | |||
587 | 133 | def _usage(self): | ||
588 | 134 | usagestr = AbrekCmd._usage(self) | ||
589 | 135 | usagestr += self._list_subcmds() | ||
590 | 136 | return usagestr | ||
591 | 137 | |||
592 | 138 | def _list_subcmds(self): | ||
593 | 139 | subcmds = [] | ||
594 | 140 | for attrname in self.__class__.__dict__.keys(): | ||
595 | 141 | if attrname.startswith('cmd_'): | ||
596 | 142 | subcmds.append(_convert_command_name(attrname)) | ||
597 | 143 | if not subcmds: | ||
598 | 144 | return '' | ||
599 | 145 | return "\n\nAvailable sub-commands:\n " + "\n ".join(subcmds) | ||
600 | 146 | |||
601 | 147 | |||
602 | 148 | def _convert_command_name(cmd): | ||
603 | 149 | return cmd[4:].replace('_','-') | ||
604 | 150 | |||
605 | 151 | |||
606 | 152 | def _find_commands(module): | ||
607 | 153 | cmds = {} | ||
608 | 154 | for name, func in module.__dict__.iteritems(): | ||
609 | 155 | if name.startswith("cmd_"): | ||
610 | 156 | real_name = _convert_command_name(name) | ||
611 | 157 | cmds[real_name] = func() | ||
612 | 158 | return cmds | ||
613 | 159 | |||
614 | 160 | |||
615 | 161 | def get_all_cmds(): | ||
616 | 162 | from abrek import builtins, dashboard, results | ||
617 | 163 | cmds = _find_commands(builtins) | ||
618 | 164 | cmds.update(_find_commands(dashboard)) | ||
619 | 165 | cmds.update(_find_commands(results)) | ||
620 | 166 | return cmds | ||
621 | 167 | |||
622 | 168 | |||
623 | 169 | def get_command(cmd_name): | ||
624 | 170 | cmds = get_all_cmds() | ||
625 | 171 | return cmds.get(cmd_name) | ||
626 | 172 | 0 | ||
627 | === removed file 'abrek/config.py' | |||
628 | --- abrek/config.py 2011-08-03 09:06:20 +0000 | |||
629 | +++ abrek/config.py 1970-01-01 00:00:00 +0000 | |||
630 | @@ -1,93 +0,0 @@ | |||
631 | 1 | # Copyright (c) 2010 Linaro | ||
632 | 2 | # | ||
633 | 3 | # This program is free software: you can redistribute it and/or modify | ||
634 | 4 | # it under the terms of the GNU General Public License as published by | ||
635 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
636 | 6 | # (at your option) any later version. | ||
637 | 7 | # | ||
638 | 8 | # This program is distributed in the hope that it will be useful, | ||
639 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
640 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
641 | 11 | # GNU General Public License for more details. | ||
642 | 12 | # | ||
643 | 13 | # You should have received a copy of the GNU General Public License | ||
644 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
645 | 15 | |||
646 | 16 | import os | ||
647 | 17 | import json | ||
648 | 18 | |||
649 | 19 | |||
650 | 20 | class AbrekConfig(object): | ||
651 | 21 | |||
652 | 22 | def __init__(self): | ||
653 | 23 | home = os.environ.get('HOME', '/') | ||
654 | 24 | baseconfig = os.environ.get('XDG_CONFIG_HOME', | ||
655 | 25 | os.path.join(home, '.config')) | ||
656 | 26 | basedata = os.environ.get('XDG_DATA_HOME', | ||
657 | 27 | os.path.join(home, '.local', 'share')) | ||
658 | 28 | self.configdir = os.path.join(baseconfig, 'abrek') | ||
659 | 29 | self.installdir = os.path.join(basedata, 'abrek', 'installed-tests') | ||
660 | 30 | self.resultsdir = os.path.join(basedata, 'abrek', 'results') | ||
661 | 31 | self.registry = self._load_registry() | ||
662 | 32 | |||
663 | 33 | @property | ||
664 | 34 | def _registry_pathname(self): | ||
665 | 35 | return os.path.join(self.configdir, "registry.json") | ||
666 | 36 | |||
667 | 37 | def _load_registry(self): | ||
668 | 38 | try: | ||
669 | 39 | with open(self._registry_pathname) as stream: | ||
670 | 40 | return json.load(stream) | ||
671 | 41 | except (IOError, ValueError) as exc: | ||
672 | 42 | return self._get_default_registry() | ||
673 | 43 | |||
674 | 44 | def _save_registry(self): | ||
675 | 45 | if not os.path.exists(self.configdir): | ||
676 | 46 | os.makedirs(self.configdir) | ||
677 | 47 | with open(self._registry_pathname, "wt") as stream: | ||
678 | 48 | json.dump(self.registry, stream, indent=2) | ||
679 | 49 | |||
680 | 50 | def _get_default_registry(self): | ||
681 | 51 | return { | ||
682 | 52 | "format": "Abrek Test Registry 1.0 Experimental", | ||
683 | 53 | "providers": [ | ||
684 | 54 | { | ||
685 | 55 | "entry_point": "abrek.providers:BuiltInProvider", | ||
686 | 56 | }, | ||
687 | 57 | { | ||
688 | 58 | "entry_point": "abrek.providers:PkgResourcesProvider", | ||
689 | 59 | }, | ||
690 | 60 | { | ||
691 | 61 | "entry_point": "abrek.providers:RegistryProvider", | ||
692 | 62 | "config": { | ||
693 | 63 | "entries": [] | ||
694 | 64 | } | ||
695 | 65 | } | ||
696 | 66 | ] | ||
697 | 67 | } | ||
698 | 68 | |||
699 | 69 | def get_provider_config(self, entry_point_name): | ||
700 | 70 | if "providers" not in self.registry: | ||
701 | 71 | self.registry["providers"] = [] | ||
702 | 72 | for provider_info in self.registry["providers"]: | ||
703 | 73 | if provider_info.get("entry_point") == entry_point_name: | ||
704 | 74 | break | ||
705 | 75 | else: | ||
706 | 76 | provider_info = {"entry_point": entry_point_name} | ||
707 | 77 | self.registry["providers"].append(provider_info) | ||
708 | 78 | if "config" not in provider_info: | ||
709 | 79 | provider_info["config"] = {} | ||
710 | 80 | return provider_info["config"] | ||
711 | 81 | |||
712 | 82 | |||
713 | 83 | _config = None | ||
714 | 84 | |||
715 | 85 | def get_config(): | ||
716 | 86 | global _config | ||
717 | 87 | if _config is not None: | ||
718 | 88 | return _config | ||
719 | 89 | return AbrekConfig() | ||
720 | 90 | |||
721 | 91 | def set_config(config): | ||
722 | 92 | global _config | ||
723 | 93 | _config = config | ||
724 | 94 | 0 | ||
725 | === removed file 'abrek/dashboard.py' | |||
726 | --- abrek/dashboard.py 2011-08-09 09:35:19 +0000 | |||
727 | +++ abrek/dashboard.py 1970-01-01 00:00:00 +0000 | |||
728 | @@ -1,206 +0,0 @@ | |||
729 | 1 | # Copyright (c) 2010 Linaro | ||
730 | 2 | # | ||
731 | 3 | # This program is free software: you can redistribute it and/or modify | ||
732 | 4 | # it under the terms of the GNU General Public License as published by | ||
733 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
734 | 6 | # (at your option) any later version. | ||
735 | 7 | # | ||
736 | 8 | # This program is distributed in the hope that it will be useful, | ||
737 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
738 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
739 | 11 | # GNU General Public License for more details. | ||
740 | 12 | # | ||
741 | 13 | # You should have received a copy of the GNU General Public License | ||
742 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
743 | 15 | |||
744 | 16 | import base64 | ||
745 | 17 | import os | ||
746 | 18 | import socket | ||
747 | 19 | import sys | ||
748 | 20 | import urllib | ||
749 | 21 | import xmlrpclib | ||
750 | 22 | from ConfigParser import ConfigParser, NoOptionError | ||
751 | 23 | from getpass import getpass | ||
752 | 24 | from optparse import make_option | ||
753 | 25 | |||
754 | 26 | from abrek.bundle import DocumentIO | ||
755 | 27 | from abrek.command import AbrekCmd, AbrekCmdWithSubcommands | ||
756 | 28 | from abrek.config import get_config | ||
757 | 29 | from abrek.testdef import testloader | ||
758 | 30 | |||
759 | 31 | |||
760 | 32 | class DashboardConfig(object): | ||
761 | 33 | """ | ||
762 | 34 | Read and write dashboard configuration data | ||
763 | 35 | """ | ||
764 | 36 | |||
765 | 37 | def __init__(self, section="Default Server"): | ||
766 | 38 | self.dashboardconf = ConfigParser() | ||
767 | 39 | self.section = section | ||
768 | 40 | self.config = get_config() | ||
769 | 41 | self.path = os.path.join(self.config.configdir, "dashboard.conf") | ||
770 | 42 | if os.path.exists(self.path): | ||
771 | 43 | self.dashboardconf.read(self.path) | ||
772 | 44 | if not (self.section in self.dashboardconf.sections()): | ||
773 | 45 | self.dashboardconf.add_section(self.section) | ||
774 | 46 | |||
775 | 47 | def set_host(self, host): | ||
776 | 48 | self.dashboardconf.set(self.section, 'host', host) | ||
777 | 49 | |||
778 | 50 | def get_host(self): | ||
779 | 51 | try: | ||
780 | 52 | host = self.dashboardconf.get(self.section, 'host') | ||
781 | 53 | return host | ||
782 | 54 | except NoOptionError: | ||
783 | 55 | return "" | ||
784 | 56 | |||
785 | 57 | host = property(get_host, set_host) | ||
786 | 58 | |||
787 | 59 | def set_user(self, user): | ||
788 | 60 | self.dashboardconf.set(self.section, 'user', user) | ||
789 | 61 | |||
790 | 62 | def get_user(self): | ||
791 | 63 | try: | ||
792 | 64 | user = self.dashboardconf.get(self.section, 'user') | ||
793 | 65 | return user | ||
794 | 66 | except NoOptionError: | ||
795 | 67 | return "" | ||
796 | 68 | |||
797 | 69 | user = property(get_user, set_user) | ||
798 | 70 | |||
799 | 71 | def set_password(self, password): | ||
800 | 72 | #Not exactly secure, but better than storing in plaintext | ||
801 | 73 | password = base64.encodestring(password).strip() | ||
802 | 74 | self.dashboardconf.set(self.section,'password', password) | ||
803 | 75 | |||
804 | 76 | def get_password(self): | ||
805 | 77 | try: | ||
806 | 78 | password = self.dashboardconf.get(self.section, 'password') | ||
807 | 79 | return base64.decodestring(password) | ||
808 | 80 | except NoOptionError: | ||
809 | 81 | return "" | ||
810 | 82 | |||
811 | 83 | password = property(get_password, set_password) | ||
812 | 84 | |||
813 | 85 | def write(self): | ||
814 | 86 | """ | ||
815 | 87 | write the dashboard configuration out to the config file | ||
816 | 88 | """ | ||
817 | 89 | if not os.path.exists(self.config.configdir): | ||
818 | 90 | os.makedirs(self.config.configdir) | ||
819 | 91 | with open(self.path, "w") as fd: | ||
820 | 92 | self.dashboardconf.write(fd) | ||
821 | 93 | |||
822 | 94 | |||
823 | 95 | class cmd_dashboard(AbrekCmdWithSubcommands): | ||
824 | 96 | """ | ||
825 | 97 | Connect to the Launch-control dashboard | ||
826 | 98 | """ | ||
827 | 99 | |||
828 | 100 | class cmd_setup(AbrekCmd): | ||
829 | 101 | """ | ||
830 | 102 | Configure information needed to push results to the dashboard | ||
831 | 103 | """ | ||
832 | 104 | options = [make_option("-u", "--user", dest="user"), | ||
833 | 105 | make_option("-p", "--password", dest="password")] | ||
834 | 106 | arglist = ["*server"] | ||
835 | 107 | |||
836 | 108 | def run(self): | ||
837 | 109 | if len(self.args) != 1: | ||
838 | 110 | print "You must specify a server" | ||
839 | 111 | sys.exit(1) | ||
840 | 112 | config = DashboardConfig() | ||
841 | 113 | if self.opts.user: | ||
842 | 114 | user = self.opts.user | ||
843 | 115 | else: | ||
844 | 116 | user = raw_input("Username: ") | ||
845 | 117 | if self.opts.password: | ||
846 | 118 | password = self.opts.password | ||
847 | 119 | else: | ||
848 | 120 | password = getpass() | ||
849 | 121 | config.host = self.args[0] | ||
850 | 122 | config.user = user | ||
851 | 123 | config.password = password | ||
852 | 124 | config.write() | ||
853 | 125 | |||
854 | 126 | |||
855 | 127 | class cmd_put(AbrekCmd): | ||
856 | 128 | """ | ||
857 | 129 | Push the results from a test to the server | ||
858 | 130 | The stream name must include slashes (e.g. /anonymous/foo/) | ||
859 | 131 | """ | ||
860 | 132 | arglist = ["*stream", "*result"] | ||
861 | 133 | |||
862 | 134 | def run(self): | ||
863 | 135 | if len(self.args) != 2: | ||
864 | 136 | print "You must specify a stream and a result" | ||
865 | 137 | sys.exit(1) | ||
866 | 138 | stream_name = self.args[0] | ||
867 | 139 | result_name = self.args[1] | ||
868 | 140 | bundle = generate_bundle(result_name) | ||
869 | 141 | db_config = DashboardConfig() | ||
870 | 142 | hosturl = urllib.basejoin(db_config.host, "xml-rpc/") | ||
871 | 143 | try: | ||
872 | 144 | server = xmlrpclib.Server(hosturl) | ||
873 | 145 | except IOError, e: | ||
874 | 146 | print ("Error connecting to server at '%s'. Error was: %s, " | ||
875 | 147 | "please run 'lava-test dashboard setup [host]'" % ( | ||
876 | 148 | hosturl, e)) | ||
877 | 149 | sys.exit(1) | ||
878 | 150 | try: | ||
879 | 151 | result = server.put(DocumentIO.dumps(bundle), result_name, | ||
880 | 152 | stream_name) | ||
881 | 153 | print "Bundle successfully uploaded to id: %s" % result | ||
882 | 154 | except xmlrpclib.Fault as strerror: | ||
883 | 155 | print "Error uploading bundle: %s" % strerror.faultString | ||
884 | 156 | sys.exit(1) | ||
885 | 157 | except socket.error as strerror: | ||
886 | 158 | print "Unable to connect to host: %s" % strerror | ||
887 | 159 | sys.exit(1) | ||
888 | 160 | except xmlrpclib.ProtocolError as strerror: | ||
889 | 161 | print "Connection error: %s" % strerror | ||
890 | 162 | sys.exit(1) | ||
891 | 163 | |||
892 | 164 | |||
893 | 165 | class cmd_bundle(AbrekCmd): | ||
894 | 166 | """ | ||
895 | 167 | Print JSON output that can be imported into the dashboard | ||
896 | 168 | """ | ||
897 | 169 | arglist = ["*result"] | ||
898 | 170 | |||
899 | 171 | def run(self): | ||
900 | 172 | if len(self.args) != 1: | ||
901 | 173 | print "You must specify a result" | ||
902 | 174 | sys.exit(1) | ||
903 | 175 | bundle = generate_bundle(self.args[0]) | ||
904 | 176 | try: | ||
905 | 177 | print DocumentIO.dumps(bundle) | ||
906 | 178 | except IOError: | ||
907 | 179 | pass | ||
908 | 180 | |||
909 | 181 | |||
910 | 182 | def generate_bundle(result): | ||
911 | 183 | config = get_config() | ||
912 | 184 | resultdir = os.path.join(config.resultsdir, result) | ||
913 | 185 | if not os.path.exists(resultdir): | ||
914 | 186 | # FIXME: UI and sys.exit mixed with internal implementation, yuck | ||
915 | 187 | print "Result directory not found" | ||
916 | 188 | sys.exit(1) | ||
917 | 189 | with open(os.path.join(resultdir, "testdata.json")) as stream: | ||
918 | 190 | bundle_text = stream.read() | ||
919 | 191 | with open(os.path.join(resultdir, "testoutput.log")) as stream: | ||
920 | 192 | output_text = stream.read() | ||
921 | 193 | fmt, bundle = DocumentIO.loads(bundle_text) | ||
922 | 194 | test = testloader(bundle['test_runs'][0]['test_id']) | ||
923 | 195 | test.parse(result) | ||
924 | 196 | bundle['test_runs'][0].update(test.parser.results) | ||
925 | 197 | bundle['test_runs'][0]["attachments"] = [ | ||
926 | 198 | { | ||
927 | 199 | "pathname": "testoutput.log", | ||
928 | 200 | "mime_type": "text/plain", | ||
929 | 201 | "content": base64.standard_b64encode(output_text) | ||
930 | 202 | } | ||
931 | 203 | ] | ||
932 | 204 | return bundle | ||
933 | 205 | |||
934 | 206 | |||
935 | 207 | 0 | ||
936 | === removed file 'abrek/hwprofile.py' | |||
937 | --- abrek/hwprofile.py 2011-05-27 02:39:03 +0000 | |||
938 | +++ abrek/hwprofile.py 1970-01-01 00:00:00 +0000 | |||
939 | @@ -1,216 +0,0 @@ | |||
940 | 1 | # Copyright (c) 2010 Linaro | ||
941 | 2 | # | ||
942 | 3 | # This program is free software: you can redistribute it and/or modify | ||
943 | 4 | # it under the terms of the GNU General Public License as published by | ||
944 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
945 | 6 | # (at your option) any later version. | ||
946 | 7 | # | ||
947 | 8 | # This program is distributed in the hope that it will be useful, | ||
948 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
949 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
950 | 11 | # GNU General Public License for more details. | ||
951 | 12 | # | ||
952 | 13 | # You should have received a copy of the GNU General Public License | ||
953 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
954 | 15 | |||
955 | 16 | import re | ||
956 | 17 | import sys | ||
957 | 18 | from subprocess import Popen, PIPE | ||
958 | 19 | from utils import read_file, get_machine_type | ||
959 | 20 | |||
960 | 21 | INTEL_KEYMAP = { | ||
961 | 22 | 'vendor_id': 'cpu_vendor_name', | ||
962 | 23 | 'cpu family': 'cpu_family', | ||
963 | 24 | 'model': 'cpu_model', | ||
964 | 25 | 'model name': 'cpu_model_name', | ||
965 | 26 | 'stepping': 'cpu_stepping', | ||
966 | 27 | 'cpu MHz': 'cpu_mhz', | ||
967 | 28 | 'flags': 'cpu_features', | ||
968 | 29 | } | ||
969 | 30 | |||
970 | 31 | INTEL_VALMAP = { | ||
971 | 32 | 'cpu family': int, | ||
972 | 33 | 'model': int, | ||
973 | 34 | 'stepping': int, | ||
974 | 35 | 'cpu MHz': float, | ||
975 | 36 | } | ||
976 | 37 | |||
977 | 38 | ARM_KEYMAP = { | ||
978 | 39 | 'Processor': 'cpu_model_name', | ||
979 | 40 | 'Features': 'cpu_features', | ||
980 | 41 | 'CPU implementer': 'cpu_implementer', | ||
981 | 42 | 'CPU architecture': 'cpu_architecture', | ||
982 | 43 | 'CPU variant': 'cpu_variant', | ||
983 | 44 | 'CPU part': 'cpu_part', | ||
984 | 45 | 'CPU revision': 'cpu_revision', | ||
985 | 46 | } | ||
986 | 47 | |||
987 | 48 | ARM_VALMAP = { | ||
988 | 49 | 'CPU implementer': lambda value: int(value, 16), | ||
989 | 50 | 'CPU architecture': int, | ||
990 | 51 | 'CPU variant': lambda value: int(value, 16), | ||
991 | 52 | 'CPU part': lambda value: int(value, 16), | ||
992 | 53 | 'CPU revision': int, | ||
993 | 54 | } | ||
994 | 55 | |||
995 | 56 | |||
996 | 57 | def _translate_cpuinfo(keymap, valmap, key, value): | ||
997 | 58 | """ | ||
998 | 59 | Translate a key and value using keymap and valmap passed in | ||
999 | 60 | """ | ||
1000 | 61 | newkey = keymap.get(key, key) | ||
1001 | 62 | newval = valmap.get(key, lambda x: x)(value) | ||
1002 | 63 | return newkey, newval | ||
1003 | 64 | |||
1004 | 65 | def get_cpu_devs(): | ||
1005 | 66 | """ | ||
1006 | 67 | Return a list of CPU devices | ||
1007 | 68 | """ | ||
1008 | 69 | pattern = re.compile('^(?P<key>.+?)\s*:\s*(?P<value>.*)$') | ||
1009 | 70 | cpunum = 0 | ||
1010 | 71 | devices = [] | ||
1011 | 72 | cpudevs = [] | ||
1012 | 73 | cpudevs.append({}) | ||
1013 | 74 | machine = get_machine_type() | ||
1014 | 75 | if machine in ('i686', 'x86_64'): | ||
1015 | 76 | keymap, valmap = INTEL_KEYMAP, INTEL_VALMAP | ||
1016 | 77 | elif machine.startswith('arm'): | ||
1017 | 78 | keymap, valmap = ARM_KEYMAP, ARM_VALMAP | ||
1018 | 79 | |||
1019 | 80 | try: | ||
1020 | 81 | cpuinfo = read_file("/proc/cpuinfo") | ||
1021 | 82 | for line in cpuinfo.splitlines(): | ||
1022 | 83 | match = pattern.match(line) | ||
1023 | 84 | if match: | ||
1024 | 85 | key, value = match.groups() | ||
1025 | 86 | key, value = _translate_cpuinfo(keymap, valmap, | ||
1026 | 87 | key, value) | ||
1027 | 88 | if cpudevs[cpunum].get(key): | ||
1028 | 89 | cpunum += 1 | ||
1029 | 90 | cpudevs.append({}) | ||
1030 | 91 | cpudevs[cpunum][key] = value | ||
1031 | 92 | for c in range(len(cpudevs)): | ||
1032 | 93 | device = {} | ||
1033 | 94 | device['device_type'] = 'device.cpu' | ||
1034 | 95 | device['description'] = 'Processor #{0}'.format(c) | ||
1035 | 96 | device['attributes'] = cpudevs[c] | ||
1036 | 97 | devices.append(device) | ||
1037 | 98 | except IOError: | ||
1038 | 99 | print >> sys.stderr, "WARNING: Could not read cpu information" | ||
1039 | 100 | return devices | ||
1040 | 101 | |||
1041 | 102 | |||
1042 | 103 | def get_board_devs(): | ||
1043 | 104 | """ | ||
1044 | 105 | Return a list of board devices | ||
1045 | 106 | """ | ||
1046 | 107 | devices = [] | ||
1047 | 108 | attributes = {} | ||
1048 | 109 | device = {} | ||
1049 | 110 | machine = get_machine_type() | ||
1050 | 111 | if machine in ('i686', 'x86_64'): | ||
1051 | 112 | try: | ||
1052 | 113 | description = read_file('/sys/class/dmi/id/board_name') or None | ||
1053 | 114 | vendor = read_file('/sys/class/dmi/id/board_vendor') or None | ||
1054 | 115 | version = read_file('/sys/class/dmi/id/board_version') or None | ||
1055 | 116 | if description: | ||
1056 | 117 | device['description'] = description.strip() | ||
1057 | 118 | if vendor: | ||
1058 | 119 | attributes['vendor'] = vendor.strip() | ||
1059 | 120 | if version: | ||
1060 | 121 | attributes['version'] = version.strip() | ||
1061 | 122 | except IOError: | ||
1062 | 123 | print >> sys.stderr, "WARNING: Could not read board information" | ||
1063 | 124 | return devices | ||
1064 | 125 | elif machine.startswith('arm'): | ||
1065 | 126 | try: | ||
1066 | 127 | cpuinfo = read_file("/proc/cpuinfo") | ||
1067 | 128 | if cpuinfo is None: | ||
1068 | 129 | return devices | ||
1069 | 130 | pattern = re.compile("^Hardware\s*:\s*(?P<description>.+)$", re.M) | ||
1070 | 131 | match = pattern.search(cpuinfo) | ||
1071 | 132 | if match is None: | ||
1072 | 133 | return devices | ||
1073 | 134 | device['description'] = match.group('description') | ||
1074 | 135 | except IOError: | ||
1075 | 136 | print >> sys.stderr, "WARNING: Could not read board information" | ||
1076 | 137 | return devices | ||
1077 | 138 | else: | ||
1078 | 139 | return devices | ||
1079 | 140 | if attributes: | ||
1080 | 141 | device['attributes'] = attributes | ||
1081 | 142 | device['device_type'] = 'device.board' | ||
1082 | 143 | devices.append(device) | ||
1083 | 144 | return devices | ||
1084 | 145 | |||
1085 | 146 | def get_mem_devs(): | ||
1086 | 147 | """ Return a list of memory devices | ||
1087 | 148 | |||
1088 | 149 | This returns up to two items, one for physical RAM and another for swap | ||
1089 | 150 | """ | ||
1090 | 151 | pattern = re.compile('^(?P<key>.+?)\s*:\s*(?P<value>.+) kB$', re.M) | ||
1091 | 152 | |||
1092 | 153 | devices = [] | ||
1093 | 154 | try: | ||
1094 | 155 | meminfo = read_file("/proc/meminfo") | ||
1095 | 156 | for match in pattern.finditer(meminfo): | ||
1096 | 157 | key, value = match.groups() | ||
1097 | 158 | if key not in ('MemTotal', 'SwapTotal'): | ||
1098 | 159 | continue | ||
1099 | 160 | capacity = int(value) << 10 #Kernel reports in 2^10 units | ||
1100 | 161 | if capacity == 0: | ||
1101 | 162 | continue | ||
1102 | 163 | if key == 'MemTotal': | ||
1103 | 164 | kind = 'RAM' | ||
1104 | 165 | else: | ||
1105 | 166 | kind = 'swap' | ||
1106 | 167 | description = "{capacity}MiB of {kind}".format( | ||
1107 | 168 | capacity=capacity >> 20, kind=kind) | ||
1108 | 169 | device = {} | ||
1109 | 170 | device['description'] = description | ||
1110 | 171 | device['attributes'] = {'capacity': str(capacity), 'kind': kind} | ||
1111 | 172 | device['device_type'] = "device.mem" | ||
1112 | 173 | devices.append(device) | ||
1113 | 174 | except IOError: | ||
1114 | 175 | print >> sys.stderr, "WARNING: Could not read memory information" | ||
1115 | 176 | return devices | ||
1116 | 177 | |||
1117 | 178 | def get_usb_devs(): | ||
1118 | 179 | """ | ||
1119 | 180 | Return a list of usb devices | ||
1120 | 181 | """ | ||
1121 | 182 | pattern = re.compile( | ||
1122 | 183 | "^Bus \d{3} Device \d{3}: ID (?P<vendor_id>[0-9a-f]{4}):" | ||
1123 | 184 | "(?P<product_id>[0-9a-f]{4}) (?P<description>.*)$") | ||
1124 | 185 | devices = [] | ||
1125 | 186 | try: | ||
1126 | 187 | for line in Popen('lsusb', stdout=PIPE).communicate()[0].splitlines(): | ||
1127 | 188 | match = pattern.match(line) | ||
1128 | 189 | if match: | ||
1129 | 190 | vendor_id, product_id, description = match.groups() | ||
1130 | 191 | attributes = {} | ||
1131 | 192 | device = {} | ||
1132 | 193 | attributes['vendor_id'] = int(vendor_id, 16) | ||
1133 | 194 | attributes['product_id'] = int(product_id, 16) | ||
1134 | 195 | device['attributes'] = attributes | ||
1135 | 196 | device['description'] = description | ||
1136 | 197 | device['device_type'] = 'device.usb' | ||
1137 | 198 | devices.append(device) | ||
1138 | 199 | except OSError: | ||
1139 | 200 | print >> sys.stderr, "WARNING: Could not read usb device information, \ | ||
1140 | 201 | unable to run lsusb, please install usbutils package" | ||
1141 | 202 | return devices | ||
1142 | 203 | |||
1143 | 204 | def get_hardware_context(): | ||
1144 | 205 | """ | ||
1145 | 206 | Return a dict with all of the hardware profile information gathered | ||
1146 | 207 | """ | ||
1147 | 208 | hardware_context = {} | ||
1148 | 209 | devices = [] | ||
1149 | 210 | devices.extend(get_cpu_devs()) | ||
1150 | 211 | devices.extend(get_board_devs()) | ||
1151 | 212 | devices.extend(get_mem_devs()) | ||
1152 | 213 | devices.extend(get_usb_devs()) | ||
1153 | 214 | hardware_context['devices'] = devices | ||
1154 | 215 | return hardware_context | ||
1155 | 216 | |||
1156 | 217 | 0 | ||
1157 | === removed file 'abrek/providers.py' | |||
1158 | --- abrek/providers.py 2011-08-17 13:34:33 +0000 | |||
1159 | +++ abrek/providers.py 1970-01-01 00:00:00 +0000 | |||
1160 | @@ -1,145 +0,0 @@ | |||
1161 | 1 | """ | ||
1162 | 2 | Test providers. | ||
1163 | 3 | |||
1164 | 4 | Allow listing and loading of tests in a generic way. | ||
1165 | 5 | """ | ||
1166 | 6 | |||
1167 | 7 | from pkg_resources import working_set | ||
1168 | 8 | |||
1169 | 9 | from abrek.api import ITestProvider | ||
1170 | 10 | from abrek.cache import AbrekCache | ||
1171 | 11 | from abrek.config import get_config | ||
1172 | 12 | from abrek.testdef import AbrekDeclarativeTest | ||
1173 | 13 | |||
1174 | 14 | |||
1175 | 15 | class BuiltInProvider(ITestProvider): | ||
1176 | 16 | """ | ||
1177 | 17 | Test provider that provides tests shipped in the Abrek source tree | ||
1178 | 18 | """ | ||
1179 | 19 | |||
1180 | 20 | _builtin_tests = [ | ||
1181 | 21 | 'bootchart', | ||
1182 | 22 | 'firefox', | ||
1183 | 23 | 'glmemperf', | ||
1184 | 24 | 'gmpbench', | ||
1185 | 25 | 'gtkperf', | ||
1186 | 26 | 'ltp', | ||
1187 | 27 | 'peacekeeper' | ||
1188 | 28 | 'posixtestsuite', | ||
1189 | 29 | 'pwrmgmt', | ||
1190 | 30 | 'pybench', | ||
1191 | 31 | 'smem', | ||
1192 | 32 | 'stream', | ||
1193 | 33 | 'tiobench', | ||
1194 | 34 | 'x11perf', | ||
1195 | 35 | 'xrestop', | ||
1196 | 36 | ] | ||
1197 | 37 | |||
1198 | 38 | def __init__(self, config): | ||
1199 | 39 | pass | ||
1200 | 40 | |||
1201 | 41 | @property | ||
1202 | 42 | def description(self): | ||
1203 | 43 | return "Tests built directly into Abrek:" | ||
1204 | 44 | |||
1205 | 45 | def __iter__(self): | ||
1206 | 46 | return iter(self._builtin_tests) | ||
1207 | 47 | |||
1208 | 48 | def __getitem__(self, test_name): | ||
1209 | 49 | try: | ||
1210 | 50 | module = __import__("abrek.test_definitions.%s" % test_name, fromlist=['']) | ||
1211 | 51 | except ImportError: | ||
1212 | 52 | raise KeyError(test_name) | ||
1213 | 53 | else: | ||
1214 | 54 | return module.testobj | ||
1215 | 55 | |||
1216 | 56 | |||
1217 | 57 | class PkgResourcesProvider(ITestProvider): | ||
1218 | 58 | """ | ||
1219 | 59 | Test provider that provides tests declared in pkg_resources working_set | ||
1220 | 60 | |||
1221 | 61 | By default it looks at the 'abrek.test_definitions' name space but it can | ||
1222 | 62 | be changed with custom 'namespace' configuration entry. | ||
1223 | 63 | """ | ||
1224 | 64 | |||
1225 | 65 | def __init__(self, config): | ||
1226 | 66 | self._config = config | ||
1227 | 67 | |||
1228 | 68 | @property | ||
1229 | 69 | def namespace(self): | ||
1230 | 70 | return self._config.get("namespace", "abrek.test_definitions") | ||
1231 | 71 | |||
1232 | 72 | @property | ||
1233 | 73 | def description(self): | ||
1234 | 74 | return "Tests provided by installed python packages:" | ||
1235 | 75 | |||
1236 | 76 | def __iter__(self): | ||
1237 | 77 | for entry_point in working_set.iter_entry_points(self.namespace): | ||
1238 | 78 | yield entry_point.name | ||
1239 | 79 | |||
1240 | 80 | def __getitem__(self, test_name): | ||
1241 | 81 | for entry_point in working_set.iter_entry_points(self.namespace, test_name): | ||
1242 | 82 | return entry_point.load().testobj | ||
1243 | 83 | raise KeyError(test_name) | ||
1244 | 84 | |||
1245 | 85 | |||
1246 | 86 | class RegistryProvider(ITestProvider): | ||
1247 | 87 | """ | ||
1248 | 88 | Test provider that provides declarative tests listed in the test registry. | ||
1249 | 89 | """ | ||
1250 | 90 | def __init__(self, config): | ||
1251 | 91 | self._config = config | ||
1252 | 92 | self._cache = None | ||
1253 | 93 | |||
1254 | 94 | @property | ||
1255 | 95 | def entries(self): | ||
1256 | 96 | """ | ||
1257 | 97 | List of URLs to AbrekDeclarativeTest description files | ||
1258 | 98 | """ | ||
1259 | 99 | return self._config.get("entries", []) | ||
1260 | 100 | |||
1261 | 101 | @property | ||
1262 | 102 | def description(self): | ||
1263 | 103 | return "Tests provided by Abrek registry:" | ||
1264 | 104 | |||
1265 | 105 | @classmethod | ||
1266 | 106 | def register_remote_test(self, test_url): | ||
1267 | 107 | config = get_config() # This is a different config object from self._config | ||
1268 | 108 | provider_config = config.get_provider_config("abrek.providers:RegistryProvider") | ||
1269 | 109 | if "entries" not in provider_config: | ||
1270 | 110 | provider_config["entries"] = [] | ||
1271 | 111 | if test_url not in provider_config["entries"]: | ||
1272 | 112 | provider_config["entries"].append(test_url) | ||
1273 | 113 | config._save_registry() | ||
1274 | 114 | else: | ||
1275 | 115 | raise ValueError("This test is already registered") | ||
1276 | 116 | |||
1277 | 117 | def _load_remote_test(self, test_url): | ||
1278 | 118 | """ | ||
1279 | 119 | Load AbrekDeclarativeTest from a (possibly cached copy of) test_url | ||
1280 | 120 | """ | ||
1281 | 121 | cache = AbrekCache.get_instance() | ||
1282 | 122 | with cache.open_cached_url(test_url) as stream: | ||
1283 | 123 | return AbrekDeclarativeTest.load_from_stream(stream) | ||
1284 | 124 | |||
1285 | 125 | def _fill_cache(self): | ||
1286 | 126 | """ | ||
1287 | 127 | Fill the cache of all remote tests | ||
1288 | 128 | """ | ||
1289 | 129 | if self._cache is not None: | ||
1290 | 130 | return | ||
1291 | 131 | self._cache = {} | ||
1292 | 132 | for test_url in self.entries: | ||
1293 | 133 | test = self._load_remote_test(test_url) | ||
1294 | 134 | if test.testname in self._cache: | ||
1295 | 135 | raise ValueError("Duplicate test %s declared" % test.testname) | ||
1296 | 136 | self._cache[test.testname] = test | ||
1297 | 137 | |||
1298 | 138 | def __iter__(self): | ||
1299 | 139 | self._fill_cache() | ||
1300 | 140 | for test_name in self._cache.iterkeys(): | ||
1301 | 141 | yield test_name | ||
1302 | 142 | |||
1303 | 143 | def __getitem__(self, test_name): | ||
1304 | 144 | self._fill_cache() | ||
1305 | 145 | return self._cache[test_name] | ||
1306 | 146 | 0 | ||
1307 | === removed file 'abrek/results.py' | |||
1308 | --- abrek/results.py 2010-10-14 13:57:35 +0000 | |||
1309 | +++ abrek/results.py 1970-01-01 00:00:00 +0000 | |||
1310 | @@ -1,111 +0,0 @@ | |||
1311 | 1 | # Copyright (c) 2010 Linaro | ||
1312 | 2 | # | ||
1313 | 3 | # This program is free software: you can redistribute it and/or modify | ||
1314 | 4 | # it under the terms of the GNU General Public License as published by | ||
1315 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
1316 | 6 | # (at your option) any later version. | ||
1317 | 7 | # | ||
1318 | 8 | # This program is distributed in the hope that it will be useful, | ||
1319 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1320 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1321 | 11 | # GNU General Public License for more details. | ||
1322 | 12 | # | ||
1323 | 13 | # You should have received a copy of the GNU General Public License | ||
1324 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1325 | 15 | |||
1326 | 16 | import os | ||
1327 | 17 | import shutil | ||
1328 | 18 | import sys | ||
1329 | 19 | from optparse import make_option | ||
1330 | 20 | |||
1331 | 21 | from abrek.command import AbrekCmd, AbrekCmdWithSubcommands | ||
1332 | 22 | from abrek.config import get_config | ||
1333 | 23 | from abrek.utils import read_file | ||
1334 | 24 | |||
1335 | 25 | |||
1336 | 26 | class cmd_results(AbrekCmdWithSubcommands): | ||
1337 | 27 | """ | ||
1338 | 28 | Operate on results of previous test runs stored locally | ||
1339 | 29 | """ | ||
1340 | 30 | |||
1341 | 31 | class cmd_list(AbrekCmd): | ||
1342 | 32 | """ | ||
1343 | 33 | List results of previous runs | ||
1344 | 34 | """ | ||
1345 | 35 | def run(self): | ||
1346 | 36 | config = get_config() | ||
1347 | 37 | print "Saved results:" | ||
1348 | 38 | try: | ||
1349 | 39 | for dir in os.listdir(config.resultsdir): | ||
1350 | 40 | print dir | ||
1351 | 41 | except OSError: | ||
1352 | 42 | print "No results found" | ||
1353 | 43 | |||
1354 | 44 | |||
1355 | 45 | class cmd_show(AbrekCmd): | ||
1356 | 46 | """ | ||
1357 | 47 | Display the output from a previous test run | ||
1358 | 48 | """ | ||
1359 | 49 | arglist = ['*result'] | ||
1360 | 50 | def run(self): | ||
1361 | 51 | if len(self.args) != 1: | ||
1362 | 52 | print "please specify the name of the result dir" | ||
1363 | 53 | sys.exit(1) | ||
1364 | 54 | config = get_config() | ||
1365 | 55 | resultsdir = os.path.join(config.resultsdir, self.args[0]) | ||
1366 | 56 | testoutput = os.path.join(resultsdir, "testoutput.log") | ||
1367 | 57 | if not os.path.exists(testoutput): | ||
1368 | 58 | print "No result found for '%s'" % self.args[0] | ||
1369 | 59 | sys.exit(1) | ||
1370 | 60 | try: | ||
1371 | 61 | print(read_file(testoutput)) | ||
1372 | 62 | except IOError: | ||
1373 | 63 | pass | ||
1374 | 64 | |||
1375 | 65 | |||
1376 | 66 | class cmd_remove(AbrekCmd): | ||
1377 | 67 | """ | ||
1378 | 68 | Remove the results of a previous test run | ||
1379 | 69 | """ | ||
1380 | 70 | arglist = ['*result'] | ||
1381 | 71 | options = [make_option('-f', '--force', action='store_true', | ||
1382 | 72 | dest='force')] | ||
1383 | 73 | def run(self): | ||
1384 | 74 | if len(self.args) != 1: | ||
1385 | 75 | print "please specify the name of the result dir" | ||
1386 | 76 | sys.exit(1) | ||
1387 | 77 | config = get_config() | ||
1388 | 78 | resultsdir = os.path.join(config.resultsdir, self.args[0]) | ||
1389 | 79 | if not os.path.exists(resultsdir): | ||
1390 | 80 | print "No result found for '%s'" % self.args[0] | ||
1391 | 81 | sys.exit(1) | ||
1392 | 82 | if not self.opts.force: | ||
1393 | 83 | print "Delete result '%s' for good? [Y/N]" % self.args[0], | ||
1394 | 84 | response = raw_input() | ||
1395 | 85 | if response[0].upper() != 'Y': | ||
1396 | 86 | sys.exit(0) | ||
1397 | 87 | shutil.rmtree(resultsdir) | ||
1398 | 88 | |||
1399 | 89 | |||
1400 | 90 | class cmd_rename(AbrekCmd): | ||
1401 | 91 | """ | ||
1402 | 92 | Rename the results from a previous test run | ||
1403 | 93 | """ | ||
1404 | 94 | arglist = ['*source', '*destination'] | ||
1405 | 95 | |||
1406 | 96 | def run(self): | ||
1407 | 97 | if len(self.args) != 2: | ||
1408 | 98 | print "please specify the name of the result, and the new name" | ||
1409 | 99 | sys.exit(1) | ||
1410 | 100 | config = get_config() | ||
1411 | 101 | srcdir = os.path.join(config.resultsdir, self.args[0]) | ||
1412 | 102 | destdir = os.path.join(config.resultsdir, self.args[1]) | ||
1413 | 103 | if not os.path.exists(srcdir): | ||
1414 | 104 | print "Result directory not found" | ||
1415 | 105 | sys.exit(1) | ||
1416 | 106 | if os.path.exists(destdir): | ||
1417 | 107 | print "Destination result name already exists" | ||
1418 | 108 | sys.exit(1) | ||
1419 | 109 | shutil.move(srcdir, destdir) | ||
1420 | 110 | |||
1421 | 111 | |||
1422 | 112 | 0 | ||
1423 | === removed file 'abrek/swprofile.py' | |||
1424 | --- abrek/swprofile.py 2011-07-22 04:00:04 +0000 | |||
1425 | +++ abrek/swprofile.py 1970-01-01 00:00:00 +0000 | |||
1426 | @@ -1,65 +0,0 @@ | |||
1427 | 1 | # Copyright (c) 2010 Linaro | ||
1428 | 2 | # | ||
1429 | 3 | # This program is free software: you can redistribute it and/or modify | ||
1430 | 4 | # it under the terms of the GNU General Public License as published by | ||
1431 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
1432 | 6 | # (at your option) any later version. | ||
1433 | 7 | # | ||
1434 | 8 | # This program is distributed in the hope that it will be useful, | ||
1435 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1436 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1437 | 11 | # GNU General Public License for more details. | ||
1438 | 12 | # | ||
1439 | 13 | # You should have received a copy of the GNU General Public License | ||
1440 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1441 | 15 | |||
1442 | 16 | import apt | ||
1443 | 17 | import lsb_release | ||
1444 | 18 | from utils import read_file | ||
1445 | 19 | |||
1446 | 20 | def get_packages(apt_cache=None): | ||
1447 | 21 | """ Get information about the packages installed | ||
1448 | 22 | |||
1449 | 23 | apt_cache - if not provided, this will be read from the system | ||
1450 | 24 | """ | ||
1451 | 25 | if apt_cache == None: | ||
1452 | 26 | apt_cache = apt.Cache() | ||
1453 | 27 | packages = [] | ||
1454 | 28 | for apt_pkg in apt_cache: | ||
1455 | 29 | if hasattr(apt_pkg, 'is_installed'): | ||
1456 | 30 | is_installed = apt_pkg.is_installed | ||
1457 | 31 | else: | ||
1458 | 32 | is_installed = apt_pkg.isInstalled # old style API | ||
1459 | 33 | if is_installed: | ||
1460 | 34 | pkg = {"name":apt_pkg.name, "version":apt_pkg.installed.version} | ||
1461 | 35 | packages.append(pkg) | ||
1462 | 36 | return packages | ||
1463 | 37 | |||
1464 | 38 | def get_software_context(apt_cache=None, lsb_information=None): | ||
1465 | 39 | """ Return dict used for storing software_context information | ||
1466 | 40 | |||
1467 | 41 | test_id - Unique identifier for this test | ||
1468 | 42 | time_check - whether or not a check was performed to see if | ||
1469 | 43 | the time on the system was synced with a time server | ||
1470 | 44 | apt_cache - if not provided, this will be read from the system | ||
1471 | 45 | lsb_information - if not provided, this will be read from the system | ||
1472 | 46 | """ | ||
1473 | 47 | software_context = {} | ||
1474 | 48 | software_context['image'] = get_image(lsb_information) | ||
1475 | 49 | software_context['packages'] = get_packages(apt_cache) | ||
1476 | 50 | return software_context | ||
1477 | 51 | |||
1478 | 52 | def get_image(lsb_information=None): | ||
1479 | 53 | """ Get information about the image we are running | ||
1480 | 54 | |||
1481 | 55 | If /etc/buildstamp exists, get the image id from that. Otherwise | ||
1482 | 56 | just use the lsb-release description for a rough idea. | ||
1483 | 57 | """ | ||
1484 | 58 | try: | ||
1485 | 59 | buildstamp = read_file("/etc/buildstamp") | ||
1486 | 60 | name = buildstamp.splitlines()[1] | ||
1487 | 61 | except IOError: | ||
1488 | 62 | if lsb_information == None: | ||
1489 | 63 | lsb_information = lsb_release.get_distro_information() | ||
1490 | 64 | name = lsb_information['DESCRIPTION'] | ||
1491 | 65 | return {"name":name} | ||
1492 | 66 | 0 | ||
1493 | === removed file 'abrek/testdef.py' | |||
1494 | --- abrek/testdef.py 2011-08-18 20:09:56 +0000 | |||
1495 | +++ abrek/testdef.py 1970-01-01 00:00:00 +0000 | |||
1496 | @@ -1,435 +0,0 @@ | |||
1497 | 1 | # Copyright (c) 2010 Linaro | ||
1498 | 2 | # | ||
1499 | 3 | # This program is free software: you can redistribute it and/or modify | ||
1500 | 4 | # it under the terms of the GNU General Public License as published by | ||
1501 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
1502 | 6 | # (at your option) any later version. | ||
1503 | 7 | # | ||
1504 | 8 | # This program is distributed in the hope that it will be useful, | ||
1505 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1506 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1507 | 11 | # GNU General Public License for more details. | ||
1508 | 12 | # | ||
1509 | 13 | # You should have received a copy of the GNU General Public License | ||
1510 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1511 | 15 | |||
1512 | 16 | import hashlib | ||
1513 | 17 | import json | ||
1514 | 18 | import os | ||
1515 | 19 | import re | ||
1516 | 20 | import shutil | ||
1517 | 21 | import decimal | ||
1518 | 22 | import sys | ||
1519 | 23 | import time | ||
1520 | 24 | from commands import getstatusoutput | ||
1521 | 25 | from datetime import datetime | ||
1522 | 26 | from uuid import uuid4 | ||
1523 | 27 | |||
1524 | 28 | from abrek import swprofile, hwprofile | ||
1525 | 29 | from abrek.api import ITest | ||
1526 | 30 | from abrek.bundle import DocumentIO | ||
1527 | 31 | from abrek.config import get_config | ||
1528 | 32 | from abrek.utils import geturl, run_and_log, write_file | ||
1529 | 33 | |||
1530 | 34 | |||
1531 | 35 | class AbrekTest(ITest): | ||
1532 | 36 | """Base class for defining tests. | ||
1533 | 37 | |||
1534 | 38 | This can be used by test definition files to create an object that | ||
1535 | 39 | contains the building blocks for installing tests, running them, | ||
1536 | 40 | and parsing the results. | ||
1537 | 41 | |||
1538 | 42 | testname - name of the test or test suite | ||
1539 | 43 | version - version of the test or test suite | ||
1540 | 44 | installer - AbrekInstaller instance to use | ||
1541 | 45 | runner - AbrekRunner instance to use | ||
1542 | 46 | parser - AbrekParser instance to use | ||
1543 | 47 | """ | ||
1544 | 48 | def __init__(self, testname, version="", installer=None, runner=None, | ||
1545 | 49 | parser=None): | ||
1546 | 50 | self.testname = testname | ||
1547 | 51 | self.version = version | ||
1548 | 52 | self.installer = installer | ||
1549 | 53 | self.runner = runner | ||
1550 | 54 | self.parser = parser | ||
1551 | 55 | self.origdir = os.path.abspath(os.curdir) | ||
1552 | 56 | |||
1553 | 57 | def install(self): | ||
1554 | 58 | """Install the test suite. | ||
1555 | 59 | |||
1556 | 60 | This creates an install directory under the user's XDG_DATA_HOME | ||
1557 | 61 | directory to mark that the test is installed. The installer's | ||
1558 | 62 | install() method is then called from this directory to complete any | ||
1559 | 63 | test specific install that may be needed. | ||
1560 | 64 | """ | ||
1561 | 65 | if not self.installer: | ||
1562 | 66 | raise RuntimeError("no installer defined for '%s'" % | ||
1563 | 67 | self.testname) | ||
1564 | 68 | config = get_config() | ||
1565 | 69 | installdir = os.path.join(config.installdir, self.testname) | ||
1566 | 70 | if os.path.exists(installdir): | ||
1567 | 71 | raise RuntimeError("%s is already installed" % self.testname) | ||
1568 | 72 | os.makedirs(installdir) | ||
1569 | 73 | os.chdir(installdir) | ||
1570 | 74 | try: | ||
1571 | 75 | self.installer.install() | ||
1572 | 76 | except Exception as strerror: | ||
1573 | 77 | self.uninstall() | ||
1574 | 78 | raise | ||
1575 | 79 | finally: | ||
1576 | 80 | os.chdir(self.origdir) | ||
1577 | 81 | |||
1578 | 82 | def uninstall(self): | ||
1579 | 83 | """Uninstall the test suite. | ||
1580 | 84 | |||
1581 | 85 | Uninstalling just recursively removes the test specific directory | ||
1582 | 86 | under the user's XDG_DATA_HOME directory. This will both mark | ||
1583 | 87 | the test as removed, and clean up any files that were downloaded | ||
1584 | 88 | or installed under that directory. Dependencies are intentionally | ||
1585 | 89 | not removed by this. | ||
1586 | 90 | """ | ||
1587 | 91 | os.chdir(self.origdir) | ||
1588 | 92 | config = get_config() | ||
1589 | 93 | path = os.path.join(config.installdir, self.testname) | ||
1590 | 94 | if os.path.exists(path): | ||
1591 | 95 | shutil.rmtree(path) | ||
1592 | 96 | |||
1593 | 97 | def _savetestdata(self, analyzer_assigned_uuid): | ||
1594 | 98 | TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ' | ||
1595 | 99 | bundle = { | ||
1596 | 100 | 'format': 'Dashboard Bundle Format 1.2', | ||
1597 | 101 | 'test_runs': [ | ||
1598 | 102 | { | ||
1599 | 103 | 'test_id': self.testname, | ||
1600 | 104 | 'analyzer_assigned_date': self.runner.starttime.strftime(TIMEFORMAT), | ||
1601 | 105 | 'analyzer_assigned_uuid': analyzer_assigned_uuid, | ||
1602 | 106 | 'time_check_performed': False, | ||
1603 | 107 | 'hardware_context': hwprofile.get_hardware_context(), | ||
1604 | 108 | 'software_context': swprofile.get_software_context(), | ||
1605 | 109 | 'test_results': [] | ||
1606 | 110 | } | ||
1607 | 111 | ] | ||
1608 | 112 | } | ||
1609 | 113 | filename = os.path.join(self.resultsdir, 'testdata.json') | ||
1610 | 114 | write_file(DocumentIO.dumps(bundle), filename) | ||
1611 | 115 | |||
1612 | 116 | def run(self, quiet=False): | ||
1613 | 117 | if not self.runner: | ||
1614 | 118 | raise RuntimeError("no test runner defined for '%s'" % | ||
1615 | 119 | self.testname) | ||
1616 | 120 | config = get_config() | ||
1617 | 121 | uuid = str(uuid4()) | ||
1618 | 122 | installdir = os.path.join(config.installdir, self.testname) | ||
1619 | 123 | resultname = (self.testname + | ||
1620 | 124 | str(time.mktime(datetime.utcnow().timetuple()))) | ||
1621 | 125 | self.resultsdir = os.path.join(config.resultsdir, resultname) | ||
1622 | 126 | os.makedirs(self.resultsdir) | ||
1623 | 127 | try: | ||
1624 | 128 | os.chdir(installdir) | ||
1625 | 129 | self.runner.run(self.resultsdir, quiet=quiet) | ||
1626 | 130 | self._savetestdata(uuid) | ||
1627 | 131 | finally: | ||
1628 | 132 | os.chdir(self.origdir) | ||
1629 | 133 | result_id = os.path.basename(self.resultsdir) | ||
1630 | 134 | print("ABREK TEST RUN COMPLETE: Result id is '%s'" % result_id) | ||
1631 | 135 | return result_id | ||
1632 | 136 | |||
1633 | 137 | def parse(self, resultname): | ||
1634 | 138 | if not self.parser: | ||
1635 | 139 | raise RuntimeError("no test parser defined for '%s'" % | ||
1636 | 140 | self.testname) | ||
1637 | 141 | config = get_config() | ||
1638 | 142 | resultsdir = os.path.join(config.resultsdir, resultname) | ||
1639 | 143 | os.chdir(resultsdir) | ||
1640 | 144 | self.parser.parse() | ||
1641 | 145 | os.chdir(self.origdir) | ||
1642 | 146 | |||
1643 | 147 | |||
1644 | 148 | class AbrekDeclarativeTest(AbrekTest): | ||
1645 | 149 | """ | ||
1646 | 150 | Declarative test is like AbrekTest but cannot contain any python code and | ||
1647 | 151 | is completely encapsulated in .json file. | ||
1648 | 152 | """ | ||
1649 | 153 | |||
1650 | 154 | @classmethod | ||
1651 | 155 | def load_from_stream(cls, stream): | ||
1652 | 156 | return cls(json.load(stream)) | ||
1653 | 157 | |||
1654 | 158 | def save_to_stream(self, stream): | ||
1655 | 159 | json.dumps(self.about, stream, indent="2") | ||
1656 | 160 | |||
1657 | 161 | def __init__(self, about): | ||
1658 | 162 | self.about = about | ||
1659 | 163 | super(AbrekDeclarativeTest, self).__init__(self.about.get('test_id')) | ||
1660 | 164 | self.installer = AbrekTestInstaller(**self.about.get('install', {})) | ||
1661 | 165 | self.runner = AbrekTestRunner(**self.about.get('run', {})) | ||
1662 | 166 | if self.about.get('parse', {}).get('native', False) is True: | ||
1663 | 167 | self.parser = AbrekNativeTestParser(self) | ||
1664 | 168 | else: | ||
1665 | 169 | self.parser = AbrekForeignTestParser(**self.about.get('parse', {})) | ||
1666 | 170 | |||
1667 | 171 | |||
1668 | 172 | class AbrekTestInstaller(object): | ||
1669 | 173 | """Base class for defining an installer object. | ||
1670 | 174 | |||
1671 | 175 | This class can be used as-is for simple installers, or extended for more | ||
1672 | 176 | advanced funcionality. | ||
1673 | 177 | |||
1674 | 178 | steps - list of steps to be executed in a shell | ||
1675 | 179 | deps - list of dependencies to apt-get install before running the steps | ||
1676 | 180 | url - location from which the test suite should be downloaded | ||
1677 | 181 | md5 - md5sum to check the integrety of the download | ||
1678 | 182 | """ | ||
1679 | 183 | def __init__(self, steps=[], deps=[], url="", md5="", **kwargs): | ||
1680 | 184 | self.steps = steps | ||
1681 | 185 | self.deps = deps | ||
1682 | 186 | self.url = url | ||
1683 | 187 | self.md5 = md5 | ||
1684 | 188 | |||
1685 | 189 | def _installdeps(self): | ||
1686 | 190 | if not self.deps: | ||
1687 | 191 | return 0 | ||
1688 | 192 | cmd = "sudo apt-get install -y %s" % " ".join(self.deps) | ||
1689 | 193 | rc, output = getstatusoutput(cmd) | ||
1690 | 194 | if rc: | ||
1691 | 195 | raise RuntimeError("Dependency installation failed. %d : %s" %(rc,output)) | ||
1692 | 196 | |||
1693 | 197 | def _download(self): | ||
1694 | 198 | """Download the file specified by the url and check the md5. | ||
1695 | 199 | |||
1696 | 200 | Returns the path and filename if successful, otherwise return None | ||
1697 | 201 | """ | ||
1698 | 202 | if not self.url: | ||
1699 | 203 | return 0 | ||
1700 | 204 | filename = geturl(self.url) | ||
1701 | 205 | #If the file does not exist, then the download was not successful | ||
1702 | 206 | if not os.path.exists(filename): | ||
1703 | 207 | return None | ||
1704 | 208 | if self.md5: | ||
1705 | 209 | checkmd5 = hashlib.md5() | ||
1706 | 210 | with open(filename, 'rb') as fd: | ||
1707 | 211 | data = fd.read(0x10000) | ||
1708 | 212 | while data: | ||
1709 | 213 | checkmd5.update(data) | ||
1710 | 214 | data = fd.read(0x10000) | ||
1711 | 215 | if checkmd5.hexdigest() != self.md5: | ||
1712 | 216 | raise RuntimeError("Unexpected md5sum downloading %s" % | ||
1713 | 217 | filename) | ||
1714 | 218 | return None | ||
1715 | 219 | return filename | ||
1716 | 220 | |||
1717 | 221 | def _runsteps(self): | ||
1718 | 222 | for cmd in self.steps: | ||
1719 | 223 | rc, output = getstatusoutput(cmd) | ||
1720 | 224 | if rc: | ||
1721 | 225 | raise RuntimeError("Run step '%s' failed. %d : %s" %(cmd,rc,output)) | ||
1722 | 226 | |||
1723 | 227 | |||
1724 | 228 | def install(self): | ||
1725 | 229 | self._installdeps() | ||
1726 | 230 | self._download() | ||
1727 | 231 | self._runsteps() | ||
1728 | 232 | |||
1729 | 233 | |||
1730 | 234 | class AbrekTestRunner(object): | ||
1731 | 235 | """Base class for defining an test runner object. | ||
1732 | 236 | |||
1733 | 237 | This class can be used as-is for simple execution with the expectation | ||
1734 | 238 | that the run() method will be called from the directory where the test | ||
1735 | 239 | was installed. Steps, if used, should handle changing directories from | ||
1736 | 240 | there to the directory where the test was extracted if necessary. | ||
1737 | 241 | This class can also be extended for more advanced funcionality. | ||
1738 | 242 | |||
1739 | 243 | steps - list of steps to be executed in a shell | ||
1740 | 244 | """ | ||
1741 | 245 | def __init__(self, steps=[]): | ||
1742 | 246 | self.steps = steps | ||
1743 | 247 | self.testoutput = [] | ||
1744 | 248 | |||
1745 | 249 | def _runsteps(self, resultsdir, quiet=False): | ||
1746 | 250 | outputlog = os.path.join(resultsdir, 'testoutput.log') | ||
1747 | 251 | with open(outputlog, 'a') as fd: | ||
1748 | 252 | for cmd in self.steps: | ||
1749 | 253 | run_and_log(cmd, fd, quiet) | ||
1750 | 254 | |||
1751 | 255 | def run(self, resultsdir, quiet=False): | ||
1752 | 256 | self.starttime = datetime.utcnow() | ||
1753 | 257 | self._runsteps(resultsdir, quiet=quiet) | ||
1754 | 258 | self.endtime = datetime.utcnow() | ||
1755 | 259 | |||
1756 | 260 | |||
1757 | 261 | class AbrekForeignTestParser(object): | ||
1758 | 262 | """Base class for defining a test parser | ||
1759 | 263 | |||
1760 | 264 | This class can be used as-is for simple results parsers, but will | ||
1761 | 265 | likely need to be extended slightly for many. If used as it is, | ||
1762 | 266 | the parse() method should be called while already in the results | ||
1763 | 267 | directory and assumes that a file for test output will exist called | ||
1764 | 268 | testoutput.log. | ||
1765 | 269 | |||
1766 | 270 | pattern - regexp pattern to identify important elements of test output | ||
1767 | 271 | For example: If your testoutput had lines that look like: | ||
1768 | 272 | "test01: PASS", then you could use a pattern like this: | ||
1769 | 273 | "^(?P<testid>\w+):\W+(?P<result>\w+)" | ||
1770 | 274 | This would result in identifying "test01" as testid and | ||
1771 | 275 | "PASS" as result. Once parse() has been called, | ||
1772 | 276 | self.results.test_results[] contains a list of dicts of all the | ||
1773 | 277 | key,value pairs found for each test result | ||
1774 | 278 | fixupdict - dict of strings to convert test results to standard strings | ||
1775 | 279 | For example: if you want to standardize on having pass/fail results | ||
1776 | 280 | in lower case, but your test outputs them in upper case, you could | ||
1777 | 281 | use a fixupdict of something like: {'PASS':'pass','FAIL':'fail'} | ||
1778 | 282 | appendall - Append a dict to the test_results entry for each result. | ||
1779 | 283 | For example: if you would like to add units="MB/s" to each result: | ||
1780 | 284 | appendall={'units':'MB/s'} | ||
1781 | 285 | """ | ||
1782 | 286 | def __init__(self, pattern=None, fixupdict=None, appendall={}): | ||
1783 | 287 | self.pattern = pattern | ||
1784 | 288 | self.fixupdict = fixupdict | ||
1785 | 289 | self.results = {'test_results':[]} | ||
1786 | 290 | self.appendall = appendall | ||
1787 | 291 | |||
1788 | 292 | def _find_testid(self, id): | ||
1789 | 293 | for x in self.results['test_results']: | ||
1790 | 294 | if x['testid'] == id: | ||
1791 | 295 | return self.results['test_results'].index(x) | ||
1792 | 296 | |||
1793 | 297 | def parse(self): | ||
1794 | 298 | """Parse test output to gather results | ||
1795 | 299 | |||
1796 | 300 | Use the pattern specified when the class was instantiated to look | ||
1797 | 301 | through the results line-by-line and find lines that match it. | ||
1798 | 302 | Results are then stored in self.results. If a fixupdict was supplied | ||
1799 | 303 | it is used to convert test result strings to a standard format. | ||
1800 | 304 | """ | ||
1801 | 305 | filename = "testoutput.log" | ||
1802 | 306 | try: | ||
1803 | 307 | pat = re.compile(self.pattern) | ||
1804 | 308 | except Exception as strerror: | ||
1805 | 309 | raise RuntimeError( | ||
1806 | 310 | "AbrekTestParser - Invalid regular expression '%s' - %s" % ( | ||
1807 | 311 | self.pattern,strerror)) | ||
1808 | 312 | |||
1809 | 313 | with open(filename, 'r') as stream: | ||
1810 | 314 | for lineno, line in enumerate(stream, 1): | ||
1811 | 315 | match = pat.search(line) | ||
1812 | 316 | if not match: | ||
1813 | 317 | continue | ||
1814 | 318 | data = match.groupdict() | ||
1815 | 319 | if 'measurement' in data: | ||
1816 | 320 | data['measurement'] = decimal.Decimal(data['measurement']) | ||
1817 | 321 | data["log_filename"] = filename | ||
1818 | 322 | data["log_lineno"] = lineno | ||
1819 | 323 | self.results['test_results'].append(data) | ||
1820 | 324 | if self.fixupdict: | ||
1821 | 325 | self.fixresults(self.fixupdict) | ||
1822 | 326 | if self.appendall: | ||
1823 | 327 | self.appendtoall(self.appendall) | ||
1824 | 328 | self.fixmeasurements() | ||
1825 | 329 | self.fixids() | ||
1826 | 330 | |||
1827 | 331 | def append(self, testid, entry): | ||
1828 | 332 | """Appends a dict to the test_results entry for a specified testid | ||
1829 | 333 | |||
1830 | 334 | This lets you add a dict to the entry for a specific testid | ||
1831 | 335 | entry should be a dict, updates it in place | ||
1832 | 336 | """ | ||
1833 | 337 | index = self._find_testid(testid) | ||
1834 | 338 | self.results['test_results'][index].update(entry) | ||
1835 | 339 | |||
1836 | 340 | def appendtoall(self, entry): | ||
1837 | 341 | """Append entry to each item in the test_results. | ||
1838 | 342 | |||
1839 | 343 | entry - dict of key,value pairs to add to each item in the | ||
1840 | 344 | test_results | ||
1841 | 345 | """ | ||
1842 | 346 | for t in self.results['test_results']: | ||
1843 | 347 | t.update(entry) | ||
1844 | 348 | |||
1845 | 349 | def fixresults(self, fixupdict): | ||
1846 | 350 | """Convert results to a known, standard format | ||
1847 | 351 | |||
1848 | 352 | pass it a dict of keys/values to replace | ||
1849 | 353 | For instance: | ||
1850 | 354 | {"TPASS":"pass", "TFAIL":"fail"} | ||
1851 | 355 | This is really only used for qualitative tests | ||
1852 | 356 | """ | ||
1853 | 357 | for t in self.results['test_results']: | ||
1854 | 358 | if t.has_key("result"): | ||
1855 | 359 | t['result'] = fixupdict[t['result']] | ||
1856 | 360 | |||
1857 | 361 | def fixmeasurements(self): | ||
1858 | 362 | """Measurements are often read as strings, but need to be float | ||
1859 | 363 | """ | ||
1860 | 364 | for id in self.results['test_results']: | ||
1861 | 365 | if id.has_key('measurement'): | ||
1862 | 366 | id['measurement'] = float(id['measurement']) | ||
1863 | 367 | |||
1864 | 368 | def fixids(self): | ||
1865 | 369 | """ | ||
1866 | 370 | Convert spaces to _ in test_case_id and remove illegal characters | ||
1867 | 371 | """ | ||
1868 | 372 | badchars = "[^a-zA-Z0-9\._-]" | ||
1869 | 373 | for id in self.results['test_results']: | ||
1870 | 374 | if id.has_key('test_case_id'): | ||
1871 | 375 | id['test_case_id'] = id['test_case_id'].replace(" ", "_") | ||
1872 | 376 | id['test_case_id'] = re.sub(badchars, "", id['test_case_id']) | ||
1873 | 377 | |||
1874 | 378 | |||
1875 | 379 | AbrekTestParser = AbrekForeignTestParser | ||
1876 | 380 | |||
1877 | 381 | |||
1878 | 382 | class AbrekNativeTestParser(object): | ||
1879 | 383 | |||
1880 | 384 | def __init__(self, test_def): | ||
1881 | 385 | self.test_def = test_def | ||
1882 | 386 | |||
1883 | 387 | def parse(self): | ||
1884 | 388 | raise NotImplementedError(self.parse) | ||
1885 | 389 | |||
1886 | 390 | |||
1887 | 391 | class TestLoader(object): | ||
1888 | 392 | """ | ||
1889 | 393 | Test loader. | ||
1890 | 394 | |||
1891 | 395 | Encapsulates Abrek's knowledge of available tests. | ||
1892 | 396 | |||
1893 | 397 | Test can be loaded by name with TetsLoader.get_test_by_name. Test can also | ||
1894 | 398 | be listed by TestLoader.get_providers() and then iterating over tests | ||
1895 | 399 | returned by each provider. | ||
1896 | 400 | """ | ||
1897 | 401 | |||
1898 | 402 | def __init__(self): | ||
1899 | 403 | self._config = get_config() | ||
1900 | 404 | |||
1901 | 405 | def get_providers(self): | ||
1902 | 406 | """ | ||
1903 | 407 | Return a generator of available providers | ||
1904 | 408 | """ | ||
1905 | 409 | import pkg_resources | ||
1906 | 410 | for provider_info in self._config.registry.get("providers", []): | ||
1907 | 411 | entry_point_name = provider_info.get("entry_point") | ||
1908 | 412 | module_name, attrs = entry_point_name.split(':', 1) | ||
1909 | 413 | attrs = attrs.split('.') | ||
1910 | 414 | try: | ||
1911 | 415 | entry_point = pkg_resources.EntryPoint(entry_point_name, module_name, attrs, | ||
1912 | 416 | dist=pkg_resources.get_distribution("lava-test")) | ||
1913 | 417 | provider_cls = entry_point.load() | ||
1914 | 418 | provider = provider_cls(provider_info.get("config", {})) | ||
1915 | 419 | yield provider | ||
1916 | 420 | except pkg_resources.DistributionNotFound as ex: | ||
1917 | 421 | raise RuntimeError("lava-test is not properly set up. Please read the REAMME file") | ||
1918 | 422 | |||
1919 | 423 | def get_test_by_name(self, test_name): | ||
1920 | 424 | """ | ||
1921 | 425 | Lookup a test with the specified name | ||
1922 | 426 | """ | ||
1923 | 427 | for provider in self.get_providers(): | ||
1924 | 428 | try: | ||
1925 | 429 | return provider[test_name] | ||
1926 | 430 | except KeyError: | ||
1927 | 431 | pass | ||
1928 | 432 | raise ValueError("No such test %r" % test_name) | ||
1929 | 433 | |||
1930 | 434 | |||
1931 | 435 | testloader = TestLoader().get_test_by_name | ||
1932 | 436 | 0 | ||
1933 | === removed directory 'bin' | |||
1934 | === removed file 'bin/lava-test' | |||
1935 | --- bin/lava-test 2011-06-10 04:49:54 +0000 | |||
1936 | +++ bin/lava-test 1970-01-01 00:00:00 +0000 | |||
1937 | @@ -1,31 +0,0 @@ | |||
1938 | 1 | #!/usr/bin/python | ||
1939 | 2 | |||
1940 | 3 | # Copyright (c) 2010 Linaro | ||
1941 | 4 | # | ||
1942 | 5 | # This program is free software: you can redistribute it and/or modify | ||
1943 | 6 | # it under the terms of the GNU General Public License as published by | ||
1944 | 7 | # the Free Software Foundation, either version 3 of the License, or | ||
1945 | 8 | # (at your option) any later version. | ||
1946 | 9 | # | ||
1947 | 10 | # This program is distributed in the hope that it will be useful, | ||
1948 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1949 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1950 | 13 | # GNU General Public License for more details. | ||
1951 | 14 | # | ||
1952 | 15 | # You should have received a copy of the GNU General Public License | ||
1953 | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1954 | 17 | |||
1955 | 18 | import os | ||
1956 | 19 | import sys | ||
1957 | 20 | |||
1958 | 21 | ABREK_BINDIR=os.path.abspath(os.path.dirname(os.path.realpath(sys.argv[0]))) | ||
1959 | 22 | ABREK_ROOT=os.path.dirname(ABREK_BINDIR) | ||
1960 | 23 | ABREK_DIR=os.path.join(ABREK_ROOT,'abrek') | ||
1961 | 24 | if os.path.exists(ABREK_DIR) and ABREK_ROOT not in sys.path: | ||
1962 | 25 | sys.path.insert(0, ABREK_ROOT) | ||
1963 | 26 | |||
1964 | 27 | import abrek.main | ||
1965 | 28 | |||
1966 | 29 | if __name__ == '__main__': | ||
1967 | 30 | exit_code = abrek.main.main(sys.argv) | ||
1968 | 31 | sys.exit(exit_code) | ||
1969 | 32 | 0 | ||
1970 | === added directory 'doc' | |||
1971 | === added file 'doc/changes.rst' | |||
1972 | --- doc/changes.rst 1970-01-01 00:00:00 +0000 | |||
1973 | +++ doc/changes.rst 2011-09-13 22:44:36 +0000 | |||
1974 | @@ -0,0 +1,25 @@ | |||
1975 | 1 | Version History | ||
1976 | 2 | *************** | ||
1977 | 3 | |||
1978 | 4 | .. _version_0_2: | ||
1979 | 5 | |||
1980 | 6 | Version 0.2 | ||
1981 | 7 | =========== | ||
1982 | 8 | |||
1983 | 9 | * Rewrite most of the code and deprecate old Abrek interfaces. This allowed us | ||
1984 | 10 | to clean up the API, rethink some of the design and integrate the code better | ||
1985 | 11 | with other parts of LAVA. | ||
1986 | 12 | |||
1987 | 13 | * Improved documentation and code reference. LAVA Test should now have | ||
1988 | 14 | sufficient documentation to help new users and contributors alike. | ||
1989 | 15 | |||
1990 | 16 | * Support for installing and running out-of-tree tests. | ||
1991 | 17 | |||
1992 | 18 | * Ability to define parsers that add new attachments. | ||
1993 | 19 | |||
1994 | 20 | * Unified command line interface with other lava tools thanks to lava-tool. | ||
1995 | 21 | |||
1996 | 22 | Version 0.1 | ||
1997 | 23 | =========== | ||
1998 | 24 | |||
1999 | 25 | * Initial release (as Abrek) | ||
2000 | 0 | 26 | ||
2001 | === added file 'doc/conf.py' | |||
2002 | --- doc/conf.py 1970-01-01 00:00:00 +0000 | |||
2003 | +++ doc/conf.py 2011-09-13 22:44:36 +0000 | |||
2004 | @@ -0,0 +1,211 @@ | |||
2005 | 1 | # -*- coding: utf-8 -*- | ||
2006 | 2 | # | ||
2007 | 3 | # Linaro JSON documentation build configuration file, created by | ||
2008 | 4 | # sphinx-quickstart on Mon Dec 27 16:39:47 2010. | ||
2009 | 5 | # | ||
2010 | 6 | # This file is execfile()d with the current directory set to its containing dir. | ||
2011 | 7 | # | ||
2012 | 8 | # Note that not all possible configuration values are present in this | ||
2013 | 9 | # autogenerated file. | ||
2014 | 10 | # | ||
2015 | 11 | # All configuration values have a default; values that are commented out | ||
2016 | 12 | # serve to show the default. | ||
2017 | 13 | |||
2018 | 14 | import sys | ||
2019 | 15 | import os | ||
2020 | 16 | |||
2021 | 17 | # If extensions (or modules to document with autodoc) are in another directory, | ||
2022 | 18 | # add these directories to sys.path here. If the directory is relative to the | ||
2023 | 19 | # documentation root, use os.path.abspath to make it absolute, like shown here. | ||
2024 | 20 | sys.path.append(os.path.abspath('..')) | ||
2025 | 21 | |||
2026 | 22 | # -- General configuration ----------------------------------------------------- | ||
2027 | 23 | |||
2028 | 24 | # Add any Sphinx extension module names here, as strings. They can be extensions | ||
2029 | 25 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. | ||
2030 | 26 | extensions = [ | ||
2031 | 27 | 'sphinx.ext.autodoc', | ||
2032 | 28 | 'sphinx.ext.doctest', | ||
2033 | 29 | 'sphinx.ext.intersphinx', | ||
2034 | 30 | 'sphinx.ext.todo', | ||
2035 | 31 | 'sphinx.ext.coverage', | ||
2036 | 32 | 'sphinx.ext.viewcode'] | ||
2037 | 33 | |||
2038 | 34 | # Configuration for sphinx.ext.todo | ||
2039 | 35 | |||
2040 | 36 | todo_include_todos = True | ||
2041 | 37 | |||
2042 | 38 | # Add any paths that contain templates here, relative to this directory. | ||
2043 | 39 | templates_path = [] | ||
2044 | 40 | |||
2045 | 41 | # The suffix of source filenames. | ||
2046 | 42 | source_suffix = '.rst' | ||
2047 | 43 | |||
2048 | 44 | # The encoding of source files. | ||
2049 | 45 | #source_encoding = 'utf-8' | ||
2050 | 46 | |||
2051 | 47 | # The master toctree document. | ||
2052 | 48 | master_doc = 'index' | ||
2053 | 49 | |||
2054 | 50 | # General information about the project. | ||
2055 | 51 | project = u'LAVA Test' | ||
2056 | 52 | copyright = u'2010-2011, Linaro Limited' | ||
2057 | 53 | |||
2058 | 54 | # The version info for the project you're documenting, acts as replacement for | ||
2059 | 55 | # |version| and |release|, also used in various other places throughout the | ||
2060 | 56 | # built documents. | ||
2061 | 57 | # | ||
2062 | 58 | # The short X.Y version. | ||
2063 | 59 | import versiontools | ||
2064 | 60 | import lava_test | ||
2065 | 61 | version = "%d.%d" % lava_test.__version__[0:2] | ||
2066 | 62 | # The full version, including alpha/beta/rc tags. | ||
2067 | 63 | release = versiontools.format_version(lava_test.__version__) | ||
2068 | 64 | |||
2069 | 65 | # The language for content autogenerated by Sphinx. Refer to documentation | ||
2070 | 66 | # for a list of supported languages. | ||
2071 | 67 | #language = None | ||
2072 | 68 | |||
2073 | 69 | # There are two options for replacing |today|: either, you set today to some | ||
2074 | 70 | # non-false value, then it is used: | ||
2075 | 71 | #today = '' | ||
2076 | 72 | # Else, today_fmt is used as the format for a strftime call. | ||
2077 | 73 | #today_fmt = '%B %d, %Y' | ||
2078 | 74 | |||
2079 | 75 | # List of documents that shouldn't be included in the build. | ||
2080 | 76 | #unused_docs = [] | ||
2081 | 77 | |||
2082 | 78 | # List of directories, relative to source directory, that shouldn't be searched | ||
2083 | 79 | # for source files. | ||
2084 | 80 | exclude_trees = [] | ||
2085 | 81 | |||
2086 | 82 | # The reST default role (used for this markup: `text`) to use for all documents. | ||
2087 | 83 | #default_role = None | ||
2088 | 84 | |||
2089 | 85 | # If true, '()' will be appended to :func: etc. cross-reference text. | ||
2090 | 86 | #add_function_parentheses = True | ||
2091 | 87 | |||
2092 | 88 | # If true, the current module name will be prepended to all description | ||
2093 | 89 | # unit titles (such as .. function::). | ||
2094 | 90 | #add_module_names = True | ||
2095 | 91 | |||
2096 | 92 | # If true, sectionauthor and moduleauthor directives will be shown in the | ||
2097 | 93 | # output. They are ignored by default. | ||
2098 | 94 | #show_authors = False | ||
2099 | 95 | |||
2100 | 96 | # The name of the Pygments (syntax highlighting) style to use. | ||
2101 | 97 | pygments_style = 'sphinx' | ||
2102 | 98 | |||
2103 | 99 | # A list of ignored prefixes for module index sorting. | ||
2104 | 100 | #modindex_common_prefix = [] | ||
2105 | 101 | |||
2106 | 102 | |||
2107 | 103 | # -- Options for HTML output --------------------------------------------------- | ||
2108 | 104 | |||
2109 | 105 | # The theme to use for HTML and HTML Help pages. Major themes that come with | ||
2110 | 106 | # Sphinx are currently 'default' and 'sphinxdoc'. | ||
2111 | 107 | html_theme = 'default' | ||
2112 | 108 | |||
2113 | 109 | # Theme options are theme-specific and customize the look and feel of a theme | ||
2114 | 110 | # further. For a list of options available for each theme, see the | ||
2115 | 111 | # documentation. | ||
2116 | 112 | #html_theme_options = {} | ||
2117 | 113 | |||
2118 | 114 | # Add any paths that contain custom themes here, relative to this directory. | ||
2119 | 115 | #html_theme_path = [] | ||
2120 | 116 | |||
2121 | 117 | # The name for this set of Sphinx documents. If None, it defaults to | ||
2122 | 118 | # "<project> v<release> documentation". | ||
2123 | 119 | #html_title = None | ||
2124 | 120 | |||
2125 | 121 | # A shorter title for the navigation bar. Default is the same as html_title. | ||
2126 | 122 | #html_short_title = None | ||
2127 | 123 | |||
2128 | 124 | # The name of an image file (relative to this directory) to place at the top | ||
2129 | 125 | # of the sidebar. | ||
2130 | 126 | #html_logo = None | ||
2131 | 127 | |||
2132 | 128 | # The name of an image file (within the static path) to use as favicon of the | ||
2133 | 129 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 | ||
2134 | 130 | # pixels large. | ||
2135 | 131 | #html_favicon = None | ||
2136 | 132 | |||
2137 | 133 | # Add any paths that contain custom static files (such as style sheets) here, | ||
2138 | 134 | # relative to this directory. They are copied after the builtin static files, | ||
2139 | 135 | # so a file named "default.css" will overwrite the builtin "default.css". | ||
2140 | 136 | html_static_path = [] | ||
2141 | 137 | |||
2142 | 138 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, | ||
2143 | 139 | # using the given strftime format. | ||
2144 | 140 | #html_last_updated_fmt = '%b %d, %Y' | ||
2145 | 141 | |||
2146 | 142 | # If true, SmartyPants will be used to convert quotes and dashes to | ||
2147 | 143 | # typographically correct entities. | ||
2148 | 144 | #html_use_smartypants = True | ||
2149 | 145 | |||
2150 | 146 | # Custom sidebar templates, maps document names to template names. | ||
2151 | 147 | #html_sidebars = {} | ||
2152 | 148 | |||
2153 | 149 | # Additional templates that should be rendered to pages, maps page names to | ||
2154 | 150 | # template names. | ||
2155 | 151 | #html_additional_pages = {} | ||
2156 | 152 | |||
2157 | 153 | # If false, no module index is generated. | ||
2158 | 154 | #html_use_modindex = True | ||
2159 | 155 | |||
2160 | 156 | # If false, no index is generated. | ||
2161 | 157 | #html_use_index = True | ||
2162 | 158 | |||
2163 | 159 | # If true, the index is split into individual pages for each letter. | ||
2164 | 160 | #html_split_index = False | ||
2165 | 161 | |||
2166 | 162 | # If true, links to the reST sources are added to the pages. | ||
2167 | 163 | #html_show_sourcelink = True | ||
2168 | 164 | |||
2169 | 165 | # If true, an OpenSearch description file will be output, and all pages will | ||
2170 | 166 | # contain a <link> tag referring to it. The value of this option must be the | ||
2171 | 167 | # base URL from which the finished HTML is served. | ||
2172 | 168 | #html_use_opensearch = '' | ||
2173 | 169 | |||
2174 | 170 | # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). | ||
2175 | 171 | #html_file_suffix = '' | ||
2176 | 172 | |||
2177 | 173 | # Output file base name for HTML help builder. | ||
2178 | 174 | htmlhelp_basename = 'LAVATestDocumentation' | ||
2179 | 175 | |||
2180 | 176 | |||
2181 | 177 | # -- Options for LaTeX output -------------------------------------------------- | ||
2182 | 178 | |||
2183 | 179 | # The paper size ('letter' or 'a4'). | ||
2184 | 180 | #latex_paper_size = 'letter' | ||
2185 | 181 | |||
2186 | 182 | # The font size ('10pt', '11pt' or '12pt'). | ||
2187 | 183 | #latex_font_size = '10pt' | ||
2188 | 184 | |||
2189 | 185 | # Grouping the document tree into LaTeX files. List of tuples | ||
2190 | 186 | # (source start file, target name, title, author, documentclass [howto/manual]). | ||
2191 | 187 | latex_documents = [ | ||
2192 | 188 | ('index', 'LAVA Test.tex', u'LAVA Test Documentation', | ||
2193 | 189 | u'Zygmunt Krynicki', 'manual'), | ||
2194 | 190 | ] | ||
2195 | 191 | |||
2196 | 192 | # The name of an image file (relative to this directory) to place at the top of | ||
2197 | 193 | # the title page. | ||
2198 | 194 | #latex_logo = None | ||
2199 | 195 | |||
2200 | 196 | # For "manual" documents, if this is true, then toplevel headings are parts, | ||
2201 | 197 | # not chapters. | ||
2202 | 198 | #latex_use_parts = False | ||
2203 | 199 | |||
2204 | 200 | # Additional stuff for the LaTeX preamble. | ||
2205 | 201 | #latex_preamble = '' | ||
2206 | 202 | |||
2207 | 203 | # Documents to append as an appendix to all manuals. | ||
2208 | 204 | #latex_appendices = [] | ||
2209 | 205 | |||
2210 | 206 | # If false, no module index is generated. | ||
2211 | 207 | #latex_use_modindex = True | ||
2212 | 208 | |||
2213 | 209 | |||
2214 | 210 | # Example configuration for intersphinx: refer to the Python standard library. | ||
2215 | 211 | intersphinx_mapping = {'http://docs.python.org/': None} | ||
2216 | 0 | 212 | ||
2217 | === added file 'doc/index.rst' | |||
2218 | --- doc/index.rst 1970-01-01 00:00:00 +0000 | |||
2219 | +++ doc/index.rst 2011-09-13 22:44:36 +0000 | |||
2220 | @@ -0,0 +1,81 @@ | |||
2221 | 1 | ======================= | ||
2222 | 2 | LAVA Test Documentation | ||
2223 | 3 | ======================= | ||
2224 | 4 | |||
2225 | 5 | LAVA Test is a wrapper framework exposing unified API and command line | ||
2226 | 6 | interface for running arbitrary tests and storing the results in a structured | ||
2227 | 7 | manner. | ||
2228 | 8 | |||
2229 | 9 | LAVA Test is a part of the LAVA stack and can be used with other LAVA | ||
2230 | 10 | components, most notably the dispatcher (for setting up the test environment | ||
2231 | 11 | and controlling execution of multiple tests) and the dashboard (for storing | ||
2232 | 12 | |||
2233 | 13 | .. seealso:: To learn more about LAVA see https://launchpad.net/lava | ||
2234 | 14 | |||
2235 | 15 | 60 second example | ||
2236 | 16 | ================= | ||
2237 | 17 | |||
2238 | 18 | This example will run on Ubuntu Lucid and beyond:: | ||
2239 | 19 | |||
2240 | 20 | $ sudo add-apt-repository ppa:linaro-validation/ppa | ||
2241 | 21 | $ sudo apt-get update | ||
2242 | 22 | $ sudo apt-get install lava-test | ||
2243 | 23 | $ lava-test install stream | ||
2244 | 24 | $ lava-test run stream | ||
2245 | 25 | |||
2246 | 26 | .. seealso:: For a more thorough description see :ref:`usage` | ||
2247 | 27 | .. seealso:: For detailed installation istructions see :ref:`installation` | ||
2248 | 28 | |||
2249 | 29 | Features | ||
2250 | 30 | ======== | ||
2251 | 31 | |||
2252 | 32 | * Ability to enumerate, install, run and remove tests on a Linux-based system. | ||
2253 | 33 | * Support for benchmarks as well as pass/fail tests. | ||
2254 | 34 | * Support for capturing environment information such as installed software and | ||
2255 | 35 | hardware information and recording that in a machine-readable manner. | ||
2256 | 36 | * Store results in raw form (log files) as well as Linaro Dashboard Bundle | ||
2257 | 37 | format that can be uploaded to the LAVA Dashboard for archiving and analysis. | ||
2258 | 38 | * Extensible API for adding new tests (:class:`~lava_test.api.core.ITest`) or even | ||
2259 | 39 | collections of tests (:class:`~lava_test.api.core.ITestProvider`). | ||
2260 | 40 | * Ever-growing collection of freely available and generic tests and benchmarks | ||
2261 | 41 | |||
2262 | 42 | .. seealso:: See what's new in :ref:`version_0_2` | ||
2263 | 43 | |||
2264 | 44 | |||
2265 | 45 | Latest documentation | ||
2266 | 46 | ==================== | ||
2267 | 47 | |||
2268 | 48 | This documentation my be out of date, we try to make sure that all the latest | ||
2269 | 49 | and greatest releases are always documented on http://lava-test.readthedocs.org/ | ||
2270 | 50 | |||
2271 | 51 | |||
2272 | 52 | Source code, bugs and patches | ||
2273 | 53 | ============================= | ||
2274 | 54 | |||
2275 | 55 | The project is maintained on Launchpad at http://launchpad.net/lava-test/. | ||
2276 | 56 | |||
2277 | 57 | You can get the source code with bazaar using ``bzr branch lp:lava-test``. | ||
2278 | 58 | Patches can be submitted using Launchpad merge proposals (for introduction to | ||
2279 | 59 | this and topic see https://help.launchpad.net/Code/Review). | ||
2280 | 60 | |||
2281 | 61 | Please report all bugs at https://bugs.launchpad.net/lava-test/+filebug. | ||
2282 | 62 | |||
2283 | 63 | Most of the team is usually available in ``#linaro`` on ``irc.freenode.net``. | ||
2284 | 64 | Feel free to drop by to chat and ask questions. | ||
2285 | 65 | |||
2286 | 66 | |||
2287 | 67 | Indices and tables | ||
2288 | 68 | ================== | ||
2289 | 69 | |||
2290 | 70 | .. toctree:: | ||
2291 | 71 | :maxdepth: 2 | ||
2292 | 72 | |||
2293 | 73 | installation.rst | ||
2294 | 74 | changes.rst | ||
2295 | 75 | usage.rst | ||
2296 | 76 | reference.rst | ||
2297 | 77 | todo.rst | ||
2298 | 78 | |||
2299 | 79 | * :ref:`genindex` | ||
2300 | 80 | * :ref:`modindex` | ||
2301 | 81 | * :ref:`search` | ||
2302 | 0 | 82 | ||
2303 | === added file 'doc/installation.rst' | |||
2304 | --- doc/installation.rst 1970-01-01 00:00:00 +0000 | |||
2305 | +++ doc/installation.rst 2011-09-13 22:44:36 +0000 | |||
2306 | @@ -0,0 +1,66 @@ | |||
2307 | 1 | |||
2308 | 2 | .. _installation: | ||
2309 | 3 | |||
2310 | 4 | Installation | ||
2311 | 5 | ============ | ||
2312 | 6 | |||
2313 | 7 | Prerequisites | ||
2314 | 8 | ^^^^^^^^^^^^^ | ||
2315 | 9 | |||
2316 | 10 | The following debian packages are needed to use LAVA Test: | ||
2317 | 11 | |||
2318 | 12 | * python-setuptools | ||
2319 | 13 | * python-apt | ||
2320 | 14 | * usbutils | ||
2321 | 15 | * python-testrepository - for running unit tests | ||
2322 | 16 | * python-sphinx - for building documentation | ||
2323 | 17 | |||
2324 | 18 | |||
2325 | 19 | Installation Options | ||
2326 | 20 | ^^^^^^^^^^^^^^^^^^^^ | ||
2327 | 21 | |||
2328 | 22 | There are several installation options available: | ||
2329 | 23 | |||
2330 | 24 | |||
2331 | 25 | Using Ubuntu PPAs | ||
2332 | 26 | ----------------- | ||
2333 | 27 | |||
2334 | 28 | For Ubuntu 10.04 onward there is a stable PPA (personal package archive): | ||
2335 | 29 | |||
2336 | 30 | * ppa:linaro-validation/ppa | ||
2337 | 31 | |||
2338 | 32 | To add a ppa to an Ubuntu system use the add-apt-repository command:: | ||
2339 | 33 | |||
2340 | 34 | sudo add-apt-repository ppa:linaro-validation/ppa | ||
2341 | 35 | |||
2342 | 36 | After you add the PPA you need to update your package cache:: | ||
2343 | 37 | |||
2344 | 38 | sudo apt-get update | ||
2345 | 39 | |||
2346 | 40 | Finally you can install the package, it is called `lava-test`:: | ||
2347 | 41 | |||
2348 | 42 | sudo apt-get install lava-test | ||
2349 | 43 | |||
2350 | 44 | |||
2351 | 45 | Using Python Package Index | ||
2352 | 46 | -------------------------- | ||
2353 | 47 | |||
2354 | 48 | This package is being actively maintained and published in the `Python Package | ||
2355 | 49 | Index <http://http://pypi.python.org>`_. You can install it if you have `pip | ||
2356 | 50 | <http://pip.openplans.org/>`_ tool using just one line:: | ||
2357 | 51 | |||
2358 | 52 | pip install lava-test | ||
2359 | 53 | |||
2360 | 54 | |||
2361 | 55 | Using source tarball | ||
2362 | 56 | -------------------- | ||
2363 | 57 | |||
2364 | 58 | To install from source you must first obtain a source tarball from either pypi | ||
2365 | 59 | or from `Launchpad <http://launchpad.net/>`_. To install the package unpack the | ||
2366 | 60 | tarball and run:: | ||
2367 | 61 | |||
2368 | 62 | python setup.py install | ||
2369 | 63 | |||
2370 | 64 | You can pass ``--user`` if you prefer to do a local (non system-wide) | ||
2371 | 65 | installation. Note that executable programs are placed in ``~/.local/bin/`` and | ||
2372 | 66 | this directory is not on ``PATH`` by default. | ||
2373 | 0 | 67 | ||
2374 | === added file 'doc/reference.rst' | |||
2375 | --- doc/reference.rst 1970-01-01 00:00:00 +0000 | |||
2376 | +++ doc/reference.rst 2011-09-13 22:44:36 +0000 | |||
2377 | @@ -0,0 +1,107 @@ | |||
2378 | 1 | .. _reference: | ||
2379 | 2 | |||
2380 | 3 | ========= | ||
2381 | 4 | Reference | ||
2382 | 5 | ========= | ||
2383 | 6 | |||
2384 | 7 | .. _command_reference: | ||
2385 | 8 | |||
2386 | 9 | Command Reference | ||
2387 | 10 | ================= | ||
2388 | 11 | |||
2389 | 12 | .. automodule:: lava_test.commands | ||
2390 | 13 | :members: | ||
2391 | 14 | |||
2392 | 15 | .. todo:: | ||
2393 | 16 | |||
2394 | 17 | * Describe basic commands | ||
2395 | 18 | * Describe arguments and options to each command in detail | ||
2396 | 19 | |||
2397 | 20 | Pathnames and files | ||
2398 | 21 | =================== | ||
2399 | 22 | |||
2400 | 23 | LAVA Test uses the following files: | ||
2401 | 24 | |||
2402 | 25 | * ``$XDG_CONFIG_HOME/lava_test/`` -- configuration files | ||
2403 | 26 | * ``$XDG_DATA_HOME/lava_test/installed-tests`` -- installed test programs | ||
2404 | 27 | * ``$XDG_DATA_HOME/lava_test/results`` -- artifacts of running tests | ||
2405 | 28 | * ``$XDG_CACHE_HOME/lava_test/`` -- download cache | ||
2406 | 29 | |||
2407 | 30 | .. _code_reference: | ||
2408 | 31 | |||
2409 | 32 | Code reference | ||
2410 | 33 | ============== | ||
2411 | 34 | |||
2412 | 35 | .. todo:: | ||
2413 | 36 | |||
2414 | 37 | * Describe general code layout | ||
2415 | 38 | * Describe key API integration points (on a separate page if needed for clarity) | ||
2416 | 39 | * Provide an example test and walk the reader through the meaning of each part | ||
2417 | 40 | |||
2418 | 41 | Abstract Interfaces | ||
2419 | 42 | ^^^^^^^^^^^^^^^^^^^ | ||
2420 | 43 | |||
2421 | 44 | .. automodule:: lava_test.api.core | ||
2422 | 45 | :members: | ||
2423 | 46 | |||
2424 | 47 | .. automodule:: lava_test.api.delegates | ||
2425 | 48 | :members: | ||
2426 | 49 | |||
2427 | 50 | .. automodule:: lava_test.api.observers | ||
2428 | 51 | :members: | ||
2429 | 52 | |||
2430 | 53 | Test definitions and test providers | ||
2431 | 54 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
2432 | 55 | |||
2433 | 56 | .. automodule:: lava_test.core.providers | ||
2434 | 57 | :members: | ||
2435 | 58 | |||
2436 | 59 | .. automodule:: lava_test.core.tests | ||
2437 | 60 | :members: | ||
2438 | 61 | |||
2439 | 62 | Test components (installers, runners and parsers) | ||
2440 | 63 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
2441 | 64 | |||
2442 | 65 | .. automodule:: lava_test.core.installers | ||
2443 | 66 | :members: | ||
2444 | 67 | |||
2445 | 68 | .. automodule:: lava_test.core.runners | ||
2446 | 69 | :members: | ||
2447 | 70 | |||
2448 | 71 | .. automodule:: lava_test.core.parsers | ||
2449 | 72 | :members: | ||
2450 | 73 | |||
2451 | 74 | Core Modules | ||
2452 | 75 | ^^^^^^^^^^^^ | ||
2453 | 76 | |||
2454 | 77 | .. automodule:: lava_test.core.artifacts | ||
2455 | 78 | :members: | ||
2456 | 79 | |||
2457 | 80 | .. automodule:: lava_test.core.config | ||
2458 | 81 | :members: | ||
2459 | 82 | |||
2460 | 83 | Environment Scanners | ||
2461 | 84 | ^^^^^^^^^^^^^^^^^^^^ | ||
2462 | 85 | |||
2463 | 86 | .. automodule:: lava_test.core.hwprofile | ||
2464 | 87 | :members: | ||
2465 | 88 | |||
2466 | 89 | .. automodule:: lava_test.core.swprofile | ||
2467 | 90 | :members: | ||
2468 | 91 | |||
2469 | 92 | Utilities | ||
2470 | 93 | ^^^^^^^^^ | ||
2471 | 94 | |||
2472 | 95 | .. automodule:: lava_test.utils | ||
2473 | 96 | :members: | ||
2474 | 97 | |||
2475 | 98 | .. automodule:: lava_test.extcmd | ||
2476 | 99 | :members: | ||
2477 | 100 | |||
2478 | 101 | |||
2479 | 102 | Abrek compatibility | ||
2480 | 103 | =================== | ||
2481 | 104 | |||
2482 | 105 | .. automodule:: abrek.testdef | ||
2483 | 106 | :members: | ||
2484 | 107 | |||
2485 | 0 | 108 | ||
2486 | === added file 'doc/todo.rst' | |||
2487 | --- doc/todo.rst 1970-01-01 00:00:00 +0000 | |||
2488 | +++ doc/todo.rst 2011-09-13 22:44:36 +0000 | |||
2489 | @@ -0,0 +1,4 @@ | |||
2490 | 1 | List of items that need work | ||
2491 | 2 | ============================ | ||
2492 | 3 | |||
2493 | 4 | .. todolist:: | ||
2494 | 0 | 5 | ||
2495 | === added file 'doc/usage.rst' | |||
2496 | --- doc/usage.rst 1970-01-01 00:00:00 +0000 | |||
2497 | +++ doc/usage.rst 2011-09-13 22:44:36 +0000 | |||
2498 | @@ -0,0 +1,195 @@ | |||
2499 | 1 | .. _usage: | ||
2500 | 2 | |||
2501 | 3 | ===== | ||
2502 | 4 | Usage | ||
2503 | 5 | ===== | ||
2504 | 6 | |||
2505 | 7 | Workflow Overview | ||
2506 | 8 | ================= | ||
2507 | 9 | |||
2508 | 10 | LAVA Test can be used in several different ways. Most notably those are | ||
2509 | 11 | standalone (without the LAVA dispatcher) and managed (when LAVA Test is | ||
2510 | 12 | installed and controlled by the LAVA dispatcher). | ||
2511 | 13 | |||
2512 | 14 | Standalone usage | ||
2513 | 15 | ^^^^^^^^^^^^^^^^ | ||
2514 | 16 | |||
2515 | 17 | In standalone mode a human operator installs LAVA Test on some device | ||
2516 | 18 | (development board, laptop or other computer or a virtual machine), installs | ||
2517 | 19 | the tests that are to be executed and then executes them manually (by manually | ||
2518 | 20 | running LAVA test, the actual tests are non-interactive). | ||
2519 | 21 | |||
2520 | 22 | Using LAVA to develop and run new tests | ||
2521 | 23 | +++++++++++++++++++++++++++++++++++++++ | ||
2522 | 24 | |||
2523 | 25 | This mode is useful for test development (adding new tests, developing custom | ||
2524 | 26 | tests especially tailored for LAVA, etc.). Here the typical cycle depends on | ||
2525 | 27 | how the tests is wrapped for usage by LAVA and what the test developer is | ||
2526 | 28 | focusing on. | ||
2527 | 29 | |||
2528 | 30 | While developing the actual test the typical set of commands might look like | ||
2529 | 31 | this:: | ||
2530 | 32 | |||
2531 | 33 | $ lava-test install my-custom-test | ||
2532 | 34 | $ lava-test run my-custom-test | ||
2533 | 35 | $ lava-test uninstall my-custom-test | ||
2534 | 36 | |||
2535 | 37 | Here the developer could observe changes to the test program (that is | ||
2536 | 38 | presumably compiled and copied somewhere by the install stage). | ||
2537 | 39 | |||
2538 | 40 | Using LAVA to analyze test results | ||
2539 | 41 | ++++++++++++++++++++++++++++++++++ | ||
2540 | 42 | |||
2541 | 43 | Developing the test is only half of the story. The other half is developing | ||
2542 | 44 | LAVA Test integration code, most importantly the artefact parser / analyzer. | ||
2543 | 45 | This part has to be implemented in python (unlike the test program that can be | ||
2544 | 46 | implemented in any language and technology). Here the developer is focusing on | ||
2545 | 47 | refining the parser to see if the outcome is as indented. Assuming that earlier | ||
2546 | 48 | the developer ran the test at least once and wrote down the result identifier | ||
2547 | 49 | the set of commands one might use is:: | ||
2548 | 50 | |||
2549 | 51 | $ lava-test parse my-custom-test my-custom-test.2011-08-19T23:53:21Z | pager | ||
2550 | 52 | |||
2551 | 53 | Here the developer has to pass both the identifier of the test | ||
2552 | 54 | (``my-custom-test``) as well as the identifier of the actual result. While | ||
2553 | 55 | currently the result identifier starts with the test identifier we wanted to | ||
2554 | 56 | avoid magic values like that so both are needed. The test defines which | ||
2555 | 57 | artefact parser to use. The result id is used to locate leftovers from running | ||
2556 | 58 | that specific test at some previous point in time. | ||
2557 | 59 | |||
2558 | 60 | By default parse will print the bundle to standard output for inspection. It | ||
2559 | 61 | should be redirected to a pager for easier verification. | ||
2560 | 62 | |||
2561 | 63 | .. note:: | ||
2562 | 64 | |||
2563 | 65 | While the syntax of the bundle created with `lava-test parse` is always | ||
2564 | 66 | correct (or, if the parser does something really, really strange, a | ||
2565 | 67 | detailed error is reported) the actual contents may not be what you | ||
2566 | 68 | intended it to be. Parsers are ultimately fragile as they mostly deal with | ||
2567 | 69 | unstructured or semi-structured free-form text that most test programs seem | ||
2568 | 70 | to produce. The ultimate goal of a developer should be to produce | ||
2569 | 71 | unambiguous, machine readable format. This level of integration would allow | ||
2570 | 72 | to wrap a whole class of tests in one go (such as all xUnit-XML speaking | ||
2571 | 73 | test frameworks). | ||
2572 | 74 | |||
2573 | 75 | Usage with the dispatcher | ||
2574 | 76 | ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
2575 | 77 | |||
2576 | 78 | The dispatcher is useful for automating LAVA Test environment setup, describing | ||
2577 | 79 | test scenarios (the list of tests to invoke) and finally storing the results in | ||
2578 | 80 | the LAVA dashboard. | ||
2579 | 81 | |||
2580 | 82 | Typically this mode is based on the following sequence of commands: | ||
2581 | 83 | |||
2582 | 84 | #. Install lava-test (from PPA or source) along with the required dependencies | ||
2583 | 85 | #. (optional) for out of tree tests install the additional `test definition` package | ||
2584 | 86 | #. Install the test or tests that are to be invoked with ``lava-tool install``. | ||
2585 | 87 | #. Run, parse and store in one go with ``lava-tool run --output=FILE``. | ||
2586 | 88 | |||
2587 | 89 | Here the whole setup is non-interactive and at the end the dispatcher can copy | ||
2588 | 90 | the output bundle for additional processing. | ||
2589 | 91 | |||
2590 | 92 | Automation considerations | ||
2591 | 93 | ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
2592 | 94 | |||
2593 | 95 | .. _wrapping_existing_test_or_benchmark: | ||
2594 | 96 | |||
2595 | 97 | Wrapping existing test or benchmark | ||
2596 | 98 | =================================== | ||
2597 | 99 | |||
2598 | 100 | LAVA Test can be extended in several different ways. There is no best method, | ||
2599 | 101 | each has some pros and cons. In general we welcome any freely redistributable, | ||
2600 | 102 | generic tests. Those enrich the LAVA ecosystem and by providing useful | ||
2601 | 103 | out-of-the-box features to our users. | ||
2602 | 104 | |||
2603 | 105 | Technically all tests are hidden behind a set of abstract interfaces that tell | ||
2604 | 106 | LAVA Test what to do in response to operator or dispatcher actions. The primary | ||
2605 | 107 | interface is :class:`~lava_test.api.core.ITest` and the three principal | ||
2606 | 108 | methods: :meth:`~lava_test.api.core.ITest.install`, | ||
2607 | 109 | :meth:`~lava_test.api.core.ITest.run`, | ||
2608 | 110 | :meth:`~lava_test.api.core.ITest.parse`. | ||
2609 | 111 | |||
2610 | 112 | In practice it is usually much easier to instantiate our pluggable delegate | ||
2611 | 113 | test (:class:`lava_test.core.tests.Test`) and define the three delegates that | ||
2612 | 114 | know how to install, run and parse. Again for each step we have a base class | ||
2613 | 115 | that can be easily customized or even used directly as is. Those classes are | ||
2614 | 116 | :class:`~lava_test.core.installers.TestInstaller`, | ||
2615 | 117 | :class:`~lava_test.core.runners.TestRunner` and | ||
2616 | 118 | :class:`~lava_test.core.parsers.TestParser`. They all implement well-defined | ||
2617 | 119 | interfaces (specified in :mod:`lava_test.api.delegates`) so if you wish to | ||
2618 | 120 | customize them you should become familiar with the API requirements first. | ||
2619 | 121 | |||
2620 | 122 | Contributing new tests to LAVA | ||
2621 | 123 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
2622 | 124 | |||
2623 | 125 | The most direct way to add a new test is to contribute patches to LAVA Test | ||
2624 | 126 | itself. This method will simply add a new test definition to the collection of | ||
2625 | 127 | available tests. | ||
2626 | 128 | |||
2627 | 129 | This method is recommended for generic tests that rarely change and are | ||
2628 | 130 | suitable for wide variety of hardware and software (assuming basic Linux-like | ||
2629 | 131 | system, Android tests are a special case). | ||
2630 | 132 | |||
2631 | 133 | The advantage is that those tests can be invoked out of the box and will be | ||
2632 | 134 | maintained by the LAVA team. The disadvantage is that all changes to those | ||
2633 | 135 | tests need to follow Linaro development work flow, get reviewed and finally | ||
2634 | 136 | merged. Depending on your situation this may be undesired. | ||
2635 | 137 | |||
2636 | 138 | .. todo:: | ||
2637 | 139 | |||
2638 | 140 | Describe how tests are discovered, loaded and used. It would be | ||
2639 | 141 | nice to have a tutorial that walks the user through wrapping a | ||
2640 | 142 | simple pass/fail test. | ||
2641 | 143 | |||
2642 | 144 | Maintaining out-of-tree tests | ||
2643 | 145 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
2644 | 146 | |||
2645 | 147 | For some kinds of tests (proprietary, non-generic, in rapid development, fused | ||
2646 | 148 | with application code) contributing their definition to upstream LAVA Test | ||
2647 | 149 | project would be impractical. | ||
2648 | 150 | |||
2649 | 151 | In such cases the test maintainer can still leverage LAVA to actually run and | ||
2650 | 152 | process the test without being entangled in the review process or going through | ||
2651 | 153 | any public channel. | ||
2652 | 154 | |||
2653 | 155 | Because LAVA Test supports pluggable test providers it is easy to add a new | ||
2654 | 156 | source of test definitions. Fortunately we ship with a very useful generic | ||
2655 | 157 | out-of-tree test provider based on the python `pkg_resources` system. | ||
2656 | 158 | |||
2657 | 159 | Any python package (that is a module or package and the corresponding setup.py | ||
2658 | 160 | and .egg_info) can define LAVA Test extensions using the `pkg_resurces` entry | ||
2659 | 161 | points system. | ||
2660 | 162 | |||
2661 | 163 | To do this write your test program as you normally would, write the LAVA Test | ||
2662 | 164 | integration code and put this into your integration package setup.py:: | ||
2663 | 165 | |||
2664 | 166 | setup( | ||
2665 | 167 | ..., | ||
2666 | 168 | entry_points="""[lava_test.test_definitions] | ||
2667 | 169 | my_test_id=my_package.my_module | ||
2668 | 170 | """) | ||
2669 | 171 | |||
2670 | 172 | Here we'd define an entry point in the ``lava_test.test_definitions`` namespace | ||
2671 | 173 | that LAVA Test searches by default. In that namespace we define one object | ||
2672 | 174 | ``my_test_id`` which points at the module ``my_package.my_module``. LAVA Test | ||
2673 | 175 | will discover this entry point, import the relevant module and make the test | ||
2674 | 176 | definition available. | ||
2675 | 177 | |||
2676 | 178 | Maintaining simple declarative tests | ||
2677 | 179 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
2678 | 180 | |||
2679 | 181 | By registering pure declarative tests at runtime. | ||
2680 | 182 | |||
2681 | 183 | .. todo:: | ||
2682 | 184 | |||
2683 | 185 | Describe how to use declarative tests. It would be a nice | ||
2684 | 186 | extension of the tutorial once the user feels comfortable with | ||
2685 | 187 | the initial python-based version. | ||
2686 | 188 | |||
2687 | 189 | Writing new tests from scratch | ||
2688 | 190 | ============================== | ||
2689 | 191 | |||
2690 | 192 | .. todo:: | ||
2691 | 193 | |||
2692 | 194 | Describe considerations for test writers. Using native test | ||
2693 | 195 | format with human-readable output adapters. | ||
2694 | 0 | 196 | ||
2695 | === modified file 'examples/power-management-tests.json' | |||
2696 | --- examples/power-management-tests.json 2011-06-28 12:51:57 +0000 | |||
2697 | +++ examples/power-management-tests.json 2011-09-13 22:44:36 +0000 | |||
2698 | @@ -1,5 +1,5 @@ | |||
2699 | 1 | { | 1 | { |
2701 | 2 | "format": "Abrek Test Definition 1.0 Experimental", | 2 | "format": "Lava-Test Test Definition 1.0", |
2702 | 3 | "test_id": "linaro.pmwg", | 3 | "test_id": "linaro.pmwg", |
2703 | 4 | "install": { | 4 | "install": { |
2704 | 5 | "steps": ["bzr get lp:~zkrynicki/+junk/linaro-pm-qa-tests"], | 5 | "steps": ["bzr get lp:~zkrynicki/+junk/linaro-pm-qa-tests"], |
2705 | 6 | 6 | ||
2706 | === modified file 'examples/stream.json' | |||
2707 | --- examples/stream.json 2011-06-28 13:31:48 +0000 | |||
2708 | +++ examples/stream.json 2011-09-13 22:44:36 +0000 | |||
2709 | @@ -1,5 +1,5 @@ | |||
2710 | 1 | { | 1 | { |
2712 | 2 | "format": "Abrek Test Definition Format 1.0 Experimental", | 2 | "format": "LAVA-Test Test Definition Format", |
2713 | 3 | "test_id": "stream-json", | 3 | "test_id": "stream-json", |
2714 | 4 | "install": { | 4 | "install": { |
2715 | 5 | "url": "http://www.cs.virginia.edu/stream/FTP/Code/stream.c", | 5 | "url": "http://www.cs.virginia.edu/stream/FTP/Code/stream.c", |
2716 | 6 | 6 | ||
2717 | === renamed directory 'abrek' => 'lava_test' | |||
2718 | === modified file 'lava_test/__init__.py' | |||
2719 | --- abrek/__init__.py 2011-08-20 02:20:37 +0000 | |||
2720 | +++ lava_test/__init__.py 2011-09-13 22:44:36 +0000 | |||
2721 | @@ -13,4 +13,4 @@ | |||
2722 | 13 | # You should have received a copy of the GNU General Public License | 13 | # You should have received a copy of the GNU General Public License |
2723 | 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/>. |
2724 | 15 | 15 | ||
2726 | 16 | __version__ = "0.2.0" | 16 | __version__ = (0, 2, 0, "dev", 0) |
2727 | 17 | 17 | ||
2728 | === added directory 'lava_test/api' | |||
2729 | === added file 'lava_test/api/__init__.py' | |||
2730 | --- lava_test/api/__init__.py 1970-01-01 00:00:00 +0000 | |||
2731 | +++ lava_test/api/__init__.py 2011-09-13 22:44:36 +0000 | |||
2732 | @@ -0,0 +1,24 @@ | |||
2733 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
2734 | 2 | # | ||
2735 | 3 | # This program is free software: you can redistribute it and/or modify | ||
2736 | 4 | # it under the terms of the GNU General Public License as published by | ||
2737 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
2738 | 6 | # (at your option) any later version. | ||
2739 | 7 | # | ||
2740 | 8 | # This program is distributed in the hope that it will be useful, | ||
2741 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2742 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2743 | 11 | # GNU General Public License for more details. | ||
2744 | 12 | # | ||
2745 | 13 | # You should have received a copy of the GNU General Public License | ||
2746 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2747 | 15 | |||
2748 | 16 | from abc import ABCMeta | ||
2749 | 17 | |||
2750 | 18 | |||
2751 | 19 | class _Interface(object): | ||
2752 | 20 | """ | ||
2753 | 21 | Interface class for simplifying usage of interface meta-classes | ||
2754 | 22 | """ | ||
2755 | 23 | |||
2756 | 24 | __metaclass__ = ABCMeta | ||
2757 | 0 | 25 | ||
2758 | === added file 'lava_test/api/core.py' | |||
2759 | --- lava_test/api/core.py 1970-01-01 00:00:00 +0000 | |||
2760 | +++ lava_test/api/core.py 2011-09-13 22:44:36 +0000 | |||
2761 | @@ -0,0 +1,164 @@ | |||
2762 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
2763 | 2 | # | ||
2764 | 3 | # This program is free software: you can redistribute it and/or modify | ||
2765 | 4 | # it under the terms of the GNU General Public License as published by | ||
2766 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
2767 | 6 | # (at your option) any later version. | ||
2768 | 7 | # | ||
2769 | 8 | # This program is distributed in the hope that it will be useful, | ||
2770 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2771 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2772 | 11 | # GNU General Public License for more details. | ||
2773 | 12 | # | ||
2774 | 13 | # You should have received a copy of the GNU General Public License | ||
2775 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2776 | 15 | |||
2777 | 16 | """ | ||
2778 | 17 | :mod:`lava_test.api.core` -- Interface classes for core LAVA Test features | ||
2779 | 18 | ========================================================================== | ||
2780 | 19 | |||
2781 | 20 | .. module: lava_test.api.core | ||
2782 | 21 | |||
2783 | 22 | :synopsis: Interface classes for core LAVA Test features | ||
2784 | 23 | """ | ||
2785 | 24 | |||
2786 | 25 | from abc import abstractmethod, abstractproperty | ||
2787 | 26 | |||
2788 | 27 | from lava_test.api import _Interface | ||
2789 | 28 | |||
2790 | 29 | class ITest(_Interface): | ||
2791 | 30 | """ | ||
2792 | 31 | Abstract test definition. | ||
2793 | 32 | |||
2794 | 33 | Test definitions allow lava-test to install, remove, run and parse log | ||
2795 | 34 | files of automatic tests. While the interface can be implemented directly | ||
2796 | 35 | you should use :class:`lava_test.core.tests.Test` that implements the core | ||
2797 | 36 | logic and allow you to customize the parts that are needed by providing | ||
2798 | 37 | delegates implementing :class:`~lava_test.api.delegates.ITestInstaller`, | ||
2799 | 38 | :class:`~lava_test.api.delegates.ITestRunner` and | ||
2800 | 39 | :class:`~lava_test.api.delegates.ITestParser`. | ||
2801 | 40 | |||
2802 | 41 | .. seealso:: :ref:`wrapping_existing_test_or_benchmark` | ||
2803 | 42 | """ | ||
2804 | 43 | |||
2805 | 44 | @abstractproperty | ||
2806 | 45 | def is_installed(self): | ||
2807 | 46 | """ | ||
2808 | 47 | True if this test is installed | ||
2809 | 48 | |||
2810 | 49 | .. versionadded:: 0.2 | ||
2811 | 50 | """ | ||
2812 | 51 | |||
2813 | 52 | @abstractmethod | ||
2814 | 53 | def install(self, observer): | ||
2815 | 54 | """ | ||
2816 | 55 | Install the test program. | ||
2817 | 56 | |||
2818 | 57 | This creates an install directory under the user's XDG_DATA_HOME | ||
2819 | 58 | directory to mark that the test is installed. The installer's | ||
2820 | 59 | install() method is then called from this directory to complete any | ||
2821 | 60 | test specific install that may be needed. | ||
2822 | 61 | |||
2823 | 62 | :param observer: | ||
2824 | 63 | Observer object that makes it possible to monitor the actions | ||
2825 | 64 | performed by the test installer. | ||
2826 | 65 | :type observer: :class:`~lava_test.api.observers.ITestInstallerObserver` | ||
2827 | 66 | |||
2828 | 67 | .. versionadded:: 0.2 | ||
2829 | 68 | """ | ||
2830 | 69 | |||
2831 | 70 | @abstractmethod | ||
2832 | 71 | def uninstall(self): | ||
2833 | 72 | """ | ||
2834 | 73 | Remove the test program | ||
2835 | 74 | |||
2836 | 75 | Recursively remove test specific directory under the user's | ||
2837 | 76 | ``XDG_DATA_HOME directory``. This will both mark the test as removed, | ||
2838 | 77 | and clean up any files that were downloaded or installed under that | ||
2839 | 78 | directory. Dependencies are intentionally not removed by this. | ||
2840 | 79 | |||
2841 | 80 | .. versionadded:: 0.1 | ||
2842 | 81 | """ | ||
2843 | 82 | |||
2844 | 83 | @abstractmethod | ||
2845 | 84 | def run(self, observer): | ||
2846 | 85 | """ | ||
2847 | 86 | Run the test program and store artifacts. | ||
2848 | 87 | |||
2849 | 88 | :param observer: | ||
2850 | 89 | Observer object that makes it possible to monitor the actions | ||
2851 | 90 | performed by the test runner. | ||
2852 | 91 | :type observer: :class:`~lava_test.api.observers.ITestRunnerObserver` | ||
2853 | 92 | :return: Test run artifacts | ||
2854 | 93 | :rtype: :class:`~lava_test.core.artifacts.TestArtifacts`. | ||
2855 | 94 | |||
2856 | 95 | .. versionadded:: 0.2 | ||
2857 | 96 | """ | ||
2858 | 97 | |||
2859 | 98 | @abstractmethod | ||
2860 | 99 | def parse(self, artifacts): | ||
2861 | 100 | """ | ||
2862 | 101 | Parse the artifacts of an earlier run. | ||
2863 | 102 | |||
2864 | 103 | :param artifacts: Object that describes which files should be parsed. | ||
2865 | 104 | :type artifacts: :class:`~lava_test.core.artifacts.TestArtifacts` | ||
2866 | 105 | :return: | ||
2867 | 106 | A dictionary with all the parsed data. In particular this is a | ||
2868 | 107 | TestRun part of the dashboard bundle so it should have the | ||
2869 | 108 | test_results list of all the results parsed from the artifacts. | ||
2870 | 109 | :rtype: :class:`dict` | ||
2871 | 110 | |||
2872 | 111 | .. versionadded:: 0.2 | ||
2873 | 112 | """ | ||
2874 | 113 | |||
2875 | 114 | |||
2876 | 115 | class ITestProvider(_Interface): | ||
2877 | 116 | """ | ||
2878 | 117 | Source of ITest instances. | ||
2879 | 118 | |||
2880 | 119 | Test providers can be used to make lava-test aware of arbitrary collections | ||
2881 | 120 | of tests that can be installed and invoked. Internally lava-test uses this | ||
2882 | 121 | class to offer built-in tests (via the | ||
2883 | 122 | :class:`~lava_test.providers.BuiltInProvider`), out-of-tree tests (via the | ||
2884 | 123 | :class:`~lava_test.providers.PkgResourcesProvider`) and declarative tests | ||
2885 | 124 | (via the :class:`~lava_test.providers.RegistryProvider`). | ||
2886 | 125 | |||
2887 | 126 | Normally this is not something you would need to implement. If you have a | ||
2888 | 127 | large collection of existing tests that can be somehow adapted in bulk, or | ||
2889 | 128 | you have your own internal registry of tests that could be adapted this way | ||
2890 | 129 | then you might use this interface to simplify test discovery. | ||
2891 | 130 | |||
2892 | 131 | Test providers need to be registered using pkg-resources entry-point | ||
2893 | 132 | feature and then added to the lava-test configuration file. See | ||
2894 | 133 | :class:`lava_test.config.LavaTestConfig` for details. | ||
2895 | 134 | |||
2896 | 135 | .. versionadded:: 0.2 | ||
2897 | 136 | """ | ||
2898 | 137 | |||
2899 | 138 | @abstractmethod | ||
2900 | 139 | def __init__(self, config): | ||
2901 | 140 | """ | ||
2902 | 141 | Initialize test provider with the specified configuration object. The | ||
2903 | 142 | configuration object is obtained from the test tool providers registry. | ||
2904 | 143 | """ | ||
2905 | 144 | |||
2906 | 145 | @abstractmethod | ||
2907 | 146 | def __iter__(self): | ||
2908 | 147 | """ | ||
2909 | 148 | Iterates over instances of ITest exposed by this provider | ||
2910 | 149 | """ | ||
2911 | 150 | |||
2912 | 151 | @abstractmethod | ||
2913 | 152 | def __getitem__(self, test_id): | ||
2914 | 153 | """ | ||
2915 | 154 | Return an instance of ITest with the specified id | ||
2916 | 155 | """ | ||
2917 | 156 | |||
2918 | 157 | @abstractproperty | ||
2919 | 158 | def description(self): | ||
2920 | 159 | """ | ||
2921 | 160 | The description string used by `lava-test list-tests` | ||
2922 | 161 | """ | ||
2923 | 162 | |||
2924 | 163 | |||
2925 | 164 | __all__ = ['ITest', 'ITestProvider'] | ||
2926 | 0 | 165 | ||
2927 | === added file 'lava_test/api/delegates.py' | |||
2928 | --- lava_test/api/delegates.py 1970-01-01 00:00:00 +0000 | |||
2929 | +++ lava_test/api/delegates.py 2011-09-13 22:44:36 +0000 | |||
2930 | @@ -0,0 +1,119 @@ | |||
2931 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
2932 | 2 | # | ||
2933 | 3 | # This program is free software: you can redistribute it and/or modify | ||
2934 | 4 | # it under the terms of the GNU General Public License as published by | ||
2935 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
2936 | 6 | # (at your option) any later version. | ||
2937 | 7 | # | ||
2938 | 8 | # This program is distributed in the hope that it will be useful, | ||
2939 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2940 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2941 | 11 | # GNU General Public License for more details. | ||
2942 | 12 | # | ||
2943 | 13 | # You should have received a copy of the GNU General Public License | ||
2944 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2945 | 15 | |||
2946 | 16 | |||
2947 | 17 | """ | ||
2948 | 18 | :mod:`lava_test.api.delegates` -- Interface classes for test delegates | ||
2949 | 19 | ====================================================================== | ||
2950 | 20 | |||
2951 | 21 | .. module: lava_test.api.delegates | ||
2952 | 22 | |||
2953 | 23 | :synopsis: Interface classes for test delegates | ||
2954 | 24 | """ | ||
2955 | 25 | |||
2956 | 26 | from abc import abstractmethod, abstractproperty | ||
2957 | 27 | |||
2958 | 28 | from lava_test.api import _Interface | ||
2959 | 29 | |||
2960 | 30 | |||
2961 | 31 | class ITestInstaller(_Interface): | ||
2962 | 32 | """ | ||
2963 | 33 | Test installer delegate class. | ||
2964 | 34 | |||
2965 | 35 | Wraps the knowledge on how to install a test. It is most helpful with | ||
2966 | 36 | :class:`~lava_test.core.tests.Test` that delegates actual actions to helper | ||
2967 | 37 | classes. | ||
2968 | 38 | |||
2969 | 39 | .. versionadded:: 0.2 | ||
2970 | 40 | """ | ||
2971 | 41 | |||
2972 | 42 | @abstractmethod | ||
2973 | 43 | def install(self, observer): | ||
2974 | 44 | """ | ||
2975 | 45 | Install the test program. | ||
2976 | 46 | |||
2977 | 47 | :param observer: | ||
2978 | 48 | Observer object that makes it possible to monitor the actions | ||
2979 | 49 | performed by the test installer. | ||
2980 | 50 | :type observer: :class:`~lava_test.api.observers.ITestInstallerObserver` | ||
2981 | 51 | |||
2982 | 52 | .. versionadded:: 0.2 | ||
2983 | 53 | """ | ||
2984 | 54 | |||
2985 | 55 | |||
2986 | 56 | class ITestRunner(_Interface): | ||
2987 | 57 | """ | ||
2988 | 58 | Test runner delegate. | ||
2989 | 59 | |||
2990 | 60 | Wraps the knowledge on how to run a test. It is most helpful with | ||
2991 | 61 | :class:`lava_test.core.tests.Test` that delegates actual actions to | ||
2992 | 62 | helper classes. | ||
2993 | 63 | |||
2994 | 64 | .. versionadded:: 0.2 | ||
2995 | 65 | """ | ||
2996 | 66 | |||
2997 | 67 | @abstractmethod | ||
2998 | 68 | def run(self, artifacts, observer): | ||
2999 | 69 | """ | ||
3000 | 70 | Run the test and create artifacts (typically log files). | ||
3001 | 71 | |||
3002 | 72 | Artifacts must be created in the directory specified by various methods | ||
3003 | 73 | and properties of of :class:`lava_test.core.TestArtifacts`. | ||
3004 | 74 | |||
3005 | 75 | :param artifacts: | ||
3006 | 76 | Object that describes where to store test run artifacts | ||
3007 | 77 | :type artifacts: :class:`~lava_test.core.artifacts.TestArtifacts`. | ||
3008 | 78 | :param observer: | ||
3009 | 79 | Observer object that makes it possible to monitor the actions | ||
3010 | 80 | performed by the test runner. | ||
3011 | 81 | :type observer: :class:`~lava_test.api.observers.ITestRunnerObserver` | ||
3012 | 82 | |||
3013 | 83 | .. versionadded:: 0.2 | ||
3014 | 84 | """ | ||
3015 | 85 | |||
3016 | 86 | |||
3017 | 87 | class ITestParser(_Interface): | ||
3018 | 88 | """ | ||
3019 | 89 | Test artefact parser delegate. | ||
3020 | 90 | |||
3021 | 91 | Wraps the knowledge on how to parse the artifacts of a previous test run. | ||
3022 | 92 | It is most helpful with :class:`~lava_test.core.tests.Test` that delegates | ||
3023 | 93 | actual actions to helper classes. | ||
3024 | 94 | |||
3025 | 95 | .. versionadded:: 0.2 | ||
3026 | 96 | """ | ||
3027 | 97 | |||
3028 | 98 | @abstractmethod | ||
3029 | 99 | def parse(self, artifacts): | ||
3030 | 100 | """ | ||
3031 | 101 | Parse the artifacts of a previous test run and return a dictionary with | ||
3032 | 102 | a partial TestRun object. | ||
3033 | 103 | |||
3034 | 104 | :param artifacts: | ||
3035 | 105 | Object that describes where to find test run artifacts | ||
3036 | 106 | :type artifacts: :class:`~lava_test.core.artifacts.TestArtifacts`. | ||
3037 | 107 | |||
3038 | 108 | .. versionadded:: 0.2 | ||
3039 | 109 | """ | ||
3040 | 110 | |||
3041 | 111 | @abstractproperty | ||
3042 | 112 | def results(self): | ||
3043 | 113 | """ | ||
3044 | 114 | Results dictionary to be merged with TestRun object inside the bundle. | ||
3045 | 115 | |||
3046 | 116 | .. seealso:: :meth:`~lava_test.core.artifacts.TestArtifacts.incorporate_parse_results` | ||
3047 | 117 | |||
3048 | 118 | .. versionadded:: 0.1 | ||
3049 | 119 | """ | ||
3050 | 0 | 120 | ||
3051 | === added file 'lava_test/api/observers.py' | |||
3052 | --- lava_test/api/observers.py 1970-01-01 00:00:00 +0000 | |||
3053 | +++ lava_test/api/observers.py 2011-09-13 22:44:36 +0000 | |||
3054 | @@ -0,0 +1,120 @@ | |||
3055 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
3056 | 2 | # | ||
3057 | 3 | # This program is free software: you can redistribute it and/or modify | ||
3058 | 4 | # it under the terms of the GNU General Public License as published by | ||
3059 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
3060 | 6 | # (at your option) any later version. | ||
3061 | 7 | # | ||
3062 | 8 | # This program is distributed in the hope that it will be useful, | ||
3063 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3064 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3065 | 11 | # GNU General Public License for more details. | ||
3066 | 12 | # | ||
3067 | 13 | # You should have received a copy of the GNU General Public License | ||
3068 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3069 | 15 | |||
3070 | 16 | |||
3071 | 17 | """ | ||
3072 | 18 | :mod:`lava_test.api.observers` -- Interface classes for observer classes | ||
3073 | 19 | ======================================================================== | ||
3074 | 20 | |||
3075 | 21 | .. module: lava_test.api.observers | ||
3076 | 22 | :synopsis: Interface classes for observer classes | ||
3077 | 23 | """ | ||
3078 | 24 | |||
3079 | 25 | from abc import abstractmethod | ||
3080 | 26 | |||
3081 | 27 | from lava_test.api import _Interface | ||
3082 | 28 | |||
3083 | 29 | |||
3084 | 30 | class IShellCommandObserver(_Interface): | ||
3085 | 31 | """ | ||
3086 | 32 | Shell command runner observer class. | ||
3087 | 33 | |||
3088 | 34 | Allows the caller to observe shell commands that occur during some | ||
3089 | 35 | operation. It is used by the command line UI. | ||
3090 | 36 | |||
3091 | 37 | .. versionadded:: 0.2 | ||
3092 | 38 | """ | ||
3093 | 39 | |||
3094 | 40 | @abstractmethod | ||
3095 | 41 | def about_to_run_shell_command(self, cmd): | ||
3096 | 42 | """ | ||
3097 | 43 | Method called when a shell command is about to be invoked by the | ||
3098 | 44 | observed object. | ||
3099 | 45 | |||
3100 | 46 | .. versionadded:: 0.2 | ||
3101 | 47 | """ | ||
3102 | 48 | |||
3103 | 49 | @abstractmethod | ||
3104 | 50 | def did_run_shell_command(self, cmd, returncode): | ||
3105 | 51 | """ | ||
3106 | 52 | Method called when a shell command has been invoked by the observed | ||
3107 | 53 | object. | ||
3108 | 54 | |||
3109 | 55 | .. versionadded:: 0.2 | ||
3110 | 56 | """ | ||
3111 | 57 | |||
3112 | 58 | @abstractmethod | ||
3113 | 59 | def display_subprocess_output(self, stream_name, line): | ||
3114 | 60 | """ | ||
3115 | 61 | Method called for each line of stdout/stderr as obtained from a | ||
3116 | 62 | subprocess. | ||
3117 | 63 | |||
3118 | 64 | .. versionadded:: 0.2 | ||
3119 | 65 | """ | ||
3120 | 66 | |||
3121 | 67 | |||
3122 | 68 | class ITestInstallerObserver(IShellCommandObserver): | ||
3123 | 69 | """ | ||
3124 | 70 | Test installer observer class. | ||
3125 | 71 | |||
3126 | 72 | Allows the caller to observe interesting actions that occur during | ||
3127 | 73 | installation process. It is used by the command line UI. | ||
3128 | 74 | |||
3129 | 75 | .. versionadded:: 0.2 | ||
3130 | 76 | """ | ||
3131 | 77 | |||
3132 | 78 | @abstractmethod | ||
3133 | 79 | def about_to_install_packages(self, package_list): | ||
3134 | 80 | """ | ||
3135 | 81 | Method called when a list of packages is about to be installed by the | ||
3136 | 82 | installer | ||
3137 | 83 | |||
3138 | 84 | .. versionadded:: 0.2 | ||
3139 | 85 | """ | ||
3140 | 86 | |||
3141 | 87 | @abstractmethod | ||
3142 | 88 | def did_install_packages(self, package_list): | ||
3143 | 89 | """ | ||
3144 | 90 | Method called when a package has been installed by the installer | ||
3145 | 91 | |||
3146 | 92 | .. versionadded:: 0.2 | ||
3147 | 93 | """ | ||
3148 | 94 | |||
3149 | 95 | @abstractmethod | ||
3150 | 96 | def about_to_download_file(self, url): | ||
3151 | 97 | """ | ||
3152 | 98 | Method called when a file is about to be downloaded | ||
3153 | 99 | |||
3154 | 100 | .. versionadded:: 0.2 | ||
3155 | 101 | """ | ||
3156 | 102 | |||
3157 | 103 | @abstractmethod | ||
3158 | 104 | def did_download_file(self, url): | ||
3159 | 105 | """ | ||
3160 | 106 | Method called when a file has been downloaded | ||
3161 | 107 | |||
3162 | 108 | .. versionadded:: 0.2 | ||
3163 | 109 | """ | ||
3164 | 110 | |||
3165 | 111 | |||
3166 | 112 | class ITestRunnerObserver(IShellCommandObserver): | ||
3167 | 113 | """ | ||
3168 | 114 | Test runner observer class. | ||
3169 | 115 | |||
3170 | 116 | Allows the caller to observe interesting actions that occur during testing | ||
3171 | 117 | process. It is used by the command line UI. | ||
3172 | 118 | |||
3173 | 119 | .. versionadded:: 0.2 | ||
3174 | 120 | """ | ||
3175 | 0 | 121 | ||
3176 | === added file 'lava_test/commands.py' | |||
3177 | --- lava_test/commands.py 1970-01-01 00:00:00 +0000 | |||
3178 | +++ lava_test/commands.py 2011-09-13 22:44:36 +0000 | |||
3179 | @@ -0,0 +1,383 @@ | |||
3180 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
3181 | 2 | # | ||
3182 | 3 | # This program is free software: you can redistribute it and/or modify | ||
3183 | 4 | # it under the terms of the GNU General Public License as published by | ||
3184 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
3185 | 6 | # (at your option) any later version. | ||
3186 | 7 | # | ||
3187 | 8 | # This program is distributed in the hope that it will be useful, | ||
3188 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3189 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3190 | 11 | # GNU General Public License for more details. | ||
3191 | 12 | # | ||
3192 | 13 | # You should have received a copy of the GNU General Public License | ||
3193 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3194 | 15 | |||
3195 | 16 | |||
3196 | 17 | import os | ||
3197 | 18 | import subprocess | ||
3198 | 19 | |||
3199 | 20 | from lava_tool.interface import Command as LavaCommand | ||
3200 | 21 | from lava_tool.interface import LavaCommandError | ||
3201 | 22 | import versiontools | ||
3202 | 23 | |||
3203 | 24 | from lava_test.api.observers import ( | ||
3204 | 25 | ITestInstallerObserver, | ||
3205 | 26 | ITestRunnerObserver) | ||
3206 | 27 | from lava_test.core.artifacts import TestArtifacts | ||
3207 | 28 | from lava_test.core.config import get_config | ||
3208 | 29 | from lava_test.core.loader import TestLoader | ||
3209 | 30 | |||
3210 | 31 | |||
3211 | 32 | class Command(LavaCommand, ITestInstallerObserver, ITestRunnerObserver): | ||
3212 | 33 | |||
3213 | 34 | def __init__(self, parser, args): | ||
3214 | 35 | super(Command, self).__init__(parser, args) | ||
3215 | 36 | self._config = get_config() | ||
3216 | 37 | self._test_loader = TestLoader(self._config) | ||
3217 | 38 | |||
3218 | 39 | @classmethod | ||
3219 | 40 | def register_arguments(cls, parser): | ||
3220 | 41 | parser.add_argument( | ||
3221 | 42 | "-q", "--quiet", | ||
3222 | 43 | action="store_true", | ||
3223 | 44 | default=False, | ||
3224 | 45 | help="Be less verbose about undertaken actions") | ||
3225 | 46 | parser.add_argument( | ||
3226 | 47 | "-Q", "--quiet-subcommands", | ||
3227 | 48 | action="store_true", | ||
3228 | 49 | default=False, | ||
3229 | 50 | help="Hide the output of all sub-commands (including tests)") | ||
3230 | 51 | |||
3231 | 52 | def say(self, text, *args, **kwargs): | ||
3232 | 53 | print "LAVA:", text.format(*args, **kwargs) | ||
3233 | 54 | |||
3234 | 55 | def about_to_install_packages(self, package_list): | ||
3235 | 56 | if self.args.quiet: | ||
3236 | 57 | return | ||
3237 | 58 | self.say("Installing packages: {0}", ", ".join(package_list)) | ||
3238 | 59 | |||
3239 | 60 | def about_to_run_shell_command(self, cmd): | ||
3240 | 61 | if self.args.quiet: | ||
3241 | 62 | return | ||
3242 | 63 | self.say("Running shell command: {0!r}", cmd) | ||
3243 | 64 | |||
3244 | 65 | def about_to_download_file(self, url): | ||
3245 | 66 | if self.args.quiet: | ||
3246 | 67 | return | ||
3247 | 68 | self.say("Downloading file from: {0!r}", url) | ||
3248 | 69 | |||
3249 | 70 | def did_install_packages(self, package_list): | ||
3250 | 71 | pass | ||
3251 | 72 | |||
3252 | 73 | def did_run_shell_command(self, cmd, returncode): | ||
3253 | 74 | if returncode is None: | ||
3254 | 75 | self.say("Command {0!r} was terminated prematurely", cmd) | ||
3255 | 76 | elif returncode != 0: | ||
3256 | 77 | self.say("Command {0!r} returned non-zero exit status {1}", | ||
3257 | 78 | cmd, returncode) | ||
3258 | 79 | |||
3259 | 80 | def did_download_file(self, url): | ||
3260 | 81 | pass | ||
3261 | 82 | |||
3262 | 83 | def display_subprocess_output(self, stream_name, line): | ||
3263 | 84 | if self.args.quiet_subcommands: | ||
3264 | 85 | return | ||
3265 | 86 | if stream_name == 'stdout': | ||
3266 | 87 | self.say('(stdout) {0}', line.rstrip()) | ||
3267 | 88 | elif stream_name == 'stderr': | ||
3268 | 89 | self.say('(stderr) {0}', line.rstrip()) | ||
3269 | 90 | |||
3270 | 91 | |||
3271 | 92 | class list_tests(Command): | ||
3272 | 93 | """ | ||
3273 | 94 | List available tests | ||
3274 | 95 | |||
3275 | 96 | .. program:: lava-test list-tests | ||
3276 | 97 | |||
3277 | 98 | Lists all available tests, grouping them by provider. | ||
3278 | 99 | """ | ||
3279 | 100 | |||
3280 | 101 | def invoke(self): | ||
3281 | 102 | for provider in self._test_loader.get_providers(): | ||
3282 | 103 | test_list = [provider[test_id] for test_id in provider] | ||
3283 | 104 | if not test_list: | ||
3284 | 105 | continue | ||
3285 | 106 | self.say("{0}", provider.description) | ||
3286 | 107 | for test in test_list: | ||
3287 | 108 | self.say(" - {test_id}", test_id=test.test_id) | ||
3288 | 109 | |||
3289 | 110 | |||
3290 | 111 | class list_installed(Command): | ||
3291 | 112 | """ | ||
3292 | 113 | List installed tests | ||
3293 | 114 | """ | ||
3294 | 115 | |||
3295 | 116 | def invoke(self): | ||
3296 | 117 | for provider in self._test_loader.get_providers(): | ||
3297 | 118 | test_list = [provider[test_id] for test_id in provider] | ||
3298 | 119 | if not test_list: | ||
3299 | 120 | continue | ||
3300 | 121 | self.say("{0}", provider.description) | ||
3301 | 122 | count = 0 | ||
3302 | 123 | for test in test_list: | ||
3303 | 124 | if not test.is_installed: | ||
3304 | 125 | continue | ||
3305 | 126 | self.say(" - {test_id}", test_id=test.test_id) | ||
3306 | 127 | count += 1 | ||
3307 | 128 | if not count: | ||
3308 | 129 | self.say("No tests installed") | ||
3309 | 130 | |||
3310 | 131 | |||
3311 | 132 | |||
3312 | 133 | class TestAffectingCommand(Command): | ||
3313 | 134 | |||
3314 | 135 | INSTALL_REQUIRED = False | ||
3315 | 136 | |||
3316 | 137 | @classmethod | ||
3317 | 138 | def register_arguments(cls, parser): | ||
3318 | 139 | super(TestAffectingCommand, cls).register_arguments(parser) | ||
3319 | 140 | parser.add_argument("test_id", | ||
3320 | 141 | help="Test or test suite identifier") | ||
3321 | 142 | |||
3322 | 143 | def invoke(self): | ||
3323 | 144 | try: | ||
3324 | 145 | test = self._test_loader[self.args.test_id] | ||
3325 | 146 | except KeyError: | ||
3326 | 147 | raise LavaCommandError("There is no test with the specified ID") | ||
3327 | 148 | return self.invoke_with_test(test) | ||
3328 | 149 | |||
3329 | 150 | |||
3330 | 151 | class install(TestAffectingCommand): | ||
3331 | 152 | """ | ||
3332 | 153 | Install a test program | ||
3333 | 154 | """ | ||
3334 | 155 | |||
3335 | 156 | def invoke_with_test(self, test): | ||
3336 | 157 | if test.is_installed: | ||
3337 | 158 | raise LavaCommandError("This test is already installed") | ||
3338 | 159 | try: | ||
3339 | 160 | test.install(self) | ||
3340 | 161 | except (subprocess.CalledProcessError, RuntimeError) as ex: | ||
3341 | 162 | raise LavaCommandError(str(ex)) | ||
3342 | 163 | |||
3343 | 164 | |||
3344 | 165 | class uninstall(TestAffectingCommand): | ||
3345 | 166 | """ | ||
3346 | 167 | Uninstall a test program | ||
3347 | 168 | """ | ||
3348 | 169 | |||
3349 | 170 | def invoke_with_test(self, test): | ||
3350 | 171 | if not test.is_installed: | ||
3351 | 172 | raise LavaCommandError("This test is not installed") | ||
3352 | 173 | test.uninstall() | ||
3353 | 174 | |||
3354 | 175 | |||
3355 | 176 | class run(TestAffectingCommand): | ||
3356 | 177 | """ | ||
3357 | 178 | Run a previously installed test program | ||
3358 | 179 | """ | ||
3359 | 180 | |||
3360 | 181 | @classmethod | ||
3361 | 182 | def register_arguments(cls, parser): | ||
3362 | 183 | super(run, cls).register_arguments(parser) | ||
3363 | 184 | group = parser.add_argument_group("initial bundle configuration") | ||
3364 | 185 | group.add_argument("-S", "--skip-software-context", | ||
3365 | 186 | default=False, | ||
3366 | 187 | action="store_true", | ||
3367 | 188 | help=("Do not store the software context in the" | ||
3368 | 189 | " initial bundle. Typically this saves OS" | ||
3369 | 190 | " image name and all the installed software" | ||
3370 | 191 | " packages.")) | ||
3371 | 192 | group.add_argument("-H", "--skip-hardware-context", | ||
3372 | 193 | default=False, | ||
3373 | 194 | action="store_true", | ||
3374 | 195 | help=("Do not store the hardware context in the" | ||
3375 | 196 | " initial bundle. Typically this saves CPU," | ||
3376 | 197 | " memory and USB device information.")) | ||
3377 | 198 | group.add_argument("--trusted-time", | ||
3378 | 199 | default=False, | ||
3379 | 200 | action="store_true", | ||
3380 | 201 | help=("Indicate that the real time clock has" | ||
3381 | 202 | " accurate data. This can differentiate" | ||
3382 | 203 | " test results created on embedded devices" | ||
3383 | 204 | " that often have inaccurate real time" | ||
3384 | 205 | " clock settings.")) | ||
3385 | 206 | group = parser.add_argument_group("complete bundle configuration") | ||
3386 | 207 | group.add_argument("-o", "--output", | ||
3387 | 208 | default=None, | ||
3388 | 209 | metavar="FILE", | ||
3389 | 210 | help=("After running the test parse the result" | ||
3390 | 211 | " artifacts, fuse them with the initial" | ||
3391 | 212 | " bundle and finally save the complete bundle" | ||
3392 | 213 | " to the specified FILE.")) | ||
3393 | 214 | group.add_argument("-A", "--skip-attachments", | ||
3394 | 215 | default=False, | ||
3395 | 216 | action="store_true", | ||
3396 | 217 | help=("Do not store standard output and standard" | ||
3397 | 218 | " error log files as attachments. This" | ||
3398 | 219 | " option is only affecting the bundle" | ||
3399 | 220 | " created with --output, the initial bundle" | ||
3400 | 221 | " is not affected as it never stores any" | ||
3401 | 222 | " attachments.")) | ||
3402 | 223 | |||
3403 | 224 | def invoke_with_test(self, test): | ||
3404 | 225 | if not test.is_installed: | ||
3405 | 226 | raise LavaCommandError("The specified test is not installed") | ||
3406 | 227 | try: | ||
3407 | 228 | artifacts = test.run(self) | ||
3408 | 229 | except subprocess.CalledProcessError as ex: | ||
3409 | 230 | if ex.returncode is None: | ||
3410 | 231 | raise LavaCommandError("Command %r was aborted" % ex.cmd) | ||
3411 | 232 | else: | ||
3412 | 233 | raise LavaCommandError(str(ex)) | ||
3413 | 234 | except RuntimeError as ex: | ||
3414 | 235 | raise LavaCommandError(str(ex)) | ||
3415 | 236 | self.say("run complete, result_id is {0!r}", artifacts.result_id) | ||
3416 | 237 | artifacts.create_initial_bundle( | ||
3417 | 238 | self.args.skip_software_context, | ||
3418 | 239 | self.args.skip_hardware_context, | ||
3419 | 240 | self.args.trusted_time) | ||
3420 | 241 | artifacts.save_bundle() | ||
3421 | 242 | if self.args.output: | ||
3422 | 243 | parse_results = test.parse(artifacts) | ||
3423 | 244 | artifacts.incorporate_parse_results(parse_results) | ||
3424 | 245 | if not self.args.skip_attachments: | ||
3425 | 246 | artifacts.attach_standard_files_to_bundle() | ||
3426 | 247 | artifacts.save_bundle_as(self.args.output) | ||
3427 | 248 | |||
3428 | 249 | |||
3429 | 250 | class parse(TestAffectingCommand): | ||
3430 | 251 | """ | ||
3431 | 252 | Parse the results of previous test run | ||
3432 | 253 | """ | ||
3433 | 254 | |||
3434 | 255 | @classmethod | ||
3435 | 256 | def register_arguments(cls, parser): | ||
3436 | 257 | super(parse, cls).register_arguments(parser) | ||
3437 | 258 | parser.add_argument("result_id", | ||
3438 | 259 | help="Test run result identifier") | ||
3439 | 260 | group = parser.add_argument_group("complete bundle configuration") | ||
3440 | 261 | group.add_argument("-o", "--output", | ||
3441 | 262 | default=None, | ||
3442 | 263 | metavar="FILE", | ||
3443 | 264 | help=("After running the test parse the result" | ||
3444 | 265 | " artifacts, fuse them with the initial" | ||
3445 | 266 | " bundle and finally save the complete bundle" | ||
3446 | 267 | " to the specified FILE.")) | ||
3447 | 268 | group.add_argument("-A", "--skip-attachments", | ||
3448 | 269 | default=False, | ||
3449 | 270 | action="store_true", | ||
3450 | 271 | help=("Do not store standard output and standard" | ||
3451 | 272 | " error log files as attachments. This" | ||
3452 | 273 | " option is only affecting the bundle" | ||
3453 | 274 | " created with --output, the initial bundle" | ||
3454 | 275 | " is not affected as it never stores any" | ||
3455 | 276 | " attachments.")) | ||
3456 | 277 | |||
3457 | 278 | def invoke_with_test(self, test): | ||
3458 | 279 | artifacts = TestArtifacts( | ||
3459 | 280 | self.args.test_id, self.args.result_id, self._config) | ||
3460 | 281 | if not os.path.exists(artifacts.bundle_pathname): | ||
3461 | 282 | raise LavaCommandError("Specified result does not exist") | ||
3462 | 283 | artifacts.load_bundle() | ||
3463 | 284 | parse_results = test.parse(artifacts) | ||
3464 | 285 | artifacts.incorporate_parse_results(parse_results) | ||
3465 | 286 | self.say("Parsed {0} test results", | ||
3466 | 287 | len(artifacts.bundle["test_runs"][0]["test_results"])) | ||
3467 | 288 | print artifacts.dumps_bundle() | ||
3468 | 289 | if self.args.output: | ||
3469 | 290 | if not self.args.skip_attachments: | ||
3470 | 291 | artifacts.attach_standard_files_to_bundle() | ||
3471 | 292 | artifacts.save_bundle_as(self.args.output) | ||
3472 | 293 | |||
3473 | 294 | |||
3474 | 295 | class show(Command): | ||
3475 | 296 | """ | ||
3476 | 297 | Display the output from a previous test run | ||
3477 | 298 | """ | ||
3478 | 299 | |||
3479 | 300 | @classmethod | ||
3480 | 301 | def register_arguments(cls, parser): | ||
3481 | 302 | super(show, cls).register_arguments(parser) | ||
3482 | 303 | parser.add_argument("result_id", | ||
3483 | 304 | help="Test run result identifier") | ||
3484 | 305 | |||
3485 | 306 | def invoke(self): | ||
3486 | 307 | artifacts = TestArtifacts(None, self.args.result_id, self._config) | ||
3487 | 308 | if not os.path.exists(artifacts.results_dir): | ||
3488 | 309 | raise LavaCommandError("Specified result does not exist") | ||
3489 | 310 | if os.path.exists(artifacts.stdout_pathname): | ||
3490 | 311 | with open(artifacts.stdout_pathname, "rt") as stream: | ||
3491 | 312 | for line in iter(stream.readline, ''): | ||
3492 | 313 | self.display_subprocess_output("stdout", line) | ||
3493 | 314 | if os.path.exists(artifacts.stderr_pathname): | ||
3494 | 315 | with open(artifacts.stderr_pathname, "rt") as stream: | ||
3495 | 316 | for line in iter(stream.readline, ''): | ||
3496 | 317 | self.display_subprocess_output("stderr", line) | ||
3497 | 318 | |||
3498 | 319 | |||
3499 | 320 | class version(Command): | ||
3500 | 321 | """ | ||
3501 | 322 | Show LAVA Test version | ||
3502 | 323 | """ | ||
3503 | 324 | |||
3504 | 325 | def invoke(self): | ||
3505 | 326 | self.say("version details:") | ||
3506 | 327 | for framework in self._get_frameworks(): | ||
3507 | 328 | self.say(" - {framework}: {version}", | ||
3508 | 329 | framework=framework.__name__, | ||
3509 | 330 | version=versiontools.format_version( | ||
3510 | 331 | framework.__version__, framework)) | ||
3511 | 332 | |||
3512 | 333 | def _get_frameworks(self): | ||
3513 | 334 | import lava_tool | ||
3514 | 335 | import lava_test | ||
3515 | 336 | import linaro_dashboard_bundle | ||
3516 | 337 | import linaro_json | ||
3517 | 338 | return [ | ||
3518 | 339 | lava_test, | ||
3519 | 340 | lava_tool, | ||
3520 | 341 | linaro_dashboard_bundle, | ||
3521 | 342 | linaro_json] | ||
3522 | 343 | |||
3523 | 344 | |||
3524 | 345 | class register_test(Command): | ||
3525 | 346 | """ | ||
3526 | 347 | Register remote test | ||
3527 | 348 | """ | ||
3528 | 349 | |||
3529 | 350 | @classmethod | ||
3530 | 351 | def register_arguments(cls, parser): | ||
3531 | 352 | super(register_test, cls).register_arguments(parser) | ||
3532 | 353 | parser.add_argument("test_url", | ||
3533 | 354 | help="Url for test definition file") | ||
3534 | 355 | |||
3535 | 356 | def invoke(self): | ||
3536 | 357 | try: | ||
3537 | 358 | from lava_test.core.providers import RegistryProvider | ||
3538 | 359 | RegistryProvider.register_remote_test(self.args.test_url) | ||
3539 | 360 | except ValueError as exc: | ||
3540 | 361 | raise LavaCommandError("Unable to register test: %s" % exc) | ||
3541 | 362 | except KeyError: | ||
3542 | 363 | raise LavaCommandError("There is no test_url") | ||
3543 | 364 | |||
3544 | 365 | class unregister_test(Command): | ||
3545 | 366 | """ | ||
3546 | 367 | Unregister remote test | ||
3547 | 368 | """ | ||
3548 | 369 | |||
3549 | 370 | @classmethod | ||
3550 | 371 | def register_arguments(cls, parser): | ||
3551 | 372 | super(unregister_test, cls).register_arguments(parser) | ||
3552 | 373 | parser.add_argument("test_url", | ||
3553 | 374 | help="Url for test definition file") | ||
3554 | 375 | |||
3555 | 376 | def invoke(self): | ||
3556 | 377 | try: | ||
3557 | 378 | from lava_test.core.providers import RegistryProvider | ||
3558 | 379 | RegistryProvider.unregister_remote_test(self.args.test_url) | ||
3559 | 380 | except ValueError as exc: | ||
3560 | 381 | raise LavaCommandError("Unable to unregister test: %s" % exc) | ||
3561 | 382 | except KeyError: | ||
3562 | 383 | raise LavaCommandError("There is no test_url") | ||
3563 | 0 | 384 | ||
3564 | === added directory 'lava_test/core' | |||
3565 | === added file 'lava_test/core/__init__.py' | |||
3566 | === added file 'lava_test/core/artifacts.py' | |||
3567 | --- lava_test/core/artifacts.py 1970-01-01 00:00:00 +0000 | |||
3568 | +++ lava_test/core/artifacts.py 2011-09-13 22:44:36 +0000 | |||
3569 | @@ -0,0 +1,277 @@ | |||
3570 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
3571 | 2 | # | ||
3572 | 3 | # This program is free software: you can redistribute it and/or modify | ||
3573 | 4 | # it under the terms of the GNU General Public License as published by | ||
3574 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
3575 | 6 | # (at your option) any later version. | ||
3576 | 7 | # | ||
3577 | 8 | # This program is distributed in the hope that it will be useful, | ||
3578 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3579 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3580 | 11 | # GNU General Public License for more details. | ||
3581 | 12 | # | ||
3582 | 13 | # You should have received a copy of the GNU General Public License | ||
3583 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3584 | 15 | |||
3585 | 16 | from __future__ import absolute_import | ||
3586 | 17 | |||
3587 | 18 | import base64 | ||
3588 | 19 | import datetime | ||
3589 | 20 | import logging | ||
3590 | 21 | import os | ||
3591 | 22 | import uuid | ||
3592 | 23 | |||
3593 | 24 | from linaro_dashboard_bundle.io import DocumentIO | ||
3594 | 25 | |||
3595 | 26 | from lava_test.core import hwprofile, swprofile | ||
3596 | 27 | from lava_test.utils import merge_dict, mkdir_p | ||
3597 | 28 | |||
3598 | 29 | |||
3599 | 30 | class TestArtifacts(object): | ||
3600 | 31 | """ | ||
3601 | 32 | Class representing test run artifacts, that is, static leftovers | ||
3602 | 33 | independent of the wrapper class that encapsulates test handling. | ||
3603 | 34 | |||
3604 | 35 | .. versionadded:: 0.2 | ||
3605 | 36 | """ | ||
3606 | 37 | |||
3607 | 38 | def __init__(self, test_id, result_id, config): | ||
3608 | 39 | self._test_id = test_id | ||
3609 | 40 | self._result_id = result_id | ||
3610 | 41 | self._config = config | ||
3611 | 42 | self._bundle = None | ||
3612 | 43 | |||
3613 | 44 | @classmethod | ||
3614 | 45 | def allocate(cls, test_id, config): | ||
3615 | 46 | """ | ||
3616 | 47 | Allocate new test artifacts object that corresponds to the specified | ||
3617 | 48 | test_id. This constructs a new result_id and creates the corresponding | ||
3618 | 49 | filesystem directory that holds those artifacts. | ||
3619 | 50 | |||
3620 | 51 | .. versionadded:: 0.2 | ||
3621 | 52 | """ | ||
3622 | 53 | result_id = ( | ||
3623 | 54 | "{test_id}.{time.tm_year:04}-{time.tm_mon:02}-{time.tm_mday:02}T" | ||
3624 | 55 | "{time.tm_hour:02}:{time.tm_min:02}:{time.tm_sec:02}Z").format( | ||
3625 | 56 | test_id=test_id, | ||
3626 | 57 | time=datetime.datetime.utcnow().timetuple()) | ||
3627 | 58 | self = cls(test_id, result_id, config) | ||
3628 | 59 | logging.debug("Creating result directory: %r", self.results_dir) | ||
3629 | 60 | mkdir_p(self.results_dir) | ||
3630 | 61 | return self | ||
3631 | 62 | |||
3632 | 63 | @property | ||
3633 | 64 | def test_id(self): | ||
3634 | 65 | """ | ||
3635 | 66 | The ID of the test this run is associated with | ||
3636 | 67 | |||
3637 | 68 | .. versionadded:: 0.2 | ||
3638 | 69 | """ | ||
3639 | 70 | return self._test_id | ||
3640 | 71 | |||
3641 | 72 | @property | ||
3642 | 73 | def result_id(self): | ||
3643 | 74 | """ | ||
3644 | 75 | The ID of the test run. | ||
3645 | 76 | |||
3646 | 77 | This field is different from analyzer_assigned_uuid at this time but | ||
3647 | 78 | may change in the future. The purpose of this field is to identify the | ||
3648 | 79 | test run and be able to locate attachments/log files/bundle on the file | ||
3649 | 80 | system. | ||
3650 | 81 | |||
3651 | 82 | .. versionadded:: 0.2 | ||
3652 | 83 | """ | ||
3653 | 84 | return self._result_id | ||
3654 | 85 | |||
3655 | 86 | @property | ||
3656 | 87 | def results_dir(self): | ||
3657 | 88 | """ | ||
3658 | 89 | Pathname of a directory with test run artifacts (log files, crash | ||
3659 | 90 | dumps, etc). | ||
3660 | 91 | |||
3661 | 92 | .. versionadded:: 0.2 | ||
3662 | 93 | """ | ||
3663 | 94 | return os.path.join(self._config.resultsdir, self.result_id) | ||
3664 | 95 | |||
3665 | 96 | def load_bundle(self): | ||
3666 | 97 | """ | ||
3667 | 98 | Load the results bundle from disk. | ||
3668 | 99 | |||
3669 | 100 | The bundle is also validated if linaro-dashboard-bundle library is | ||
3670 | 101 | installed. | ||
3671 | 102 | """ | ||
3672 | 103 | with open(self.bundle_pathname, 'rt') as stream: | ||
3673 | 104 | self._bundle = DocumentIO.load(stream)[1] | ||
3674 | 105 | |||
3675 | 106 | def dumps_bundle(self): | ||
3676 | 107 | return DocumentIO.dumps(self._bundle) | ||
3677 | 108 | |||
3678 | 109 | def save_bundle(self): | ||
3679 | 110 | """ | ||
3680 | 111 | Save the results bundle to the disk | ||
3681 | 112 | |||
3682 | 113 | The bundle is also validated if linaro-dashboard-bundle library is | ||
3683 | 114 | installed. | ||
3684 | 115 | """ | ||
3685 | 116 | self.save_bundle_as(self.bundle_pathname) | ||
3686 | 117 | |||
3687 | 118 | def save_bundle_as(self, pathname): | ||
3688 | 119 | """ | ||
3689 | 120 | Save the results bundle to the specified file on disk. | ||
3690 | 121 | |||
3691 | 122 | The bundle should have been created or loaded earlier | ||
3692 | 123 | """ | ||
3693 | 124 | with open(pathname, 'wt') as stream: | ||
3694 | 125 | DocumentIO.dump(stream, self._bundle) | ||
3695 | 126 | |||
3696 | 127 | @property | ||
3697 | 128 | def bundle(self): | ||
3698 | 129 | """ | ||
3699 | 130 | The deserialized bundle object. | ||
3700 | 131 | |||
3701 | 132 | This can be either created with create_bundle() or loaded | ||
3702 | 133 | from disk with load_bundle() | ||
3703 | 134 | """ | ||
3704 | 135 | return self._bundle | ||
3705 | 136 | |||
3706 | 137 | def create_initial_bundle(self, | ||
3707 | 138 | skip_software_context=False, | ||
3708 | 139 | skip_hardware_context=False, | ||
3709 | 140 | time_check_performed=False): | ||
3710 | 141 | """ | ||
3711 | 142 | Create the bundle object. | ||
3712 | 143 | |||
3713 | 144 | This creates a typical bundle structure. Optionally it can also add | ||
3714 | 145 | software and hardware context information. | ||
3715 | 146 | |||
3716 | 147 | For a complete bundle you may want to add attachments and incorporate | ||
3717 | 148 | parse results by calling appropriate methods after loading or creating | ||
3718 | 149 | the initial bundle. | ||
3719 | 150 | """ | ||
3720 | 151 | TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ' | ||
3721 | 152 | # Generate UUID and analyzer_assigned_date for the test run | ||
3722 | 153 | analyzer_assigned_uuid = str(uuid.uuid1()) | ||
3723 | 154 | analyzer_assigned_date = datetime.datetime.utcnow() | ||
3724 | 155 | # Create basic test run structure | ||
3725 | 156 | test_run = { | ||
3726 | 157 | 'test_id': self.test_id, | ||
3727 | 158 | 'analyzer_assigned_date': analyzer_assigned_date.strftime( | ||
3728 | 159 | TIMEFORMAT), | ||
3729 | 160 | 'analyzer_assigned_uuid': analyzer_assigned_uuid, | ||
3730 | 161 | 'time_check_performed': time_check_performed, | ||
3731 | 162 | "test_results": [], | ||
3732 | 163 | "attachments": [], | ||
3733 | 164 | } | ||
3734 | 165 | # Store hardware and software context if requested | ||
3735 | 166 | if not skip_software_context: | ||
3736 | 167 | test_run['software_context'] = swprofile.get_software_context() | ||
3737 | 168 | if not skip_hardware_context: | ||
3738 | 169 | test_run['hardware_context'] = hwprofile.get_hardware_context() | ||
3739 | 170 | # Create the bundle object | ||
3740 | 171 | self._bundle = { | ||
3741 | 172 | 'format': 'Dashboard Bundle Format 1.2', | ||
3742 | 173 | 'test_runs': [test_run]} | ||
3743 | 174 | |||
3744 | 175 | @property | ||
3745 | 176 | def test_run(self): | ||
3746 | 177 | try: | ||
3747 | 178 | return self._bundle["test_runs"][0] | ||
3748 | 179 | except KeyError: | ||
3749 | 180 | raise AttributeError("test_run can be accessed only after you load" | ||
3750 | 181 | " or create an initial bundle") | ||
3751 | 182 | |||
3752 | 183 | def attach_file(self, real_pathname, stored_pathname, mime_type): | ||
3753 | 184 | """ | ||
3754 | 185 | Append an attachment to the test run. | ||
3755 | 186 | |||
3756 | 187 | The file is only attached if real_pathname designates an existing, | ||
3757 | 188 | nonempty file. If the mime_type starts with 'text/' the file is opened | ||
3758 | 189 | in text mode, otherwise binary mode is used. | ||
3759 | 190 | """ | ||
3760 | 191 | if not os.path.exists(real_pathname): | ||
3761 | 192 | return | ||
3762 | 193 | if mime_type.startswith('text/'): | ||
3763 | 194 | mode = 'rt' | ||
3764 | 195 | else: | ||
3765 | 196 | mode = 'rb' | ||
3766 | 197 | with open(real_pathname, mode) as stream: | ||
3767 | 198 | data = stream.read() | ||
3768 | 199 | if not data: | ||
3769 | 200 | return | ||
3770 | 201 | self.test_run['attachments'].append({ | ||
3771 | 202 | "pathname": stored_pathname, | ||
3772 | 203 | "mime_type": mime_type, | ||
3773 | 204 | "content": base64.standard_b64encode(data)}) | ||
3774 | 205 | |||
3775 | 206 | def incorporate_parse_results(self, parse_results): | ||
3776 | 207 | """ | ||
3777 | 208 | Merge the data returned by the test parser into the current test run. | ||
3778 | 209 | |||
3779 | 210 | Non-overlapping data is simply added. Overlapping data is either merged | ||
3780 | 211 | (lists are extended, dictionaries are recursively merged) or | ||
3781 | 212 | overwritten (all other types). | ||
3782 | 213 | """ | ||
3783 | 214 | assert isinstance(parse_results, dict) | ||
3784 | 215 | # Use whatever the parser gave us to improve the results | ||
3785 | 216 | logging.debug("Using parser data to enrich test run details") | ||
3786 | 217 | merge_dict(self.test_run, parse_results) | ||
3787 | 218 | |||
3788 | 219 | def attach_standard_files_to_bundle(self): | ||
3789 | 220 | """ | ||
3790 | 221 | Attach standard output and standard error log files to the bundle. | ||
3791 | 222 | |||
3792 | 223 | Both files are only attached if exist and non-empty. The attachments | ||
3793 | 224 | are actually associated with a test run, not a bundle, but the | ||
3794 | 225 | description is good enough for simplicity. | ||
3795 | 226 | """ | ||
3796 | 227 | self.attach_file(self.stdout_pathname, "testoutput.log", "text/plain") | ||
3797 | 228 | self.attach_file(self.stderr_pathname, "testoutput.err", "text/plain") | ||
3798 | 229 | |||
3799 | 230 | @property | ||
3800 | 231 | def bundle_pathname(self): | ||
3801 | 232 | """ | ||
3802 | 233 | Pathname of the result bundle. | ||
3803 | 234 | |||
3804 | 235 | The bundle contains the snapshot of environment information as well as | ||
3805 | 236 | test identity and is created when you invoke ITest.run(). | ||
3806 | 237 | |||
3807 | 238 | The bundle file name is always "testdata.json" | ||
3808 | 239 | |||
3809 | 240 | .. versionadded:: 0.2 | ||
3810 | 241 | """ | ||
3811 | 242 | return self.get_artefact_pathname("testdata.json") | ||
3812 | 243 | |||
3813 | 244 | @property | ||
3814 | 245 | def stdout_pathname(self): | ||
3815 | 246 | """ | ||
3816 | 247 | Pathname of the log file of the standard output as returned by the test | ||
3817 | 248 | program. | ||
3818 | 249 | |||
3819 | 250 | The log file name is always "testoutput.log" | ||
3820 | 251 | |||
3821 | 252 | .. versionadded:: 0.2 | ||
3822 | 253 | """ | ||
3823 | 254 | return self.get_artefact_pathname("testoutput.log") | ||
3824 | 255 | |||
3825 | 256 | @property | ||
3826 | 257 | def stderr_pathname(self): | ||
3827 | 258 | """ | ||
3828 | 259 | Pathname of the log file of the standard output as returned by the test | ||
3829 | 260 | program. | ||
3830 | 261 | |||
3831 | 262 | The log file name is always "testoutput.err" | ||
3832 | 263 | |||
3833 | 264 | .. versionadded:: 0.2 | ||
3834 | 265 | """ | ||
3835 | 266 | return self.get_artefact_pathname("testoutput.err") | ||
3836 | 267 | |||
3837 | 268 | def get_artefact_pathname(self, artefact_name): | ||
3838 | 269 | """ | ||
3839 | 270 | Return a pathname of a test run artefact file. | ||
3840 | 271 | |||
3841 | 272 | This is more useful than hard-coding the path as it allows the test | ||
3842 | 273 | runner not to worry about the location of the results directory. | ||
3843 | 274 | |||
3844 | 275 | .. versionadded:: 0.2 | ||
3845 | 276 | """ | ||
3846 | 277 | return os.path.join(self.results_dir, artefact_name) | ||
3847 | 0 | 278 | ||
3848 | === added file 'lava_test/core/config.py' | |||
3849 | --- lava_test/core/config.py 1970-01-01 00:00:00 +0000 | |||
3850 | +++ lava_test/core/config.py 2011-09-13 22:44:36 +0000 | |||
3851 | @@ -0,0 +1,97 @@ | |||
3852 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
3853 | 2 | # | ||
3854 | 3 | # This program is free software: you can redistribute it and/or modify | ||
3855 | 4 | # it under the terms of the GNU General Public License as published by | ||
3856 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
3857 | 6 | # (at your option) any later version. | ||
3858 | 7 | # | ||
3859 | 8 | # This program is distributed in the hope that it will be useful, | ||
3860 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3861 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3862 | 11 | # GNU General Public License for more details. | ||
3863 | 12 | # | ||
3864 | 13 | # You should have received a copy of the GNU General Public License | ||
3865 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3866 | 15 | |||
3867 | 16 | import os | ||
3868 | 17 | import json | ||
3869 | 18 | |||
3870 | 19 | |||
3871 | 20 | class LavaTestConfig(object): | ||
3872 | 21 | |||
3873 | 22 | def __init__(self): | ||
3874 | 23 | home = os.environ.get('HOME', '/') | ||
3875 | 24 | baseconfig = os.environ.get('XDG_CONFIG_HOME', | ||
3876 | 25 | os.path.join(home, '.config')) | ||
3877 | 26 | basedata = os.environ.get('XDG_DATA_HOME', | ||
3878 | 27 | os.path.join(home, '.local', 'share')) | ||
3879 | 28 | self.configdir = os.path.join(baseconfig, 'lava_test') | ||
3880 | 29 | self.installdir = os.path.join(basedata, 'lava_test', 'installed-tests') | ||
3881 | 30 | self.resultsdir = os.path.join(basedata, 'lava_test', 'results') | ||
3882 | 31 | self.registry = self._load_registry() | ||
3883 | 32 | |||
3884 | 33 | @property | ||
3885 | 34 | def _registry_pathname(self): | ||
3886 | 35 | return os.path.join(self.configdir, "registry.json") | ||
3887 | 36 | |||
3888 | 37 | def _load_registry(self): | ||
3889 | 38 | try: | ||
3890 | 39 | with open(self._registry_pathname) as stream: | ||
3891 | 40 | return json.load(stream) | ||
3892 | 41 | except (IOError, ValueError): | ||
3893 | 42 | return self._get_default_registry() | ||
3894 | 43 | |||
3895 | 44 | def _save_registry(self): | ||
3896 | 45 | if not os.path.exists(self.configdir): | ||
3897 | 46 | os.makedirs(self.configdir) | ||
3898 | 47 | with open(self._registry_pathname, "wt") as stream: | ||
3899 | 48 | json.dump(self.registry, stream, indent=2) | ||
3900 | 49 | |||
3901 | 50 | def _get_default_registry(self): | ||
3902 | 51 | return { | ||
3903 | 52 | "format": "Lava-Test Test Registry 1.0", | ||
3904 | 53 | "providers": [{ | ||
3905 | 54 | "entry_point": "lava_test.core.providers:BuiltInProvider" | ||
3906 | 55 | }, { | ||
3907 | 56 | "entry_point": "lava_test.core.providers:PkgResourcesProvider", | ||
3908 | 57 | "config": {"namespace": "lava_test.test_definitions" } | ||
3909 | 58 | }, | ||
3910 | 59 | { | ||
3911 | 60 | "entry_point": "lava_test.core.providers:RegistryProvider", | ||
3912 | 61 | "config": {"entries": [] } | ||
3913 | 62 | }] | ||
3914 | 63 | } | ||
3915 | 64 | |||
3916 | 65 | def get_provider_config(self, entry_point_name): | ||
3917 | 66 | if "providers" not in self.registry: | ||
3918 | 67 | self.registry["providers"] = [] | ||
3919 | 68 | for provider_info in self.registry["providers"]: | ||
3920 | 69 | if provider_info.get("entry_point") == entry_point_name: | ||
3921 | 70 | break | ||
3922 | 71 | else: | ||
3923 | 72 | provider_info = {"entry_point": entry_point_name} | ||
3924 | 73 | self.registry["providers"].append(provider_info) | ||
3925 | 74 | if "config" not in provider_info: | ||
3926 | 75 | provider_info["config"] = {} | ||
3927 | 76 | return provider_info["config"] | ||
3928 | 77 | |||
3929 | 78 | def get_logging_config_file(self): | ||
3930 | 79 | logging_file = os.path.join(self.configdir, "logging.conf") | ||
3931 | 80 | if os.path.exists(logging_file): | ||
3932 | 81 | return logging_file | ||
3933 | 82 | else: | ||
3934 | 83 | return None | ||
3935 | 84 | |||
3936 | 85 | _config = None | ||
3937 | 86 | |||
3938 | 87 | |||
3939 | 88 | def get_config(): | ||
3940 | 89 | global _config | ||
3941 | 90 | if _config is not None: | ||
3942 | 91 | return _config | ||
3943 | 92 | return LavaTestConfig() | ||
3944 | 93 | |||
3945 | 94 | |||
3946 | 95 | def set_config(config): | ||
3947 | 96 | global _config | ||
3948 | 97 | _config = config | ||
3949 | 0 | 98 | ||
3950 | === added file 'lava_test/core/hwprofile.py' | |||
3951 | --- lava_test/core/hwprofile.py 1970-01-01 00:00:00 +0000 | |||
3952 | +++ lava_test/core/hwprofile.py 2011-09-13 22:44:36 +0000 | |||
3953 | @@ -0,0 +1,223 @@ | |||
3954 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
3955 | 2 | # | ||
3956 | 3 | # This program is free software: you can redistribute it and/or modify | ||
3957 | 4 | # it under the terms of the GNU General Public License as published by | ||
3958 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
3959 | 6 | # (at your option) any later version. | ||
3960 | 7 | # | ||
3961 | 8 | # This program is distributed in the hope that it will be useful, | ||
3962 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3963 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3964 | 11 | # GNU General Public License for more details. | ||
3965 | 12 | # | ||
3966 | 13 | # You should have received a copy of the GNU General Public License | ||
3967 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3968 | 15 | |||
3969 | 16 | import re | ||
3970 | 17 | import sys | ||
3971 | 18 | from subprocess import Popen, PIPE | ||
3972 | 19 | from lava_test.utils import read_file, get_machine_type | ||
3973 | 20 | |||
3974 | 21 | |||
3975 | 22 | INTEL_KEYMAP = { | ||
3976 | 23 | 'vendor_id': 'cpu_vendor_name', | ||
3977 | 24 | 'cpu family': 'cpu_family', | ||
3978 | 25 | 'model': 'cpu_model', | ||
3979 | 26 | 'model name': 'cpu_model_name', | ||
3980 | 27 | 'stepping': 'cpu_stepping', | ||
3981 | 28 | 'cpu MHz': 'cpu_mhz', | ||
3982 | 29 | 'flags': 'cpu_features', | ||
3983 | 30 | } | ||
3984 | 31 | |||
3985 | 32 | |||
3986 | 33 | INTEL_VALMAP = { | ||
3987 | 34 | 'cpu family': int, | ||
3988 | 35 | 'model': int, | ||
3989 | 36 | 'stepping': int, | ||
3990 | 37 | 'cpu MHz': float, | ||
3991 | 38 | } | ||
3992 | 39 | |||
3993 | 40 | |||
3994 | 41 | ARM_KEYMAP = { | ||
3995 | 42 | 'Processor': 'cpu_model_name', | ||
3996 | 43 | 'Features': 'cpu_features', | ||
3997 | 44 | 'CPU implementer': 'cpu_implementer', | ||
3998 | 45 | 'CPU architecture': 'cpu_architecture', | ||
3999 | 46 | 'CPU variant': 'cpu_variant', | ||
4000 | 47 | 'CPU part': 'cpu_part', | ||
4001 | 48 | 'CPU revision': 'cpu_revision', | ||
4002 | 49 | } | ||
4003 | 50 | |||
4004 | 51 | |||
4005 | 52 | ARM_VALMAP = { | ||
4006 | 53 | 'CPU implementer': lambda value: int(value, 16), | ||
4007 | 54 | 'CPU architecture': int, | ||
4008 | 55 | 'CPU variant': lambda value: int(value, 16), | ||
4009 | 56 | 'CPU part': lambda value: int(value, 16), | ||
4010 | 57 | 'CPU revision': int, | ||
4011 | 58 | } | ||
4012 | 59 | |||
4013 | 60 | |||
4014 | 61 | def _translate_cpuinfo(keymap, valmap, key, value): | ||
4015 | 62 | """ | ||
4016 | 63 | Translate a key and value using keymap and valmap passed in | ||
4017 | 64 | """ | ||
4018 | 65 | newkey = keymap.get(key, key) | ||
4019 | 66 | newval = valmap.get(key, lambda x: x)(value) | ||
4020 | 67 | return newkey, newval | ||
4021 | 68 | |||
4022 | 69 | |||
4023 | 70 | def get_cpu_devs(): | ||
4024 | 71 | """ | ||
4025 | 72 | Return a list of CPU devices | ||
4026 | 73 | """ | ||
4027 | 74 | pattern = re.compile('^(?P<key>.+?)\s*:\s*(?P<value>.*)$') | ||
4028 | 75 | cpunum = 0 | ||
4029 | 76 | devices = [] | ||
4030 | 77 | cpudevs = [] | ||
4031 | 78 | cpudevs.append({}) | ||
4032 | 79 | machine = get_machine_type() | ||
4033 | 80 | if machine in ('i686', 'x86_64'): | ||
4034 | 81 | keymap, valmap = INTEL_KEYMAP, INTEL_VALMAP | ||
4035 | 82 | elif machine.startswith('arm'): | ||
4036 | 83 | keymap, valmap = ARM_KEYMAP, ARM_VALMAP | ||
4037 | 84 | |||
4038 | 85 | try: | ||
4039 | 86 | cpuinfo = read_file("/proc/cpuinfo") | ||
4040 | 87 | for line in cpuinfo.splitlines(): | ||
4041 | 88 | match = pattern.match(line) | ||
4042 | 89 | if match: | ||
4043 | 90 | key, value = match.groups() | ||
4044 | 91 | key, value = _translate_cpuinfo(keymap, valmap, | ||
4045 | 92 | key, value) | ||
4046 | 93 | if cpudevs[cpunum].get(key): | ||
4047 | 94 | cpunum += 1 | ||
4048 | 95 | cpudevs.append({}) | ||
4049 | 96 | cpudevs[cpunum][key] = value | ||
4050 | 97 | for c in range(len(cpudevs)): | ||
4051 | 98 | device = {} | ||
4052 | 99 | device['device_type'] = 'device.cpu' | ||
4053 | 100 | device['description'] = 'Processor #{0}'.format(c) | ||
4054 | 101 | device['attributes'] = cpudevs[c] | ||
4055 | 102 | devices.append(device) | ||
4056 | 103 | except IOError: | ||
4057 | 104 | print >> sys.stderr, "WARNING: Could not read cpu information" | ||
4058 | 105 | return devices | ||
4059 | 106 | |||
4060 | 107 | |||
4061 | 108 | def get_board_devs(): | ||
4062 | 109 | """ | ||
4063 | 110 | Return a list of board devices | ||
4064 | 111 | """ | ||
4065 | 112 | devices = [] | ||
4066 | 113 | attributes = {} | ||
4067 | 114 | device = {} | ||
4068 | 115 | machine = get_machine_type() | ||
4069 | 116 | if machine in ('i686', 'x86_64'): | ||
4070 | 117 | try: | ||
4071 | 118 | description = read_file('/sys/class/dmi/id/board_name') or None | ||
4072 | 119 | vendor = read_file('/sys/class/dmi/id/board_vendor') or None | ||
4073 | 120 | version = read_file('/sys/class/dmi/id/board_version') or None | ||
4074 | 121 | if description: | ||
4075 | 122 | device['description'] = description.strip() | ||
4076 | 123 | if vendor: | ||
4077 | 124 | attributes['vendor'] = vendor.strip() | ||
4078 | 125 | if version: | ||
4079 | 126 | attributes['version'] = version.strip() | ||
4080 | 127 | except IOError: | ||
4081 | 128 | print >> sys.stderr, "WARNING: Could not read board information" | ||
4082 | 129 | return devices | ||
4083 | 130 | elif machine.startswith('arm'): | ||
4084 | 131 | try: | ||
4085 | 132 | cpuinfo = read_file("/proc/cpuinfo") | ||
4086 | 133 | if cpuinfo is None: | ||
4087 | 134 | return devices | ||
4088 | 135 | pattern = re.compile("^Hardware\s*:\s*(?P<description>.+)$", re.M) | ||
4089 | 136 | match = pattern.search(cpuinfo) | ||
4090 | 137 | if match is None: | ||
4091 | 138 | return devices | ||
4092 | 139 | device['description'] = match.group('description') | ||
4093 | 140 | except IOError: | ||
4094 | 141 | print >> sys.stderr, "WARNING: Could not read board information" | ||
4095 | 142 | return devices | ||
4096 | 143 | else: | ||
4097 | 144 | return devices | ||
4098 | 145 | if attributes: | ||
4099 | 146 | device['attributes'] = attributes | ||
4100 | 147 | device['device_type'] = 'device.board' | ||
4101 | 148 | devices.append(device) | ||
4102 | 149 | return devices | ||
4103 | 150 | |||
4104 | 151 | |||
4105 | 152 | def get_mem_devs(): | ||
4106 | 153 | """ Return a list of memory devices | ||
4107 | 154 | |||
4108 | 155 | This returns up to two items, one for physical RAM and another for swap | ||
4109 | 156 | """ | ||
4110 | 157 | pattern = re.compile('^(?P<key>.+?)\s*:\s*(?P<value>.+) kB$', re.M) | ||
4111 | 158 | |||
4112 | 159 | devices = [] | ||
4113 | 160 | try: | ||
4114 | 161 | meminfo = read_file("/proc/meminfo") | ||
4115 | 162 | for match in pattern.finditer(meminfo): | ||
4116 | 163 | key, value = match.groups() | ||
4117 | 164 | if key not in ('MemTotal', 'SwapTotal'): | ||
4118 | 165 | continue | ||
4119 | 166 | capacity = int(value) << 10 # Kernel reports in 2^10 units | ||
4120 | 167 | if capacity == 0: | ||
4121 | 168 | continue | ||
4122 | 169 | if key == 'MemTotal': | ||
4123 | 170 | kind = 'RAM' | ||
4124 | 171 | else: | ||
4125 | 172 | kind = 'swap' | ||
4126 | 173 | description = "{capacity}MiB of {kind}".format( | ||
4127 | 174 | capacity=capacity >> 20, kind=kind) | ||
4128 | 175 | device = {} | ||
4129 | 176 | device['description'] = description | ||
4130 | 177 | device['attributes'] = {'capacity': str(capacity), 'kind': kind} | ||
4131 | 178 | device['device_type'] = "device.mem" | ||
4132 | 179 | devices.append(device) | ||
4133 | 180 | except IOError: | ||
4134 | 181 | print >> sys.stderr, "WARNING: Could not read memory information" | ||
4135 | 182 | return devices | ||
4136 | 183 | |||
4137 | 184 | |||
4138 | 185 | def get_usb_devs(): | ||
4139 | 186 | """ | ||
4140 | 187 | Return a list of usb devices | ||
4141 | 188 | """ | ||
4142 | 189 | pattern = re.compile( | ||
4143 | 190 | "^Bus \d{3} Device \d{3}: ID (?P<vendor_id>[0-9a-f]{4}):" | ||
4144 | 191 | "(?P<product_id>[0-9a-f]{4}) (?P<description>.*)$") | ||
4145 | 192 | devices = [] | ||
4146 | 193 | try: | ||
4147 | 194 | for line in Popen('lsusb', stdout=PIPE).communicate()[0].splitlines(): | ||
4148 | 195 | match = pattern.match(line) | ||
4149 | 196 | if match: | ||
4150 | 197 | vendor_id, product_id, description = match.groups() | ||
4151 | 198 | attributes = {} | ||
4152 | 199 | device = {} | ||
4153 | 200 | attributes['vendor_id'] = int(vendor_id, 16) | ||
4154 | 201 | attributes['product_id'] = int(product_id, 16) | ||
4155 | 202 | device['attributes'] = attributes | ||
4156 | 203 | device['description'] = description | ||
4157 | 204 | device['device_type'] = 'device.usb' | ||
4158 | 205 | devices.append(device) | ||
4159 | 206 | except OSError: | ||
4160 | 207 | print >> sys.stderr, "WARNING: Could not read usb device information, \ | ||
4161 | 208 | unable to run lsusb, please install usbutils package" | ||
4162 | 209 | return devices | ||
4163 | 210 | |||
4164 | 211 | |||
4165 | 212 | def get_hardware_context(): | ||
4166 | 213 | """ | ||
4167 | 214 | Return a dict with all of the hardware profile information gathered | ||
4168 | 215 | """ | ||
4169 | 216 | hardware_context = {} | ||
4170 | 217 | devices = [] | ||
4171 | 218 | devices.extend(get_cpu_devs()) | ||
4172 | 219 | devices.extend(get_board_devs()) | ||
4173 | 220 | devices.extend(get_mem_devs()) | ||
4174 | 221 | devices.extend(get_usb_devs()) | ||
4175 | 222 | hardware_context['devices'] = devices | ||
4176 | 223 | return hardware_context | ||
4177 | 0 | 224 | ||
4178 | === added file 'lava_test/core/installers.py' | |||
4179 | --- lava_test/core/installers.py 1970-01-01 00:00:00 +0000 | |||
4180 | +++ lava_test/core/installers.py 2011-09-13 22:44:36 +0000 | |||
4181 | @@ -0,0 +1,105 @@ | |||
4182 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
4183 | 2 | # | ||
4184 | 3 | # This program is free software: you can redistribute it and/or modify | ||
4185 | 4 | # it under the terms of the GNU General Public License as published by | ||
4186 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
4187 | 6 | # (at your option) any later version. | ||
4188 | 7 | # | ||
4189 | 8 | # This program is distributed in the hope that it will be useful, | ||
4190 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4191 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4192 | 11 | # GNU General Public License for more details. | ||
4193 | 12 | # | ||
4194 | 13 | # You should have received a copy of the GNU General Public License | ||
4195 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4196 | 15 | |||
4197 | 16 | import hashlib | ||
4198 | 17 | import os | ||
4199 | 18 | |||
4200 | 19 | from lava_test.api.delegates import ITestInstaller | ||
4201 | 20 | from lava_test.extcmd import ExternalCommandWithDelegate | ||
4202 | 21 | from lava_test.utils import geturl | ||
4203 | 22 | |||
4204 | 23 | |||
4205 | 24 | class TestInstaller(ITestInstaller): | ||
4206 | 25 | """ | ||
4207 | 26 | Base class for defining an installer object. | ||
4208 | 27 | |||
4209 | 28 | This class can be used as-is for simple installers, or extended | ||
4210 | 29 | for more advanced functionality. | ||
4211 | 30 | |||
4212 | 31 | :ivar steps: | ||
4213 | 32 | List of steps to be executed in a shell | ||
4214 | 33 | |||
4215 | 34 | :ivar deps: | ||
4216 | 35 | List of Debian or Ubuntu packages to apt-get install before running the | ||
4217 | 36 | steps. | ||
4218 | 37 | |||
4219 | 38 | :ivar url: | ||
4220 | 39 | Location from which the test suite should be downloaded. | ||
4221 | 40 | |||
4222 | 41 | :ivar md5: | ||
4223 | 42 | The md5sum to check the integrety of the download | ||
4224 | 43 | """ | ||
4225 | 44 | def __init__(self, steps=None, deps=None, url=None, md5=None, **kwargs): | ||
4226 | 45 | self.steps = steps or [] | ||
4227 | 46 | self.deps = deps or [] | ||
4228 | 47 | self.url = url | ||
4229 | 48 | self.md5 = md5 | ||
4230 | 49 | |||
4231 | 50 | def __repr__(self): | ||
4232 | 51 | return "<%s steps=%r deps=%r url=%r md5=%r>" % ( | ||
4233 | 52 | self.__class__.__name__, | ||
4234 | 53 | self.steps, self.deps, self.url, self.md5) | ||
4235 | 54 | |||
4236 | 55 | def _run_shell_cmd(self, cmd, observer): | ||
4237 | 56 | if observer: observer.about_to_run_shell_command(cmd) | ||
4238 | 57 | extcmd = ExternalCommandWithDelegate(observer) | ||
4239 | 58 | returncode = extcmd.check_call(cmd, shell=True) | ||
4240 | 59 | if observer: observer.did_run_shell_command(cmd, returncode) | ||
4241 | 60 | |||
4242 | 61 | def _installdeps(self, observer): | ||
4243 | 62 | if self.deps: | ||
4244 | 63 | if observer: observer.about_to_install_packages(self.deps) | ||
4245 | 64 | # XXX: Possible point of target-specific package installation | ||
4246 | 65 | cmd = "sudo apt-get install -y " + " ".join(self.deps) | ||
4247 | 66 | self._run_shell_cmd(cmd, observer) | ||
4248 | 67 | if observer: observer.did_install_packages(self.deps) | ||
4249 | 68 | |||
4250 | 69 | def _download(self, observer): | ||
4251 | 70 | """ | ||
4252 | 71 | Download the file specified by the url and check the md5. | ||
4253 | 72 | |||
4254 | 73 | Returns the path and filename if successful, otherwise return None | ||
4255 | 74 | """ | ||
4256 | 75 | if not self.url: | ||
4257 | 76 | return | ||
4258 | 77 | if observer: observer.about_to_download_file(self.url) | ||
4259 | 78 | filename = geturl(self.url) | ||
4260 | 79 | # If the file does not exist, then the download was not | ||
4261 | 80 | # successful | ||
4262 | 81 | if not os.path.exists(filename): | ||
4263 | 82 | raise RuntimeError( | ||
4264 | 83 | "Failed to download %r" % self.url) | ||
4265 | 84 | if observer: observer.did_download_file(self.url) | ||
4266 | 85 | if self.md5: | ||
4267 | 86 | checkmd5 = hashlib.md5() | ||
4268 | 87 | with open(filename, 'rb') as fd: | ||
4269 | 88 | data = fd.read(0x10000) | ||
4270 | 89 | while data: | ||
4271 | 90 | checkmd5.update(data) | ||
4272 | 91 | data = fd.read(0x10000) | ||
4273 | 92 | if checkmd5.hexdigest() != self.md5: | ||
4274 | 93 | raise RuntimeError( | ||
4275 | 94 | "md5sum mismatch of file %r, got %s expected %s" % ( | ||
4276 | 95 | filename, checkmd5.hexdigest(), self.md5)) | ||
4277 | 96 | return filename | ||
4278 | 97 | |||
4279 | 98 | def _runsteps(self, observer): | ||
4280 | 99 | for cmd in self.steps: | ||
4281 | 100 | self._run_shell_cmd(cmd, observer) | ||
4282 | 101 | |||
4283 | 102 | def install(self, observer=None): | ||
4284 | 103 | self._installdeps(observer) | ||
4285 | 104 | self._download(observer) | ||
4286 | 105 | self._runsteps(observer) | ||
4287 | 0 | 106 | ||
4288 | === added file 'lava_test/core/loader.py' | |||
4289 | --- lava_test/core/loader.py 1970-01-01 00:00:00 +0000 | |||
4290 | +++ lava_test/core/loader.py 2011-09-13 22:44:36 +0000 | |||
4291 | @@ -0,0 +1,83 @@ | |||
4292 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
4293 | 2 | # | ||
4294 | 3 | # This program is free software: you can redistribute it and/or modify | ||
4295 | 4 | # it under the terms of the GNU General Public License as published by | ||
4296 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
4297 | 6 | # (at your option) any later version. | ||
4298 | 7 | # | ||
4299 | 8 | # This program is distributed in the hope that it will be useful, | ||
4300 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4301 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4302 | 11 | # GNU General Public License for more details. | ||
4303 | 12 | # | ||
4304 | 13 | # You should have received a copy of the GNU General Public License | ||
4305 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4306 | 15 | |||
4307 | 16 | from __future__ import absolute_import | ||
4308 | 17 | from lava_test.core.config import get_config | ||
4309 | 18 | |||
4310 | 19 | class TestLoader(object): | ||
4311 | 20 | """ | ||
4312 | 21 | Test loader. | ||
4313 | 22 | |||
4314 | 23 | Encapsulates LAVA Test's knowledge of available tests. | ||
4315 | 24 | |||
4316 | 25 | Test can be loaded by name with | ||
4317 | 26 | :meth:`lava_test.core.loader.TestLoader.__getitem__()`. Test can also be | ||
4318 | 27 | listed by :meth:`lava_test.core.loader.TestLoader.get_providers()` and then | ||
4319 | 28 | iterating over tests returned by each provider. | ||
4320 | 29 | """ | ||
4321 | 30 | |||
4322 | 31 | def __init__(self, config): | ||
4323 | 32 | self._config = config | ||
4324 | 33 | |||
4325 | 34 | def get_providers(self): | ||
4326 | 35 | """ | ||
4327 | 36 | Return a generator of available providers | ||
4328 | 37 | """ | ||
4329 | 38 | import pkg_resources | ||
4330 | 39 | for provider_info in self._config.registry.get("providers", []): | ||
4331 | 40 | entry_point_name = provider_info.get("entry_point") | ||
4332 | 41 | module_name, attrs = entry_point_name.split(':', 1) | ||
4333 | 42 | attrs = attrs.split('.') | ||
4334 | 43 | try: | ||
4335 | 44 | entry_point = pkg_resources.EntryPoint( | ||
4336 | 45 | entry_point_name, module_name, attrs, | ||
4337 | 46 | dist=pkg_resources.get_distribution("lava-test")) | ||
4338 | 47 | provider_cls = entry_point.load() | ||
4339 | 48 | provider = provider_cls(provider_info.get("config", {})) | ||
4340 | 49 | yield provider | ||
4341 | 50 | except pkg_resources.DistributionNotFound: | ||
4342 | 51 | raise RuntimeError( | ||
4343 | 52 | "lava-test is not properly set up." | ||
4344 | 53 | " Please read the README file") | ||
4345 | 54 | except ImportError, err: | ||
4346 | 55 | print "Couldn't load module : %s . Maybe configuration needs to be updated" % module_name | ||
4347 | 56 | print "The configuration is stored at %s" %(get_config().configdir) | ||
4348 | 57 | |||
4349 | 58 | |||
4350 | 59 | |||
4351 | 60 | def __getitem__(self, test_id): | ||
4352 | 61 | """ | ||
4353 | 62 | Lookup a test with the specified test_id | ||
4354 | 63 | """ | ||
4355 | 64 | for provider in self.get_providers(): | ||
4356 | 65 | try: | ||
4357 | 66 | return provider[test_id] | ||
4358 | 67 | except KeyError: | ||
4359 | 68 | pass | ||
4360 | 69 | raise KeyError(test_id) | ||
4361 | 70 | |||
4362 | 71 | def get_test_by_name(self, test_id): | ||
4363 | 72 | """ | ||
4364 | 73 | Lookup a test with the specified name | ||
4365 | 74 | |||
4366 | 75 | .. deprecated:: 0.2 | ||
4367 | 76 | Use __getitem__ instead | ||
4368 | 77 | """ | ||
4369 | 78 | for provider in self.get_providers(): | ||
4370 | 79 | try: | ||
4371 | 80 | return provider[test_id] | ||
4372 | 81 | except KeyError: | ||
4373 | 82 | pass | ||
4374 | 83 | raise ValueError("No such test %r" % test_id) | ||
4375 | 0 | 84 | ||
4376 | === added file 'lava_test/core/parsers.py' | |||
4377 | --- lava_test/core/parsers.py 1970-01-01 00:00:00 +0000 | |||
4378 | +++ lava_test/core/parsers.py 2011-09-13 22:44:36 +0000 | |||
4379 | @@ -0,0 +1,147 @@ | |||
4380 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
4381 | 2 | # | ||
4382 | 3 | # This program is free software: you can redistribute it and/or modify | ||
4383 | 4 | # it under the terms of the GNU General Public License as published by | ||
4384 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
4385 | 6 | # (at your option) any later version. | ||
4386 | 7 | # | ||
4387 | 8 | # This program is distributed in the hope that it will be useful, | ||
4388 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4389 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4390 | 11 | # GNU General Public License for more details. | ||
4391 | 12 | # | ||
4392 | 13 | # You should have received a copy of the GNU General Public License | ||
4393 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4394 | 15 | |||
4395 | 16 | import decimal | ||
4396 | 17 | import os | ||
4397 | 18 | import re | ||
4398 | 19 | |||
4399 | 20 | from lava_test.api.delegates import ITestParser | ||
4400 | 21 | |||
4401 | 22 | |||
4402 | 23 | class TestParser(ITestParser): | ||
4403 | 24 | """ | ||
4404 | 25 | Base class for defining a test parser | ||
4405 | 26 | |||
4406 | 27 | This class can be used as-is for simple results parsers, but will likely | ||
4407 | 28 | need to be extended slightly for many. If used as it is, the parse() | ||
4408 | 29 | method should be called while already in the results directory and assumes | ||
4409 | 30 | that a file for test output will exist called testoutput.log. | ||
4410 | 31 | |||
4411 | 32 | :ivar pattern: | ||
4412 | 33 | regexp pattern to identify important elements of test output For | ||
4413 | 34 | example: If your testoutput had lines that look like: "test01: PASS" | ||
4414 | 35 | then you could use a pattern like this: | ||
4415 | 36 | "^(?P<testid>\w+):\W+(?P<result>\w+)" This would result in | ||
4416 | 37 | identifying "test01" as testid and "PASS" as result. Once parse() | ||
4417 | 38 | has been called, self.results.test_results[] contains a list of | ||
4418 | 39 | dicts of all the key,value pairs found for each test result. | ||
4419 | 40 | |||
4420 | 41 | :ivar fixupdict: | ||
4421 | 42 | Dict of strings to convert test results to standard strings For | ||
4422 | 43 | example: if you want to standardize on having pass/fail results in | ||
4423 | 44 | lower case, but your test outputs them in upper case, you could use a | ||
4424 | 45 | fixupdict of something like: {'PASS':'pass','FAIL':'fail'} | ||
4425 | 46 | |||
4426 | 47 | :ivar appendall: | ||
4427 | 48 | Append a dict to the test_results entry for each result. | ||
4428 | 49 | For example: if you would like to add units="MB/s" to each result: | ||
4429 | 50 | appendall={'units':'MB/s'} | ||
4430 | 51 | |||
4431 | 52 | :ivar results: | ||
4432 | 53 | Dictionary of data that was scrubbed from the log file for this test | ||
4433 | 54 | run. Most notably it contains the test_results array. | ||
4434 | 55 | """ | ||
4435 | 56 | def __init__(self, pattern=None, fixupdict=None, appendall={}): | ||
4436 | 57 | if pattern is not None: | ||
4437 | 58 | try: | ||
4438 | 59 | re.compile(pattern) | ||
4439 | 60 | except Exception as ex: | ||
4440 | 61 | raise ValueError( | ||
4441 | 62 | "Invalid regular expression %r: %s", pattern, ex) | ||
4442 | 63 | self._results = {'test_results': []} | ||
4443 | 64 | self.pattern = pattern | ||
4444 | 65 | self.fixupdict = fixupdict | ||
4445 | 66 | self.appendall = appendall | ||
4446 | 67 | |||
4447 | 68 | def __repr__(self): | ||
4448 | 69 | return "<%s pattern=%r fixupdict=%r appendall=%r>" % ( | ||
4449 | 70 | self.__class__.__name__, | ||
4450 | 71 | self.pattern, self.fixupdict, self.appendall) | ||
4451 | 72 | |||
4452 | 73 | @property | ||
4453 | 74 | def results(self): | ||
4454 | 75 | return self._results | ||
4455 | 76 | |||
4456 | 77 | def parse(self, artifacts): | ||
4457 | 78 | if os.path.exists(artifacts.stdout_pathname): | ||
4458 | 79 | return self.parse_pathname( | ||
4459 | 80 | artifacts.stdout_pathname, | ||
4460 | 81 | os.path.relpath(artifacts.stdout_pathname, | ||
4461 | 82 | artifacts.results_dir)) | ||
4462 | 83 | if os.path.exists(artifacts.stderr_pathname): | ||
4463 | 84 | return self.parse_pathname( | ||
4464 | 85 | artifacts.stderr_pathname, | ||
4465 | 86 | os.path.relpath(artifacts.stderr_pathname, | ||
4466 | 87 | artifacts.results_dir)) | ||
4467 | 88 | |||
4468 | 89 | def parse_pathname(self, pathname, relative_pathname=None): | ||
4469 | 90 | with open(pathname, 'rt') as stream: | ||
4470 | 91 | for lineno, line in enumerate(stream, 1): | ||
4471 | 92 | match = re.search(self.pattern, line) | ||
4472 | 93 | if not match: | ||
4473 | 94 | continue | ||
4474 | 95 | data = match.groupdict() | ||
4475 | 96 | data["log_filename"] = relative_pathname or pathname | ||
4476 | 97 | data["log_lineno"] = lineno | ||
4477 | 98 | self._results['test_results'].append( | ||
4478 | 99 | self.analyze_test_result(data)) | ||
4479 | 100 | return self.results | ||
4480 | 101 | |||
4481 | 102 | @property | ||
4482 | 103 | def badchars(self): | ||
4483 | 104 | return "[^a-zA-Z0-9\._-]" | ||
4484 | 105 | |||
4485 | 106 | def analyze_test_result(self, data): | ||
4486 | 107 | """ | ||
4487 | 108 | Analyze sigle match (typically single line) and convert it into a | ||
4488 | 109 | proper test result object. | ||
4489 | 110 | |||
4490 | 111 | Currently this method does the following transformations: | ||
4491 | 112 | * measurement is converted to decimal if present | ||
4492 | 113 | * test_case_id is rewritten to strip badchars | ||
4493 | 114 | * test_case_id is rewritten to convert spaces to underscores | ||
4494 | 115 | * result is transformed using fixuptdict, if defined | ||
4495 | 116 | * appendall information is added, if defined | ||
4496 | 117 | """ | ||
4497 | 118 | if 'measurement' in data: | ||
4498 | 119 | try: | ||
4499 | 120 | data['measurement'] = decimal.Decimal(data['measurement']) | ||
4500 | 121 | except decimal.InvalidOperation: | ||
4501 | 122 | del data['measurement'] | ||
4502 | 123 | if 'test_case_id' in data: | ||
4503 | 124 | data['test_case_id'] = re.sub(self.badchars, "", | ||
4504 | 125 | data['test_case_id']) | ||
4505 | 126 | data['test_case_id'] = data['test_case_id'].replace(" ", "_") | ||
4506 | 127 | if 'result' in data and self.fixupdict: | ||
4507 | 128 | data['result'] = self.fixupdict[data['result']] | ||
4508 | 129 | if self.appendall: | ||
4509 | 130 | data.update(self.appendall) | ||
4510 | 131 | return data | ||
4511 | 132 | |||
4512 | 133 | |||
4513 | 134 | class NativeTestParser(ITestParser): | ||
4514 | 135 | """ | ||
4515 | 136 | Unfinished native test parser. | ||
4516 | 137 | |||
4517 | 138 | This was meant to be a pass-through for tests that directly create bundles | ||
4518 | 139 | """ | ||
4519 | 140 | def __init__(self, test_def): | ||
4520 | 141 | self.test_def = test_def | ||
4521 | 142 | |||
4522 | 143 | def parse(self, artifacts): | ||
4523 | 144 | raise NotImplementedError() | ||
4524 | 145 | |||
4525 | 146 | def results(self): | ||
4526 | 147 | raise NotImplementedError() | ||
4527 | 0 | 148 | ||
4528 | === added file 'lava_test/core/providers.py' | |||
4529 | --- lava_test/core/providers.py 1970-01-01 00:00:00 +0000 | |||
4530 | +++ lava_test/core/providers.py 2011-09-13 22:44:36 +0000 | |||
4531 | @@ -0,0 +1,165 @@ | |||
4532 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
4533 | 2 | # | ||
4534 | 3 | # This program is free software: you can redistribute it and/or modify | ||
4535 | 4 | # it under the terms of the GNU General Public License as published by | ||
4536 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
4537 | 6 | # (at your option) any later version. | ||
4538 | 7 | # | ||
4539 | 8 | # This program is distributed in the hope that it will be useful, | ||
4540 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4541 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4542 | 11 | # GNU General Public License for more details. | ||
4543 | 12 | # | ||
4544 | 13 | # You should have received a copy of the GNU General Public License | ||
4545 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4546 | 15 | |||
4547 | 16 | from lava_test.api.core import ITestProvider | ||
4548 | 17 | from lava_test.core.config import get_config | ||
4549 | 18 | from lava_test.core.tests import DeclarativeTest | ||
4550 | 19 | from lava_test.utils import Cache | ||
4551 | 20 | |||
4552 | 21 | |||
4553 | 22 | class BuiltInProvider(ITestProvider): | ||
4554 | 23 | """ | ||
4555 | 24 | Test provider that provides tests shipped in the Lava-Test source tree | ||
4556 | 25 | """ | ||
4557 | 26 | |||
4558 | 27 | _builtin_tests = [ | ||
4559 | 28 | 'glmemperf', | ||
4560 | 29 | 'gmpbench', | ||
4561 | 30 | 'gtkperf', | ||
4562 | 31 | 'ltp', | ||
4563 | 32 | 'posixtestsuite', | ||
4564 | 33 | 'pwrmgmt', | ||
4565 | 34 | 'stream', | ||
4566 | 35 | 'tiobench', | ||
4567 | 36 | 'x11perf', | ||
4568 | 37 | ] | ||
4569 | 38 | |||
4570 | 39 | def __init__(self, config): | ||
4571 | 40 | pass | ||
4572 | 41 | |||
4573 | 42 | @property | ||
4574 | 43 | def description(self): | ||
4575 | 44 | return "Tests built directly into LAVA Test:" | ||
4576 | 45 | |||
4577 | 46 | def __iter__(self): | ||
4578 | 47 | return iter(self._builtin_tests) | ||
4579 | 48 | |||
4580 | 49 | def __getitem__(self, test_id): | ||
4581 | 50 | if test_id not in self._builtin_tests: | ||
4582 | 51 | raise KeyError(test_id) | ||
4583 | 52 | module = __import__("lava_test.test_definitions.%s" % test_id, | ||
4584 | 53 | fromlist=['']) | ||
4585 | 54 | return module.testobj | ||
4586 | 55 | |||
4587 | 56 | |||
4588 | 57 | class PkgResourcesProvider(ITestProvider): | ||
4589 | 58 | """ | ||
4590 | 59 | Test provider that provides tests declared in pkg_resources working_set | ||
4591 | 60 | |||
4592 | 61 | By default it looks at the 'lava_test.test_definitions' name space but it can | ||
4593 | 62 | be changed with custom 'namespace' configuration entry. | ||
4594 | 63 | """ | ||
4595 | 64 | |||
4596 | 65 | def __init__(self, config): | ||
4597 | 66 | self._config = config | ||
4598 | 67 | |||
4599 | 68 | @property | ||
4600 | 69 | def namespace(self): | ||
4601 | 70 | return self._config.get("namespace", "lava_test.test_definitions") | ||
4602 | 71 | |||
4603 | 72 | @property | ||
4604 | 73 | def description(self): | ||
4605 | 74 | return ("Tests provided by installed python packages" | ||
4606 | 75 | " (from namespace {0}):").format(self.namespace) | ||
4607 | 76 | |||
4608 | 77 | def __iter__(self): | ||
4609 | 78 | from pkg_resources import working_set | ||
4610 | 79 | for entry_point in working_set.iter_entry_points(self.namespace): | ||
4611 | 80 | yield entry_point.name | ||
4612 | 81 | |||
4613 | 82 | def __getitem__(self, test_name): | ||
4614 | 83 | from pkg_resources import working_set | ||
4615 | 84 | for entry_point in working_set.iter_entry_points(self.namespace, | ||
4616 | 85 | test_name): | ||
4617 | 86 | return entry_point.load().testobj | ||
4618 | 87 | raise KeyError(test_name) | ||
4619 | 88 | |||
4620 | 89 | |||
4621 | 90 | class RegistryProvider(ITestProvider): | ||
4622 | 91 | """ | ||
4623 | 92 | Test provider that provides declarative tests listed in the test registry. | ||
4624 | 93 | """ | ||
4625 | 94 | def __init__(self, config): | ||
4626 | 95 | self._config = config | ||
4627 | 96 | self._cache = None | ||
4628 | 97 | |||
4629 | 98 | @property | ||
4630 | 99 | def entries(self): | ||
4631 | 100 | """ | ||
4632 | 101 | List of URLs to DeclarativeTest description files | ||
4633 | 102 | """ | ||
4634 | 103 | return self._config.get("entries", []) | ||
4635 | 104 | |||
4636 | 105 | @property | ||
4637 | 106 | def description(self): | ||
4638 | 107 | return "Tests provided by LAVA Test registry:" | ||
4639 | 108 | |||
4640 | 109 | @classmethod | ||
4641 | 110 | def register_remote_test(self, test_url): | ||
4642 | 111 | config = get_config() # This is a different config object from | ||
4643 | 112 | # self._config | ||
4644 | 113 | provider_config = config.get_provider_config( | ||
4645 | 114 | "lava_test.core.providers:RegistryProvider") | ||
4646 | 115 | if "entries" not in provider_config: | ||
4647 | 116 | provider_config["entries"] = [] | ||
4648 | 117 | if test_url not in provider_config["entries"]: | ||
4649 | 118 | provider_config["entries"].append(test_url) | ||
4650 | 119 | config._save_registry() | ||
4651 | 120 | else: | ||
4652 | 121 | raise ValueError("This test is already registered") | ||
4653 | 122 | |||
4654 | 123 | @classmethod | ||
4655 | 124 | def unregister_remote_test(self, test_url): | ||
4656 | 125 | config = get_config() # This is a different config object from | ||
4657 | 126 | # self._config | ||
4658 | 127 | provider_config = config.get_provider_config( | ||
4659 | 128 | "lava_test.core.providers:RegistryProvider") | ||
4660 | 129 | if "entries" not in provider_config: | ||
4661 | 130 | provider_config["entries"] = [] | ||
4662 | 131 | if test_url in provider_config["entries"]: | ||
4663 | 132 | provider_config["entries"].remove(test_url) | ||
4664 | 133 | config._save_registry() | ||
4665 | 134 | else: | ||
4666 | 135 | raise ValueError("This test is not registered") | ||
4667 | 136 | |||
4668 | 137 | def _load_remote_test(self, test_url): | ||
4669 | 138 | """ | ||
4670 | 139 | Load DeclarativeTest from a (possibly cached copy of) test_url | ||
4671 | 140 | """ | ||
4672 | 141 | cache = Cache.get_instance() | ||
4673 | 142 | with cache.open_cached_url(test_url) as stream: | ||
4674 | 143 | return DeclarativeTest.load_from_stream(stream) | ||
4675 | 144 | |||
4676 | 145 | def _fill_cache(self): | ||
4677 | 146 | """ | ||
4678 | 147 | Fill the cache of all remote tests | ||
4679 | 148 | """ | ||
4680 | 149 | if self._cache is not None: | ||
4681 | 150 | return | ||
4682 | 151 | self._cache = {} | ||
4683 | 152 | for test_url in self.entries: | ||
4684 | 153 | test = self._load_remote_test(test_url) | ||
4685 | 154 | if test.test_id in self._cache: | ||
4686 | 155 | raise ValueError("Duplicate test %s declared" % test.test_id) | ||
4687 | 156 | self._cache[test.test_id] = test | ||
4688 | 157 | |||
4689 | 158 | def __iter__(self): | ||
4690 | 159 | self._fill_cache() | ||
4691 | 160 | for test_id in self._cache.iterkeys(): | ||
4692 | 161 | yield test_id | ||
4693 | 162 | |||
4694 | 163 | def __getitem__(self, test_id): | ||
4695 | 164 | self._fill_cache() | ||
4696 | 165 | return self._cache[test_id] | ||
4697 | 0 | 166 | ||
4698 | === added file 'lava_test/core/runners.py' | |||
4699 | --- lava_test/core/runners.py 1970-01-01 00:00:00 +0000 | |||
4700 | +++ lava_test/core/runners.py 2011-09-13 22:44:36 +0000 | |||
4701 | @@ -0,0 +1,66 @@ | |||
4702 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
4703 | 2 | # | ||
4704 | 3 | # This program is free software: you can redistribute it and/or modify | ||
4705 | 4 | # it under the terms of the GNU General Public License as published by | ||
4706 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
4707 | 6 | # (at your option) any later version. | ||
4708 | 7 | # | ||
4709 | 8 | # This program is distributed in the hope that it will be useful, | ||
4710 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4711 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4712 | 11 | # GNU General Public License for more details. | ||
4713 | 12 | # | ||
4714 | 13 | # You should have received a copy of the GNU General Public License | ||
4715 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4716 | 15 | |||
4717 | 16 | import datetime | ||
4718 | 17 | |||
4719 | 18 | from lava_test.api.delegates import ITestRunner | ||
4720 | 19 | from lava_test.extcmd import (DisplayDelegate, ExternalCommandWithDelegate) | ||
4721 | 20 | |||
4722 | 21 | |||
4723 | 22 | class TestRunner(ITestRunner): | ||
4724 | 23 | """ | ||
4725 | 24 | Base class for defining an test runner object. | ||
4726 | 25 | |||
4727 | 26 | This class can be used as-is for simple execution with the expectation that | ||
4728 | 27 | the run() method will be called from the directory where the test was | ||
4729 | 28 | installed. Steps, if used, should handle changing directories from there to | ||
4730 | 29 | the directory where the test was extracted if necessary. This class can | ||
4731 | 30 | also be extended for more advanced functionality. | ||
4732 | 31 | |||
4733 | 32 | :ivar steps: | ||
4734 | 33 | list of shell commands to execute | ||
4735 | 34 | """ | ||
4736 | 35 | def __init__(self, steps=None): | ||
4737 | 36 | self.steps = steps or [] | ||
4738 | 37 | self.testoutput = [] # XXX: is this still used? | ||
4739 | 38 | |||
4740 | 39 | def __repr__(self): | ||
4741 | 40 | return "<%s steps=%r>" % (self.__class__.__name__, self.steps) | ||
4742 | 41 | |||
4743 | 42 | def _run_lava_test_steps(self, artifacts, observer): | ||
4744 | 43 | stdout = open(artifacts.stdout_pathname, 'at') | ||
4745 | 44 | stderr = open(artifacts.stderr_pathname, 'at') | ||
4746 | 45 | delegate = DisplayDelegate(stdout, stderr, observer) | ||
4747 | 46 | extcmd = ExternalCommandWithDelegate(delegate) | ||
4748 | 47 | try: | ||
4749 | 48 | for cmd in self.steps: | ||
4750 | 49 | if observer: observer.about_to_run_shell_command(cmd) | ||
4751 | 50 | returncode = extcmd.call(cmd, shell=True) | ||
4752 | 51 | if observer: observer.did_run_shell_command(cmd, returncode) | ||
4753 | 52 | finally: | ||
4754 | 53 | stdout.close() | ||
4755 | 54 | stderr.close() | ||
4756 | 55 | |||
4757 | 56 | def run(self, artifacts, observer=None): | ||
4758 | 57 | """ | ||
4759 | 58 | Run the test program by executing steps in sequence. | ||
4760 | 59 | |||
4761 | 60 | .. seealso:: | ||
4762 | 61 | |||
4763 | 62 | :meth:`~lava_test.api.delegates.TestRunner.run` | ||
4764 | 63 | """ | ||
4765 | 64 | self.starttime = datetime.datetime.utcnow() | ||
4766 | 65 | self._run_lava_test_steps(artifacts, observer) | ||
4767 | 66 | self.endtime = datetime.datetime.utcnow() | ||
4768 | 0 | 67 | ||
4769 | === added file 'lava_test/core/swprofile.py' | |||
4770 | --- lava_test/core/swprofile.py 1970-01-01 00:00:00 +0000 | |||
4771 | +++ lava_test/core/swprofile.py 2011-09-13 22:44:36 +0000 | |||
4772 | @@ -0,0 +1,72 @@ | |||
4773 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
4774 | 2 | # | ||
4775 | 3 | # This program is free software: you can redistribute it and/or modify | ||
4776 | 4 | # it under the terms of the GNU General Public License as published by | ||
4777 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
4778 | 6 | # (at your option) any later version. | ||
4779 | 7 | # | ||
4780 | 8 | # This program is distributed in the hope that it will be useful, | ||
4781 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4782 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4783 | 11 | # GNU General Public License for more details. | ||
4784 | 12 | # | ||
4785 | 13 | # You should have received a copy of the GNU General Public License | ||
4786 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4787 | 15 | |||
4788 | 16 | import apt | ||
4789 | 17 | |||
4790 | 18 | from lava_test.utils import read_file | ||
4791 | 19 | |||
4792 | 20 | |||
4793 | 21 | def get_packages(apt_cache=None): | ||
4794 | 22 | """ Get information about the packages installed | ||
4795 | 23 | |||
4796 | 24 | apt_cache - if not provided, this will be read from the system | ||
4797 | 25 | """ | ||
4798 | 26 | if apt_cache == None: | ||
4799 | 27 | apt_cache = apt.Cache() | ||
4800 | 28 | packages = [] | ||
4801 | 29 | for apt_pkg in apt_cache: | ||
4802 | 30 | if hasattr(apt_pkg, 'is_installed'): | ||
4803 | 31 | is_installed = apt_pkg.is_installed | ||
4804 | 32 | else: | ||
4805 | 33 | is_installed = apt_pkg.isInstalled # old style API | ||
4806 | 34 | if is_installed: | ||
4807 | 35 | pkg = { | ||
4808 | 36 | "name": apt_pkg.name, | ||
4809 | 37 | "version": apt_pkg.installed.version} | ||
4810 | 38 | packages.append(pkg) | ||
4811 | 39 | return packages | ||
4812 | 40 | |||
4813 | 41 | |||
4814 | 42 | def get_software_context(apt_cache=None, lsb_information=None): | ||
4815 | 43 | """ Return dict used for storing software_context information | ||
4816 | 44 | |||
4817 | 45 | test_id - Unique identifier for this test | ||
4818 | 46 | time_check - whether or not a check was performed to see if | ||
4819 | 47 | the time on the system was synced with a time server | ||
4820 | 48 | apt_cache - if not provided, this will be read from the system | ||
4821 | 49 | lsb_information - if not provided, this will be read from the system | ||
4822 | 50 | """ | ||
4823 | 51 | software_context = {} | ||
4824 | 52 | software_context['image'] = get_image(lsb_information) | ||
4825 | 53 | software_context['packages'] = get_packages(apt_cache) | ||
4826 | 54 | return software_context | ||
4827 | 55 | |||
4828 | 56 | |||
4829 | 57 | def get_image(lsb_information=None): | ||
4830 | 58 | """ Get information about the image we are running | ||
4831 | 59 | |||
4832 | 60 | If /etc/buildstamp exists, get the image id from that. Otherwise | ||
4833 | 61 | just use the lsb-release description for a rough idea. | ||
4834 | 62 | """ | ||
4835 | 63 | try: | ||
4836 | 64 | buildstamp = read_file("/etc/buildstamp") | ||
4837 | 65 | name = buildstamp.splitlines()[1] | ||
4838 | 66 | except IOError: | ||
4839 | 67 | import lsb_release | ||
4840 | 68 | |||
4841 | 69 | if lsb_information == None: | ||
4842 | 70 | lsb_information = lsb_release.get_distro_information() | ||
4843 | 71 | name = lsb_information['DESCRIPTION'] | ||
4844 | 72 | return {"name": name} | ||
4845 | 0 | 73 | ||
4846 | === added file 'lava_test/core/tests.py' | |||
4847 | --- lava_test/core/tests.py 1970-01-01 00:00:00 +0000 | |||
4848 | +++ lava_test/core/tests.py 2011-09-13 22:44:36 +0000 | |||
4849 | @@ -0,0 +1,166 @@ | |||
4850 | 1 | # Copyright (c) 2010, 2011 Linaro | ||
4851 | 2 | # | ||
4852 | 3 | # This program is free software: you can redistribute it and/or modify | ||
4853 | 4 | # it under the terms of the GNU General Public License as published by | ||
4854 | 5 | # the Free Software Foundation, either version 3 of the License, or | ||
4855 | 6 | # (at your option) any later version. | ||
4856 | 7 | # | ||
4857 | 8 | # This program is distributed in the hope that it will be useful, | ||
4858 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4859 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4860 | 11 | # GNU General Public License for more details. | ||
4861 | 12 | # | ||
4862 | 13 | # You should have received a copy of the GNU General Public License | ||
4863 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4864 | 15 | |||
4865 | 16 | from __future__ import absolute_import | ||
4866 | 17 | |||
4867 | 18 | import json | ||
4868 | 19 | import logging | ||
4869 | 20 | import os | ||
4870 | 21 | import shutil | ||
4871 | 22 | |||
4872 | 23 | from lava_test.api.core import ITest | ||
4873 | 24 | from lava_test.core.artifacts import TestArtifacts | ||
4874 | 25 | from lava_test.core.config import get_config | ||
4875 | 26 | from lava_test.core.installers import TestInstaller | ||
4876 | 27 | from lava_test.core.parsers import TestParser, NativeTestParser | ||
4877 | 28 | from lava_test.core.runners import TestRunner | ||
4878 | 29 | from lava_test.utils import changed_directory | ||
4879 | 30 | |||
4880 | 31 | |||
4881 | 32 | class Test(ITest): | ||
4882 | 33 | """ | ||
4883 | 34 | Reusable class for defining tests. | ||
4884 | 35 | |||
4885 | 36 | This class uses composition instead of inheritance. You should be able to | ||
4886 | 37 | customize the parts you care about by providing delegate objects. This | ||
4887 | 38 | class can be used by test definition files to create an object that | ||
4888 | 39 | contains the building blocks for installing tests, running them, and | ||
4889 | 40 | parsing the results. | ||
4890 | 41 | |||
4891 | 42 | :ivar test_id: | ||
4892 | 43 | Name of the test or test suite | ||
4893 | 44 | :ivar test_version: | ||
4894 | 45 | Version of the test or test suite | ||
4895 | 46 | :ivar installer: | ||
4896 | 47 | ITestInstaller instance to use | ||
4897 | 48 | :ivar runner: | ||
4898 | 49 | ITestRunner instance to use | ||
4899 | 50 | :ivar parser: | ||
4900 | 51 | ITestParser instance to use | ||
4901 | 52 | """ | ||
4902 | 53 | |||
4903 | 54 | def __init__(self, test_id, test_version=None, | ||
4904 | 55 | installer=None, runner=None, parser=None): | ||
4905 | 56 | self._test_id = test_id | ||
4906 | 57 | self._test_version = test_version | ||
4907 | 58 | # Delegate objects | ||
4908 | 59 | self.installer = installer | ||
4909 | 60 | self.runner = runner | ||
4910 | 61 | self.parser = parser | ||
4911 | 62 | # Config instance | ||
4912 | 63 | self._config = get_config() | ||
4913 | 64 | |||
4914 | 65 | def __repr__(self): | ||
4915 | 66 | return ("<%s test_id=%r test_version=%r installer=%r runner=%r" | ||
4916 | 67 | " parser=%r>") % ( | ||
4917 | 68 | self.__class__.__name__, self.test_id, self.test_version, | ||
4918 | 69 | self.installer, self.runner, self.parser) | ||
4919 | 70 | |||
4920 | 71 | @property | ||
4921 | 72 | def test_id(self): | ||
4922 | 73 | """ | ||
4923 | 74 | Return the ID of the test. | ||
4924 | 75 | """ | ||
4925 | 76 | return self._test_id | ||
4926 | 77 | |||
4927 | 78 | @property | ||
4928 | 79 | def test_version(self): | ||
4929 | 80 | """ | ||
4930 | 81 | Return the version of the test | ||
4931 | 82 | """ | ||
4932 | 83 | return self._test_version | ||
4933 | 84 | |||
4934 | 85 | @property | ||
4935 | 86 | def install_dir(self): | ||
4936 | 87 | """ | ||
4937 | 88 | Pathname of a directory with binary and data files installed by the | ||
4938 | 89 | test. | ||
4939 | 90 | |||
4940 | 91 | .. versionadded:: 0.2 | ||
4941 | 92 | """ | ||
4942 | 93 | return os.path.join(self._config.installdir, self.test_id) | ||
4943 | 94 | |||
4944 | 95 | @property | ||
4945 | 96 | def is_installed(self): | ||
4946 | 97 | return os.path.exists(self.install_dir) | ||
4947 | 98 | |||
4948 | 99 | def install(self, observer=None): | ||
4949 | 100 | if self.is_installed: | ||
4950 | 101 | raise RuntimeError( | ||
4951 | 102 | "%s is already installed" % self.test_id) | ||
4952 | 103 | if not self.installer: | ||
4953 | 104 | raise RuntimeError( | ||
4954 | 105 | "no installer defined for '%s'" % self.test_id) | ||
4955 | 106 | with changed_directory(self.install_dir): | ||
4956 | 107 | try: | ||
4957 | 108 | logging.debug( | ||
4958 | 109 | "Invoking %r.install(...)", self.installer) | ||
4959 | 110 | self.installer.install(observer) | ||
4960 | 111 | except: | ||
4961 | 112 | self.uninstall() | ||
4962 | 113 | raise | ||
4963 | 114 | |||
4964 | 115 | def uninstall(self): | ||
4965 | 116 | logging.debug("Removing test %r", self.test_id) | ||
4966 | 117 | if os.path.exists(self.install_dir): | ||
4967 | 118 | shutil.rmtree(self.install_dir) | ||
4968 | 119 | |||
4969 | 120 | def run(self, observer=None): | ||
4970 | 121 | if not self.runner: | ||
4971 | 122 | raise RuntimeError( | ||
4972 | 123 | "no test runner defined for '%s'" % self.test_id) | ||
4973 | 124 | artifacts = TestArtifacts.allocate(self.test_id, self._config) | ||
4974 | 125 | with changed_directory(self.install_dir): | ||
4975 | 126 | logging.debug( | ||
4976 | 127 | "Invoking %r.run_and_store_artifacts(...)", | ||
4977 | 128 | self.runner, observer) | ||
4978 | 129 | self.runner.run(artifacts, observer) | ||
4979 | 130 | return artifacts | ||
4980 | 131 | |||
4981 | 132 | def parse(self, artifacts): | ||
4982 | 133 | if self.parser: | ||
4983 | 134 | logging.debug("Invoking %r.parse()", self.parser) | ||
4984 | 135 | with changed_directory(artifacts.results_dir, False): | ||
4985 | 136 | self.parser.parse(artifacts) | ||
4986 | 137 | return self.parser.results | ||
4987 | 138 | |||
4988 | 139 | |||
4989 | 140 | class DeclarativeTest(Test): | ||
4990 | 141 | """ | ||
4991 | 142 | Declaretive ITest implementation. | ||
4992 | 143 | |||
4993 | 144 | Declarative test is like :class:`lava_test.core.tests.Test` but cannot | ||
4994 | 145 | contain any python code and is completely encapsulated in a .json file. | ||
4995 | 146 | |||
4996 | 147 | The idea is to write .json files that assemble a Test instance using | ||
4997 | 148 | readily-available TestInstaller, TestRunner and TestParser subclasses. | ||
4998 | 149 | """ | ||
4999 | 150 | |||
5000 | 151 | def __init__(self, about): |
The diff has been truncated for viewing.