Merge lp:~adeuring/launchpad/hwdb-submissions-with-udev-data-2 into lp:launchpad/db-devel
- hwdb-submissions-with-udev-data-2
- Merge into db-devel
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~adeuring/launchpad/hwdb-submissions-with-udev-data-2 |
Merge into: | lp:launchpad/db-devel |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~adeuring/launchpad/hwdb-submissions-with-udev-data-2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Henning Eggers (community) | code | Approve | |
Review via email: mp+11691@code.launchpad.net |
Commit message
Description of the change
Abel Deuring (adeuring) wrote : | # |
Henning Eggers (henninge) wrote : | # |
Thanks, Abel, for continuing on this!
merge-conditional
Please see my coments below and think about the test as I suggest. I am not sure how expensive my suggestion is so you might want to put it off for a later branch.
Henning
> === modified file
> 'lib/canonical/
> --- lib/canonical/
> 2009-06-25 05:30:52 +0000
> +++ lib/canonical/
[...]
> + def testHardwareSub
> """The <hardware> tag has a fixed set of allowed sub-tags.
>
> - Valid sub-tags are <hal>, <processors>, <aliases>.
> - <aliases> is optional; <hal> and <processors> are required.
> + Valid sub-tags are <hal>, <udev>, <dmi>, <sysfs-attributes>,
> + <processors>, <aliases>. <aliases> is optional, <processors>
> + is required, and either <hal> or all three tags <udev>, <dmi>,
> + <sysfs-attributes> must be present.
> """
> - # Omitting either of the required tags leads on an error.
> - for tag in ('hal', 'processors'):
> + # Omitting any of the three tags <udev>, <dmi>, <sysfs-attributes>
> + # makes the data invalid.
> + all_tags = ['udev', 'dmi', 'sysfs-attributes']
> + for index in range(len(
'enumerate' is your friend here ... ;-)
for index, missing_tag in enumerate(
> + test_tags = all_tags[:]
> + missing_tag = test_tags[index]
> + del test_tags[index]
> + replace_text = [
> + '<%s>text</%s>' % (tag, tag) for tag in test_tags]
> + replace_text = ''.join(
> sample_data = self.replaceSam
> data=self.
[...]
> @@ -1603,23 +1691,12 @@
> 'Extra element aliases in interleave',
> 'missing attribute of <alias>')
>
> - # target must be an integer.
> + # The value of target does not have to be an integer.
This comment only makes sense if you know that this used to be the case. But I think it should be worded in a way that some-one without knowledge of the history of this file understands what this is about.
"The value is any string that describes the device." ?
But in general you should rethink the purpose of this test. I have to be honest that I don't really understand what it is about ... ;-) Maybe it's gotten useless now that the "integer only" restriction is gone.
It may be more useful to check if the value has the correct form for the source (hal, udev, etc) that it is used with.
> sample_data = self.sample_
> '<alias target="65">', '<alias target=
> result, submission_id = self.runValidat
> - self.assertErro
> - submission_id, result,
> - 'Extra element aliases in interleave',
> - 'missing attribute of <alias>')
> -
> - # target must not be empty.
> - sample_data = self.sample_
> - '<alias target="65">', '<alias target=""...
Abel Deuring (adeuring) wrote : | # |
On 14.09.2009 16:23, Henning Eggers wrote:
> Review: Approve code
> Thanks, Abel, for continuing on this!
>
> merge-conditional
>
> Please see my coments below and think about the test as I suggest. I am not sure how expensive my suggestion is so you might want to put it off for a later branch.
>
> Henning
>
>> === modified file
>> 'lib/canonical/
>> --- lib/canonical/
>> 2009-06-25 05:30:52 +0000
>> +++ lib/canonical/
>
> [...]
>
>> + def testHardwareSub
>> """The <hardware> tag has a fixed set of allowed sub-tags.
>>
>> - Valid sub-tags are <hal>, <processors>, <aliases>.
>> - <aliases> is optional; <hal> and <processors> are required.
>> + Valid sub-tags are <hal>, <udev>, <dmi>, <sysfs-attributes>,
>> + <processors>, <aliases>. <aliases> is optional, <processors>
>> + is required, and either <hal> or all three tags <udev>, <dmi>,
>> + <sysfs-attributes> must be present.
>> """
>> - # Omitting either of the required tags leads on an error.
>> - for tag in ('hal', 'processors'):
>> + # Omitting any of the three tags <udev>, <dmi>, <sysfs-attributes>
>> + # makes the data invalid.
>> + all_tags = ['udev', 'dmi', 'sysfs-attributes']
>> + for index in range(len(
>
> 'enumerate' is your friend here ... ;-)
>
> for index, missing_tag in enumerate(
right, changed.
>
>> + test_tags = all_tags[:]
>> + missing_tag = test_tags[index]
>> + del test_tags[index]
>> + replace_text = [
>> + '<%s>text</%s>' % (tag, tag) for tag in test_tags]
>> + replace_text = ''.join(
>> sample_data = self.replaceSam
>> data=self.
>
> [...]
>
>> @@ -1603,23 +1691,12 @@
>> 'Extra element aliases in interleave',
>> 'missing attribute of <alias>')
>>
>> - # target must be an integer.
>> + # The value of target does not have to be an integer.
>
> This comment only makes sense if you know that this used to be the case. But I think it should be worded in a way that some-one without knowledge of the history of this file understands what this is about.
>
> "The value is any string that describes the device." ?
Right. I simply removed the test.
>
> But in general you should rethink the purpose of this test. I have to be honest that I don't really understand what it is about ... ;-) Maybe it's gotten useless now that the "integer only" restriction is gone.
> It may be more useful to check if the value has the correct form for the source (hal, udev, etc) that it is used with.
Such a check will be done in another stage of the procdeesing of HWDB
submissions; in one of the branches I intend to work on.
Abel
Preview Diff
1 | === modified file 'lib/canonical/launchpad/scripts/hardware-1_0.rng' |
2 | --- lib/canonical/launchpad/scripts/hardware-1_0.rng 2009-02-24 17:43:37 +0000 |
3 | +++ lib/canonical/launchpad/scripts/hardware-1_0.rng 2009-09-14 09:16:45 +0000 |
4 | @@ -98,40 +98,64 @@ |
5 | </element> |
6 | </zeroOrMore> |
7 | </element> |
8 | + <optional> |
9 | + <element name="kernel-release"> |
10 | + <attribute name="value"> |
11 | + <text/> |
12 | + </attribute> |
13 | + </element> |
14 | + </optional> |
15 | </interleave> |
16 | </define> |
17 | |
18 | <define name="hardwareSection"> |
19 | <interleave> |
20 | - <element name="hal"> |
21 | - <attribute name="version"> |
22 | - <text/> |
23 | - </attribute> |
24 | - <oneOrMore> |
25 | - <element name="device"> |
26 | - <attribute name="id"> |
27 | - <data type="integer"> |
28 | - <except> |
29 | - <value/> |
30 | - </except> |
31 | - </data> |
32 | - </attribute> |
33 | - <attribute name="udi"> |
34 | - <text/> |
35 | - </attribute> |
36 | - <optional> |
37 | - <attribute name="parent"> |
38 | - <data type="integer"/> |
39 | - </attribute> |
40 | - </optional> |
41 | - <!-- XXX: Abel Deuring 2007-12-07: |
42 | - specify a set of required properties? --> |
43 | - <oneOrMore> |
44 | - <ref name="property"/> |
45 | - </oneOrMore> |
46 | - </element> |
47 | - </oneOrMore> |
48 | - </element> |
49 | + <choice> |
50 | + <element name="hal"> |
51 | + <attribute name="version"> |
52 | + <text/> |
53 | + </attribute> |
54 | + <oneOrMore> |
55 | + <element name="device"> |
56 | + <attribute name="id"> |
57 | + <data type="integer"> |
58 | + <except> |
59 | + <value/> |
60 | + </except> |
61 | + </data> |
62 | + </attribute> |
63 | + <attribute name="udi"> |
64 | + <text/> |
65 | + </attribute> |
66 | + <optional> |
67 | + <attribute name="parent"> |
68 | + <data type="integer"/> |
69 | + </attribute> |
70 | + </optional> |
71 | + <!-- XXX: Abel Deuring 2007-12-07: |
72 | + specify a set of required properties? --> |
73 | + <oneOrMore> |
74 | + <ref name="property"/> |
75 | + </oneOrMore> |
76 | + </element> |
77 | + </oneOrMore> |
78 | + </element> |
79 | + <group> |
80 | + <interleave> |
81 | + <element name="udev"> |
82 | + <text/> |
83 | + </element> |
84 | + <element name="dmi"> |
85 | + <text/> |
86 | + </element> |
87 | + <element name="sysfs-attributes"> |
88 | + <zeroOrMore> |
89 | + <text/> |
90 | + </zeroOrMore> |
91 | + </element> |
92 | + </interleave> |
93 | + </group> |
94 | + </choice> |
95 | <element name="processors"> |
96 | <oneOrMore> |
97 | <element name="processor"> |
98 | @@ -156,11 +180,7 @@ |
99 | <zeroOrMore> |
100 | <element name="alias"> |
101 | <attribute name="target"> |
102 | - <data type="integer"> |
103 | - <except> |
104 | - <value/> |
105 | - </except> |
106 | - </data> |
107 | + <text/> |
108 | </attribute> |
109 | <interleave> |
110 | <element name="vendor"> |
111 | @@ -292,11 +312,7 @@ |
112 | <zeroOrMore> |
113 | <element name="target"> |
114 | <attribute name="id"> |
115 | - <data type="integer"> |
116 | - <except> |
117 | - <value/> |
118 | - </except> |
119 | - </data> |
120 | + <text/> |
121 | </attribute> |
122 | <interleave> |
123 | <zeroOrMore> |
124 | |
125 | === added file 'lib/canonical/launchpad/scripts/tests/hardwaretest-udev.xml' |
126 | --- lib/canonical/launchpad/scripts/tests/hardwaretest-udev.xml 1970-01-01 00:00:00 +0000 |
127 | +++ lib/canonical/launchpad/scripts/tests/hardwaretest-udev.xml 2009-09-14 09:16:45 +0000 |
128 | @@ -0,0 +1,453 @@ |
129 | +<?xml version="1.0" ?> |
130 | +<system version="1.0"> |
131 | + |
132 | + <!-- summary: generic information about the submission --> |
133 | + <summary> |
134 | + |
135 | + <!-- live_cd: Was this submission made on a system running an Ubuntu Live |
136 | + CD or on a regular Ubuntu/Linux installation? |
137 | + --> |
138 | + <live_cd value="False"/> |
139 | + |
140 | + <!-- system_id: A hash of the "system identifier". This value is intended |
141 | + to identify the tested computer model; the value should |
142 | + be derived from the properties |
143 | + system.product, system.vendor of the HAL UDI |
144 | + /org/freedesktop/Hal/devices/computer. |
145 | + --> |
146 | + <system_id value="f982bb1ab536469cebfd6eaadcea0ffc"/> |
147 | + |
148 | + <!-- distribution, distroseries: These values are retrieved from |
149 | + /etc/lsb-release, parameters DISTRIB_ID and DISTRIB_RELEASE. |
150 | + --> |
151 | + <distribution value="Ubuntu"/> |
152 | + <distroseries value="7.04"/> |
153 | + |
154 | + <!-- architecture: The processor architecture of the operating system. |
155 | + --> |
156 | + <architecture value="amd64"/> |
157 | + |
158 | + <!-- private: If False, this submission is publicly accessible from |
159 | + Launchpad, else it is only accesible by the submitter, by |
160 | + Launchpad administrators and by scripts running with |
161 | + administrator rights. Submissions marked "private" should |
162 | + only be used to gather statistical data. |
163 | + --> |
164 | + <private value="False"/> |
165 | + |
166 | + <!-- contactable: If True, the owner agrees to be contacted by other |
167 | + persons about devices which appear in his submission. |
168 | + Example of a use case: Developers can ask device owners |
169 | + to perform tests. |
170 | + --> |
171 | + <contactable value="False"/> |
172 | + |
173 | + <!-- date_created: Date and time (UTC) of the submission. |
174 | + --> |
175 | + <date_created value="2007-09-28T16:09:20.126842"/> |
176 | + |
177 | + <!-- client: The name and version of the program that created the |
178 | + submission data. |
179 | + --> |
180 | + <client name="hwtest" version="0.9"> |
181 | + |
182 | + <!-- plugin: name and version of a plugin used by the client. |
183 | + This tag may appear more than once. |
184 | + --> |
185 | + <plugin name="architecture_info" version="1.1"/> |
186 | + <plugin name="find_network_controllers" version="2.34"/> |
187 | + <plugin name="internet_ping" version="1.1"/> |
188 | + <plugin name="harddisk_speed" version="0.7"/> |
189 | + </client> |
190 | + |
191 | + <!-- The kernel name and version, as shown by "uname -r" |
192 | + --> |
193 | + <kernel-release value="2.6.28-14-generic"/> |
194 | + </summary> |
195 | + |
196 | + <!-- hardware: data about the hardware the submission was made on. |
197 | + --> |
198 | + <hardware> |
199 | + |
200 | + <!-- udev: The output of running "udevadm info - -export-db" --> |
201 | + |
202 | + <udev>P: /devices/LNXSYSTM:00 |
203 | +E: UDEV_LOG=3 |
204 | +E: DEVPATH=/devices/LNXSYSTM:00 |
205 | +E: MODALIAS=acpi:LNXSYSTM: |
206 | + |
207 | +P: /devices/pci0000:00/0000:00:1a.0 |
208 | +E: UDEV_LOG=3 |
209 | +E: DEVPATH=/devices/pci0000:00/0000:00:1a.0 |
210 | +E: DRIVER=uhci_hcd |
211 | +E: PCI_CLASS=C0300 |
212 | +E: PCI_ID=8086:2834 |
213 | +E: PCI_SUBSYS_ID=17AA:20AA |
214 | +E: PCI_SLOT_NAME=0000:00:1a.0 |
215 | +E: MODALIAS=pci:v00008086d00002834sv000017AAsd000020AAbc0Csc03i00 |
216 | + |
217 | +P: /devices/pci0000:00/0000:00:1a.0/usb3 |
218 | +N: bus/usb/003/001 |
219 | +S: char/189:256 |
220 | +E: UDEV_LOG=3 |
221 | +E: DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb3 |
222 | +E: MAJOR=189 |
223 | +E: MINOR=256 |
224 | +E: DEVTYPE=usb_device |
225 | +E: DRIVER=usb |
226 | +E: DEVICE=/proc/bus/usb/003/001 |
227 | +E: PRODUCT=1d6b/1/206 |
228 | +E: TYPE=9/0/0 |
229 | +E: BUSNUM=003 |
230 | +E: DEVNUM=001 |
231 | +E: DEVNAME=/dev/bus/usb/003/001 |
232 | +E: DEVLINKS=/dev/char/189:256 |
233 | + |
234 | +P: /devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0 |
235 | +E: UDEV_LOG=3 |
236 | +E: DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0 |
237 | +E: DEVTYPE=usb_interface |
238 | +E: DRIVER=hub |
239 | +E: DEVICE=/proc/bus/usb/003/001 |
240 | +E: PRODUCT=1d6b/1/206 |
241 | +E: TYPE=9/0/0 |
242 | +E: INTERFACE=9/0/0 |
243 | +E: MODALIAS=usb:v1D6Bp0001d0206dc09dsc00dp00ic09isc00ip00 |
244 | + |
245 | +P: /devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0/usb_endpoint/usbdev3.1_ep81 |
246 | +N: usbdev3.1_ep81 |
247 | +S: char/252:4 |
248 | +E: UDEV_LOG=3 |
249 | +E: DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0/usb_endpoint/usbdev3.1_ep81 |
250 | +E: MAJOR=252 |
251 | +E: MINOR=4 |
252 | +E: DEVNAME=/dev/usbdev3.1_ep81 |
253 | +E: DEVLINKS=/dev/char/252:4 |
254 | + |
255 | +P: /devices/pci0000:00/0000:00:1f.1 |
256 | +E: UDEV_LOG=3 |
257 | +E: DEVPATH=/devices/pci0000:00/0000:00:1f.1 |
258 | +E: DRIVER=ata_piix |
259 | +E: PCI_CLASS=1018A |
260 | +E: PCI_ID=8086:2850 |
261 | +E: PCI_SUBSYS_ID=17AA:20A6 |
262 | +E: PCI_SLOT_NAME=0000:00:1f.1 |
263 | +E: MODALIAS=pci:v00008086d00002850sv000017AAsd000020A6bc01sc01i8a |
264 | + |
265 | +P: /devices/pci0000:00/0000:00:1f.1/host3 |
266 | +E: UDEV_LOG=3 |
267 | +E: DEVPATH=/devices/pci0000:00/0000:00:1f.1/host3 |
268 | +E: DEVTYPE=scsi_host |
269 | + |
270 | +P: /devices/pci0000:00/0000:00:1f.1/host3/scsi_host/host3 |
271 | +E: UDEV_LOG=3 |
272 | +E: DEVPATH=/devices/pci0000:00/0000:00:1f.1/host3/scsi_host/host3 |
273 | + |
274 | +P: /devices/pci0000:00/0000:00:1f.1/host3/target3:0:0 |
275 | +E: UDEV_LOG=3 |
276 | +E: DEVPATH=/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0 |
277 | +E: DEVTYPE=scsi_target |
278 | + |
279 | +P: /devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0 |
280 | +E: UDEV_LOG=3 |
281 | +E: DEVPATH=/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0 |
282 | +E: DEVTYPE=scsi_device |
283 | +E: DRIVER=sr |
284 | +E: MODALIAS=scsi:t-0x05 |
285 | +</udev> |
286 | + |
287 | + <!-- The content of publicly accessible files in /sys/class/dmi/id/ |
288 | + format: filename:content |
289 | + as for example generated by "grep -r . /sys/class/dmi/id/" |
290 | + --> |
291 | + |
292 | + <dmi>/sys/class/dmi/id/bios_vendor:LENOVO |
293 | +/sys/class/dmi/id/bios_version:7LETB9WW (2.19 ) |
294 | +/sys/class/dmi/id/bios_date:06/06/2008 |
295 | +/sys/class/dmi/id/sys_vendor:LENOVO |
296 | +/sys/class/dmi/id/product_name:6457BAG |
297 | +/sys/class/dmi/id/product_version:ThinkPad T61 |
298 | +/sys/class/dmi/id/board_vendor:LENOVO |
299 | +/sys/class/dmi/id/board_name:6457BAG |
300 | +/sys/class/dmi/id/board_version:Not Available |
301 | +/sys/class/dmi/id/chassis_vendor:LENOVO |
302 | +/sys/class/dmi/id/chassis_type:10 |
303 | +/sys/class/dmi/id/chassis_version:Not Available |
304 | +/sys/class/dmi/id/chassis_asset_tag:No Asset Information |
305 | +/sys/class/dmi/id/modalias:dmi:bvnLENOVO:bvr7LETB9WW(2.19) |
306 | +</dmi> |
307 | + |
308 | + <!-- Additional data for SCSI devices: vendor, model, type |
309 | + |
310 | + For each udev node which has DEVTYPE=scsi_device, we need |
311 | + the content of the sysfs files vendor, model, type. The data |
312 | + is stored in the same format as the DMI data: |
313 | + /path/to/file:filecontent |
314 | + --> |
315 | + <sysfs-attributes>/sys/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0/vendor:HL-DT-ST |
316 | +/sys/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0/model:DVDRAM GSA-4083N |
317 | +/sys/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0/type:5 |
318 | + </sysfs-attributes> |
319 | + |
320 | + <!-- processors: Data about processors installed in a system. |
321 | + The data is retrieved from /proc/cpuinfo. |
322 | + --> |
323 | + <processors> |
324 | + |
325 | + <!-- processor: Data from /proc/cpuinfo about a single processor. |
326 | + --> |
327 | + <processor id="123" name="0"> |
328 | + |
329 | + <!-- property: The data of one line of /proc/cpuinfo. |
330 | + attribute name: The name of the property |
331 | + (the text left of the ':' in a line of /proc/cpuinfo) |
332 | + attribute type: A Python type appropriate for the value. |
333 | + --> |
334 | + <property name="wp" type="bool"> |
335 | + True |
336 | + </property> |
337 | + <property name="flags" type="list"> |
338 | + <value type="str"> |
339 | + fpu |
340 | + </value> |
341 | + <value type="str"> |
342 | + vme |
343 | + </value> |
344 | + <value type="str"> |
345 | + de |
346 | + </value> |
347 | + </property> |
348 | + <property name="cpu_mhz" type="float"> |
349 | + 1000.0 |
350 | + </property> |
351 | + </processor> |
352 | + </processors> |
353 | + |
354 | + <!-- aliases: optional data provided by the user: |
355 | + The name of a peripheral, PCI card etc as shown by a label on |
356 | + the device. OEM devices are often sold under different names |
357 | + by different vendors; having a set of alias names for a device |
358 | + allows users of the HWDB to search for information by these |
359 | + "marketing names". |
360 | + --> |
361 | + <aliases> |
362 | + <!-- alias: The "label name" of a device or system. |
363 | + attribute target: The sysfs path of a device as given |
364 | + in <udev>. |
365 | + --> |
366 | + <alias target="/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0"> |
367 | + |
368 | + <!-- vendor: The vendor name shown on the device label. |
369 | + --> |
370 | + <vendor>Medion</vendor> |
371 | + |
372 | + <!-- model: The model name of shown on the label. |
373 | + --> |
374 | + <model>QuickPrint 9876</model> |
375 | + </alias> |
376 | + </aliases> |
377 | + </hardware> |
378 | + |
379 | + <!-- software: Data about the software installed on the system. |
380 | + --> |
381 | + <software> |
382 | + |
383 | + <!-- lsbrelease: The data from /etc/lsb-release. |
384 | + --> |
385 | + <lsbrelease> |
386 | + |
387 | + <!-- property: the data from one line of /etc/lsb-release. |
388 | + attribute type: A Python type appropriate for this |
389 | + property (str). |
390 | + --> |
391 | + <property name="release" type="str"> |
392 | + 7.04 |
393 | + </property> |
394 | + <property name="codename" type="str"> |
395 | + feisty |
396 | + </property> |
397 | + <property name="distributor-id" type="str"> |
398 | + Ubuntu |
399 | + </property> |
400 | + <property name="description" type="str"> |
401 | + Ubuntu 7.04 |
402 | + </property> |
403 | + <property name="dict_example" type="dict"> |
404 | + <value name="a" type="str">value for key a</value> |
405 | + <value name="b" type="int">1234</value> |
406 | + </property> |
407 | + </lsbrelease> |
408 | + |
409 | + <!-- packages: Data about the installed software packages. |
410 | + --> |
411 | + <packages> |
412 | + |
413 | + <!-- package: Data about a single package. |
414 | + The <property> sub-tags contain the DEB properties |
415 | + "name", "priority", "section", "source", "version", |
416 | + "installed_size", "size", "summary". |
417 | + |
418 | + XXX Abel Deuring 2007-12-12: What about submissions |
419 | + from RPM-based Linux versions? (And "exotic" variants |
420 | + like Gentoo?) |
421 | + --> |
422 | + <package name="metacity" id="200"> |
423 | + <property name="installed_size" type="int"> |
424 | + 868352 |
425 | + </property> |
426 | + <property name="section" type="str"> |
427 | + x11 |
428 | + </property> |
429 | + <property name="summary" type="str"> |
430 | + A lightweight GTK2 based Window Manager |
431 | + </property> |
432 | + <property name="priority" type="str"> |
433 | + optional |
434 | + </property> |
435 | + <property name="source" type="str"> |
436 | + metacity |
437 | + </property> |
438 | + <property name="version" type="str"> |
439 | + 1:2.18.2-0ubuntu1.1 |
440 | + </property> |
441 | + <property name="size" type="int"> |
442 | + 429128 |
443 | + </property> |
444 | + </package> |
445 | + </packages> |
446 | + <!-- Information extracted from Xorg.0.log. |
447 | + HAL does not provide any information about Xorg drivers, so |
448 | + we retrieve that from the xserver's log file. |
449 | + --> |
450 | + <xorg version="1.3.0"> |
451 | + <!-- driver: Data about a driver. |
452 | + (optional) |
453 | + attribute name: The name of the driver. |
454 | + attribute version: The version of the driver. |
455 | + attribute class: The module class of the driver |
456 | + attribute device: The ID of a device driven by this driver. |
457 | + --> |
458 | + <driver name="fglrx" version="1.23" class="X.Org Video Driver" |
459 | + device="12"/> |
460 | + </xorg> |
461 | + </software> |
462 | + |
463 | + <!-- questions: User's answers to questions asked by the client. |
464 | + --> |
465 | + <questions> |
466 | + |
467 | + <!-- question: Data of a question. |
468 | + attribute name: The unique name of the question. |
469 | + attribute plugin: The name of the plugin which asked |
470 | + the question. |
471 | + attribute version: The version of the question. |
472 | + attribute type: Allowed values are "manual" and "automatic". |
473 | + A "manual" question requires user input for the answer; |
474 | + an "automatic" question gets the answer automatically. |
475 | + --> |
476 | + <question name="detected_network_controllers" |
477 | + plugin="find_network_controllers"> |
478 | + |
479 | + <!-- target: Information about a device or software package the |
480 | + question is about. The attribute "id" is the sysfs path of |
481 | + a device as given in <udev>, or the ID of a software package |
482 | + node. |
483 | + This node may appear multiple times. |
484 | + --> |
485 | + <target id="/devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0/usb_endpoint/usbdev3.1_ep81"> |
486 | + <!-- driver: The driver which controls the target device. This tag |
487 | + may appear more than once. |
488 | + |
489 | + While we are working on a project called "Hardware Database", |
490 | + we are not that much interested in the question, if a device |
491 | + works "as such", but if their Linux driver(s) work. |
492 | + |
493 | + It is not in every case possible to identify the used driver |
494 | + from HAL data, so we need another way to add this information. |
495 | + (example: HAL does not know, which driver is used for the |
496 | + graphics card.) |
497 | + |
498 | + Example for multiple drivers: Some scanners have a SCSI _and_ |
499 | + a USB interface; if such a scanner is tested, we not only want |
500 | + to know, which Sane backend is used, but also, which interface |
501 | + is used. |
502 | + |
503 | + Also, it might be interesting to know for many USB 2.0 devices, |
504 | + if a USB 1 (uhci_hcd or ohci_hcd driver) or the USB 2 driver |
505 | + (ehci_hcd) was used. A USB 1 driver might for example explain |
506 | + latency problems. |
507 | + --> |
508 | + <driver>ipw3945</driver> |
509 | + </target> |
510 | + |
511 | + <!-- ID of the 88E8055 PCI-E Gigabit Ethernet Controller --> |
512 | + <target id="/devices/pci0000:00/0000:00:1f.1"/> |
513 | + |
514 | + <!-- command: The command line of an external command required to |
515 | + ask this question. |
516 | + --> |
517 | + <command/> |
518 | + |
519 | + <!-- answer: The answer to the question. Two types of answers are |
520 | + defined, "multiple_choice" and "measurement". (See below |
521 | + for an example of the latter.) |
522 | + attribute type: Must be "multiple_choice" or "measurement". |
523 | + --> |
524 | + <answer type="multiple_choice">pass</answer> |
525 | + |
526 | + <!-- answer_choices: The list of possible choices. |
527 | + The data should only be used for consistency |
528 | + checks and to detect variants of the question. |
529 | + --> |
530 | + <answer_choices> |
531 | + <value type="str">fail</value> |
532 | + <value type="str">pass</value> |
533 | + <value type="str">skip</value> |
534 | + </answer_choices> |
535 | + |
536 | + <!-- A user comment about the device or about the test. |
537 | + --> |
538 | + <comment> |
539 | + The WLAN adapter drops the connection very frequently. |
540 | + </comment> |
541 | + </question> |
542 | + |
543 | + <question name="internet_ping" |
544 | + plugin="internet_ping"> |
545 | + <target id="/devices/pci0000:00/0000:00:1f.1"/> |
546 | + <command/> |
547 | + <answer type="multiple_choice">pass</answer> |
548 | + <answer_choices> |
549 | + <value type="str">fail</value> |
550 | + <value type="str">pass</value> |
551 | + <value type="str">skip</value> |
552 | + </answer_choices> |
553 | + </question> |
554 | + |
555 | + <!-- example for a "measurement question" |
556 | + --> |
557 | + <question name="harddisk_speed" |
558 | + plugin="harddisk_speed"> |
559 | + <target id="/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0"/> |
560 | + <command>hdparm -t /dev/sda</command> |
561 | + <!-- answer: The answer to a "measurement question". |
562 | + attribute type: See above. |
563 | + attribute unit: The unit of the result of the measurement. |
564 | + XXX Abel Deuring 2007-12-12 bug=175978 We should |
565 | + enumerate a list of allowed units, in order to avoid |
566 | + multiple units for the same dimension. e.g., B/sec, |
567 | + MB/sec or inch, cm, foot. |
568 | + |
569 | + For dimensionless values, the attribute unit is omitted. |
570 | + |
571 | + "Percentage" and similar "convenience pseudo-units" like |
572 | + ppm are _not_ allowed; instead a dimensionless |
573 | + value must be used, where 0 is equivalent 0% and 1.0 is |
574 | + equivalent to 100%. |
575 | + --> |
576 | + <answer type="measurement" unit="MB/sec">38.4</answer> |
577 | + </question> |
578 | + </questions> |
579 | + <!-- miscellaneous additional text data. |
580 | + --> |
581 | +</system> |
582 | |
583 | === modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_validation.py' |
584 | --- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_validation.py 2009-06-25 05:30:52 +0000 |
585 | +++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_validation.py 2009-09-14 11:44:39 +0000 |
586 | @@ -375,8 +375,20 @@ |
587 | |
588 | The only allowed tags are specified by the Relax NG schema: |
589 | live_cd, system_id, distribution, distroseries, architecture, |
590 | - private, contactable, date_created. |
591 | + private, contactable, date_created (tested in |
592 | + testSummaryRequiredTags()), and the optional tag <kernel-release>. |
593 | """ |
594 | + # we can add the tag <kernel-release> |
595 | + sample_data = self.insertSampledata( |
596 | + data=self.sample_data, |
597 | + insert_text='<kernel-release value="2.6.28-15-generic"/>', |
598 | + where='</summary>') |
599 | + result, submission_id = self.runValidator(sample_data) |
600 | + self.assertNotEqual( |
601 | + result, None, |
602 | + 'Valid submission containing a <kernel-release> tag rejected.') |
603 | + |
604 | + # Adding any other tag is not possible. |
605 | sample_data = self.insertSampledata( |
606 | data=self.sample_data, |
607 | insert_text='<nonsense/>', |
608 | @@ -609,24 +621,100 @@ |
609 | 'Invalid attribute foo for element plugin', |
610 | 'invalid attribute in client plugin') |
611 | |
612 | - def testHardwareSubTags(self): |
613 | + def testHardwareSubTagHalOrUdev(self): |
614 | + """The <hardware> tag requires data about hardware devices. |
615 | + |
616 | + This data is stored either in the sub-tag <hal> or in the |
617 | + three tags <udev>, <dmi>, <sysfs-attributes>. |
618 | + """ |
619 | + # Omitting <hal> leads to an error. |
620 | + sample_data = self.replaceSampledata( |
621 | + data=self.sample_data, |
622 | + replace_text='', |
623 | + from_text='<hal', |
624 | + to_text='</hal>') |
625 | + result, submission_id = self.runValidator(sample_data) |
626 | + self.assertErrorMessage( |
627 | + submission_id, result, |
628 | + 'Expecting an element hal, got nothing', |
629 | + 'missing tag <hal> in <hardware>') |
630 | + |
631 | + # But we may replace <hal> by the three tags <udev>, <dmi>, |
632 | + #<sysfs-attributes>. |
633 | + sample_data = self.replaceSampledata( |
634 | + data=self.sample_data, |
635 | + replace_text=""" |
636 | + <udev>some text</udev> |
637 | + <dmi>some text</dmi> |
638 | + <sysfs-attributes>some text</sysfs-attributes> |
639 | + """, |
640 | + from_text='<hal', |
641 | + to_text='</hal>') |
642 | + result, submission_id = self.runValidator(sample_data) |
643 | + self.assertNotEqual( |
644 | + result, None, |
645 | + 'submission with valid <udev>, <dmi>, <sysfs-attributes> tags ' |
646 | + 'rejected') |
647 | + |
648 | + def testHardwareSubTagUdevIncomplete(self): |
649 | """The <hardware> tag has a fixed set of allowed sub-tags. |
650 | |
651 | - Valid sub-tags are <hal>, <processors>, <aliases>. |
652 | - <aliases> is optional; <hal> and <processors> are required. |
653 | + Valid sub-tags are <hal>, <udev>, <dmi>, <sysfs-attributes>, |
654 | + <processors>, <aliases>. <aliases> is optional, <processors> |
655 | + is required, and either <hal> or all three tags <udev>, <dmi>, |
656 | + <sysfs-attributes> must be present. |
657 | """ |
658 | - # Omitting either of the required tags leads on an error. |
659 | - for tag in ('hal', 'processors'): |
660 | + # Omitting any of the three tags <udev>, <dmi>, <sysfs-attributes> |
661 | + # makes the data invalid. |
662 | + all_tags = ['udev', 'dmi', 'sysfs-attributes'] |
663 | + for index in range(len(all_tags)): |
664 | + test_tags = all_tags[:] |
665 | + missing_tag = test_tags[index] |
666 | + del test_tags[index] |
667 | + replace_text = [ |
668 | + '<%s>text</%s>' % (tag, tag) for tag in test_tags] |
669 | + replace_text = ''.join(replace_text) |
670 | sample_data = self.replaceSampledata( |
671 | data=self.sample_data, |
672 | - replace_text='', |
673 | - from_text='<%s' % tag, |
674 | - to_text='</%s>' % tag) |
675 | - result, submission_id = self.runValidator(sample_data) |
676 | - self.assertErrorMessage( |
677 | - submission_id, result, |
678 | - 'Expecting an element %s, got nothing' % tag, |
679 | - 'missing tag <%s> in <hardware>' % tag) |
680 | + replace_text=replace_text, |
681 | + from_text='<hal', |
682 | + to_text='</hal>') |
683 | + result, submission_id = self.runValidator(sample_data) |
684 | + self.assertErrorMessage( |
685 | + submission_id, result, |
686 | + 'Expecting an element %s, got nothing' % missing_tag, |
687 | + 'missing tag <%s> in <hardware>' % missing_tag) |
688 | + |
689 | + def testHardwareSubTagHalMixedWithUdev(self): |
690 | + """Mixing <hal> with <udev>, <dmi>, <sysfs-attributes> is impossible. |
691 | + """ |
692 | + # A submission containing the tag <hal> as well as one of <udev>, |
693 | + # <dmi>, <sysfs-attributes> is invalid. |
694 | + for tag in ['udev', 'dmi', 'sysfs-attributes']: |
695 | + sample_data = self.insertSampledata( |
696 | + data=self.sample_data, |
697 | + insert_text='<%s>some text</%s>' % (tag, tag), |
698 | + where='<hal') |
699 | + result, submission_id = self.runValidator(sample_data) |
700 | + self.assertErrorMessage( |
701 | + submission_id, result, |
702 | + 'Invalid sequence in interleave', |
703 | + '<hal> mixed with <%s> in <hardware>' % tag) |
704 | + |
705 | + def testHardwareOtherSubTags(self): |
706 | + """The <hardware> tag has a fixed set of allowed sub-tags. |
707 | + """ |
708 | + # The <processors> tag must not be omitted. |
709 | + sample_data = self.replaceSampledata( |
710 | + data=self.sample_data, |
711 | + replace_text='', |
712 | + from_text='<processors', |
713 | + to_text='</processors>') |
714 | + result, submission_id = self.runValidator(sample_data) |
715 | + self.assertErrorMessage( |
716 | + submission_id, result, |
717 | + 'Expecting an element processors, got nothing', |
718 | + '<processor> tag omitted') |
719 | |
720 | # The <aliases> tag may be omitted. |
721 | sample_data = self.replaceSampledata( |
722 | @@ -1603,23 +1691,12 @@ |
723 | 'Extra element aliases in interleave', |
724 | 'missing attribute of <alias>') |
725 | |
726 | - # target must be an integer. |
727 | + # The value of target does not have to be an integer. |
728 | sample_data = self.sample_data.replace( |
729 | '<alias target="65">', '<alias target="noInteger">') |
730 | result, submission_id = self.runValidator(sample_data) |
731 | - self.assertErrorMessage( |
732 | - submission_id, result, |
733 | - 'Extra element aliases in interleave', |
734 | - 'missing attribute of <alias>') |
735 | - |
736 | - # target must not be empty. |
737 | - sample_data = self.sample_data.replace( |
738 | - '<alias target="65">', '<alias target="">') |
739 | - result, submission_id = self.runValidator(sample_data) |
740 | - self.assertErrorMessage( |
741 | - submission_id, result, |
742 | - 'Element hardware failed to validate content', |
743 | - 'missing attribute of <alias>') |
744 | + self.assertNotEqual( |
745 | + result, None, '<alias target="noInteger"> rejected') |
746 | |
747 | # Other attributes are not allowed. We get again the same |
748 | # quite unspecific error message as above. |
This branch is based on lp:~adeuring/launchpad/hwdb-submissions-with-udev-data and adds some tests for the changed RelaxNG schema for HWDB submissions. (see also the MP https:/ /code.edge. launchpad. net/~adeuring/ launchpad/ hwdb-submission s-with- udev-data/ +merge/ 11683 for a exlanation what this branch is about)
These tests modify the existing sample submission file by inserting more data, or by replacing/removing sme data from the file.
The new tests ensure that:
- the new tga <kernel-release value="whatever"/> can be inserted into <summary>
- the <hal> node can be replaced by the three node <udev>, <dmi>, <sysfs-attributes>
- <hal> may not be mixed with <udev>, <dmi>, <sysfs-attributes>
The diff against the base branch:
=== modified file 'lib/canonical/ launchpad/ scripts/ tests/test_ hwdb_submission _validation. py' launchpad/ scripts/ tests/test_ hwdb_submission _validation. py 2009-06-25 05:30:52 +0000 launchpad/ scripts/ tests/test_ hwdb_submission _validation. py 2009-09-14 11:42:30 +0000
--- lib/canonical/
+++ lib/canonical/
@@ -375,8 +375,20 @@
The only allowed tags are specified by the Relax NG schema: iredTags( )), and the optional tag <kernel-release>. ledata( sample_ data, text='< kernel- release value=" 2.6.28- 15-generic" />', or(sample_ data) qual(
sample_ data = self.insertSamp ledata(
data= self.sample_ data,
insert_ text='< nonsense/ >',
' Invalid attribute foo for element plugin',
' invalid attribute in client plugin')
live_cd, system_id, distribution, distroseries, architecture,
- private, contactable, date_created.
+ private, contactable, date_created (tested in
+ testSummaryRequ
"""
+ # we can add the tag <kernel-release>
+ sample_data = self.insertSamp
+ data=self.
+ insert_
+ where='</summary>')
+ result, submission_id = self.runValidat
+ self.assertNotE
+ result, None,
+ 'Valid submission containing a <kernel-release> tag rejected.')
+
+ # Adding any other tag is not possible.
@@ -609,24 +621,100 @@
- def testHardwareSub Tags(self) : TagHalOrUdev( self): pledata( sample_ data, or(sample_ data) rMessage( attributes> . pledata( sample_ data, attributes> some text</s...
+ def testHardwareSub
+ """The <hardware> tag requires data about hardware devices.
+
+ This data is stored either in the sub-tag <hal> or in the
+ three tags <udev>, <dmi>, <sysfs-attributes>.
+ """
+ # Omitting <hal> leads to an error.
+ sample_data = self.replaceSam
+ data=self.
+ replace_text='',
+ from_text='<hal',
+ to_text='</hal>')
+ result, submission_id = self.runValidat
+ self.assertErro
+ submission_id, result,
+ 'Expecting an element hal, got nothing',
+ 'missing tag <hal> in <hardware>')
+
+ # But we may replace <hal> by the three tags <udev>, <dmi>,
+ #<sysfs-
+ sample_data = self.replaceSam
+ data=self.
+ replace_text="""
+ <udev>some text</udev>
+ <dmi>some text</dmi>
+ <sysfs-