Merge lp:~nick-schutt/lava-dispatcher/nick-1130814 into lp:lava-dispatcher
- nick-1130814
- Merge into trunk
Proposed by
Nicholas Schutt
Status: | Merged |
---|---|
Merged at revision: | 568 |
Proposed branch: | lp:~nick-schutt/lava-dispatcher/nick-1130814 |
Merge into: | lp:lava-dispatcher |
Diff against target: |
440 lines (+67/-62) 9 files modified
lava_dispatcher/actions/lava_android_test.py (+4/-5) lava_dispatcher/client/lmc_utils.py (+7/-7) lava_dispatcher/context.py (+24/-1) lava_dispatcher/device/fastmodel.py (+5/-10) lava_dispatcher/device/master.py (+3/-3) lava_dispatcher/device/nexus.py (+6/-13) lava_dispatcher/device/qemu.py (+1/-5) lava_dispatcher/device/sdmux.py (+9/-11) lava_dispatcher/utils.py (+8/-7) |
To merge this branch: | bzr merge lp:~nick-schutt/lava-dispatcher/nick-1130814 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Linaro Validation Team | Pending | ||
Review via email: mp+152326@code.launchpad.net |
Commit message
Description of the change
Ignore the number in the branch name; it's for bug #1127288
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lava_dispatcher/actions/lava_android_test.py' | |||
2 | --- lava_dispatcher/actions/lava_android_test.py 2012-11-22 02:14:51 +0000 | |||
3 | +++ lava_dispatcher/actions/lava_android_test.py 2013-03-08 06:44:20 +0000 | |||
4 | @@ -20,7 +20,6 @@ | |||
5 | 20 | # along with this program; if not, see <http://www.gnu.org/licenses>. | 20 | # along with this program; if not, see <http://www.gnu.org/licenses>. |
6 | 21 | 21 | ||
7 | 22 | import os | 22 | import os |
8 | 23 | import subprocess | ||
9 | 24 | import logging | 23 | import logging |
10 | 25 | from lava_dispatcher.actions import BaseAction | 24 | from lava_dispatcher.actions import BaseAction |
11 | 26 | from lava_dispatcher.errors import OperationFailed, TimeoutError | 25 | from lava_dispatcher.errors import OperationFailed, TimeoutError |
12 | @@ -69,7 +68,7 @@ | |||
13 | 69 | t = DrainConsoleOutput(proc=session._connection, timeout=timeout) | 68 | t = DrainConsoleOutput(proc=session._connection, timeout=timeout) |
14 | 70 | t.start() | 69 | t.start() |
15 | 71 | logging.info("Execute command on host: %s" % (' '.join(cmds))) | 70 | logging.info("Execute command on host: %s" % (' '.join(cmds))) |
17 | 72 | rc = subprocess.call(cmds) | 71 | rc = self.context.run_command(cmds) |
18 | 73 | t.join() | 72 | t.join() |
19 | 74 | if rc == 124: | 73 | if rc == 124: |
20 | 75 | raise TimeoutError( | 74 | raise TimeoutError( |
21 | @@ -132,7 +131,7 @@ | |||
22 | 132 | cmds.insert(0, 'timeout') | 131 | cmds.insert(0, 'timeout') |
23 | 133 | cmds.insert(1, '%ss' % timeout) | 132 | cmds.insert(1, '%ss' % timeout) |
24 | 134 | logging.info("Execute command on host: %s" % (' '.join(cmds))) | 133 | logging.info("Execute command on host: %s" % (' '.join(cmds))) |
26 | 135 | rc = subprocess.call(cmds) | 134 | rc = self.context.run_command(cmds) |
27 | 136 | if rc == 124: | 135 | if rc == 124: |
28 | 137 | raise TimeoutError( | 136 | raise TimeoutError( |
29 | 138 | "The test (%s) on device(%s) times out." % ( | 137 | "The test (%s) on device(%s) times out." % ( |
30 | @@ -180,7 +179,7 @@ | |||
31 | 180 | cmds.insert(1, '%ss' % timeout) | 179 | cmds.insert(1, '%ss' % timeout) |
32 | 181 | 180 | ||
33 | 182 | logging.info("Execute command on host: %s" % (' '.join(cmds))) | 181 | logging.info("Execute command on host: %s" % (' '.join(cmds))) |
35 | 183 | rc = subprocess.call(cmds) | 182 | rc = self.context.run_command(cmds) |
36 | 184 | if rc == 124: | 183 | if rc == 124: |
37 | 185 | raise TimeoutError( | 184 | raise TimeoutError( |
38 | 186 | "Failed to run monkeyrunner test url[%s] " | 185 | "Failed to run monkeyrunner test url[%s] " |
39 | @@ -219,7 +218,7 @@ | |||
40 | 219 | cmds.insert(0, 'timeout') | 218 | cmds.insert(0, 'timeout') |
41 | 220 | cmds.insert(1, '%ss' % timeout) | 219 | cmds.insert(1, '%ss' % timeout) |
42 | 221 | logging.info("Execute command on host: %s" % (' '.join(cmds))) | 220 | logging.info("Execute command on host: %s" % (' '.join(cmds))) |
44 | 222 | rc = subprocess.call(cmds) | 221 | rc = self.context.run_commands(cmds) |
45 | 223 | if rc == 124: | 222 | if rc == 124: |
46 | 224 | raise OperationFailed( | 223 | raise OperationFailed( |
47 | 225 | "The installation of test case(%s)" | 224 | "The installation of test case(%s)" |
48 | 226 | 225 | ||
49 | === modified file 'lava_dispatcher/client/lmc_utils.py' | |||
50 | --- lava_dispatcher/client/lmc_utils.py 2012-11-20 13:34:19 +0000 | |||
51 | +++ lava_dispatcher/client/lmc_utils.py 2013-03-08 06:44:20 +0000 | |||
52 | @@ -50,24 +50,24 @@ | |||
53 | 50 | logging.info("Executing the linaro-media-create command") | 50 | logging.info("Executing the linaro-media-create command") |
54 | 51 | logging.info(cmd) | 51 | logging.info(cmd) |
55 | 52 | 52 | ||
57 | 53 | _run_linaro_media_create(cmd) | 53 | _run_linaro_media_create(client.context, cmd) |
58 | 54 | return image_file | 54 | return image_file |
59 | 55 | 55 | ||
61 | 56 | def generate_fastmodel_image(hwpack, rootfs, odir, bootloader='u_boot', size="2000M"): | 56 | def generate_fastmodel_image(context, hwpack, rootfs, odir, bootloader='u_boot', size="2000M"): |
62 | 57 | cmd = ("flock /var/lock/lava-lmc.lck sudo linaro-media-create " | 57 | cmd = ("flock /var/lock/lava-lmc.lck sudo linaro-media-create " |
63 | 58 | "--dev fastmodel --output-directory %s --image-size %s " | 58 | "--dev fastmodel --output-directory %s --image-size %s " |
64 | 59 | "--hwpack %s --binary %s --hwpack-force-yes --bootloader %s" % | 59 | "--hwpack %s --binary %s --hwpack-force-yes --bootloader %s" % |
65 | 60 | (odir, size, hwpack, rootfs, bootloader) ) | 60 | (odir, size, hwpack, rootfs, bootloader) ) |
66 | 61 | logging.info("Generating fastmodel image with: %s" % cmd) | 61 | logging.info("Generating fastmodel image with: %s" % cmd) |
68 | 62 | _run_linaro_media_create(cmd) | 62 | _run_linaro_media_create(context, cmd) |
69 | 63 | 63 | ||
71 | 64 | def generate_android_image(device, boot, data, system, ofile, size="2000M"): | 64 | def generate_android_image(context, device, boot, data, system, ofile, size="2000M"): |
72 | 65 | cmd = ("flock /var/lock/lava-lmc.lck linaro-android-media-create " | 65 | cmd = ("flock /var/lock/lava-lmc.lck linaro-android-media-create " |
73 | 66 | "--dev %s --image_file %s --image_size %s " | 66 | "--dev %s --image_file %s --image_size %s " |
74 | 67 | "--boot %s --userdata %s --system %s" % | 67 | "--boot %s --userdata %s --system %s" % |
75 | 68 | (device, ofile, size, boot, data, system) ) | 68 | (device, ofile, size, boot, data, system) ) |
76 | 69 | logging.info("Generating android image with: %s" % cmd) | 69 | logging.info("Generating android image with: %s" % cmd) |
78 | 70 | _run_linaro_media_create(cmd) | 70 | _run_linaro_media_create(context, cmd) |
79 | 71 | 71 | ||
80 | 72 | def get_partition_offset(image, partno): | 72 | def get_partition_offset(image, partno): |
81 | 73 | cmd = 'parted %s -m -s unit b print' % image | 73 | cmd = 'parted %s -m -s unit b print' % image |
82 | @@ -97,10 +97,10 @@ | |||
83 | 97 | logging_system('sudo umount ' + mntdir) | 97 | logging_system('sudo umount ' + mntdir) |
84 | 98 | logging_system('rm -rf ' + mntdir) | 98 | logging_system('rm -rf ' + mntdir) |
85 | 99 | 99 | ||
87 | 100 | def _run_linaro_media_create(cmd): | 100 | def _run_linaro_media_create(context, cmd): |
88 | 101 | """Run linaro-media-create and accept licenses thrown up in the process. | 101 | """Run linaro-media-create and accept licenses thrown up in the process. |
89 | 102 | """ | 102 | """ |
91 | 103 | proc = pexpect.spawn(cmd, logfile=sys.stdout) | 103 | proc = context.spawn(cmd) |
92 | 104 | 104 | ||
93 | 105 | # This code is a bit out of control. It describes a state machine. Each | 105 | # This code is a bit out of control. It describes a state machine. Each |
94 | 106 | # state has a name, a mapping patterns to wait for -> state to move to, a | 106 | # state has a name, a mapping patterns to wait for -> state to move to, a |
95 | 107 | 107 | ||
96 | === modified file 'lava_dispatcher/context.py' | |||
97 | --- lava_dispatcher/context.py 2013-01-23 23:10:37 +0000 | |||
98 | +++ lava_dispatcher/context.py 2013-03-08 06:44:20 +0000 | |||
99 | @@ -21,13 +21,17 @@ | |||
100 | 21 | import atexit | 21 | import atexit |
101 | 22 | import logging | 22 | import logging |
102 | 23 | import os | 23 | import os |
103 | 24 | import subprocess | ||
104 | 24 | import sys | 25 | import sys |
105 | 25 | import tempfile | 26 | import tempfile |
106 | 26 | 27 | ||
107 | 27 | from lava_dispatcher.config import get_device_config | 28 | from lava_dispatcher.config import get_device_config |
108 | 28 | from lava_dispatcher.client.targetdevice import TargetBasedClient | 29 | from lava_dispatcher.client.targetdevice import TargetBasedClient |
109 | 29 | from lava_dispatcher.test_data import LavaTestData | 30 | from lava_dispatcher.test_data import LavaTestData |
111 | 30 | from lava_dispatcher.utils import rmtree | 31 | from lava_dispatcher.utils import ( |
112 | 32 | logging_spawn, | ||
113 | 33 | rmtree, | ||
114 | 34 | ) | ||
115 | 31 | 35 | ||
116 | 32 | 36 | ||
117 | 33 | def _write_and_flush(fobj, data): | 37 | def _write_and_flush(fobj, data): |
118 | @@ -116,3 +120,22 @@ | |||
119 | 116 | 120 | ||
120 | 117 | def get_device_version(self): | 121 | def get_device_version(self): |
121 | 118 | return self.client.target_device.get_device_version() | 122 | return self.client.target_device.get_device_version() |
122 | 123 | |||
123 | 124 | def spawn(self, command, timeout=30): | ||
124 | 125 | proc = logging_spawn(command, timeout) | ||
125 | 126 | proc.logfile_read = self.logfile_read | ||
126 | 127 | return proc | ||
127 | 128 | |||
128 | 129 | def run_command(self, command, failok=True): | ||
129 | 130 | """run command 'command' with output going to output-dir if specified""" | ||
130 | 131 | if isinstance(command, (str, unicode)): | ||
131 | 132 | command = ['sh', '-c', command] | ||
132 | 133 | output_txt = self.client.context.output.output_txt | ||
133 | 134 | output_args = {'stdout': output_txt, 'stderr': subprocess.STDOUT} | ||
134 | 135 | logging.debug("Executing on host : '%r'" % command) | ||
135 | 136 | if failok: | ||
136 | 137 | rc = subprocess.call(command, **output_args) | ||
137 | 138 | else: | ||
138 | 139 | rc = subprocess.check_call(command, **output_args) | ||
139 | 140 | return rc | ||
140 | 141 | |||
141 | 119 | 142 | ||
142 | === modified file 'lava_dispatcher/device/fastmodel.py' | |||
143 | --- lava_dispatcher/device/fastmodel.py 2013-02-18 02:11:39 +0000 | |||
144 | +++ lava_dispatcher/device/fastmodel.py 2013-03-08 06:44:20 +0000 | |||
145 | @@ -25,8 +25,6 @@ | |||
146 | 25 | import os | 25 | import os |
147 | 26 | import shutil | 26 | import shutil |
148 | 27 | import stat | 27 | import stat |
149 | 28 | import threading | ||
150 | 29 | import re | ||
151 | 30 | import subprocess | 28 | import subprocess |
152 | 31 | 29 | ||
153 | 32 | import lava_dispatcher.device.boot_options as boot_options | 30 | import lava_dispatcher.device.boot_options as boot_options |
154 | @@ -107,7 +105,7 @@ | |||
155 | 107 | self._sd_image = '%s/android.img' % os.path.dirname(self._system) | 105 | self._sd_image = '%s/android.img' % os.path.dirname(self._system) |
156 | 108 | 106 | ||
157 | 109 | generate_android_image( | 107 | generate_android_image( |
159 | 110 | 'vexpress-a9', self._boot, self._data, self._system, self._sd_image | 108 | self.context, 'vexpress-a9', self._boot, self._data, self._system, self._sd_image |
160 | 111 | ) | 109 | ) |
161 | 112 | 110 | ||
162 | 113 | self._copy_axf(self.config.boot_part, '') | 111 | self._copy_axf(self.config.boot_part, '') |
163 | @@ -119,7 +117,7 @@ | |||
164 | 119 | rootfs = download_image(rootfs, self.context, decompress=False) | 117 | rootfs = download_image(rootfs, self.context, decompress=False) |
165 | 120 | odir = os.path.dirname(rootfs) | 118 | odir = os.path.dirname(rootfs) |
166 | 121 | 119 | ||
168 | 122 | generate_fastmodel_image(hwpack, rootfs, odir, bootloader) | 120 | generate_fastmodel_image(self.context, hwpack, rootfs, odir, bootloader) |
169 | 123 | self._sd_image = '%s/sd.img' % odir | 121 | self._sd_image = '%s/sd.img' % odir |
170 | 124 | self._axf = None | 122 | self._axf = None |
171 | 125 | for f in self.config.simulator_axf_files: | 123 | for f in self.config.simulator_axf_files: |
172 | @@ -203,10 +201,7 @@ | |||
173 | 203 | # the simulator proc only has stdout/stderr about the simulator | 201 | # the simulator proc only has stdout/stderr about the simulator |
174 | 204 | # we hook up into a telnet port which emulates a serial console | 202 | # we hook up into a telnet port which emulates a serial console |
175 | 205 | logging.info('launching fastmodel with command %r' % sim_cmd) | 203 | logging.info('launching fastmodel with command %r' % sim_cmd) |
180 | 206 | self._sim_proc = logging_spawn( | 204 | self._sim_proc = self.context.spawn(sim_cmd, timeout=1200) |
177 | 207 | sim_cmd, | ||
178 | 208 | logfile=self.context.logfile_read, | ||
179 | 209 | timeout=1200) | ||
181 | 210 | self._sim_proc.expect(self.PORT_PATTERN, timeout=300) | 205 | self._sim_proc.expect(self.PORT_PATTERN, timeout=300) |
182 | 211 | self._serial_port = self._sim_proc.match.groups()[0] | 206 | self._serial_port = self._sim_proc.match.groups()[0] |
183 | 212 | logging.info('serial console port on: %s' % self._serial_port) | 207 | logging.info('serial console port on: %s' % self._serial_port) |
184 | @@ -221,9 +216,9 @@ | |||
185 | 221 | logging.info('simulator is started connecting to serial port') | 216 | logging.info('simulator is started connecting to serial port') |
186 | 222 | self.proc = logging_spawn( | 217 | self.proc = logging_spawn( |
187 | 223 | 'telnet localhost %s' % self._serial_port, | 218 | 'telnet localhost %s' % self._serial_port, |
188 | 224 | logfile=self._create_rtsm_ostream( | ||
189 | 225 | self.context.logfile_read), | ||
190 | 226 | timeout=1200) | 219 | timeout=1200) |
191 | 220 | self.proc.logfile_read = self._create_rtsm_ostream( | ||
192 | 221 | self.proc.logfile_read) | ||
193 | 227 | return self.proc | 222 | return self.proc |
194 | 228 | 223 | ||
195 | 229 | def get_test_data_attachments(self): | 224 | def get_test_data_attachments(self): |
196 | 230 | 225 | ||
197 | === modified file 'lava_dispatcher/device/master.py' | |||
198 | --- lava_dispatcher/device/master.py 2013-01-30 18:45:16 +0000 | |||
199 | +++ lava_dispatcher/device/master.py 2013-03-08 06:44:20 +0000 | |||
200 | @@ -82,9 +82,9 @@ | |||
201 | 82 | self.device_version = None | 82 | self.device_version = None |
202 | 83 | 83 | ||
203 | 84 | if config.pre_connect_command: | 84 | if config.pre_connect_command: |
205 | 85 | logging_system(config.pre_connect_command) | 85 | self.context.run_command(config.pre_connect_command) |
206 | 86 | 86 | ||
208 | 87 | self.proc = connect_to_serial(config, self.context.logfile_read) | 87 | self.proc = connect_to_serial(self.context) |
209 | 88 | 88 | ||
210 | 89 | def get_device_version(self): | 89 | def get_device_version(self): |
211 | 90 | return self.device_version | 90 | return self.device_version |
212 | @@ -397,7 +397,7 @@ | |||
213 | 397 | logging.info("Perform hard reset on the system") | 397 | logging.info("Perform hard reset on the system") |
214 | 398 | self.master_ip = None | 398 | self.master_ip = None |
215 | 399 | if self.config.hard_reset_command != "": | 399 | if self.config.hard_reset_command != "": |
217 | 400 | logging_system(self.config.hard_reset_command) | 400 | self.context.run_command(self.config.hard_reset_command) |
218 | 401 | else: | 401 | else: |
219 | 402 | self.proc.send("~$") | 402 | self.proc.send("~$") |
220 | 403 | self.proc.sendline("hardreset") | 403 | self.proc.sendline("hardreset") |
221 | 404 | 404 | ||
222 | === modified file 'lava_dispatcher/device/nexus.py' | |||
223 | --- lava_dispatcher/device/nexus.py 2013-02-04 13:31:34 +0000 | |||
224 | +++ lava_dispatcher/device/nexus.py 2013-03-08 06:44:20 +0000 | |||
225 | @@ -19,7 +19,6 @@ | |||
226 | 19 | # with this program; if not, see <http://www.gnu.org/licenses>. | 19 | # with this program; if not, see <http://www.gnu.org/licenses>. |
227 | 20 | 20 | ||
228 | 21 | import subprocess | 21 | import subprocess |
229 | 22 | import pexpect | ||
230 | 23 | from time import sleep | 22 | from time import sleep |
231 | 24 | import logging | 23 | import logging |
232 | 25 | import contextlib | 24 | import contextlib |
233 | @@ -31,8 +30,6 @@ | |||
234 | 31 | download_image | 30 | download_image |
235 | 32 | ) | 31 | ) |
236 | 33 | from lava_dispatcher.utils import ( | 32 | from lava_dispatcher.utils import ( |
237 | 34 | logging_system, | ||
238 | 35 | logging_spawn, | ||
239 | 36 | mkdtemp | 33 | mkdtemp |
240 | 37 | ) | 34 | ) |
241 | 38 | from lava_dispatcher.errors import ( | 35 | from lava_dispatcher.errors import ( |
242 | @@ -40,13 +37,9 @@ | |||
243 | 40 | ) | 37 | ) |
244 | 41 | 38 | ||
245 | 42 | 39 | ||
247 | 43 | def _call(cmd, ignore_failure, timeout): | 40 | def _call(context, cmd, ignore_failure, timeout): |
248 | 44 | cmd = 'timeout ' + str(timeout) + 's ' + cmd | 41 | cmd = 'timeout ' + str(timeout) + 's ' + cmd |
254 | 45 | logging.debug("Running on the host: %s", cmd) | 42 | context.run_command(cmd, failok=ignore_failure) |
250 | 46 | if ignore_failure: | ||
251 | 47 | subprocess.call(cmd, shell=True) | ||
252 | 48 | else: | ||
253 | 49 | subprocess.check_call(cmd, shell=True) | ||
255 | 50 | 43 | ||
256 | 51 | 44 | ||
257 | 52 | class FastBoot(object): | 45 | class FastBoot(object): |
258 | @@ -57,7 +50,7 @@ | |||
259 | 57 | def __call__(self, args, ignore_failure=False, timeout=600): | 50 | def __call__(self, args, ignore_failure=False, timeout=600): |
260 | 58 | command = self.device.config.fastboot_command + ' ' + args | 51 | command = self.device.config.fastboot_command + ' ' + args |
261 | 59 | command = "flock /var/lock/lava-fastboot.lck " + command | 52 | command = "flock /var/lock/lava-fastboot.lck " + command |
263 | 60 | _call(command, ignore_failure, timeout) | 53 | _call(self.device.context, command, ignore_failure, timeout) |
264 | 61 | 54 | ||
265 | 62 | def enter(self): | 55 | def enter(self): |
266 | 63 | if self.on(): | 56 | if self.on(): |
267 | @@ -71,7 +64,7 @@ | |||
268 | 71 | # probably hung. | 64 | # probably hung. |
269 | 72 | if self.device.config.hard_reset_command: | 65 | if self.device.config.hard_reset_command: |
270 | 73 | logging.debug("Will hard reset the device") | 66 | logging.debug("Will hard reset the device") |
272 | 74 | logging_system(self.device.config.hard_reset_command) | 67 | self.context.run_command(self.device.config.hard_reset_command) |
273 | 75 | else: | 68 | else: |
274 | 76 | logging.critical( | 69 | logging.critical( |
275 | 77 | "Hard reset command not configured. " | 70 | "Hard reset command not configured. " |
276 | @@ -187,9 +180,9 @@ | |||
277 | 187 | def _adb(self, args, ignore_failure=False, spawn=False, timeout=600): | 180 | def _adb(self, args, ignore_failure=False, spawn=False, timeout=600): |
278 | 188 | cmd = self.config.adb_command + ' ' + args | 181 | cmd = self.config.adb_command + ' ' + args |
279 | 189 | if spawn: | 182 | if spawn: |
281 | 190 | return logging_spawn(cmd, timeout=60) | 183 | return self.context.spawn(cmd, timeout=60) |
282 | 191 | else: | 184 | else: |
284 | 192 | _call(cmd, ignore_failure, timeout) | 185 | _call(self.context, cmd, ignore_failure, timeout) |
285 | 193 | 186 | ||
286 | 194 | def _get_image(self, url): | 187 | def _get_image(self, url): |
287 | 195 | sdir = self.working_dir | 188 | sdir = self.working_dir |
288 | 196 | 189 | ||
289 | === modified file 'lava_dispatcher/device/qemu.py' | |||
290 | --- lava_dispatcher/device/qemu.py 2013-01-16 23:27:28 +0000 | |||
291 | +++ lava_dispatcher/device/qemu.py 2013-03-08 06:44:20 +0000 | |||
292 | @@ -36,7 +36,6 @@ | |||
293 | 36 | from lava_dispatcher.utils import ( | 36 | from lava_dispatcher.utils import ( |
294 | 37 | ensure_directory, | 37 | ensure_directory, |
295 | 38 | extract_targz, | 38 | extract_targz, |
296 | 39 | logging_spawn, | ||
297 | 40 | ) | 39 | ) |
298 | 41 | 40 | ||
299 | 42 | 41 | ||
300 | @@ -79,10 +78,7 @@ | |||
301 | 79 | self.config.qemu_drive_interface, | 78 | self.config.qemu_drive_interface, |
302 | 80 | self._sd_image) | 79 | self._sd_image) |
303 | 81 | logging.info('launching qemu with command %r' % qemu_cmd) | 80 | logging.info('launching qemu with command %r' % qemu_cmd) |
308 | 82 | proc = logging_spawn( | 81 | proc = self.context.spawn(qemu_cmd, timeout=1200) |
305 | 83 | qemu_cmd, | ||
306 | 84 | logfile=self.context.logfile_read, | ||
307 | 85 | timeout=1200) | ||
309 | 86 | return proc | 82 | return proc |
310 | 87 | 83 | ||
311 | 88 | def get_device_version(self): | 84 | def get_device_version(self): |
312 | 89 | 85 | ||
313 | === modified file 'lava_dispatcher/device/sdmux.py' | |||
314 | --- lava_dispatcher/device/sdmux.py 2013-01-28 23:59:47 +0000 | |||
315 | +++ lava_dispatcher/device/sdmux.py 2013-03-08 06:44:20 +0000 | |||
316 | @@ -42,7 +42,6 @@ | |||
317 | 42 | connect_to_serial, | 42 | connect_to_serial, |
318 | 43 | ensure_directory, | 43 | ensure_directory, |
319 | 44 | extract_targz, | 44 | extract_targz, |
320 | 45 | logging_system, | ||
321 | 46 | ) | 45 | ) |
322 | 47 | 46 | ||
323 | 48 | 47 | ||
324 | @@ -87,7 +86,7 @@ | |||
325 | 87 | raise CriticalError('Device config requires "power_off_cmd"') | 86 | raise CriticalError('Device config requires "power_off_cmd"') |
326 | 88 | 87 | ||
327 | 89 | if config.pre_connect_command: | 88 | if config.pre_connect_command: |
329 | 90 | logging_system(config.pre_connect_command) | 89 | self.context.run_command(config.pre_connect_command) |
330 | 91 | 90 | ||
331 | 92 | def deploy_linaro(self, hwpack=None, rootfs=None): | 91 | def deploy_linaro(self, hwpack=None, rootfs=None): |
332 | 93 | img = generate_image(self, hwpack, rootfs, self.scratch_dir) | 92 | img = generate_image(self, hwpack, rootfs, self.scratch_dir) |
333 | @@ -115,7 +114,7 @@ | |||
334 | 115 | 114 | ||
335 | 116 | img = os.path.join(scratch, 'android.img') | 115 | img = os.path.join(scratch, 'android.img') |
336 | 117 | device_type = self.config.lmc_dev_arg | 116 | device_type = self.config.lmc_dev_arg |
338 | 118 | generate_android_image(device_type, boot, data, system, img) | 117 | generate_android_image(self.context, device_type, boot, data, system, img) |
339 | 119 | self._customize_android(img) | 118 | self._customize_android(img) |
340 | 120 | self._write_image(img) | 119 | self._write_image(img) |
341 | 121 | 120 | ||
342 | @@ -170,7 +169,7 @@ | |||
343 | 170 | raise CriticalError('Unable to access sdmux device') | 169 | raise CriticalError('Unable to access sdmux device') |
344 | 171 | finally: | 170 | finally: |
345 | 172 | logging.info('powering off sdmux') | 171 | logging.info('powering off sdmux') |
347 | 173 | subprocess.check_call([muxscript, '-d', muxid, 'off']) | 172 | self.context.run_command([muxscript, '-d', muxid, 'off'], failok=False) |
348 | 174 | 173 | ||
349 | 175 | @contextlib.contextmanager | 174 | @contextlib.contextmanager |
350 | 176 | def file_system(self, partition, directory): | 175 | def file_system(self, partition, directory): |
351 | @@ -185,7 +184,7 @@ | |||
352 | 185 | with self.mux_device() as device: | 184 | with self.mux_device() as device: |
353 | 186 | device = '%s%s' % (device, partition) | 185 | device = '%s%s' % (device, partition) |
354 | 187 | try: | 186 | try: |
356 | 188 | subprocess.check_call(['mount', device, mntdir]) | 187 | self.context.run_command(['mount', device, mntdir], failok=False) |
357 | 189 | if directory[0] == '/': | 188 | if directory[0] == '/': |
358 | 190 | directory = directory[1:] | 189 | directory = directory[1:] |
359 | 191 | path = os.path.join(mntdir, directory) | 190 | path = os.path.join(mntdir, directory) |
360 | @@ -203,11 +202,11 @@ | |||
361 | 203 | logging.info('unmounting sdmux') | 202 | logging.info('unmounting sdmux') |
362 | 204 | try: | 203 | try: |
363 | 205 | _flush_files(mntdir) | 204 | _flush_files(mntdir) |
365 | 206 | subprocess.check_call(['umount', device]) | 205 | self.context.run_command(['umount', device], failok=False) |
366 | 207 | except subprocess.CalledProcessError: | 206 | except subprocess.CalledProcessError: |
367 | 208 | logging.exception('umount failed, re-try in 10 seconds') | 207 | logging.exception('umount failed, re-try in 10 seconds') |
368 | 209 | time.sleep(10) | 208 | time.sleep(10) |
370 | 210 | if subprocess.call(['umount', device]) != 0: | 209 | if self.context.run_command(['umount', device]) != 0: |
371 | 211 | logging.error( | 210 | logging.error( |
372 | 212 | 'Unable to unmount sdmux device %s', device) | 211 | 'Unable to unmount sdmux device %s', device) |
373 | 213 | 212 | ||
374 | @@ -219,14 +218,13 @@ | |||
375 | 219 | 218 | ||
376 | 220 | def power_off(self, proc): | 219 | def power_off(self, proc): |
377 | 221 | super(SDMuxTarget, self).power_off(proc) | 220 | super(SDMuxTarget, self).power_off(proc) |
379 | 222 | logging_system(self.config.power_off_cmd) | 221 | self.context.run_command(self.config.power_off_cmd) |
380 | 223 | 222 | ||
381 | 224 | def power_on(self): | 223 | def power_on(self): |
384 | 225 | self.proc = connect_to_serial( | 224 | self.proc = connect_to_serial(self.context) |
383 | 226 | self.config, self.context.logfile_read) | ||
385 | 227 | 225 | ||
386 | 228 | logging.info('powering on') | 226 | logging.info('powering on') |
388 | 229 | logging_system(self.config.power_on_cmd) | 227 | self.context.run_command(self.config.power_on_cmd) |
389 | 230 | 228 | ||
390 | 231 | return self.proc | 229 | return self.proc |
391 | 232 | 230 | ||
392 | 233 | 231 | ||
393 | === modified file 'lava_dispatcher/utils.py' | |||
394 | --- lava_dispatcher/utils.py 2013-01-16 23:27:28 +0000 | |||
395 | +++ lava_dispatcher/utils.py 2013-03-08 06:44:20 +0000 | |||
396 | @@ -169,9 +169,9 @@ | |||
397 | 169 | 169 | ||
398 | 170 | class logging_spawn(pexpect.spawn): | 170 | class logging_spawn(pexpect.spawn): |
399 | 171 | 171 | ||
401 | 172 | def __init__(self, command, timeout=30, logfile=None): | 172 | def __init__(self, command, timeout=30): |
402 | 173 | pexpect.spawn.__init__( | 173 | pexpect.spawn.__init__( |
404 | 174 | self, command, timeout=timeout, logfile=logfile) | 174 | self, command, timeout=timeout) |
405 | 175 | 175 | ||
406 | 176 | # serial can be slow, races do funny things, so increase delay | 176 | # serial can be slow, races do funny things, so increase delay |
407 | 177 | self.delaybeforesend = 0.05 | 177 | self.delaybeforesend = 0.05 |
408 | @@ -214,7 +214,7 @@ | |||
409 | 214 | timeout=1, lava_no_logging=1) | 214 | timeout=1, lava_no_logging=1) |
410 | 215 | 215 | ||
411 | 216 | 216 | ||
413 | 217 | def connect_to_serial(device_config, logfile_read): | 217 | def connect_to_serial(context): |
414 | 218 | """ | 218 | """ |
415 | 219 | Attempts to connect to a serial console server like conmux or cyclades | 219 | Attempts to connect to a serial console server like conmux or cyclades |
416 | 220 | """ | 220 | """ |
417 | @@ -237,8 +237,9 @@ | |||
418 | 237 | results.append(result) | 237 | results.append(result) |
419 | 238 | 238 | ||
420 | 239 | while retry_count < retry_limit: | 239 | while retry_count < retry_limit: |
423 | 240 | proc = logging_spawn(device_config.connection_command, timeout=1200) | 240 | proc = context.spawn( |
424 | 241 | proc.logfile_read = logfile_read | 241 | context.client.config.connection_command, |
425 | 242 | timeout=1200) | ||
426 | 242 | logging.info('Attempting to connect to device') | 243 | logging.info('Attempting to connect to device') |
427 | 243 | match = proc.expect(patterns, timeout=10) | 244 | match = proc.expect(patterns, timeout=10) |
428 | 244 | result = results[match] | 245 | result = results[match] |
429 | @@ -252,9 +253,9 @@ | |||
430 | 252 | atexit.register(proc.close, True) | 253 | atexit.register(proc.close, True) |
431 | 253 | return proc | 254 | return proc |
432 | 254 | elif result == 'reset-port': | 255 | elif result == 'reset-port': |
434 | 255 | reset_cmd = device_config.reset_port_command | 256 | reset_cmd = context.client.config.reset_port_command |
435 | 256 | if reset_cmd: | 257 | if reset_cmd: |
437 | 257 | logging_system(reset_cmd) | 258 | context.run_command(reset_cmd) |
438 | 258 | else: | 259 | else: |
439 | 259 | raise CriticalError('no reset_port command configured') | 260 | raise CriticalError('no reset_port command configured') |
440 | 260 | proc.close(True) | 261 | proc.close(True) |