Merge lp:~adeuring/launchpad/hwdb-build-udev-device-list-2 into lp:launchpad
- hwdb-build-udev-device-list-2
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Jeroen T. Vermeulen |
Approved revision: | no longer in the source branch. |
Merged at revision: | not available |
Proposed branch: | lp:~adeuring/launchpad/hwdb-build-udev-device-list-2 |
Merge into: | lp:launchpad |
Diff against target: |
1064 lines 2 files modified
lib/canonical/launchpad/scripts/hwdbsubmissions.py (+69/-8) lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py (+208/-159) |
To merge this branch: | bzr merge lp:~adeuring/launchpad/hwdb-build-udev-device-list-2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeroen T. Vermeulen (community) | Approve | ||
Review via email: mp+13695@code.launchpad.net |
Commit message
Description of the change
Abel Deuring (adeuring) wrote : | # |
Abel Deuring (adeuring) wrote : | # |
test: ./bin/test --test=
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files:
lib/canonical
lib/canonical
== Pyflakes notices ==
lib/canonical/
22: redefinition of unused 'etree' from line 20
== Pylint notices ==
lib/canonical/
20: [F0401] Unable to import 'xml.etree.
Jeroen T. Vermeulen (jtv) wrote : | # |
Looks fine. I appreciate the courage it takes to defy review limits for the cleanup.
We discussed a few superficialities on IRC. I'll trust your judgment on which tests should test the hal devices and which should test all devices. Beyond that, it looks solid to me.
Preview Diff
1 | === modified file 'lib/canonical/launchpad/icing/style-3-0.css' |
2 | === modified file 'lib/canonical/launchpad/scripts/hwdbsubmissions.py' |
3 | --- lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-20 13:33:14 +0000 |
4 | +++ lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-21 10:10:35 +0000 |
5 | @@ -1397,15 +1397,75 @@ |
6 | |
7 | def buildDeviceList(self, parsed_data): |
8 | """Create a list of devices from a submission.""" |
9 | - self.hal_devices = hal_devices = {} |
10 | + if 'hal' in parsed_data['hardware']: |
11 | + return self.buildHalDeviceList(parsed_data) |
12 | + else: |
13 | + return self.buildUdevDeviceList(parsed_data) |
14 | + |
15 | + def buildHalDeviceList(self, parsed_data): |
16 | + """Create a list of devices from the HAL data of a submission.""" |
17 | + self.devices = {} |
18 | for hal_data in parsed_data['hardware']['hal']['devices']: |
19 | udi = hal_data['udi'] |
20 | - hal_devices[udi] = HALDevice(hal_data['id'], udi, |
21 | - hal_data['properties'], self) |
22 | - for device in hal_devices.values(): |
23 | + self.devices[udi] = HALDevice(hal_data['id'], udi, |
24 | + hal_data['properties'], self) |
25 | + for device in self.devices.values(): |
26 | parent_udi = device.parent_udi |
27 | if parent_udi is not None: |
28 | - hal_devices[parent_udi].addChild(device) |
29 | + self.devices[parent_udi].addChild(device) |
30 | + return True |
31 | + |
32 | + def buildUdevDeviceList(self, parsed_data): |
33 | + """Create a list of devices from the udev data of a submission.""" |
34 | + self.devices = {} |
35 | + sysfs_data = parsed_data['hardware']['sysfs-attributes'] |
36 | + dmi_data = parsed_data['hardware']['dmi'] |
37 | + for udev_data in parsed_data['hardware']['udev']: |
38 | + device_path = udev_data['P'] |
39 | + if device_path == UDEV_ROOT_PATH: |
40 | + device = UdevDevice( |
41 | + self, udev_data, sysfs_data=sysfs_data.get(device_path), |
42 | + dmi_data=dmi_data) |
43 | + else: |
44 | + device = UdevDevice( |
45 | + self, udev_data, sysfs_data=sysfs_data.get(device_path)) |
46 | + self.devices[device_path] = device |
47 | + |
48 | + # The parent-child relations are derived from the path names of |
49 | + # the devices. If A and B are the path names of two devices, |
50 | + # the device with path name A is an ancestor of the device with |
51 | + # path name B, iff B.startswith(A). If C is the set of the path |
52 | + # names of all ancestors of A, the element with the longest path |
53 | + # name belongs to the parent of A. |
54 | + # |
55 | + # There is one exception to this rule: The root node has the |
56 | + # the path name '/devices/LNXSYSTM:00', while the path names |
57 | + # of PCI devices start with '/devices/pci'. We'll temporarily |
58 | + # change the path name of the root device so that the rule |
59 | + # holds for all devices. |
60 | + if UDEV_ROOT_PATH not in self.devices: |
61 | + self._logError('No udev root device defined', self.submission_key) |
62 | + return False |
63 | + self.devices['/devices'] = self.devices[UDEV_ROOT_PATH] |
64 | + del self.devices[UDEV_ROOT_PATH] |
65 | + |
66 | + path_names = sorted(self.devices, key=len, reverse=True) |
67 | + for path_index, path_name in enumerate(path_names[:-1]): |
68 | + # Ensure that the last ancestor of each device is our |
69 | + # root node. |
70 | + if not path_name.startswith('/devices'): |
71 | + self._logError( |
72 | + 'Invalid device path name: %r' % path_name, |
73 | + self.submission_key) |
74 | + return False |
75 | + for parent_path in path_names[path_index+1:]: |
76 | + if path_name.startswith(parent_path): |
77 | + self.devices[parent_path].addChild( |
78 | + self.devices[path_name]) |
79 | + break |
80 | + self.devices[UDEV_ROOT_PATH] = self.devices['/devices'] |
81 | + del self.devices['/devices'] |
82 | + return True |
83 | |
84 | def buildUdevDeviceList(self, parsed_data): |
85 | """Create a list of devices from the udev data of a submission.""" |
86 | @@ -1460,7 +1520,7 @@ |
87 | |
88 | def getKernelPackageName(self): |
89 | """Return the kernel package name of the submission,""" |
90 | - root_hal_device = self.hal_devices[ROOT_UDI] |
91 | + root_hal_device = self.devices[ROOT_UDI] |
92 | kernel_version = root_hal_device.getProperty('system.kernel.version') |
93 | if kernel_version is None: |
94 | self._logWarning( |
95 | @@ -1521,8 +1581,9 @@ |
96 | self.parsed_data = parsed_data |
97 | if not self.checkConsistency(parsed_data): |
98 | return False |
99 | - self.buildDeviceList(parsed_data) |
100 | - root_device = self.hal_devices[ROOT_UDI] |
101 | + if not self.buildDeviceList(parsed_data): |
102 | + return False |
103 | + root_device = self.devices[ROOT_UDI] |
104 | root_device.createDBData(submission, None) |
105 | return True |
106 | |
107 | |
108 | === modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py' |
109 | --- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-20 14:03:44 +0000 |
110 | +++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-21 10:10:35 +0000 |
111 | @@ -136,7 +136,44 @@ |
112 | class TestHWDBSubmissionProcessing(TestCaseHWDB): |
113 | """Tests for processing of HWDB submissions.""" |
114 | |
115 | - def testBuildDeviceList(self): |
116 | + def test_buildDeviceList(self): |
117 | + """Test of SubmissionParser.buildDeviceList().""" |
118 | + class MockSubmissionParser(SubmissionParser): |
119 | + """A SubmissionParser variant for testing.""" |
120 | + |
121 | + def __init__(self, hal_result, udev_result): |
122 | + super(MockSubmissionParser, self).__init__() |
123 | + self.hal_result = hal_result |
124 | + self.udev_result = udev_result |
125 | + |
126 | + def buildHalDeviceList(self, parsed_data): |
127 | + """See `SubmissionParser`.""" |
128 | + return self.hal_result |
129 | + |
130 | + def buildUdevDeviceList(self, parsed_data): |
131 | + """See `SubmissionParser`.""" |
132 | + return self.udev_result |
133 | + |
134 | + parsed_data_hal = { |
135 | + 'hardware': {'hal': None} |
136 | + } |
137 | + |
138 | + parser = MockSubmissionParser(True, True) |
139 | + self.assertTrue(parser.buildDeviceList(parsed_data_hal)) |
140 | + |
141 | + parser = MockSubmissionParser(False, True) |
142 | + self.assertFalse(parser.buildDeviceList(parsed_data_hal)) |
143 | + |
144 | + parsed_data_udev = { |
145 | + 'hardware': {'udev': None} |
146 | + } |
147 | + parser = MockSubmissionParser(True, True) |
148 | + self.assertTrue(parser.buildDeviceList(parsed_data_udev)) |
149 | + |
150 | + parser = MockSubmissionParser(True, False) |
151 | + self.assertFalse(parser.buildDeviceList(parsed_data_udev)) |
152 | + |
153 | + def test_buildHalDeviceList(self): |
154 | """Test the creation of list HALDevice instances for a submission.""" |
155 | devices = [ |
156 | { |
157 | @@ -160,11 +197,11 @@ |
158 | }, |
159 | } |
160 | parser = SubmissionParser(self.log) |
161 | - parser.buildDeviceList(parsed_data) |
162 | - self.assertEqual(len(parser.hal_devices), len(devices), |
163 | - 'Numbers of devices in parser.hal_devices and in ' |
164 | + parser.buildHalDeviceList(parsed_data) |
165 | + self.assertEqual(len(parser.devices), len(devices), |
166 | + 'Numbers of devices in parser.devices and in ' |
167 | 'sample data are different') |
168 | - root_device = parser.hal_devices[self.UDI_COMPUTER] |
169 | + root_device = parser.devices[self.UDI_COMPUTER] |
170 | self.assertEqual(root_device.id, 1, |
171 | 'Unexpected value of root device ID.') |
172 | self.assertEqual(root_device.udi, self.UDI_COMPUTER, |
173 | @@ -172,7 +209,7 @@ |
174 | self.assertEqual(root_device.properties, |
175 | devices[0]['properties'], |
176 | 'Unexpected properties of root device.') |
177 | - child_device = parser.hal_devices[self.UDI_SATA_CONTROLLER] |
178 | + child_device = parser.devices[self.UDI_SATA_CONTROLLER] |
179 | self.assertEqual(child_device.id, 2, |
180 | 'Unexpected value of child device ID.') |
181 | self.assertEqual(child_device.udi, self.UDI_SATA_CONTROLLER, |
182 | @@ -181,8 +218,8 @@ |
183 | devices[1]['properties'], |
184 | 'Unexpected properties of child device.') |
185 | |
186 | - parent = parser.hal_devices[self.UDI_COMPUTER] |
187 | - child = parser.hal_devices[self.UDI_SATA_CONTROLLER] |
188 | + parent = parser.devices[self.UDI_COMPUTER] |
189 | + child = parser.devices[self.UDI_SATA_CONTROLLER] |
190 | self.assertEqual(parent.children, [child], |
191 | 'Child missing in parent.children.') |
192 | self.assertEqual(child.parent, parent, |
193 | @@ -744,11 +781,10 @@ |
194 | } |
195 | |
196 | parser = SubmissionParser() |
197 | - parser.buildDeviceList(parsed_data) |
198 | + parser.buildHalDeviceList(parsed_data) |
199 | |
200 | - usb_fake_scsi_disk = parser.hal_devices[ |
201 | - self.UDI_USB_STORAGE_SCSI_DEVICE] |
202 | - usb_main_device = parser.hal_devices[self.UDI_USB_STORAGE_IF0] |
203 | + usb_fake_scsi_disk = parser.devices[self.UDI_USB_STORAGE_SCSI_DEVICE] |
204 | + usb_main_device = parser.devices[self.UDI_USB_STORAGE_IF0] |
205 | self.assertEqual(usb_main_device, usb_fake_scsi_disk.scsi_controller) |
206 | |
207 | def test_HALDevice_scsi_controller_pci_controller(self): |
208 | @@ -795,10 +831,10 @@ |
209 | } |
210 | |
211 | parser = SubmissionParser() |
212 | - parser.buildDeviceList(parsed_data) |
213 | + parser.buildHalDeviceList(parsed_data) |
214 | |
215 | - scsi_device = parser.hal_devices[self.UDI_SATA_DISK] |
216 | - controller = parser.hal_devices[self.UDI_SATA_CONTROLLER] |
217 | + scsi_device = parser.devices[self.UDI_SATA_DISK] |
218 | + controller = parser.devices[self.UDI_SATA_CONTROLLER] |
219 | self.assertEqual(controller, scsi_device.scsi_controller) |
220 | |
221 | def test_HALDevice_scsi_controller_non_scsi_device(self): |
222 | @@ -822,9 +858,9 @@ |
223 | } |
224 | |
225 | parser = SubmissionParser() |
226 | - parser.buildDeviceList(parsed_data) |
227 | + parser.buildHalDeviceList(parsed_data) |
228 | |
229 | - device = parser.hal_devices[self.UDI_COMPUTER] |
230 | + device = parser.devices[self.UDI_COMPUTER] |
231 | self.assertEqual(None, device.scsi_controller) |
232 | |
233 | def test_HALDevice_scsi_controller_no_grandparent(self): |
234 | @@ -859,9 +895,9 @@ |
235 | |
236 | parser = SubmissionParser(self.log) |
237 | parser.submission_key = 'SCSI device without grandparent device' |
238 | - parser.buildDeviceList(parsed_data) |
239 | + parser.buildHalDeviceList(parsed_data) |
240 | |
241 | - scsi_device = parser.hal_devices[self.UDI_SATA_DISK] |
242 | + scsi_device = parser.devices[self.UDI_SATA_DISK] |
243 | self.assertEqual(None, scsi_device.scsi_controller) |
244 | self.assertWarningMessage( |
245 | parser.submission_key, |
246 | @@ -893,9 +929,9 @@ |
247 | |
248 | parser = SubmissionParser(self.log) |
249 | parser.submission_key = 'SCSI device without parent device' |
250 | - parser.buildDeviceList(parsed_data) |
251 | + parser.buildHalDeviceList(parsed_data) |
252 | |
253 | - scsi_device = parser.hal_devices[self.UDI_SATA_DISK] |
254 | + scsi_device = parser.devices[self.UDI_SATA_DISK] |
255 | self.assertEqual(None, scsi_device.scsi_controller) |
256 | self.assertWarningMessage( |
257 | parser.submission_key, |
258 | @@ -930,8 +966,8 @@ |
259 | }, |
260 | } |
261 | parser = SubmissionParser(self.log) |
262 | - parser.buildDeviceList(parsed_data) |
263 | - test_device = parser.hal_devices[UDI_TEST_DEVICE] |
264 | + parser.buildHalDeviceList(parsed_data) |
265 | + test_device = parser.devices[UDI_TEST_DEVICE] |
266 | test_bus = test_device.real_bus |
267 | self.assertEqual(test_bus, real_bus, |
268 | 'Unexpected result of HALDevice.real_bus for ' |
269 | @@ -957,8 +993,8 @@ |
270 | }, |
271 | } |
272 | parser = SubmissionParser(self.log) |
273 | - parser.buildDeviceList(parsed_data) |
274 | - test_device = parser.hal_devices[self.UDI_COMPUTER] |
275 | + parser.buildHalDeviceList(parsed_data) |
276 | + test_device = parser.devices[self.UDI_COMPUTER] |
277 | test_bus = test_device.real_bus |
278 | self.assertEqual(test_bus, HWBus.SYSTEM, |
279 | 'Unexpected result of HALDevice.real_bus for ' |
280 | @@ -1017,10 +1053,9 @@ |
281 | } |
282 | |
283 | parser = SubmissionParser(self.log) |
284 | - parser.buildDeviceList(parsed_data) |
285 | + parser.buildHalDeviceList(parsed_data) |
286 | |
287 | - usb_fake_scsi_disk = parser.hal_devices[ |
288 | - self.UDI_USB_STORAGE_SCSI_DEVICE] |
289 | + usb_fake_scsi_disk = parser.devices[self.UDI_USB_STORAGE_SCSI_DEVICE] |
290 | self.assertEqual(usb_fake_scsi_disk.real_bus, None, |
291 | 'Unexpected result of HALDevice.real_bus for the fake SCSI ' |
292 | 'disk HAL node of a USB storage device bus.') |
293 | @@ -1085,12 +1120,12 @@ |
294 | ) |
295 | |
296 | parser = SubmissionParser(self.log) |
297 | - parser.buildDeviceList(parsed_data) |
298 | + parser.buildHalDeviceList(parsed_data) |
299 | |
300 | for device_subclass, expected_bus in pci_subclass_bus: |
301 | devices[0]['properties']['pci.device_subclass'] = ( |
302 | device_subclass, 'int') |
303 | - fake_scsi_disk = parser.hal_devices[self.UDI_SATA_DISK] |
304 | + fake_scsi_disk = parser.devices[self.UDI_SATA_DISK] |
305 | found_bus = fake_scsi_disk.real_bus |
306 | self.assertEqual(found_bus, expected_bus, |
307 | 'Unexpected result of HWDevice.real_bus for PCI storage ' |
308 | @@ -1125,8 +1160,8 @@ |
309 | } |
310 | parser = SubmissionParser(self.log) |
311 | parser.submission_key = 'Test SCSI disk without a grandparent' |
312 | - parser.buildDeviceList(parsed_data) |
313 | - scsi_disk = parser.hal_devices[self.UDI_SCSI_DISK] |
314 | + parser.buildHalDeviceList(parsed_data) |
315 | + scsi_disk = parser.devices[self.UDI_SCSI_DISK] |
316 | bus = scsi_disk.real_bus |
317 | self.assertEqual(bus, None, |
318 | 'Unexpected result of HALDevice.real_bus for a SCSI device ' |
319 | @@ -1155,8 +1190,8 @@ |
320 | } |
321 | parser = SubmissionParser(self.log) |
322 | parser.submission_key = 'Test SCSI disk without a parent' |
323 | - parser.buildDeviceList(parsed_data) |
324 | - scsi_disk = parser.hal_devices[self.UDI_SCSI_DISK] |
325 | + parser.buildHalDeviceList(parsed_data) |
326 | + scsi_disk = parser.devices[self.UDI_SCSI_DISK] |
327 | bus = scsi_disk.real_bus |
328 | self.assertEqual(bus, None, |
329 | 'Unexpected result of HALDevice.real_bus for a SCSI device ' |
330 | @@ -1210,8 +1245,8 @@ |
331 | parser = SubmissionParser(self.log) |
332 | parser.submission_key = ( |
333 | 'Test SCSI disk with invalid controller device class') |
334 | - parser.buildDeviceList(parsed_data) |
335 | - scsi_disk = parser.hal_devices[self.UDI_SATA_DISK] |
336 | + parser.buildHalDeviceList(parsed_data) |
337 | + scsi_disk = parser.devices[self.UDI_SATA_DISK] |
338 | bus = scsi_disk.real_bus |
339 | self.assertEqual(bus, None, |
340 | 'Unexpected result of HALDevice.real_bus for a SCSI device ' |
341 | @@ -1286,8 +1321,8 @@ |
342 | parent_device['udi'], 'str') |
343 | devices.append(tested_device) |
344 | parsed_data['hardware']['hal']['devices'] = devices |
345 | - parser.buildDeviceList(parsed_data) |
346 | - tested_hal_device = parser.hal_devices[self.UDI_PCCARD_DEVICE] |
347 | + parser.buildHalDeviceList(parsed_data) |
348 | + tested_hal_device = parser.devices[self.UDI_PCCARD_DEVICE] |
349 | found_bus = tested_hal_device.real_bus |
350 | expected_bus = expected_result_for_parent_device[ |
351 | parent_device['udi']] |
352 | @@ -1317,8 +1352,8 @@ |
353 | |
354 | parser = SubmissionParser(self.log) |
355 | parser.submission_key = 'Test of unknown bus name' |
356 | - parser.buildDeviceList(parsed_data) |
357 | - found_bus = parser.hal_devices[self.UDI_PCCARD_DEVICE].real_bus |
358 | + parser.buildHalDeviceList(parsed_data) |
359 | + found_bus = parser.devices[self.UDI_PCCARD_DEVICE].real_bus |
360 | self.assertEqual(found_bus, None, |
361 | 'Unexpected result of HWDevice.real_bus for an ' |
362 | 'unknown bus name: Expected None, got %r.' |
363 | @@ -1346,8 +1381,8 @@ |
364 | |
365 | parser = SubmissionParser() |
366 | parser.submission_key = 'Test of HALDevice.is_root_device' |
367 | - parser.buildDeviceList(parsed_data) |
368 | - self.assertTrue(parser.hal_devices[self.UDI_COMPUTER].is_root_device) |
369 | + parser.buildHalDeviceList(parsed_data) |
370 | + self.assertTrue(parser.devices[self.UDI_COMPUTER].is_root_device) |
371 | |
372 | def test_HALDevice_is_root_device_for_non_root_device(self): |
373 | """Test of HALDevice.is_root_device for a non-root device.""" |
374 | @@ -1368,9 +1403,9 @@ |
375 | |
376 | parser = SubmissionParser() |
377 | parser.submission_key = 'Test of HALDevice.is_root_device' |
378 | - parser.buildDeviceList(parsed_data) |
379 | + parser.buildHalDeviceList(parsed_data) |
380 | self.assertFalse( |
381 | - parser.hal_devices[self.UDI_PCCARD_DEVICE].is_root_device) |
382 | + parser.devices[self.UDI_PCCARD_DEVICE].is_root_device) |
383 | |
384 | def renameInfoBusToInfoSubsystem(self, devices): |
385 | """Rename the property info.bus in a device list to info.subsystem. |
386 | @@ -1418,14 +1453,14 @@ |
387 | }, |
388 | } |
389 | parser = SubmissionParser(self.log) |
390 | - parser.buildDeviceList(parsed_data) |
391 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_PCI_SIDE] |
392 | + parser.buildHalDeviceList(parsed_data) |
393 | + device = parser.devices[self.UDI_USB_CONTROLLER_PCI_SIDE] |
394 | self.failUnless(device.is_real_device, |
395 | 'Device with info.bus property not treated as a ' |
396 | 'real device.') |
397 | self.renameInfoBusToInfoSubsystem(devices) |
398 | - parser.buildDeviceList(parsed_data) |
399 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_PCI_SIDE] |
400 | + parser.buildHalDeviceList(parsed_data) |
401 | + device = parser.devices[self.UDI_USB_CONTROLLER_PCI_SIDE] |
402 | self.failUnless(device.is_real_device, |
403 | 'Device with info.subsystem property not treated as ' |
404 | 'a real device.') |
405 | @@ -1449,8 +1484,8 @@ |
406 | } |
407 | |
408 | parser = SubmissionParser(self.log) |
409 | - parser.buildDeviceList(parsed_data) |
410 | - device = parser.hal_devices[UDI_HAL_STORAGE_DEVICE] |
411 | + parser.buildHalDeviceList(parsed_data) |
412 | + device = parser.devices[UDI_HAL_STORAGE_DEVICE] |
413 | self.failIf(device.is_real_device, |
414 | 'Device without info.bus property treated as a ' |
415 | 'real device') |
416 | @@ -1489,8 +1524,8 @@ |
417 | 'sound', 'ssb', 'tty', 'usb', 'video4linux', ) |
418 | for tested_bus in ignored_buses: |
419 | properties['info.bus'] = (tested_bus, 'str') |
420 | - parser.buildDeviceList(parsed_data) |
421 | - device = parser.hal_devices[self.UDI_USB_HUB_IF0] |
422 | + parser.buildHalDeviceList(parsed_data) |
423 | + device = parser.devices[self.UDI_USB_HUB_IF0] |
424 | self.failIf( |
425 | device.is_real_device, |
426 | 'Device with info.bus=%s treated as a real device' |
427 | @@ -1499,8 +1534,8 @@ |
428 | del properties['info.bus'] |
429 | for tested_bus in ignored_buses: |
430 | properties['info.subsystem'] = (tested_bus, 'str') |
431 | - parser.buildDeviceList(parsed_data) |
432 | - device = parser.hal_devices[self.UDI_USB_HUB_IF0] |
433 | + parser.buildHalDeviceList(parsed_data) |
434 | + device = parser.devices[self.UDI_USB_HUB_IF0] |
435 | self.failIf( |
436 | device.is_real_device, |
437 | 'Device with info.subsystem=%s treated as a real device' |
438 | @@ -1532,12 +1567,12 @@ |
439 | ) |
440 | |
441 | parser = SubmissionParser(self.log) |
442 | - parser.buildDeviceList(parsed_data) |
443 | + parser.buildHalDeviceList(parsed_data) |
444 | |
445 | for device_subclass, expected_is_real in pci_subclass_bus: |
446 | devices[0]['properties']['pci.device_subclass'] = ( |
447 | device_subclass, 'int') |
448 | - scsi_device = parser.hal_devices[self.UDI_SATA_DISK] |
449 | + scsi_device = parser.devices[self.UDI_SATA_DISK] |
450 | found_is_real = scsi_device.is_real_device |
451 | self.assertEqual(found_is_real, expected_is_real, |
452 | 'Unexpected result of HWDevice.is_real_device for a HAL SCSI ' |
453 | @@ -1641,15 +1676,15 @@ |
454 | } |
455 | |
456 | parser = SubmissionParser(self.log) |
457 | - parser.buildDeviceList(parsed_data) |
458 | + parser.buildHalDeviceList(parsed_data) |
459 | |
460 | - scsi_device = parser.hal_devices[self.UDI_USB_STORAGE_SCSI_DEVICE] |
461 | + scsi_device = parser.devices[self.UDI_USB_STORAGE_SCSI_DEVICE] |
462 | self.failIf(scsi_device.is_real_device, |
463 | 'Unexpected result of HWDevice.is_real_device for a HAL SCSI ' |
464 | 'device as a subdevice of a USB storage device.') |
465 | |
466 | self.renameInfoBusToInfoSubsystem(devices) |
467 | - scsi_device = parser.hal_devices[self.UDI_USB_STORAGE_SCSI_DEVICE] |
468 | + scsi_device = parser.devices[self.UDI_USB_STORAGE_SCSI_DEVICE] |
469 | self.failIf(scsi_device.is_real_device, |
470 | 'Unexpected result of HWDevice.is_real_device for a HAL SCSI ' |
471 | 'device as a subdevice of a USB storage device.') |
472 | @@ -1672,8 +1707,8 @@ |
473 | } |
474 | |
475 | parser = SubmissionParser(self.log) |
476 | - parser.buildDeviceList(parsed_data) |
477 | - device = parser.hal_devices[self.UDI_COMPUTER] |
478 | + parser.buildHalDeviceList(parsed_data) |
479 | + device = parser.devices[self.UDI_COMPUTER] |
480 | self.failUnless(device.is_real_device, |
481 | 'Root device not treated as a real device') |
482 | |
483 | @@ -1745,11 +1780,11 @@ |
484 | } |
485 | |
486 | parser = SubmissionParser(self.log) |
487 | - parser.buildDeviceList(parsed_data) |
488 | + parser.buildHalDeviceList(parsed_data) |
489 | |
490 | # The PCI-USB bridge is a child of the system. |
491 | - root_device = parser.hal_devices[self.UDI_COMPUTER] |
492 | - pci_usb_bridge = parser.hal_devices[self.UDI_USB_CONTROLLER_PCI_SIDE] |
493 | + root_device = parser.devices[self.UDI_COMPUTER] |
494 | + pci_usb_bridge = parser.devices[self.UDI_USB_CONTROLLER_PCI_SIDE] |
495 | self.assertEqual(root_device.getRealChildren(), [pci_usb_bridge], |
496 | 'Unexpected list of real children of the root ' |
497 | 'device') |
498 | @@ -1759,7 +1794,7 @@ |
499 | # but the node for the USB device is considered to be a child |
500 | # of the bridge. |
501 | |
502 | - usb_device = parser.hal_devices[self.UDI_USB_HUB] |
503 | + usb_device = parser.devices[self.UDI_USB_HUB] |
504 | self.assertEqual(pci_usb_bridge.getRealChildren(), [usb_device], |
505 | 'Unexpected list of real children of the PCI-> ' |
506 | 'USB bridge') |
507 | @@ -1793,8 +1828,8 @@ |
508 | }, |
509 | } |
510 | parser = SubmissionParser(self.log) |
511 | - parser.buildDeviceList(parsed_data) |
512 | - device = parser.hal_devices[self.UDI_SATA_CONTROLLER] |
513 | + parser.buildHalDeviceList(parsed_data) |
514 | + device = parser.devices[self.UDI_SATA_CONTROLLER] |
515 | self.failUnless( |
516 | device.has_reliable_data, |
517 | 'Regular device treated as not having reliable data.') |
518 | @@ -1821,8 +1856,8 @@ |
519 | 'mmc', 'mmc_host', 'pcmcia', 'platform', 'pnp', |
520 | 'power_supply', 'unknown'): |
521 | properties['info.bus'] = (bus, 'str') |
522 | - parser.buildDeviceList(parsed_data) |
523 | - device = parser.hal_devices[self.UDI_SATA_CONTROLLER] |
524 | + parser.buildHalDeviceList(parsed_data) |
525 | + device = parser.devices[self.UDI_SATA_CONTROLLER] |
526 | self.failIf(device.has_reliable_data, |
527 | 'Device with bus=%s treated as having reliable data.' % bus) |
528 | |
529 | @@ -1853,8 +1888,8 @@ |
530 | } |
531 | parser = SubmissionParser(self.log) |
532 | properties = devices[0]['properties'] |
533 | - parser.buildDeviceList(parsed_data) |
534 | - device = parser.hal_devices[self.UDI_COMPUTER] |
535 | + parser.buildHalDeviceList(parsed_data) |
536 | + device = parser.devices[self.UDI_COMPUTER] |
537 | self.failUnless(device.has_reliable_data, |
538 | 'Root device not treated as having reliable data.') |
539 | |
540 | @@ -1921,8 +1956,8 @@ |
541 | parser = SubmissionParser(self.log) |
542 | submission_key = 'test_missing_%s' % missing_data |
543 | parser.submission_key = submission_key |
544 | - parser.buildDeviceList(test_parsed_data) |
545 | - device = parser.hal_devices[self.UDI_SATA_CONTROLLER] |
546 | + parser.buildHalDeviceList(test_parsed_data) |
547 | + device = parser.devices[self.UDI_SATA_CONTROLLER] |
548 | self.failIf( |
549 | device.has_reliable_data, |
550 | 'Device with missing property %s treated as having reliable' |
551 | @@ -1971,8 +2006,8 @@ |
552 | } |
553 | |
554 | parser = SubmissionParser(self.log) |
555 | - parser.buildDeviceList(parsed_data) |
556 | - device = parser.hal_devices[self.UDI_SATA_DISK] |
557 | + parser.buildHalDeviceList(parsed_data) |
558 | + device = parser.devices[self.UDI_SATA_DISK] |
559 | self.failIf( |
560 | device.has_reliable_data, |
561 | 'IDE Device with missing properties vendor ID, product ID, ' |
562 | @@ -2003,8 +2038,8 @@ |
563 | }, |
564 | } |
565 | parser = SubmissionParser(self.log) |
566 | - parser.buildDeviceList(parsed_data) |
567 | - device = parser.hal_devices[self.UDI_SCSI_DISK] |
568 | + parser.buildHalDeviceList(parsed_data) |
569 | + device = parser.devices[self.UDI_SCSI_DISK] |
570 | vendor_model = device.getScsiVendorAndModelName() |
571 | self.assertEqual( |
572 | { |
573 | @@ -2042,8 +2077,8 @@ |
574 | }, |
575 | } |
576 | parser = SubmissionParser(self.log) |
577 | - parser.buildDeviceList(parsed_data) |
578 | - device = parser.hal_devices[self.UDI_SCSI_DISK] |
579 | + parser.buildHalDeviceList(parsed_data) |
580 | + device = parser.devices[self.UDI_SCSI_DISK] |
581 | vendor_model = device.getScsiVendorAndModelName() |
582 | self.assertEqual( |
583 | { |
584 | @@ -2080,8 +2115,8 @@ |
585 | }, |
586 | } |
587 | parser = SubmissionParser(self.log) |
588 | - parser.buildDeviceList(parsed_data) |
589 | - device = parser.hal_devices[self.UDI_SCSI_DISK] |
590 | + parser.buildHalDeviceList(parsed_data) |
591 | + device = parser.devices[self.UDI_SCSI_DISK] |
592 | vendor_product = device.getScsiVendorAndModelName() |
593 | self.assertEqual( |
594 | { |
595 | @@ -2116,8 +2151,8 @@ |
596 | }, |
597 | } |
598 | parser = SubmissionParser(self.log) |
599 | - parser.buildDeviceList(parsed_data) |
600 | - found_vendor = parser.hal_devices[self.UDI_SATA_CONTROLLER].vendor |
601 | + parser.buildHalDeviceList(parsed_data) |
602 | + found_vendor = parser.devices[self.UDI_SATA_CONTROLLER].vendor |
603 | self.assertEqual(found_vendor, 'Intel Corporation', |
604 | 'Unexpected result of HWDevice.vendor. ' |
605 | 'Expected Intel Corporation, got %r.' |
606 | @@ -2147,8 +2182,8 @@ |
607 | }, |
608 | } |
609 | parser = SubmissionParser(self.log) |
610 | - parser.buildDeviceList(parsed_data) |
611 | - found_vendor = parser.hal_devices[self.UDI_SATA_CONTROLLER].vendor |
612 | + parser.buildHalDeviceList(parsed_data) |
613 | + found_vendor = parser.devices[self.UDI_SATA_CONTROLLER].vendor |
614 | self.assertEqual(found_vendor, 'Intel Corporation', |
615 | 'Unexpected result of HWDevice.vendor, ' |
616 | 'if info.vendor does not exist. ' |
617 | @@ -2175,8 +2210,8 @@ |
618 | }, |
619 | } |
620 | parser = SubmissionParser(self.log) |
621 | - parser.buildDeviceList(parsed_data) |
622 | - found_vendor = parser.hal_devices[self.UDI_SCSI_DISK].vendor |
623 | + parser.buildHalDeviceList(parsed_data) |
624 | + found_vendor = parser.devices[self.UDI_SCSI_DISK].vendor |
625 | self.assertEqual(found_vendor, 'SEAGATE', |
626 | 'Unexpected result of HWDevice.vendor ' |
627 | 'for SCSI device. Expected SEAGATE, got %r.' |
628 | @@ -2203,8 +2238,8 @@ |
629 | }, |
630 | } |
631 | parser = SubmissionParser(self.log) |
632 | - parser.buildDeviceList(parsed_data) |
633 | - found_vendor = parser.hal_devices[self.UDI_SCSI_DISK].vendor |
634 | + parser.buildHalDeviceList(parsed_data) |
635 | + found_vendor = parser.devices[self.UDI_SCSI_DISK].vendor |
636 | self.assertEqual(found_vendor, 'Hitachi', |
637 | 'Unexpected result of HWDevice.vendor, for fake ' |
638 | 'SCSI device. Expected Hitachi, got %r.' |
639 | @@ -2233,8 +2268,8 @@ |
640 | }, |
641 | } |
642 | parser = SubmissionParser(self.log) |
643 | - parser.buildDeviceList(parsed_data) |
644 | - found_vendor = parser.hal_devices[self.UDI_COMPUTER].vendor |
645 | + parser.buildHalDeviceList(parsed_data) |
646 | + found_vendor = parser.devices[self.UDI_COMPUTER].vendor |
647 | self.assertEqual(found_vendor, 'FUJITSU SIEMENS', |
648 | 'Unexpected result of HWDevice.vendor for a ' |
649 | 'system. Expected FUJITSU SIEMENS, got %r.' |
650 | @@ -2266,8 +2301,8 @@ |
651 | }, |
652 | } |
653 | parser = SubmissionParser(self.log) |
654 | - parser.buildDeviceList(parsed_data) |
655 | - found_product = parser.hal_devices[self.UDI_SATA_CONTROLLER].product |
656 | + parser.buildHalDeviceList(parsed_data) |
657 | + found_product = parser.devices[self.UDI_SATA_CONTROLLER].product |
658 | self.assertEqual(found_product, '82801GBM/GHM SATA AHCI Controller', |
659 | 'Unexpected result of HWDevice.product. ' |
660 | 'Expected 82801GBM/GHM SATA AHCI Controller, got %r.' |
661 | @@ -2297,8 +2332,8 @@ |
662 | }, |
663 | } |
664 | parser = SubmissionParser(self.log) |
665 | - parser.buildDeviceList(parsed_data) |
666 | - found_product = parser.hal_devices[self.UDI_SATA_CONTROLLER].product |
667 | + parser.buildHalDeviceList(parsed_data) |
668 | + found_product = parser.devices[self.UDI_SATA_CONTROLLER].product |
669 | self.assertEqual(found_product, '82801GBM/GHM SATA AHCI Controller', |
670 | 'Unexpected result of HWDevice.product, ' |
671 | 'if info.product does not exist. ' |
672 | @@ -2327,8 +2362,8 @@ |
673 | }, |
674 | } |
675 | parser = SubmissionParser(self.log) |
676 | - parser.buildDeviceList(parsed_data) |
677 | - found_product = parser.hal_devices[self.UDI_SCSI_DISK].product |
678 | + parser.buildHalDeviceList(parsed_data) |
679 | + found_product = parser.devices[self.UDI_SCSI_DISK].product |
680 | self.assertEqual(found_product, 'ST36530N', |
681 | 'Unexpected result of HWDevice.product ' |
682 | 'for SCSI device. Expected ST36530N, got %r.' |
683 | @@ -2355,8 +2390,8 @@ |
684 | }, |
685 | } |
686 | parser = SubmissionParser(self.log) |
687 | - parser.buildDeviceList(parsed_data) |
688 | - found_product = parser.hal_devices[self.UDI_SCSI_DISK].product |
689 | + parser.buildHalDeviceList(parsed_data) |
690 | + found_product = parser.devices[self.UDI_SCSI_DISK].product |
691 | self.assertEqual(found_product, 'HTS54161', |
692 | 'Unexpected result of HWDevice.product, for fake ' |
693 | 'SCSI device. Expected HTS54161, got %r.' |
694 | @@ -2385,8 +2420,8 @@ |
695 | }, |
696 | } |
697 | parser = SubmissionParser(self.log) |
698 | - parser.buildDeviceList(parsed_data) |
699 | - found_product = parser.hal_devices[self.UDI_COMPUTER].product |
700 | + parser.buildHalDeviceList(parsed_data) |
701 | + found_product = parser.devices[self.UDI_COMPUTER].product |
702 | self.assertEqual(found_product, 'LIFEBOOK E8210', |
703 | 'Unexpected result of HWDevice.product, ' |
704 | 'if info.product does not exist. ' |
705 | @@ -2418,8 +2453,8 @@ |
706 | }, |
707 | } |
708 | parser = SubmissionParser(self.log) |
709 | - parser.buildDeviceList(parsed_data) |
710 | - found_vendor_id = parser.hal_devices[ |
711 | + parser.buildHalDeviceList(parsed_data) |
712 | + found_vendor_id = parser.devices[ |
713 | self.UDI_SATA_CONTROLLER].vendor_id |
714 | self.assertEqual(found_vendor_id, self.PCI_VENDOR_ID_INTEL, |
715 | 'Unexpected result of HWDevice.vendor_id. ' |
716 | @@ -2451,8 +2486,8 @@ |
717 | }, |
718 | } |
719 | parser = SubmissionParser(self.log) |
720 | - parser.buildDeviceList(parsed_data) |
721 | - found_vendor_id = parser.hal_devices[self.UDI_SCSI_DISK].vendor_id |
722 | + parser.buildHalDeviceList(parsed_data) |
723 | + found_vendor_id = parser.devices[self.UDI_SCSI_DISK].vendor_id |
724 | self.assertEqual(found_vendor_id, 'SEAGATE', |
725 | 'Unexpected result of HWDevice.vendor_id for a. ' |
726 | 'SCSI device. Expected SEAGATE, got %r.' |
727 | @@ -2480,8 +2515,8 @@ |
728 | }, |
729 | } |
730 | parser = SubmissionParser(self.log) |
731 | - parser.buildDeviceList(parsed_data) |
732 | - found_vendor_id = parser.hal_devices[self.UDI_SCSI_DISK].vendor_id |
733 | + parser.buildHalDeviceList(parsed_data) |
734 | + found_vendor_id = parser.devices[self.UDI_SCSI_DISK].vendor_id |
735 | self.assertEqual(found_vendor_id, 'Hitachi', |
736 | 'Unexpected result of HWDevice.vendor_id for a. ' |
737 | 'fake SCSI device. Expected Hitachi, got %r.' |
738 | @@ -2510,8 +2545,8 @@ |
739 | }, |
740 | } |
741 | parser = SubmissionParser(self.log) |
742 | - parser.buildDeviceList(parsed_data) |
743 | - found_vendor_id = parser.hal_devices[self.UDI_COMPUTER].vendor_id |
744 | + parser.buildHalDeviceList(parsed_data) |
745 | + found_vendor_id = parser.devices[self.UDI_COMPUTER].vendor_id |
746 | self.assertEqual(found_vendor_id, 'FUJITSU SIEMENS', |
747 | 'Unexpected result of HWDevice.vendor_id for a ' |
748 | 'system. Expected FUJITSU SIEMENS, got %r.' |
749 | @@ -2542,9 +2577,8 @@ |
750 | }, |
751 | } |
752 | parser = SubmissionParser(self.log) |
753 | - parser.buildDeviceList(parsed_data) |
754 | - found_product_id = parser.hal_devices[ |
755 | - self.UDI_SATA_CONTROLLER].product_id |
756 | + parser.buildHalDeviceList(parsed_data) |
757 | + found_product_id = parser.devices[self.UDI_SATA_CONTROLLER].product_id |
758 | self.assertEqual(found_product_id, 0x27c5, |
759 | 'Unexpected result of HWDevice.product_id. ' |
760 | 'Expected 0x27c5, got 0x%x.' |
761 | @@ -2576,8 +2610,8 @@ |
762 | }, |
763 | } |
764 | parser = SubmissionParser(self.log) |
765 | - parser.buildDeviceList(parsed_data) |
766 | - found_product_id = parser.hal_devices[self.UDI_SCSI_DISK].product_id |
767 | + parser.buildHalDeviceList(parsed_data) |
768 | + found_product_id = parser.devices[self.UDI_SCSI_DISK].product_id |
769 | self.assertEqual(found_product_id, 'ST36530N', |
770 | 'Unexpected result of HWDevice.product_id for a. ' |
771 | 'SCSI device. Expected ST35630N, got %r.' |
772 | @@ -2605,8 +2639,8 @@ |
773 | }, |
774 | } |
775 | parser = SubmissionParser(self.log) |
776 | - parser.buildDeviceList(parsed_data) |
777 | - found_product_id = parser.hal_devices[self.UDI_SCSI_DISK].product_id |
778 | + parser.buildHalDeviceList(parsed_data) |
779 | + found_product_id = parser.devices[self.UDI_SCSI_DISK].product_id |
780 | self.assertEqual(found_product_id, 'HTS54161', |
781 | 'Unexpected result of HWDevice.product_id for a. ' |
782 | 'fake SCSI device. Expected HTS54161, got %r.' |
783 | @@ -2635,8 +2669,8 @@ |
784 | }, |
785 | } |
786 | parser = SubmissionParser(self.log) |
787 | - parser.buildDeviceList(parsed_data) |
788 | - found_product_id = parser.hal_devices[self.UDI_COMPUTER].product_id |
789 | + parser.buildHalDeviceList(parsed_data) |
790 | + found_product_id = parser.devices[self.UDI_COMPUTER].product_id |
791 | self.assertEqual(found_product_id, 'LIFEBOOK E8210', |
792 | 'Unexpected result of HWDevice.product_id for a ' |
793 | 'system. Expected LIFEBOOK E8210, got %r.' |
794 | @@ -2672,8 +2706,8 @@ |
795 | properties['%s.vendor' % bus] = vendor_id |
796 | else: |
797 | properties['%s.vendor_id' % bus] = vendor_id |
798 | - parser.buildDeviceList(parsed_data) |
799 | - found_vendor_id = parser.hal_devices[ |
800 | + parser.buildHalDeviceList(parsed_data) |
801 | + found_vendor_id = parser.devices[ |
802 | self.UDI_SATA_DISK].vendor_id_for_db |
803 | self.assertEqual(found_vendor_id, expected_vendor_id, |
804 | 'Unexpected result of HWDevice.vendor_id_for_db for bus ' |
805 | @@ -2699,9 +2733,8 @@ |
806 | }, |
807 | } |
808 | parser = SubmissionParser(self.log) |
809 | - parser.buildDeviceList(parsed_data) |
810 | - found_vendor_id = parser.hal_devices[ |
811 | - self.UDI_COMPUTER].vendor_id_for_db |
812 | + parser.buildHalDeviceList(parsed_data) |
813 | + found_vendor_id = parser.devices[self.UDI_COMPUTER].vendor_id_for_db |
814 | self.assertEqual(found_vendor_id, 'FUJITSU SIEMENS', |
815 | 'Unexpected result of HWDevice.vendor_id_for_db for system. ' |
816 | 'Expected FUJITSU SIEMENS, got %r.' % found_vendor_id) |
817 | @@ -2737,8 +2770,8 @@ |
818 | properties['%s.model' % bus] = product_id |
819 | else: |
820 | properties['%s.product_id' % bus] = product_id |
821 | - parser.buildDeviceList(parsed_data) |
822 | - found_product_id = parser.hal_devices[ |
823 | + parser.buildHalDeviceList(parsed_data) |
824 | + found_product_id = parser.devices[ |
825 | self.UDI_SATA_DISK].product_id_for_db |
826 | self.assertEqual(found_product_id, expected_product_id, |
827 | 'Unexpected result of HWDevice.product_id_for_db for bus ' |
828 | @@ -2764,9 +2797,8 @@ |
829 | }, |
830 | } |
831 | parser = SubmissionParser(self.log) |
832 | - parser.buildDeviceList(parsed_data) |
833 | - found_product_id = parser.hal_devices[ |
834 | - self.UDI_COMPUTER].product_id_for_db |
835 | + parser.buildHalDeviceList(parsed_data) |
836 | + found_product_id = parser.devices[self.UDI_COMPUTER].product_id_for_db |
837 | self.assertEqual(found_product_id, 'E8210', |
838 | 'Unexpected result of HWDevice.product_id_for_db for system. ' |
839 | 'Expected FUJITSU SIEMENS, got %r.' % found_product_id) |
840 | @@ -2829,16 +2861,16 @@ |
841 | def testUSBDeviceRegularCase(self): |
842 | """Test of HALDevice.is_real_device: info.bus == 'usb_device'.""" |
843 | parser = SubmissionParser(self.log) |
844 | - parser.buildDeviceList(self.parsed_data) |
845 | - device = parser.hal_devices[self.UDI_USB_STORAGE] |
846 | + parser.buildHalDeviceList(self.parsed_data) |
847 | + device = parser.devices[self.UDI_USB_STORAGE] |
848 | self.failUnless( |
849 | device.is_real_device, |
850 | 'Testing info.bus property: Regular USB Device not treated ' |
851 | 'as a real device.') |
852 | |
853 | self.renameInfoBusToInfoSubsystem() |
854 | - parser.buildDeviceList(self.parsed_data) |
855 | - device = parser.hal_devices[self.UDI_USB_STORAGE] |
856 | + parser.buildHalDeviceList(self.parsed_data) |
857 | + device = parser.devices[self.UDI_USB_STORAGE] |
858 | self.failUnless( |
859 | device.is_real_device, |
860 | 'Testing info.subsystem property: Regular USB Device not treated ' |
861 | @@ -2852,17 +2884,16 @@ |
862 | """ |
863 | |
864 | parser = SubmissionParser(self.log) |
865 | - parser.buildDeviceList(self.parsed_data) |
866 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
867 | + parser.buildHalDeviceList(self.parsed_data) |
868 | + device = parser.devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
869 | self.failIf( |
870 | device.is_real_device, |
871 | 'Testing info.bus property: USB Device with vendor/product ' |
872 | 'ID 0:0 property treated as a real device.') |
873 | |
874 | self.renameInfoBusToInfoSubsystem() |
875 | - parser.buildDeviceList(self.parsed_data) |
876 | - parser.buildDeviceList(self.parsed_data) |
877 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
878 | + parser.buildHalDeviceList(self.parsed_data) |
879 | + device = parser.devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
880 | self.failIf( |
881 | device.is_real_device, |
882 | 'Testing info.subsystem property: USB Device with vendor/product ' |
883 | @@ -2879,8 +2910,8 @@ |
884 | parent_properties['pci.device_class'] = (PCI_CLASS_STORAGE, 'int') |
885 | parser = SubmissionParser(self.log) |
886 | parser.submission_key = 'USB device test 1' |
887 | - parser.buildDeviceList(self.parsed_data) |
888 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
889 | + parser.buildHalDeviceList(self.parsed_data) |
890 | + device = parser.devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
891 | self.failIf( |
892 | device.is_real_device, |
893 | 'Testing info.bus property: USB Device with vendor/product ' |
894 | @@ -2892,8 +2923,8 @@ |
895 | + self.UDI_USB_CONTROLLER_USB_SIDE) |
896 | |
897 | self.renameInfoBusToInfoSubsystem() |
898 | - parser.buildDeviceList(self.parsed_data) |
899 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
900 | + parser.buildHalDeviceList(self.parsed_data) |
901 | + device = parser.devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
902 | self.failIf( |
903 | device.is_real_device, |
904 | 'Testing info.subsystem property: USB Device with vendor/product ' |
905 | @@ -2915,8 +2946,8 @@ |
906 | parent_properties['pci.device_subclass'] = (1, 'int') |
907 | parser = SubmissionParser(self.log) |
908 | parser.submission_key = 'USB device test 2' |
909 | - parser.buildDeviceList(self.parsed_data) |
910 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
911 | + parser.buildHalDeviceList(self.parsed_data) |
912 | + device = parser.devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
913 | self.failIf( |
914 | device.is_real_device, |
915 | 'Testing info.bus property: USB Device with vendor/product ' |
916 | @@ -2928,8 +2959,8 @@ |
917 | + self.UDI_USB_CONTROLLER_USB_SIDE) |
918 | |
919 | self.renameInfoBusToInfoSubsystem() |
920 | - parser.buildDeviceList(self.parsed_data) |
921 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
922 | + parser.buildHalDeviceList(self.parsed_data) |
923 | + device = parser.devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
924 | self.failIf( |
925 | device.is_real_device, |
926 | 'Testing info.subsystem property: USB Device with vendor/product ' |
927 | @@ -2951,8 +2982,8 @@ |
928 | parent_properties['info.bus'] = ('not pci', 'str') |
929 | parser = SubmissionParser(self.log) |
930 | parser.submission_key = 'USB device test 3' |
931 | - parser.buildDeviceList(self.parsed_data) |
932 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
933 | + parser.buildHalDeviceList(self.parsed_data) |
934 | + device = parser.devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
935 | self.failIf( |
936 | device.is_real_device, |
937 | 'Testing info.bus property: USB Device with vendor/product ' |
938 | @@ -2966,15 +2997,15 @@ |
939 | # All other devices which have an info.bus property return True |
940 | # for HALDevice.is_real_device. The USB host controller in the |
941 | # test data is an example. |
942 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_PCI_SIDE] |
943 | + device = parser.devices[self.UDI_USB_CONTROLLER_PCI_SIDE] |
944 | self.failUnless( |
945 | device.is_real_device, |
946 | 'Testing info.bus property: Device with existing info.bus ' |
947 | 'property not treated as a real device.') |
948 | |
949 | self.renameInfoBusToInfoSubsystem() |
950 | - parser.buildDeviceList(self.parsed_data) |
951 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
952 | + parser.buildHalDeviceList(self.parsed_data) |
953 | + device = parser.devices[self.UDI_USB_CONTROLLER_USB_SIDE] |
954 | self.failIf( |
955 | device.is_real_device, |
956 | 'Testing info.subsystem property: USB Device with vendor/product ' |
957 | @@ -2985,7 +3016,7 @@ |
958 | 'parent device does not look like a USB host controller: ' |
959 | + self.UDI_USB_CONTROLLER_USB_SIDE) |
960 | |
961 | - device = parser.hal_devices[self.UDI_USB_CONTROLLER_PCI_SIDE] |
962 | + device = parser.devices[self.UDI_USB_CONTROLLER_PCI_SIDE] |
963 | self.failUnless( |
964 | device.is_real_device, |
965 | 'Testing info.subsystem property: Device with existing info.bus ' |
966 | @@ -4318,7 +4349,7 @@ |
967 | self.setHALDevices(devices) |
968 | parser = SubmissionParser(self.log) |
969 | parser.buildDeviceList(self.parsed_data) |
970 | - device = parser.hal_devices[self.UDI_COMPUTER] |
971 | + device = parser.devices[self.UDI_COMPUTER] |
972 | self.assertEqual(device.getDriver(), None, |
973 | 'HALDevice.getDriver found a driver where none is expected.') |
974 | |
975 | @@ -4332,7 +4363,7 @@ |
976 | parser = SubmissionParser(self.log) |
977 | parser.parsed_data = self.parsed_data |
978 | parser.buildDeviceList(self.parsed_data) |
979 | - device = parser.hal_devices[self.UDI_PCI_PCCARD_BRIDGE] |
980 | + device = parser.devices[self.UDI_PCI_PCCARD_BRIDGE] |
981 | driver = device.getDriver() |
982 | self.assertNotEqual(driver, None, |
983 | 'HALDevice.getDriver did not find a driver where one ' |
984 | @@ -4372,7 +4403,7 @@ |
985 | |
986 | # HALDevice.ensureVendorIDVendorNameExists() creates these |
987 | # records. |
988 | - hal_system = parser.hal_devices[self.UDI_COMPUTER] |
989 | + hal_system = parser.devices[self.UDI_COMPUTER] |
990 | hal_system.ensureVendorIDVendorNameExists() |
991 | |
992 | vendor_name = vendor_name_set.getByName('Lenovo') |
993 | @@ -4400,7 +4431,7 @@ |
994 | parser.parsed_data = self.parsed_data |
995 | parser.buildDeviceList(self.parsed_data) |
996 | |
997 | - hal_device = parser.hal_devices[test_udi] |
998 | + hal_device = parser.devices[test_udi] |
999 | hal_device.ensureVendorIDVendorNameExists() |
1000 | |
1001 | vendor_id_set = getUtility(IHWVendorIDSet) |
1002 | @@ -4474,7 +4505,7 @@ |
1003 | |
1004 | # HALDevice.ensureVendorIDVendorNameExists() creates these |
1005 | # records. |
1006 | - scsi_disk = parser.hal_devices[self.UDI_SCSI_DISK] |
1007 | + scsi_disk = parser.devices[self.UDI_SCSI_DISK] |
1008 | scsi_disk.ensureVendorIDVendorNameExists() |
1009 | |
1010 | vendor_name = vendor_name_set.getByName('WDC') |
1011 | @@ -4506,7 +4537,7 @@ |
1012 | submission_set = getUtility(IHWSubmissionSet) |
1013 | submission = submission_set.getBySubmissionKey('test_submission_id_1') |
1014 | |
1015 | - hal_device = parser.hal_devices[self.UDI_COMPUTER] |
1016 | + hal_device = parser.devices[self.UDI_COMPUTER] |
1017 | hal_device.createDBData(submission, None) |
1018 | |
1019 | # HALDevice.createDBData created a HWDevice record. |
1020 | @@ -4573,7 +4604,7 @@ |
1021 | submission_set = getUtility(IHWSubmissionSet) |
1022 | submission = submission_set.getBySubmissionKey('test_submission_id_1') |
1023 | |
1024 | - hal_root_device = parser.hal_devices[self.UDI_COMPUTER] |
1025 | + hal_root_device = parser.devices[self.UDI_COMPUTER] |
1026 | hal_root_device.createDBData(submission, None) |
1027 | |
1028 | # We now have a HWDevice record for the PCCard bridge... |
1029 | @@ -4680,7 +4711,7 @@ |
1030 | submission_set = getUtility(IHWSubmissionSet) |
1031 | submission = submission_set.getBySubmissionKey('test_submission_id_1') |
1032 | |
1033 | - hal_root_device = parser.hal_devices[self.UDI_COMPUTER] |
1034 | + hal_root_device = parser.devices[self.UDI_COMPUTER] |
1035 | hal_root_device.createDBData(submission, None) |
1036 | |
1037 | # The USB controller has a HWDevice record. |
1038 | @@ -4934,6 +4965,24 @@ |
1039 | self.failIf( |
1040 | result, 'Submission with inconsistent data treated as valid.') |
1041 | |
1042 | + def test_processSubmission_buildDeviceList_failing(self): |
1043 | + """Test of SubmissionParser.processSubmission(). |
1044 | + |
1045 | + If the method buildDeviceList() fails for a submission, it is |
1046 | + rejected. |
1047 | + """ |
1048 | + def no(*args, **kw): |
1049 | + return False |
1050 | + |
1051 | + submission_key = 'builddevicelist-fails' |
1052 | + submission_data = self.getSampleData( |
1053 | + 'simple_valid_hwdb_submission.xml') |
1054 | + submission = self.createSubmissionData( |
1055 | + submission_data, False, submission_key) |
1056 | + parser = SubmissionParser() |
1057 | + parser.buildDeviceList = no |
1058 | + self.assertFalse(parser.processSubmission(submission)) |
1059 | + |
1060 | def testProcessSubmissionRealData(self): |
1061 | """Test of SubmissionParser.processSubmission(). |
1062 | |
1063 | |
1064 | === modified file 'lib/lp/registry/browser/product.py' |
This branch renames the method SubmissionParse r.buildDeviceLi st() to SubmissionParse r.buildHalDevic eList() , and it adds a new method SubmissionParse r.buildDeviceLi st(), which calls buildHalDeviceL ist() and buildUdevDevice List().
HWDB Submissions coming from the clinet in Karmic do no longer contain data gathered by HAL; instead, the contain udev data.
The udev data looks quite different and is thus processed differently. Single devices found in submissions with HAL data are represented by instances of class HalDevice, while devices from submissions with udev data are represented by instances of class UdevDevice.
One step in the proeccsing of a HWDB submission is the creation of instances of HalDevice/ Udevdevice, which is done in the methods buildHalDeviceL ist() and buildUdevDevice List(), respectively.
Depending on the type of the submission, the "right" method from these two should be called, which is done in buildDeviceList().
SuubmissionPars er.buildDveiceL ist makes the implicit assumption that parsed_ data['hardware' ] has either an item ith the key 'hal' or an item with the key 'udev' (needed in buldUdevDeviceL ist()), but not both. This is guaranteed by an earlier stage of submission processing.
A second change is mostly mechanical, but causes half of all diff lines: I renames the property SubmissisonPars er.hal_ devices to SubmissionParse r.devices, so that it fits a bit better for submissions containg udev data.
The interesting part of the diff are the first 100 line and the last 20 lines; the remaining part of the diff just reflects the name change SubmissisonPars er.hal_ devices -> SubmissionParse r.devices; I also changed the calls of parser. buildDeviceList () to parser. buildHalDeviceL ist() in those tests that are specific for HAL data.