Merge lp:~adeuring/launchpad/hwdb-class-udev-device-10 into lp:launchpad
- hwdb-class-udev-device-10
- Merge into devel
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~adeuring/launchpad/hwdb-class-udev-device-10 |
Merge into: | lp:launchpad |
Diff against target: |
175 lines 2 files modified
lib/canonical/launchpad/scripts/hwdbsubmissions.py (+8/-4) lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py (+119/-0) |
To merge this branch: | bzr merge lp:~adeuring/launchpad/hwdb-class-udev-device-10 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Eleanor Berger (community) | code | Approve | |
Review via email: mp+13567@code.launchpad.net |
Commit message
Description of the change
Abel Deuring (adeuring) wrote : | # |
Abel Deuring (adeuring) wrote : | # |
this brach is based on lp:~adeuring/launchpad/hwdb-class-udev-device-9, which has not yet landed. Here is the diff against that branch:
=== modified file 'lib/canonical/
--- lib/canonical/
+++ lib/canonical/
@@ -2015,6 +2015,10 @@
missing vendor/product information in order to store the
data reliably in the HWDB.
+ raw_bus == 'acpi' is used in udev data for the main system,
+ for CPUs, power supply etc. Except for the main sytsem, none
+ of them provides a vendor or product id, so we ignore them.
+
XXX Abel Deuring 2008-05-06: IEEE1394 devices are a bit
nasty: The standard does not define any specification
for product IDs or product names, hence HAL often uses
@@ -2038,7 +2042,7 @@
ensure that we have vendor ID, product ID and product name.
"""
bus = self.raw_bus
- if bus == 'unknown' and self.udi != ROOT_UDI:
+ if bus in ('unknown', 'acpi') and not self.is_
# The root node is course a real device; storing data
# about other devices with the bus "unkown" is pointless.
return False
@@ -2059,11 +2063,11 @@
# it.
if self.real_bus != HWBus.IDE:
- 'A HALDevice that is supposed to be a real device does '
+ 'A %s that is supposed to be a real device does '
- % (self.real_bus, self.vendor_id, self.product_id,
- self.product, self.udi),
+ % (self._
+ self.product_id, self.product, self.device_id),
return False
return True
=== modified file 'lib/canonical/
--- lib/canonical/
+++ lib/canonical/
@@ -3320,6 +3320,21 @@
'E': {}
}
+ self.cpu_
+ 'P': '/devices/
+ 'E': {
+ 'DRIVER': 'processor',
+ 'SUBSYSTEM': 'acpi',
+ },
+ }
+
+ self.platform_
+ 'P': '/devices/
+ 'E': {
+ 'SUBSYSTEM': 'platform',
+ },
+ }
+
def test_device_
"""Test of UdevDevice.
device = UdevDevice(None, self.pci_
@@ -3881,6 +3896,110 @@
+ def test_has_
+ """Test of Udev...
Eleanor Berger (intellectronica) : | # |
Preview Diff
1 | === modified file 'lib/canonical/launchpad/scripts/hwdbsubmissions.py' |
2 | --- lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-19 10:45:31 +0000 |
3 | +++ lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-19 16:40:51 +0000 |
4 | @@ -2015,6 +2015,10 @@ |
5 | missing vendor/product information in order to store the |
6 | data reliably in the HWDB. |
7 | |
8 | + raw_bus == 'acpi' is used in udev data for the main system, |
9 | + for CPUs, power supply etc. Except for the main sytsem, none |
10 | + of them provides a vendor or product id, so we ignore them. |
11 | + |
12 | XXX Abel Deuring 2008-05-06: IEEE1394 devices are a bit |
13 | nasty: The standard does not define any specification |
14 | for product IDs or product names, hence HAL often uses |
15 | @@ -2038,7 +2042,7 @@ |
16 | ensure that we have vendor ID, product ID and product name. |
17 | """ |
18 | bus = self.raw_bus |
19 | - if bus == 'unknown' and self.udi != ROOT_UDI: |
20 | + if bus in ('unknown', 'acpi') and not self.is_root_device: |
21 | # The root node is course a real device; storing data |
22 | # about other devices with the bus "unkown" is pointless. |
23 | return False |
24 | @@ -2059,11 +2063,11 @@ |
25 | # it. |
26 | if self.real_bus != HWBus.IDE: |
27 | self.parser._logWarning( |
28 | - 'A HALDevice that is supposed to be a real device does ' |
29 | + 'A %s that is supposed to be a real device does ' |
30 | 'not provide bus, vendor ID, product ID or product name: ' |
31 | '%r %r %r %r %s' |
32 | - % (self.real_bus, self.vendor_id, self.product_id, |
33 | - self.product, self.udi), |
34 | + % (self.__class__.__name__, self.real_bus, self.vendor_id, |
35 | + self.product_id, self.product, self.device_id), |
36 | self.parser.submission_key) |
37 | return False |
38 | return True |
39 | |
40 | === modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py' |
41 | --- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-19 10:45:31 +0000 |
42 | +++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-19 16:40:51 +0000 |
43 | @@ -3320,6 +3320,21 @@ |
44 | 'E': {} |
45 | } |
46 | |
47 | + self.cpu_device_data = { |
48 | + 'P': '/devices/LNXSYSTM:00/LNXCPU:00', |
49 | + 'E': { |
50 | + 'DRIVER': 'processor', |
51 | + 'SUBSYSTEM': 'acpi', |
52 | + }, |
53 | + } |
54 | + |
55 | + self.platform_device_data = { |
56 | + 'P': '/devices/platform/dock.0', |
57 | + 'E': { |
58 | + 'SUBSYSTEM': 'platform', |
59 | + }, |
60 | + } |
61 | + |
62 | def test_device_id(self): |
63 | """Test of UdevDevice.device_id.""" |
64 | device = UdevDevice(None, self.pci_sata_controller) |
65 | @@ -3881,6 +3896,110 @@ |
66 | device.device_id == self.usb_storage_usb_device_path, |
67 | device.is_real_device)) |
68 | |
69 | + def test_has_reliable_data_system(self): |
70 | + """Test of UdevDevice.has_reliable_data for a system.""" |
71 | + root_device = UdevDevice( |
72 | + None, self.root_device, dmi_data=self.root_device_dmi_data) |
73 | + self.assertTrue(root_device.has_reliable_data) |
74 | + |
75 | + def test_has_reliable_data_system_no_vendor_name(self): |
76 | + """Test of UdevDevice.has_reliable_data for a system. |
77 | + |
78 | + If the DMI data does not provide vendor name, has_reliable_data |
79 | + is False. |
80 | + """ |
81 | + del self.root_device_dmi_data['/sys/class/dmi/id/sys_vendor'] |
82 | + root_device = UdevDevice( |
83 | + None, self.root_device, dmi_data=self.root_device_dmi_data) |
84 | + parser = SubmissionParser(self.log) |
85 | + parser.submission_key = 'root device without vendor name' |
86 | + root_device.parser = parser |
87 | + self.assertFalse(root_device.has_reliable_data) |
88 | + self.assertWarningMessage( |
89 | + parser.submission_key, |
90 | + "A UdevDevice that is supposed to be a real device does not " |
91 | + "provide bus, vendor ID, product ID or product name: " |
92 | + "<DBItem HWBus.SYSTEM, (0) System> None 'LIFEBOOK E8210' " |
93 | + "'LIFEBOOK E8210' /devices/LNXSYSTM:00") |
94 | + |
95 | + |
96 | + def test_has_reliable_data_system_no_product_name(self): |
97 | + """Test of UdevDevice.has_reliable_data for a system. |
98 | + |
99 | + If the DMI data does not provide product name, has_reliable_data |
100 | + is False. |
101 | + """ |
102 | + del self.root_device_dmi_data['/sys/class/dmi/id/product_name'] |
103 | + root_device = UdevDevice( |
104 | + None, self.root_device, dmi_data=self.root_device_dmi_data) |
105 | + parser = SubmissionParser(self.log) |
106 | + parser.submission_key = 'root device without product name' |
107 | + root_device.parser = parser |
108 | + self.assertFalse(root_device.has_reliable_data) |
109 | + self.assertWarningMessage( |
110 | + parser.submission_key, |
111 | + "A UdevDevice that is supposed to be a real device does not " |
112 | + "provide bus, vendor ID, product ID or product name: " |
113 | + "<DBItem HWBus.SYSTEM, (0) System> 'FUJITSU SIEMENS' None None " |
114 | + "/devices/LNXSYSTM:00") |
115 | + |
116 | + def test_has_reliable_data_acpi_device(self): |
117 | + """Test of UdevDevice.has_reliable_data for an ACPI device. |
118 | + |
119 | + APCI devices are considered not to have reliable data. The only |
120 | + exception is the root device, see test_has_reliable_data_system. |
121 | + """ |
122 | + acpi_device = UdevDevice(None, self.cpu_device_data) |
123 | + self.assertEqual('acpi', acpi_device.raw_bus) |
124 | + self.assertFalse(acpi_device.has_reliable_data) |
125 | + |
126 | + def test_has_reliable_data_platform_device(self): |
127 | + """Test of UdevDevice.has_reliable_data for a "platform" device. |
128 | + |
129 | + devices with raw_bus == 'platform' are considered not to have |
130 | + reliable data. |
131 | + """ |
132 | + platform_device = UdevDevice(None, self.platform_device_data) |
133 | + self.assertFalse(platform_device.has_reliable_data) |
134 | + |
135 | + def test_has_reliable_data_pci_device(self): |
136 | + """Test of UdevDevice.has_reliable_data for a PCI device.""" |
137 | + devices = self.buildUdevDeviceHierarchy( |
138 | + self.pci_bridge_pccard_hierarchy_data) |
139 | + pci_device = devices[self.pci_pccard_bridge_path] |
140 | + self.assertTrue(pci_device.has_reliable_data) |
141 | + |
142 | + def test_has_reliable_data_usb_device(self): |
143 | + """Test of UdevDevice.has_reliable_data for a USB device.""" |
144 | + usb_device = UdevDevice(None, self.usb_storage_usb_device_data) |
145 | + self.assertTrue(usb_device.has_reliable_data) |
146 | + |
147 | + def test_has_reliable_data_scsi_device(self): |
148 | + """Test of UdevDevice.has_reliable_data for a SCSI device.""" |
149 | + devices = self.buildUdevDeviceHierarchy( |
150 | + self.scsi_device_hierarchy_data) |
151 | + scsi_device = devices[self.scsi_scanner_device_path] |
152 | + self.assertTrue(scsi_device.has_reliable_data) |
153 | + |
154 | + def test_has_reliable_data_usb_interface_device(self): |
155 | + """Test of UdevDevice.has_reliable_data for a USB interface. |
156 | + |
157 | + UdevDevice.has_reliable_data should only be called for nodes |
158 | + where is_rel_device is True. If called for other nodes, we |
159 | + may get a warning because they do not provide reqired data, |
160 | + like a bus, vendor or product ID. |
161 | + """ |
162 | + parser = SubmissionParser(self.log) |
163 | + parser.submission_key = ( |
164 | + 'UdevDevice.has_reliable_data for a USB interface') |
165 | + usb_interface = UdevDevice(parser, self.usb_storage_usb_interface) |
166 | + self.assertFalse(usb_interface.has_reliable_data) |
167 | + self.assertWarningMessage( |
168 | + parser.submission_key, |
169 | + 'A UdevDevice that is supposed to be a real device does not ' |
170 | + 'provide bus, vendor ID, product ID or product name: None None ' |
171 | + 'None None /devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0') |
172 | + |
173 | |
174 | class TestHWDBSubmissionTablePopulation(TestCaseHWDB): |
175 | """Tests of the HWDB popoluation with submitted data.""" |
This branch modifies the implementation of the property BaseDevice. has_reliable_ data in the script l/c/l/scipts/ hwdbsubmissions .py so that is works as expected for submissions with udev data.
BaseDevice. has_reliable_ data is used to determine if the data of a device node is "complete enough" to be stored in our database, ḿeaning that the node provides a bus as enumerated by HWBus, a vendor ID, a product ID and a product name.
The root device of a submissions is again a bit messy: For udev submissions, its raw_bus value is "acpi", while it is either None or "unknown" in submissions with HAL data. Hence I had to change "bus == 'unknown' ..." to "if bus in ('unknown', 'acpi')...". ('acpi' is not used as a value of raw_bus for submissions with HAL data.)
A log message is recorded, if the device soes not provide all required value. The format string of the message expanded the value self.udi, which exists only in class HALDevice, so I changed that to self.device_id.
The tests of the property are quite straightforward, I think.