Merge lp:~adeuring/launchpad/hwdb-class-udev-device-8 into lp:launchpad
Proposed by
Abel Deuring
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~adeuring/launchpad/hwdb-class-udev-device-8 |
Merge into: | lp:launchpad |
Diff against target: |
197 lines 2 files modified
lib/canonical/launchpad/scripts/hwdbsubmissions.py (+1/-1) lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py (+53/-24) |
To merge this branch: | bzr merge lp:~adeuring/launchpad/hwdb-class-udev-device-8 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Eleanor Berger (community) | code | Approve | |
Review via email: mp+13554@code.launchpad.net |
To post a comment you must log in.
This branch fixes a stupid mistake I made in the property UdevDevice. scsi_controller . This property is supposed to return the node of the controller of a SCSI device.
(Background: We get data about hardware mostly from udev; a udev device is represented in the HWDB submission processing script by class UdevDevice. udev devices have parent-child relationships, where device A is an ancestor of device B, if the pathname of device B extends the pathname of device A.)
This mistake happened for two reasons:
1. I copy&pasted the sample data used in tests from "udevadm info --export-db" to the test data as defined in l/c/l/scripts/ tests/test_ hwdb_submission _processing. py, without looking at the data suffciently carefully. So, when reading and copying a relevant part of this data, like:
P: /devices/ pci0000: 00/0000: 00:1f.1/ host4
E: DEVTYPE=scsi_host
E: SUBSYSTEM=scsi
P: /devices/ pci0000: 00/0000: 00:1f.1/ host4/scsi_ host/host4
E: SUBSYSTEM=scsi_host
P: /devices/ pci0000: 00/0000: 00:1f.1/ host4/target4: 0:0
E: DEVTYPE=scsi_target
E: SUBSYSTEM=scsi
P: /devices/ pci0000: 00/0000: 00:1f.1/ host4/target4: 0:0/4:0: 0:0 scsi:t- 0x05
E: DEVTYPE=scsi_device
E: DRIVER=sr
E: MODALIAS=
E: SUBSYSTEM=scsi
I managed to ignore the fact that the path names /devices/ pci0000: 00/0000: 00:1f.1/ host4/scsi_ host/host4 and /devices/ pci0000: 00/0000: 00:1f.1/ host4/target4: 0:0 say that these nodes are siblings, but simply assumed that the former is the parent of the latter.
2. The method UdevDevice.setUo() defines lots of test data. A single udev device is represented by a dictionary like self.pci_ device_ data; a set of devices needed for some tests was represented by a sequence like self.scsi_ device_ hierarchy_ data. The method UdevDevice. buildUdevDevice Hierarchy( ) takes such a list and simply assumed that device N of the sequence is the parent of device N+1.
This way, my wrong assumption about the parent-child relation in the example above is simply mapped into the test data.
So I changed UdevDevice. buildUdevDevice Hierarchy( ) to build the parent-child relations by looking at the path names of the devices (property device_id). Since the test data is copy&pasted from real-world data, we can be quite sure that the relations defined by this method are now correct.
The method now also returns a dictionary instead of a sequence, allowing to identify "interesting" devices by their path names, instead of a somewhat obscure index.
test: ./bin/test --test= test_hwdb_ submission_ processing
= 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 complaint about etree is not related to my changes.