Merge lp:~adeuring/launchpad/hwdb-class-udev-device-4 into lp:launchpad/db-devel
- hwdb-class-udev-device-4
- Merge into db-devel
Status: | Merged |
---|---|
Approved by: | Brad Crittenden |
Approved revision: | no longer in the source branch. |
Merged at revision: | not available |
Proposed branch: | lp:~adeuring/launchpad/hwdb-class-udev-device-4 |
Merge into: | lp:launchpad/db-devel |
Diff against target: |
664 lines 2 files modified
lib/canonical/launchpad/scripts/hwdbsubmissions.py (+157/-16) lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py (+207/-58) |
To merge this branch: | bzr merge lp:~adeuring/launchpad/hwdb-class-udev-device-4 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brad Crittenden (community) | code | Approve | |
Canonical Launchpad Engineering | Pending | ||
Review via email: mp+13300@code.launchpad.net |
Commit message
Description of the change
Abel Deuring (adeuring) wrote : | # |
Brad Crittenden (bac) wrote : | # |
Hi Abel,
Thanks for the changes. We discussed some of my suggestions on IRC already. Please post an incremental diff when you've made these changes.
--Brad
> === modified file 'lib/canonical/
> --- lib/canonical/
> +++ lib/canonical/
@@ -59,6 +59,7 @@
> re.VERBOSE)
>
> ROOT_UDI = '/org/freedeskt
> +UDEV_ROOT_PATH = '/devices/
>
> # These UDIs appears in some submissions more than once.
> KNOWN_DUPLICATE
> @@ -1606,6 +1607,7 @@
> @property
> def driver_name(self):
> """The name of the driver contolling this device. May be None."""
> + raise NotImplementedError
Nice clean up.
> def translateScsiBu
> """Return the real bus of a device where raw_bus=='scsi'.
> @@ -2358,7 +2360,7 @@
> class UdevDevice(
> """The representation of a udev device node."""
>
> - def __init__(self, udev_data, sysfs_data, parser):
> + def __init__(self, udev_data, sysfs_data, dmi_data, parser):
> """HALDevice constructor.
Seeing all of your test changes that required adding another parameter
make me wonder if you don't want to have default values on some of
these, especially the new one. Also I'm surprised to see you didn't
add the new on at the end, which helps with backward compatability.
> :param udevdata: The udev data for this device
> @@ -2369,6 +2371,7 @@
> super(UdevDevice, self)._
> self.udev = udev_data
> self.sysfs = sysfs_data
> + self.dmi = dmi_data
>
> @property
> def device_id(self):
> @@ -2410,6 +2413,24 @@
> return self.pci_
As we discussed on IRC, a lot of your code would be cleaner if methods
such as this one returned a dictionary with 'vendor' and 'product' as
the keys. Take a stab at doing that throughout and see what happens.
> @property
> + def pci_ids(self):
> + """The PCI vendor and product IDs.
> +
> + :return: (vendor_id, product_id) for PCI devices
> + or (None, None) for other devices.
> + """
> + if self.is_pci:
> + # SubmissionParse
> + # each PCI device has the property PCI_ID and that is
> + # consists of two 4-digit hexadecimal numbers, separated
> + # by a ':'.
> + id_string = self.udev[
> + ids = id_string.
> + return [int(part, 16) for part in ids]
> + else:
> + return [None, None]
> +
> + @property
> def is_usb(self):
> """True, if this is a USB device, else False."""
> return self.udev[
> @@ -2476,6 +2497,116 @@
> else:
> return None
>
> + @property
> + def raw_bus(self):
> + """See `BaseDevice`."""
> + # udev specifies the property SUBSYSTEM for most devices;
> + # some devices have additionally the more specific property
...
Abel Deuring (adeuring) wrote : | # |
Hi Brad,
thanks for your review.
On 13.10.2009 21:28, Brad Crittenden wrote:
> Review: Needs Fixing code
> Hi Abel,
>
> Thanks for the changes. We discussed some of my suggestions on IRC already. Please post an incremental diff when you've made these changes.
>
> --Brad
>
>
>> === modified file 'lib/canonical/
>> --- lib/canonical/
>> +++ lib/canonical/
> @@ -59,6 +59,7 @@
>> re.VERBOSE)
>>
>> ROOT_UDI = '/org/freedeskt
>> +UDEV_ROOT_PATH = '/devices/
>>
>> # These UDIs appears in some submissions more than once.
>> KNOWN_DUPLICATE
>> @@ -1606,6 +1607,7 @@
>> @property
>> def driver_name(self):
>> """The name of the driver contolling this device. May be None."""
>> + raise NotImplementedError
>
> Nice clean up.
>
>> def translateScsiBu
>> """Return the real bus of a device where raw_bus=='scsi'.
>> @@ -2358,7 +2360,7 @@
>> class UdevDevice(
>> """The representation of a udev device node."""
>>
>> - def __init__(self, udev_data, sysfs_data, parser):
>> + def __init__(self, udev_data, sysfs_data, dmi_data, parser):
>> """HALDevice constructor.
>
> Seeing all of your test changes that required adding another parameter
> make me wonder if you don't want to have default values on some of
> these, especially the new one. Also I'm surprised to see you didn't
> add the new on at the end, which helps with backward compatability.
Well, class UdevDevice is yet not used anywhere, so backward
compatibility is not an issue. But you are right, dmi_data and
sysfs_data in many cases not needed, while parser _is_ needed (in class
BaseDevice), so I shuffled the parameters again...
>
>> :param udevdata: The udev data for this device
>> @@ -2369,6 +2371,7 @@
>> super(UdevDevice, self)._
>> self.udev = udev_data
>> self.sysfs = sysfs_data
>> + self.dmi = dmi_data
>>
>> @property
>> def device_id(self):
>> @@ -2410,6 +2413,24 @@
>> return self.pci_
>
> As we discussed on IRC, a lot of your code would be cleaner if methods
> such as this one returned a dictionary with 'vendor' and 'product' as
> the keys. Take a stab at doing that throughout and see what happens.
Changed. Though this made the diff a bit larger, since it affected (via
the method getScsiVendorAn
>
>> @property
>> + def pci_ids(self):
>> + """The PCI vendor and product IDs.
>> +
>> + :return: (vendor_id, product_id) for PCI devices
>> + or (None, None) for other devices.
>> + """
>> + if self.is_pci:
>> + # SubmissionParse
>> + # each PCI device has the property PCI_ID and that is
>> + # consists of two 4-digit hexadecimal numbers, separated
>> + # by a ':'.
>> + id_string = self.udev[
>> + ids = id...
Brad Crittenden (bac) wrote : | # |
Thanks for the changes Abel!
Preview Diff
1 | === modified file 'lib/canonical/launchpad/scripts/hwdbsubmissions.py' | |||
2 | --- lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-12 15:36:04 +0000 | |||
3 | +++ lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-13 21:06:13 +0000 | |||
4 | @@ -59,6 +59,7 @@ | |||
5 | 59 | re.VERBOSE) | 59 | re.VERBOSE) |
6 | 60 | 60 | ||
7 | 61 | ROOT_UDI = '/org/freedesktop/Hal/devices/computer' | 61 | ROOT_UDI = '/org/freedesktop/Hal/devices/computer' |
8 | 62 | UDEV_ROOT_PATH = '/devices/LNXSYSTM:00' | ||
9 | 62 | 63 | ||
10 | 63 | # These UDIs appears in some submissions more than once. | 64 | # These UDIs appears in some submissions more than once. |
11 | 64 | KNOWN_DUPLICATE_UDIS = set(( | 65 | KNOWN_DUPLICATE_UDIS = set(( |
12 | @@ -1606,6 +1607,7 @@ | |||
13 | 1606 | @property | 1607 | @property |
14 | 1607 | def driver_name(self): | 1608 | def driver_name(self): |
15 | 1608 | """The name of the driver contolling this device. May be None.""" | 1609 | """The name of the driver contolling this device. May be None.""" |
16 | 1610 | raise NotImplementedError | ||
17 | 1609 | 1611 | ||
18 | 1610 | def translateScsiBus(self): | 1612 | def translateScsiBus(self): |
19 | 1611 | """Return the real bus of a device where raw_bus=='scsi'. | 1613 | """Return the real bus of a device where raw_bus=='scsi'. |
20 | @@ -2067,10 +2069,15 @@ | |||
21 | 2067 | # it is hard to find a better heuristic to separate | 2069 | # it is hard to find a better heuristic to separate |
22 | 2068 | # the vendor name from the product name. | 2070 | # the vendor name from the product name. |
23 | 2069 | splitted_name = self.scsi_model.split(' ', 1) | 2071 | splitted_name = self.scsi_model.split(' ', 1) |
28 | 2070 | if len(splitted_name) < 2: | 2072 | if len(splitted_name) == 2: |
29 | 2071 | return 'ATA', splitted_name[0] | 2073 | return { |
30 | 2072 | return splitted_name | 2074 | 'vendor': splitted_name[0], |
31 | 2073 | return (vendor, self.scsi_model) | 2075 | 'product': splitted_name[1], |
32 | 2076 | } | ||
33 | 2077 | return { | ||
34 | 2078 | 'vendor': vendor, | ||
35 | 2079 | 'product': self.scsi_model, | ||
36 | 2080 | } | ||
37 | 2074 | 2081 | ||
38 | 2075 | def getDriver(self): | 2082 | def getDriver(self): |
39 | 2076 | """Return the HWDriver instance associated with this device. | 2083 | """Return the HWDriver instance associated with this device. |
40 | @@ -2289,11 +2296,7 @@ | |||
41 | 2289 | # below does not work properly. | 2296 | # below does not work properly. |
42 | 2290 | return self.getProperty('system.hardware.' + type_) | 2297 | return self.getProperty('system.hardware.' + type_) |
43 | 2291 | elif bus == 'scsi': | 2298 | elif bus == 'scsi': |
49 | 2292 | vendor, product = self.getScsiVendorAndModelName() | 2299 | return self.getScsiVendorAndModelName()[type_] |
45 | 2293 | if type_ == 'vendor': | ||
46 | 2294 | return vendor | ||
47 | 2295 | else: | ||
48 | 2296 | return product | ||
50 | 2297 | else: | 2300 | else: |
51 | 2298 | result = self.getProperty('info.' + type_) | 2301 | result = self.getProperty('info.' + type_) |
52 | 2299 | if result is None: | 2302 | if result is None: |
53 | @@ -2358,7 +2361,7 @@ | |||
54 | 2358 | class UdevDevice(BaseDevice): | 2361 | class UdevDevice(BaseDevice): |
55 | 2359 | """The representation of a udev device node.""" | 2362 | """The representation of a udev device node.""" |
56 | 2360 | 2363 | ||
58 | 2361 | def __init__(self, udev_data, sysfs_data, parser): | 2364 | def __init__(self, parser, udev_data, sysfs_data=None, dmi_data=None): |
59 | 2362 | """HALDevice constructor. | 2365 | """HALDevice constructor. |
60 | 2363 | 2366 | ||
61 | 2364 | :param udevdata: The udev data for this device | 2367 | :param udevdata: The udev data for this device |
62 | @@ -2369,6 +2372,7 @@ | |||
63 | 2369 | super(UdevDevice, self).__init__(parser) | 2372 | super(UdevDevice, self).__init__(parser) |
64 | 2370 | self.udev = udev_data | 2373 | self.udev = udev_data |
65 | 2371 | self.sysfs = sysfs_data | 2374 | self.sysfs = sysfs_data |
66 | 2375 | self.dmi = dmi_data | ||
67 | 2372 | 2376 | ||
68 | 2373 | @property | 2377 | @property |
69 | 2374 | def device_id(self): | 2378 | def device_id(self): |
70 | @@ -2376,6 +2380,14 @@ | |||
71 | 2376 | return self.udev['P'] | 2380 | return self.udev['P'] |
72 | 2377 | 2381 | ||
73 | 2378 | @property | 2382 | @property |
74 | 2383 | def root_device_ids(self): | ||
75 | 2384 | """The vendor and product IDs of the root device.""" | ||
76 | 2385 | return { | ||
77 | 2386 | 'vendor': self.dmi.get('/sys/class/dmi/id/sys_vendor'), | ||
78 | 2387 | 'product': self.dmi.get('/sys/class/dmi/id/product_name') | ||
79 | 2388 | } | ||
80 | 2389 | |||
81 | 2390 | @property | ||
82 | 2379 | def is_pci(self): | 2391 | def is_pci(self): |
83 | 2380 | """True, if this is a PCI device, else False.""" | 2392 | """True, if this is a PCI device, else False.""" |
84 | 2381 | return self.udev['E'].get('SUBSYSTEM') == 'pci' | 2393 | return self.udev['E'].get('SUBSYSTEM') == 'pci' |
85 | @@ -2410,6 +2422,30 @@ | |||
86 | 2410 | return self.pci_class_info[1] | 2422 | return self.pci_class_info[1] |
87 | 2411 | 2423 | ||
88 | 2412 | @property | 2424 | @property |
89 | 2425 | def pci_ids(self): | ||
90 | 2426 | """The PCI vendor and product IDs. | ||
91 | 2427 | |||
92 | 2428 | :return: A dictionary containing the vendor and product IDs. | ||
93 | 2429 | The IDs are set to None for Non-PCI devices. | ||
94 | 2430 | """ | ||
95 | 2431 | if self.is_pci: | ||
96 | 2432 | # SubmissionParser.checkUdevPciProperties() ensures that | ||
97 | 2433 | # each PCI device has the property PCI_ID and that is | ||
98 | 2434 | # consists of two 4-digit hexadecimal numbers, separated | ||
99 | 2435 | # by a ':'. | ||
100 | 2436 | id_string = self.udev['E']['PCI_ID'] | ||
101 | 2437 | ids = id_string.split(':') | ||
102 | 2438 | return { | ||
103 | 2439 | 'vendor': int(ids[0], 16), | ||
104 | 2440 | 'product': int(ids[1], 16), | ||
105 | 2441 | } | ||
106 | 2442 | else: | ||
107 | 2443 | return { | ||
108 | 2444 | 'vendor': None, | ||
109 | 2445 | 'product': None, | ||
110 | 2446 | } | ||
111 | 2447 | |||
112 | 2448 | @property | ||
113 | 2413 | def is_usb(self): | 2449 | def is_usb(self): |
114 | 2414 | """True, if this is a USB device, else False.""" | 2450 | """True, if this is a USB device, else False.""" |
115 | 2415 | return self.udev['E'].get('SUBSYSTEM') == 'usb' | 2451 | return self.udev['E'].get('SUBSYSTEM') == 'usb' |
116 | @@ -2418,8 +2454,9 @@ | |||
117 | 2418 | def usb_ids(self): | 2454 | def usb_ids(self): |
118 | 2419 | """The vendor ID, product ID, product version for USB devices. | 2455 | """The vendor ID, product ID, product version for USB devices. |
119 | 2420 | 2456 | ||
122 | 2421 | :return: [vendor_id, product_id, version] for USB devices | 2457 | :return: A dictionary containing the vendor and product IDs and |
123 | 2422 | or [None, None, None] for other devices. | 2458 | the product version for USB devices. |
124 | 2459 | The IDs are set to None for Non-USB devices. | ||
125 | 2423 | """ | 2460 | """ |
126 | 2424 | if self.is_usb: | 2461 | if self.is_usb: |
127 | 2425 | # udev represents USB device IDs as strings | 2462 | # udev represents USB device IDs as strings |
128 | @@ -2428,19 +2465,27 @@ | |||
129 | 2428 | # SubmissionParser.checkUdevUsbProperties() ensures that | 2465 | # SubmissionParser.checkUdevUsbProperties() ensures that |
130 | 2429 | # the string PRODUCT is in the format required below. | 2466 | # the string PRODUCT is in the format required below. |
131 | 2430 | product_info = self.udev['E']['PRODUCT'].split('/') | 2467 | product_info = self.udev['E']['PRODUCT'].split('/') |
133 | 2431 | return [int(part, 16) for part in product_info] | 2468 | return { |
134 | 2469 | 'vendor': int(product_info[0], 16), | ||
135 | 2470 | 'product': int(product_info[1], 16), | ||
136 | 2471 | 'version': int(product_info[2], 16), | ||
137 | 2472 | } | ||
138 | 2432 | else: | 2473 | else: |
140 | 2433 | return [None, None, None] | 2474 | return { |
141 | 2475 | 'vendor': None, | ||
142 | 2476 | 'product': None, | ||
143 | 2477 | 'version': None, | ||
144 | 2478 | } | ||
145 | 2434 | 2479 | ||
146 | 2435 | @property | 2480 | @property |
147 | 2436 | def usb_vendor_id(self): | 2481 | def usb_vendor_id(self): |
148 | 2437 | """See `BaseDevice`.""" | 2482 | """See `BaseDevice`.""" |
150 | 2438 | return self.usb_ids[0] | 2483 | return self.usb_ids['vendor'] |
151 | 2439 | 2484 | ||
152 | 2440 | @property | 2485 | @property |
153 | 2441 | def usb_product_id(self): | 2486 | def usb_product_id(self): |
154 | 2442 | """See `BaseDevice`.""" | 2487 | """See `BaseDevice`.""" |
156 | 2443 | return self.usb_ids[1] | 2488 | return self.usb_ids['product'] |
157 | 2444 | 2489 | ||
158 | 2445 | @property | 2490 | @property |
159 | 2446 | def is_scsi_device(self): | 2491 | def is_scsi_device(self): |
160 | @@ -2476,6 +2521,102 @@ | |||
161 | 2476 | else: | 2521 | else: |
162 | 2477 | return None | 2522 | return None |
163 | 2478 | 2523 | ||
164 | 2524 | @property | ||
165 | 2525 | def raw_bus(self): | ||
166 | 2526 | """See `BaseDevice`.""" | ||
167 | 2527 | # udev specifies the property SUBSYSTEM for most devices; | ||
168 | 2528 | # some devices have additionally the more specific property | ||
169 | 2529 | # DEVTYPE. DEVTYPE is preferable. | ||
170 | 2530 | # The root device has the subsystem/bus value "acpi", which | ||
171 | 2531 | # is a bit nonsensical. | ||
172 | 2532 | if self.device_id == UDEV_ROOT_PATH: | ||
173 | 2533 | return None | ||
174 | 2534 | properties = self.udev['E'] | ||
175 | 2535 | devtype = properties.get('DEVTYPE') | ||
176 | 2536 | if devtype is not None: | ||
177 | 2537 | return devtype | ||
178 | 2538 | return properties.get('SUBSYSTEM') | ||
179 | 2539 | |||
180 | 2540 | def getVendorOrProduct(self, type_): | ||
181 | 2541 | """Return the vendor or product of this device. | ||
182 | 2542 | |||
183 | 2543 | :return: The vendor or product data for this device. | ||
184 | 2544 | :param type_: 'vendor' or 'product' | ||
185 | 2545 | """ | ||
186 | 2546 | assert type_ in ('vendor', 'product'), ( | ||
187 | 2547 | 'Unexpected value of type_: %r' % type_) | ||
188 | 2548 | |||
189 | 2549 | bus = self.raw_bus | ||
190 | 2550 | if self.device_id == UDEV_ROOT_PATH: | ||
191 | 2551 | # udev does not known about any product information for | ||
192 | 2552 | # the root device. We use DMI data instead. | ||
193 | 2553 | return self.root_device_ids[type_] | ||
194 | 2554 | elif bus == 'scsi_device': | ||
195 | 2555 | return self.getScsiVendorAndModelName()[type_] | ||
196 | 2556 | elif bus in ('pci', 'usb_device'): | ||
197 | 2557 | # XXX Abel Deuring 2009-10-13, bug 450480: udev does not | ||
198 | 2558 | # provide human-readable vendor and product names for | ||
199 | 2559 | # USB and PCI devices. We should retrieve these from | ||
200 | 2560 | # http://www.linux-usb.org/usb.ids and | ||
201 | 2561 | # http://pciids.sourceforge.net/v2.2/pci.ids | ||
202 | 2562 | return 'Unknown' | ||
203 | 2563 | else: | ||
204 | 2564 | # We don't process yet other devices than complete systems, | ||
205 | 2565 | # PCI, USB devices and those devices that are represented | ||
206 | 2566 | # in udev as SCSI devices: real SCSI devices, and | ||
207 | 2567 | # IDE/ATA/SATA devices. | ||
208 | 2568 | return None | ||
209 | 2569 | |||
210 | 2570 | @property | ||
211 | 2571 | def vendor(self): | ||
212 | 2572 | """See `BaseDevice`.""" | ||
213 | 2573 | return self.getVendorOrProduct('vendor') | ||
214 | 2574 | |||
215 | 2575 | @property | ||
216 | 2576 | def product(self): | ||
217 | 2577 | """See `BaseDevice`.""" | ||
218 | 2578 | return self.getVendorOrProduct('product') | ||
219 | 2579 | |||
220 | 2580 | def getVendorOrProductID(self, type_): | ||
221 | 2581 | """Return the vendor or product ID of this device. | ||
222 | 2582 | |||
223 | 2583 | :return: The vendor or product ID for this device. | ||
224 | 2584 | :param type_: 'vendor' or 'product' | ||
225 | 2585 | """ | ||
226 | 2586 | assert type_ in ('vendor', 'product'), ( | ||
227 | 2587 | 'Unexpected value of type_: %r' % type_) | ||
228 | 2588 | |||
229 | 2589 | bus = self.raw_bus | ||
230 | 2590 | if self.device_id == UDEV_ROOT_PATH: | ||
231 | 2591 | # udev does not known about any product information for | ||
232 | 2592 | # the root device. We use DMI data instead. | ||
233 | 2593 | if type_ == 'vendor': | ||
234 | 2594 | return self.dmi.get('/sys/class/dmi/id/sys_vendor') | ||
235 | 2595 | else: | ||
236 | 2596 | return self.dmi.get('/sys/class/dmi/id/product_name') | ||
237 | 2597 | elif bus == 'scsi_device': | ||
238 | 2598 | return self.getScsiVendorAndModelName()[type_] | ||
239 | 2599 | elif bus == 'pci': | ||
240 | 2600 | return self.pci_ids[type_] | ||
241 | 2601 | elif bus == 'usb_device': | ||
242 | 2602 | return self.usb_ids[type_] | ||
243 | 2603 | else: | ||
244 | 2604 | # We don't process yet other devices than complete systems, | ||
245 | 2605 | # PCI, USB devices and those devices that are represented | ||
246 | 2606 | # in udev as SCSI devices: real SCSI devices, and | ||
247 | 2607 | # IDE/ATA/SATA devices. | ||
248 | 2608 | return None | ||
249 | 2609 | |||
250 | 2610 | @property | ||
251 | 2611 | def vendor_id(self): | ||
252 | 2612 | """See `BaseDevice`.""" | ||
253 | 2613 | return self.getVendorOrProductID('vendor') | ||
254 | 2614 | |||
255 | 2615 | @property | ||
256 | 2616 | def product_id(self): | ||
257 | 2617 | """See `BaseDevice`.""" | ||
258 | 2618 | return self.getVendorOrProductID('product') | ||
259 | 2619 | |||
260 | 2479 | 2620 | ||
261 | 2480 | class ProcessingLoop(object): | 2621 | class ProcessingLoop(object): |
262 | 2481 | """An `ITunableLoop` for processing HWDB submissions.""" | 2622 | """An `ITunableLoop` for processing HWDB submissions.""" |
263 | 2482 | 2623 | ||
264 | === modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py' | |||
265 | --- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-12 14:50:22 +0000 | |||
266 | +++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-13 21:06:13 +0000 | |||
267 | @@ -1598,18 +1598,16 @@ | |||
268 | 1598 | parser = SubmissionParser(self.log) | 1598 | parser = SubmissionParser(self.log) |
269 | 1599 | parser.buildDeviceList(parsed_data) | 1599 | parser.buildDeviceList(parsed_data) |
270 | 1600 | device = parser.hal_devices[self.UDI_SCSI_DISK] | 1600 | device = parser.hal_devices[self.UDI_SCSI_DISK] |
272 | 1601 | vendor, model = device.getScsiVendorAndModelName() | 1601 | vendor_model = device.getScsiVendorAndModelName() |
273 | 1602 | self.assertEqual( | 1602 | self.assertEqual( |
275 | 1603 | vendor, 'SHARP', | 1603 | { |
276 | 1604 | 'vendor': 'SHARP', | ||
277 | 1605 | 'product': 'JX250 SCSI', | ||
278 | 1606 | }, | ||
279 | 1607 | vendor_model, | ||
280 | 1604 | 'Unexpected result of HWDevice.getScsiVendorAndModelName ' | 1608 | 'Unexpected result of HWDevice.getScsiVendorAndModelName ' |
281 | 1605 | 'for a regular SCSI device. Expected vendor name SHARP, got %r.' | 1609 | 'for a regular SCSI device. Expected vendor name SHARP, got %r.' |
289 | 1606 | % vendor) | 1610 | % vendor_model) |
283 | 1607 | self.assertEqual( | ||
284 | 1608 | model, 'JX250 SCSI', | ||
285 | 1609 | 'Unexpected result of HWDevice.getScsiVendorAndModelName ' | ||
286 | 1610 | 'for a regular SCSI device. Expected model name JX250 SCSI , ' | ||
287 | 1611 | 'got %r.' | ||
288 | 1612 | % model) | ||
290 | 1613 | 1611 | ||
291 | 1614 | def testHALDeviceSCSIVendorModelNameATADiskShortModelName(self): | 1612 | def testHALDeviceSCSIVendorModelNameATADiskShortModelName(self): |
292 | 1615 | """Test of HALDevice.getScsiVendorAndModelName, ATA disk (1). | 1613 | """Test of HALDevice.getScsiVendorAndModelName, ATA disk (1). |
293 | @@ -1639,18 +1637,16 @@ | |||
294 | 1639 | parser = SubmissionParser(self.log) | 1637 | parser = SubmissionParser(self.log) |
295 | 1640 | parser.buildDeviceList(parsed_data) | 1638 | parser.buildDeviceList(parsed_data) |
296 | 1641 | device = parser.hal_devices[self.UDI_SCSI_DISK] | 1639 | device = parser.hal_devices[self.UDI_SCSI_DISK] |
309 | 1642 | vendor, model = device.getScsiVendorAndModelName() | 1640 | vendor_model = device.getScsiVendorAndModelName() |
310 | 1643 | self.assertEqual( | 1641 | self.assertEqual( |
311 | 1644 | vendor, 'Hitachi', | 1642 | { |
312 | 1645 | 'Unexpected result of HWDevice.getScsiVendorAndModelName ' | 1643 | 'vendor': 'Hitachi', |
313 | 1646 | 'for an ATA SCSI device. Expected vendor name Hitachi, got %r.' | 1644 | 'product': 'HTS54161', |
314 | 1647 | % vendor) | 1645 | }, |
315 | 1648 | self.assertEqual( | 1646 | vendor_model, |
316 | 1649 | model, 'HTS54161', | 1647 | 'Unexpected result of HWDevice.getScsiVendorAndModelName ' |
317 | 1650 | 'Unexpected result of HWDevice.getScsiVendorAndModelName ' | 1648 | 'for an ATA SCSI device: %r.' |
318 | 1651 | 'for a reguale SCSI device. Expected vendor name HTS54161, ' | 1649 | % vendor_model) |
307 | 1652 | 'got %r.' | ||
308 | 1653 | % model) | ||
319 | 1654 | 1650 | ||
320 | 1655 | def testHALDeviceSCSIVendorModelNameATADiskLongModelName(self): | 1651 | def testHALDeviceSCSIVendorModelNameATADiskLongModelName(self): |
321 | 1656 | """Test of HALDevice.getScsiVendorAndModelName, ATA disk (2). | 1652 | """Test of HALDevice.getScsiVendorAndModelName, ATA disk (2). |
322 | @@ -1679,18 +1675,16 @@ | |||
323 | 1679 | parser = SubmissionParser(self.log) | 1675 | parser = SubmissionParser(self.log) |
324 | 1680 | parser.buildDeviceList(parsed_data) | 1676 | parser.buildDeviceList(parsed_data) |
325 | 1681 | device = parser.hal_devices[self.UDI_SCSI_DISK] | 1677 | device = parser.hal_devices[self.UDI_SCSI_DISK] |
338 | 1682 | vendor, model = device.getScsiVendorAndModelName() | 1678 | vendor_product = device.getScsiVendorAndModelName() |
339 | 1683 | self.assertEqual( | 1679 | self.assertEqual( |
340 | 1684 | vendor, 'ATA', | 1680 | { |
341 | 1685 | 'Unexpected result of HWDevice.getScsiVendorAndModelName ' | 1681 | 'vendor': 'ATA', |
342 | 1686 | 'for a reguale SCSI device. Expected vendor name ATA, got %r.' | 1682 | 'product': 'HTC426060G9AT00', |
343 | 1687 | % vendor) | 1683 | }, |
344 | 1688 | self.assertEqual( | 1684 | vendor_product, |
345 | 1689 | model, 'HTC426060G9AT00', | 1685 | 'Unexpected result of HWDevice.getScsiVendorAndModelName ' |
346 | 1690 | 'Unexpected result of HWDevice.getScsiVendorAndModelName ' | 1686 | 'for a reguale SCSI device: %r.' |
347 | 1691 | 'for a reguale SCSI device. Expected vendor name ' | 1687 | % vendor_product) |
336 | 1692 | 'HTC426060G9AT00 , got %r.' | ||
337 | 1693 | % model) | ||
348 | 1694 | 1688 | ||
349 | 1695 | def testHALDeviceVendorFromInfoVendor(self): | 1689 | def testHALDeviceVendorFromInfoVendor(self): |
350 | 1696 | """Test of HALDevice.vendor, regular case. | 1690 | """Test of HALDevice.vendor, regular case. |
351 | @@ -2606,6 +2600,11 @@ | |||
352 | 2606 | } | 2600 | } |
353 | 2607 | } | 2601 | } |
354 | 2608 | 2602 | ||
355 | 2603 | root_device_dmi_data = { | ||
356 | 2604 | '/sys/class/dmi/id/sys_vendor': 'FUJITSU SIEMENS', | ||
357 | 2605 | '/sys/class/dmi/id/product_name': 'LIFEBOOK E8210', | ||
358 | 2606 | } | ||
359 | 2607 | |||
360 | 2609 | pci_device_data = { | 2608 | pci_device_data = { |
361 | 2610 | 'P': '/devices/pci0000:00/0000:00:1f.2', | 2609 | 'P': '/devices/pci0000:00/0000:00:1f.2', |
362 | 2611 | 'E': { | 2610 | 'E': { |
363 | @@ -2641,97 +2640,149 @@ | |||
364 | 2641 | 'type': '5', | 2640 | 'type': '5', |
365 | 2642 | } | 2641 | } |
366 | 2643 | 2642 | ||
367 | 2643 | no_subsystem_device_data = { | ||
368 | 2644 | 'P': '/devices/pnp0/00:00', | ||
369 | 2645 | 'E': {} | ||
370 | 2646 | } | ||
371 | 2647 | |||
372 | 2644 | def test_device_id(self): | 2648 | def test_device_id(self): |
373 | 2645 | """Test of UdevDevice.device_id.""" | 2649 | """Test of UdevDevice.device_id.""" |
375 | 2646 | device = UdevDevice(self.pci_device_data, None, None) | 2650 | device = UdevDevice(None, self.pci_device_data) |
376 | 2647 | self.assertEqual( | 2651 | self.assertEqual( |
377 | 2648 | '/devices/pci0000:00/0000:00:1f.2', device.device_id, | 2652 | '/devices/pci0000:00/0000:00:1f.2', device.device_id, |
378 | 2649 | 'Unexpected value of UdevDevice.device_id.') | 2653 | 'Unexpected value of UdevDevice.device_id.') |
379 | 2650 | 2654 | ||
380 | 2655 | def test_root_device_ids(self): | ||
381 | 2656 | device = UdevDevice( | ||
382 | 2657 | None, self.root_device, None, self.root_device_dmi_data) | ||
383 | 2658 | self.assertEqual( | ||
384 | 2659 | { | ||
385 | 2660 | 'vendor': 'FUJITSU SIEMENS', | ||
386 | 2661 | 'product': 'LIFEBOOK E8210', | ||
387 | 2662 | }, | ||
388 | 2663 | device.root_device_ids) | ||
389 | 2664 | |||
390 | 2665 | device = UdevDevice( | ||
391 | 2666 | None, self.root_device, None, {}) | ||
392 | 2667 | self.assertEqual( | ||
393 | 2668 | { | ||
394 | 2669 | 'vendor': None, | ||
395 | 2670 | 'product': None, | ||
396 | 2671 | }, | ||
397 | 2672 | device.root_device_ids) | ||
398 | 2673 | |||
399 | 2651 | def test_is_pci(self): | 2674 | def test_is_pci(self): |
400 | 2652 | """Test of UdevDevice.is_pci.""" | 2675 | """Test of UdevDevice.is_pci.""" |
402 | 2653 | device = UdevDevice(self.pci_device_data, None, None) | 2676 | device = UdevDevice(None, self.pci_device_data) |
403 | 2654 | self.assertTrue(device.is_pci) | 2677 | self.assertTrue(device.is_pci) |
404 | 2655 | 2678 | ||
406 | 2656 | device = UdevDevice(self.root_device, None, None) | 2679 | device = UdevDevice(None, self.root_device) |
407 | 2657 | self.assertFalse(device.is_pci) | 2680 | self.assertFalse(device.is_pci) |
408 | 2658 | 2681 | ||
409 | 2659 | def test_pci_class_info(self): | 2682 | def test_pci_class_info(self): |
410 | 2660 | """Test of UdevDevice.pci_class_info""" | 2683 | """Test of UdevDevice.pci_class_info""" |
412 | 2661 | device = UdevDevice(self.pci_device_data, None, None) | 2684 | device = UdevDevice(None, self.pci_device_data) |
413 | 2662 | self.assertEqual( | 2685 | self.assertEqual( |
414 | 2663 | (1, 6, 2), device.pci_class_info, | 2686 | (1, 6, 2), device.pci_class_info, |
415 | 2664 | 'Invalid value of UdevDevice.pci_class_info for PCI device.') | 2687 | 'Invalid value of UdevDevice.pci_class_info for PCI device.') |
416 | 2665 | 2688 | ||
418 | 2666 | device = UdevDevice(self.root_device, None, None) | 2689 | device = UdevDevice(None, self.root_device) |
419 | 2667 | self.assertEqual( | 2690 | self.assertEqual( |
420 | 2668 | (None, None, None), device.pci_class_info, | 2691 | (None, None, None), device.pci_class_info, |
421 | 2669 | 'Invalid value of UdevDevice.pci_class_info for Non-PCI device.') | 2692 | 'Invalid value of UdevDevice.pci_class_info for Non-PCI device.') |
422 | 2670 | 2693 | ||
423 | 2671 | def test_pci_class(self): | 2694 | def test_pci_class(self): |
424 | 2672 | """Test of UdevDevice.pci_class""" | 2695 | """Test of UdevDevice.pci_class""" |
426 | 2673 | device = UdevDevice(self.pci_device_data, None, None) | 2696 | device = UdevDevice(None, self.pci_device_data) |
427 | 2674 | self.assertEqual( | 2697 | self.assertEqual( |
428 | 2675 | 1, device.pci_class, | 2698 | 1, device.pci_class, |
429 | 2676 | 'Invalid value of UdevDevice.pci_class for PCI device.') | 2699 | 'Invalid value of UdevDevice.pci_class for PCI device.') |
430 | 2677 | 2700 | ||
432 | 2678 | device = UdevDevice(self.root_device, None, None) | 2701 | device = UdevDevice(None, self.root_device) |
433 | 2679 | self.assertEqual( | 2702 | self.assertEqual( |
434 | 2680 | None, device.pci_class, | 2703 | None, device.pci_class, |
435 | 2681 | 'Invalid value of UdevDevice.pci_class for Non-PCI device.') | 2704 | 'Invalid value of UdevDevice.pci_class for Non-PCI device.') |
436 | 2682 | 2705 | ||
437 | 2683 | def test_pci_subclass(self): | 2706 | def test_pci_subclass(self): |
438 | 2684 | """Test of UdevDevice.pci_subclass""" | 2707 | """Test of UdevDevice.pci_subclass""" |
440 | 2685 | device = UdevDevice(self.pci_device_data, None, None) | 2708 | device = UdevDevice(None, self.pci_device_data) |
441 | 2686 | self.assertEqual( | 2709 | self.assertEqual( |
442 | 2687 | 6, device.pci_subclass, | 2710 | 6, device.pci_subclass, |
443 | 2688 | 'Invalid value of UdevDevice.pci_class for PCI device.') | 2711 | 'Invalid value of UdevDevice.pci_class for PCI device.') |
444 | 2689 | 2712 | ||
446 | 2690 | device = UdevDevice(self.root_device, None, None) | 2713 | device = UdevDevice(None, self.root_device) |
447 | 2691 | self.assertEqual( | 2714 | self.assertEqual( |
448 | 2692 | None, device.pci_class, | 2715 | None, device.pci_class, |
449 | 2693 | 'Invalid value of UdevDevice.pci_class for Non-PCI device.') | 2716 | 'Invalid value of UdevDevice.pci_class for Non-PCI device.') |
450 | 2694 | 2717 | ||
451 | 2718 | def test_pci_ids(self): | ||
452 | 2719 | """Test of UdevDevice.pci_ids""" | ||
453 | 2720 | device = UdevDevice(None, self.pci_device_data) | ||
454 | 2721 | self.assertEqual( | ||
455 | 2722 | {'vendor': 0x8086, | ||
456 | 2723 | 'product': 0x27C5, | ||
457 | 2724 | }, | ||
458 | 2725 | device.pci_ids, | ||
459 | 2726 | 'Invalid value of UdevDevice.pci_ids for PCI device.') | ||
460 | 2727 | |||
461 | 2728 | device = UdevDevice(None, self.usb_device_data) | ||
462 | 2729 | self.assertEqual( | ||
463 | 2730 | {'vendor': None, | ||
464 | 2731 | 'product': None, | ||
465 | 2732 | }, | ||
466 | 2733 | device.pci_ids, | ||
467 | 2734 | 'Invalid value of UdevDevice.pci_ids for Non-PCI device.') | ||
468 | 2735 | |||
469 | 2695 | def test_is_usb(self): | 2736 | def test_is_usb(self): |
470 | 2696 | """Test of UdevDevice.is_usb""" | 2737 | """Test of UdevDevice.is_usb""" |
472 | 2697 | device = UdevDevice(self.usb_device_data, None, None) | 2738 | device = UdevDevice(None, self.usb_device_data) |
473 | 2698 | self.assertTrue(device.is_usb) | 2739 | self.assertTrue(device.is_usb) |
474 | 2699 | 2740 | ||
476 | 2700 | device = UdevDevice(self.pci_device_data, None, None) | 2741 | device = UdevDevice(None, self.pci_device_data) |
477 | 2701 | self.assertFalse(device.is_usb) | 2742 | self.assertFalse(device.is_usb) |
478 | 2702 | 2743 | ||
479 | 2703 | def test_usb_ids(self): | 2744 | def test_usb_ids(self): |
480 | 2704 | """Test of UdevDevice.usb_ids""" | 2745 | """Test of UdevDevice.usb_ids""" |
482 | 2705 | device = UdevDevice(self.usb_device_data, None, None) | 2746 | device = UdevDevice(None, self.usb_device_data) |
483 | 2706 | self.assertEqual( | 2747 | self.assertEqual( |
485 | 2707 | [0x46d, 0xa01, 0x1013], device.usb_ids, | 2748 | { |
486 | 2749 | 'vendor': 0x46d, | ||
487 | 2750 | 'product': 0xa01, | ||
488 | 2751 | 'version': 0x1013, | ||
489 | 2752 | }, | ||
490 | 2753 | device.usb_ids, | ||
491 | 2708 | 'Invalid value of UdevDevice.usb_ids for USB device.') | 2754 | 'Invalid value of UdevDevice.usb_ids for USB device.') |
492 | 2709 | 2755 | ||
494 | 2710 | device = UdevDevice(self.root_device, None, None) | 2756 | device = UdevDevice(None, self.root_device) |
495 | 2711 | self.assertEqual( | 2757 | self.assertEqual( |
497 | 2712 | [None, None, None], device.usb_ids, | 2758 | { |
498 | 2759 | 'vendor': None, | ||
499 | 2760 | 'product': None, | ||
500 | 2761 | 'version': None, | ||
501 | 2762 | }, | ||
502 | 2763 | device.usb_ids, | ||
503 | 2713 | 'Invalid value of UdevDevice.usb_ids for Non-USB device.') | 2764 | 'Invalid value of UdevDevice.usb_ids for Non-USB device.') |
504 | 2714 | 2765 | ||
505 | 2715 | def test_usb_vendor_id(self): | 2766 | def test_usb_vendor_id(self): |
506 | 2716 | """Test of UdevDevice.usb_vendor_id""" | 2767 | """Test of UdevDevice.usb_vendor_id""" |
508 | 2717 | device = UdevDevice(self.usb_device_data, None, None) | 2768 | device = UdevDevice(None, self.usb_device_data) |
509 | 2718 | self.assertEqual( | 2769 | self.assertEqual( |
510 | 2719 | 0x46d, device.usb_vendor_id, | 2770 | 0x46d, device.usb_vendor_id, |
511 | 2720 | 'Invalid value of UdevDevice.usb_vendor_id for USB device.') | 2771 | 'Invalid value of UdevDevice.usb_vendor_id for USB device.') |
512 | 2721 | 2772 | ||
514 | 2722 | device = UdevDevice(self.root_device, None, None) | 2773 | device = UdevDevice(None, self.root_device) |
515 | 2723 | self.assertEqual( | 2774 | self.assertEqual( |
516 | 2724 | None, device.usb_vendor_id, | 2775 | None, device.usb_vendor_id, |
517 | 2725 | 'Invalid value of UdevDevice.usb_vendor_id for Non-USB device.') | 2776 | 'Invalid value of UdevDevice.usb_vendor_id for Non-USB device.') |
518 | 2726 | 2777 | ||
519 | 2727 | def test_usb_product_id(self): | 2778 | def test_usb_product_id(self): |
520 | 2728 | """Test of UdevDevice.usb_product_id""" | 2779 | """Test of UdevDevice.usb_product_id""" |
522 | 2729 | device = UdevDevice(self.usb_device_data, None, None) | 2780 | device = UdevDevice(None, self.usb_device_data) |
523 | 2730 | self.assertEqual( | 2781 | self.assertEqual( |
524 | 2731 | 0xa01, device.usb_product_id, | 2782 | 0xa01, device.usb_product_id, |
525 | 2732 | 'Invalid value of UdevDevice.usb_product_id for USB device.') | 2783 | 'Invalid value of UdevDevice.usb_product_id for USB device.') |
526 | 2733 | 2784 | ||
528 | 2734 | device = UdevDevice(self.root_device, None, None) | 2785 | device = UdevDevice(None, self.root_device) |
529 | 2735 | self.assertEqual( | 2786 | self.assertEqual( |
530 | 2736 | None, device.usb_product_id, | 2787 | None, device.usb_product_id, |
531 | 2737 | 'Invalid value of UdevDevice.usb_product_id for Non-USB device.') | 2788 | 'Invalid value of UdevDevice.usb_product_id for Non-USB device.') |
532 | @@ -2739,29 +2790,127 @@ | |||
533 | 2739 | def test_is_scsi_device(self): | 2790 | def test_is_scsi_device(self): |
534 | 2740 | """Test of UdevDevice.is_scsi_device.""" | 2791 | """Test of UdevDevice.is_scsi_device.""" |
535 | 2741 | device = UdevDevice( | 2792 | device = UdevDevice( |
537 | 2742 | self.scsi_device_data, self.scsi_device_sysfs_data, None) | 2793 | None, self.scsi_device_data, self.scsi_device_sysfs_data) |
538 | 2743 | self.assertTrue(device.is_scsi_device) | 2794 | self.assertTrue(device.is_scsi_device) |
539 | 2744 | 2795 | ||
541 | 2745 | device = UdevDevice(self.root_device, None, None) | 2796 | device = UdevDevice(None, self.root_device) |
542 | 2746 | self.assertFalse(device.is_scsi_device) | 2797 | self.assertFalse(device.is_scsi_device) |
543 | 2747 | 2798 | ||
544 | 2748 | def test_scsi_vendor(self): | 2799 | def test_scsi_vendor(self): |
545 | 2749 | """Test of UdevDevice.scsi_vendor.""" | 2800 | """Test of UdevDevice.scsi_vendor.""" |
546 | 2750 | device = UdevDevice( | 2801 | device = UdevDevice( |
548 | 2751 | self.scsi_device_data, self.scsi_device_sysfs_data, None) | 2802 | None, self.scsi_device_data, self.scsi_device_sysfs_data, None) |
549 | 2752 | self.assertEqual('MATSHITA', device.scsi_vendor) | 2803 | self.assertEqual('MATSHITA', device.scsi_vendor) |
551 | 2753 | device = UdevDevice(self.root_device, None, None) | 2804 | device = UdevDevice(None, self.root_device) |
552 | 2754 | self.assertEqual(None, device.scsi_vendor) | 2805 | self.assertEqual(None, device.scsi_vendor) |
553 | 2755 | 2806 | ||
554 | 2756 | def test_scsi_model(self): | 2807 | def test_scsi_model(self): |
555 | 2757 | """Test of UdevDevice.scsi_model.""" | 2808 | """Test of UdevDevice.scsi_model.""" |
556 | 2758 | device = UdevDevice( | 2809 | device = UdevDevice( |
558 | 2759 | self.scsi_device_data, self.scsi_device_sysfs_data, None) | 2810 | None, self.scsi_device_data, self.scsi_device_sysfs_data) |
559 | 2760 | self.assertEqual('DVD-RAM UJ-841S', device.scsi_model) | 2811 | self.assertEqual('DVD-RAM UJ-841S', device.scsi_model) |
560 | 2761 | 2812 | ||
562 | 2762 | device = UdevDevice(self.root_device, None, None) | 2813 | device = UdevDevice(None, self.root_device) |
563 | 2763 | self.assertEqual(None, device.scsi_model) | 2814 | self.assertEqual(None, device.scsi_model) |
564 | 2764 | 2815 | ||
565 | 2816 | def test_raw_bus(self): | ||
566 | 2817 | """Test of UdevDevice.raw_bus.""" | ||
567 | 2818 | device = UdevDevice(None, self.root_device) | ||
568 | 2819 | self.assertEqual(None, device.raw_bus) | ||
569 | 2820 | |||
570 | 2821 | device = UdevDevice(None, self.pci_device_data) | ||
571 | 2822 | self.assertEqual('pci', device.raw_bus) | ||
572 | 2823 | |||
573 | 2824 | device = UdevDevice(None, self.usb_device_data) | ||
574 | 2825 | self.assertEqual('usb_device', device.raw_bus) | ||
575 | 2826 | |||
576 | 2827 | device = UdevDevice(None, self.no_subsystem_device_data) | ||
577 | 2828 | self.assertEqual(None, device.raw_bus) | ||
578 | 2829 | |||
579 | 2830 | def test_getVendorOrProduct(self): | ||
580 | 2831 | """Test of UdevDevice.getVendorOrProduct().""" | ||
581 | 2832 | device = UdevDevice( | ||
582 | 2833 | None, self.root_device, None, self.root_device_dmi_data) | ||
583 | 2834 | self.assertEqual( | ||
584 | 2835 | 'FUJITSU SIEMENS', device.getVendorOrProduct('vendor')) | ||
585 | 2836 | self.assertEqual( | ||
586 | 2837 | 'LIFEBOOK E8210', device.getVendorOrProduct('product')) | ||
587 | 2838 | self.assertRaises( | ||
588 | 2839 | AssertionError, device.getVendorOrProduct, 'nonsense') | ||
589 | 2840 | |||
590 | 2841 | device = UdevDevice(None, self.pci_device_data) | ||
591 | 2842 | self.assertEqual('Unknown', device.getVendorOrProduct('vendor')) | ||
592 | 2843 | self.assertEqual('Unknown', device.getVendorOrProduct('product')) | ||
593 | 2844 | |||
594 | 2845 | device = UdevDevice(None, self.usb_device_data) | ||
595 | 2846 | self.assertEqual('Unknown', device.getVendorOrProduct('vendor')) | ||
596 | 2847 | self.assertEqual('Unknown', device.getVendorOrProduct('product')) | ||
597 | 2848 | |||
598 | 2849 | device = UdevDevice( | ||
599 | 2850 | None, self.scsi_device_data, self.scsi_device_sysfs_data) | ||
600 | 2851 | self.assertEqual('MATSHITA', device.getVendorOrProduct('vendor')) | ||
601 | 2852 | self.assertEqual( | ||
602 | 2853 | 'DVD-RAM UJ-841S', device.getVendorOrProduct('product')) | ||
603 | 2854 | |||
604 | 2855 | device = UdevDevice(None, self.no_subsystem_device_data) | ||
605 | 2856 | self.assertEqual(None, device.getVendorOrProduct('vendor')) | ||
606 | 2857 | self.assertEqual(None, device.getVendorOrProduct('product')) | ||
607 | 2858 | |||
608 | 2859 | def test_vendor(self): | ||
609 | 2860 | """Test of UdevDevice.vendor.""" | ||
610 | 2861 | device = UdevDevice( | ||
611 | 2862 | None, self.root_device, None, self.root_device_dmi_data) | ||
612 | 2863 | self.assertEqual('FUJITSU SIEMENS', device.vendor) | ||
613 | 2864 | |||
614 | 2865 | def test_product(self): | ||
615 | 2866 | """Test of UdevDevice.product.""" | ||
616 | 2867 | device = UdevDevice( | ||
617 | 2868 | None, self.root_device, None, self.root_device_dmi_data) | ||
618 | 2869 | self.assertEqual('LIFEBOOK E8210', device.product) | ||
619 | 2870 | |||
620 | 2871 | def test_getVendorOrProductID(self): | ||
621 | 2872 | """Test of UdevDevice.getVendorOrProduct().""" | ||
622 | 2873 | device = UdevDevice( | ||
623 | 2874 | None, self.root_device, None, self.root_device_dmi_data) | ||
624 | 2875 | self.assertEqual( | ||
625 | 2876 | 'FUJITSU SIEMENS', device.getVendorOrProductID('vendor')) | ||
626 | 2877 | self.assertEqual( | ||
627 | 2878 | 'LIFEBOOK E8210', device.getVendorOrProductID('product')) | ||
628 | 2879 | self.assertRaises( | ||
629 | 2880 | AssertionError, device.getVendorOrProductID, 'nonsense') | ||
630 | 2881 | |||
631 | 2882 | device = UdevDevice(None, self.pci_device_data) | ||
632 | 2883 | self.assertEqual(0x8086, device.getVendorOrProductID('vendor')) | ||
633 | 2884 | self.assertEqual(0x27C5, device.getVendorOrProductID('product')) | ||
634 | 2885 | |||
635 | 2886 | device = UdevDevice(None, self.usb_device_data) | ||
636 | 2887 | self.assertEqual(0x46d, device.getVendorOrProductID('vendor')) | ||
637 | 2888 | self.assertEqual(0xa01, device.getVendorOrProductID('product')) | ||
638 | 2889 | |||
639 | 2890 | device = UdevDevice( | ||
640 | 2891 | None, self.scsi_device_data, self.scsi_device_sysfs_data) | ||
641 | 2892 | self.assertEqual('MATSHITA', device.getVendorOrProductID('vendor')) | ||
642 | 2893 | self.assertEqual( | ||
643 | 2894 | 'DVD-RAM UJ-841S', device.getVendorOrProductID('product')) | ||
644 | 2895 | |||
645 | 2896 | device = UdevDevice( | ||
646 | 2897 | None, self.no_subsystem_device_data) | ||
647 | 2898 | self.assertEqual(None, device.getVendorOrProductID('vendor')) | ||
648 | 2899 | self.assertEqual(None, device.getVendorOrProductID('product')) | ||
649 | 2900 | |||
650 | 2901 | def test_vendor_id(self): | ||
651 | 2902 | """Test of UdevDevice.vendor_id.""" | ||
652 | 2903 | device = UdevDevice( | ||
653 | 2904 | None, self.root_device, None, self.root_device_dmi_data) | ||
654 | 2905 | self.assertEqual('FUJITSU SIEMENS', device.vendor_id) | ||
655 | 2906 | |||
656 | 2907 | def test_product_id(self): | ||
657 | 2908 | """Test of UdevDevice.product_id.""" | ||
658 | 2909 | device = UdevDevice( | ||
659 | 2910 | None, self.root_device, None, self.root_device_dmi_data) | ||
660 | 2911 | self.assertEqual('LIFEBOOK E8210', device.product_id) | ||
661 | 2912 | |||
662 | 2913 | |||
663 | 2765 | class TestHWDBSubmissionTablePopulation(TestCaseHWDB): | 2914 | class TestHWDBSubmissionTablePopulation(TestCaseHWDB): |
664 | 2766 | """Tests of the HWDB popoluation with submitted data.""" | 2915 | """Tests of the HWDB popoluation with submitted data.""" |
665 | 2767 | 2916 |
This branch adds the properties pci_ids, raw_bus, vendor, vendor_id, product, product_id to class UdevDevice.
The HWDB client in Karmic will no longer send data gathered from HAL, but gathered from udev, supplemented by sysfs and DMI data.
The HWDB submission processing script represents devices found in the submission data in a class derived from BaseDevice; this branch is another step to complete the implementation of class UdevDevice.
I forgot in earlier branches to specify the DMI data as a parameter of the UdevDevice constructor, so this branch contains also a number of purely formal changes in the tests, where class UdevDevice is instantiated.
I also noticed that I forgot a "raise NotImplemented" for a property of class BaseDevice.
test: test_hwdb_ submission_ processing
./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: /launchpad/ scripts/ hwdbsubmissions .py /launchpad/ scripts/ tests/test_ hwdb_submission _processing. py
lib/canonical
lib/canonical
== Pyflakes notices ==
lib/canonical/ launchpad/ scripts/ hwdbsubmissions .py
22: redefinition of unused 'etree' from line 20
== Pylint notices ==
lib/canonical/ launchpad/ scripts/ hwdbsubmissions .py cElementTree' (No module named etree)
20: [F0401] Unable to import 'xml.etree.
The complaints about etree are not related to my changes.