Merge lp:~adeuring/launchpad/hwdb-test-natty-mess into lp:launchpad
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Abel Deuring | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 13870 | ||||
Proposed branch: | lp:~adeuring/launchpad/hwdb-test-natty-mess | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
560 lines (+529/-1) 3 files modified
lib/canonical/launchpad/scripts/tests/hardwaretest-natty.xml (+473/-0) lib/lp/hardwaredb/scripts/hwdbsubmissions.py (+37/-1) lib/lp/hardwaredb/tests/test_hwdb_submission_validation.py (+19/-0) |
||||
To merge this branch: | bzr merge lp:~adeuring/launchpad/hwdb-test-natty-mess | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Francis J. Lacoste (community) | Approve | ||
Review via email: mp+73722@code.launchpad.net |
Commit message
[r=flacoste][bug=839102] allow processing of HWDB submissions from Natty
Description of the change
This branch fixes the problem that HWDB submissions from Natty can not be processed.
The reason for the failure is simple: The submission processing script expects an XML file with a structure as defined in lib/canonical/
One part of the required XML data looks like
<hardware>
<udev>(lots of text data)
</udev>
<dmi>(more text data)
</dmi>
(other tags)
</hardware>
The reports from Natty do not contain the tags <udev> and <dmi>; their content is instead stored in
<context>
<info command="udevadm info --export-db">(text data)
</info>
<info command="grep -r . /sys/class/dmi/id/ 2>/dev/
</info>
</context>
The fix is quite simple: Two regular expressions check if the tags <udev> and <dmi> exist within <hardware>; if not, these tags are inserted, provided that the corresponding <info> nodes can be found.
This is a bit of a "brute force" fix. I tried at first to modify the etree structure, but then flacoste gave me the hint that the RelaxNG validation is _not_ on the etree representaion of the data, but on the "text string". Creating the etree, modifying it, writing its contents into a StringIO buffer, and finally passing the buffer's content to the RNG validator should have worked too, but would be much slower.
A note about the diff: The first 480 lines are the content of a new file with test data. Its content is a variant of the already existing file lib/canonical/
diff -u hardwaretest-
in lib/canonical/
test: ./bin/test hardwaredb -vvt test_hwdb_
I find the test a bit weak as it just checks that result isn't None. But I guess that's fine since the result from runValidator is a parsed etree that we know match the expected structure.
Thanks for fixing this Abel!