Merge lp:~adeuring/launchpad/hwdb-class-udev-device-5 into lp:launchpad/db-devel

Proposed by Abel Deuring
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~adeuring/launchpad/hwdb-class-udev-device-5
Merge into: lp:launchpad/db-devel
Diff against target: 1059 lines
2 files modified
lib/canonical/launchpad/scripts/hwdbsubmissions.py (+200/-36)
lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py (+473/-67)
To merge this branch: bzr merge lp:~adeuring/launchpad/hwdb-class-udev-device-5
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+13350@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) wrote :
Download full text (3.4 KiB)

This branch is another step to prepare the BWDB submission processing script for submissions from Karmic's HWDB client.

- a fix of two properties for class UdevDevice:

BaseDevice.vendor_id_for_db and BaseDevice.product_id_for_db look up the dictionaries DB_FORMAT_FOR_VENDOR_ID and DB_FORMAT_FOR_PRODUCT_ID, respectively, using BaseDevice,raw_bus as the key. The udev data contains slightly different bus/subsystem data, so we get the raw_value "scsi_device" for submissions with udev data, while we have raw_bus == "scsi" for HAL-based submissions. Hence I added a "scsi_device" entry to the dicitionaries. Since the raw_bus value "scsi_device" is not used by HAL, there are no side effects for HAL-based submissions.

- a new property UdevDevice.driver_name

- The method BaseDevice.translateScsiBus() figures out, if a given device where rw_bus is "scsi" (submission with HAL data) or "scsi_device" (submissions with udev data) is a real SCSI device or if it is in fact a USB storage device or a IDE/ATA/SATA device. (Since most od today's storage devices understand SCSI commands, the Linux kernel accesses them via the SCSI layer.) We detect the real device type of given device with raw_bus in ("scsi", "scsi_device") by looking at the device that controls the given (fake) SCSI device: If the controller is a USB device, we have a memory stick, a card reader or a "real" IDE/SATA disk connected to USB adapter; if the controller is a PCI device, we have a real SCSI device, or an IDE/ATA/SATA device. What exactly ww have in the latter case, can be derived from the PCI class/subclass of the controller.

For submissions with HAL, the controller is the grandparent of the SCSI device, but for submissions with udev data, the controller is the grand-grand-grand-grand-grandparent (6th ancestor).

Since the core logic of translateScsiBus() is identical for HAL and udev data, I did not move the method to the two classes HALDevice, UdevDevice derived from BaseDevice. Instead, I defined a new property BaseDevice.scsi_controller that must be implemented by both HALDevice and UdevDevice.

A implementation of UdevDevice.scsi_controller is still missing -- when I started to write tests for that property, I noticed that the diff of the branch would probably exceed our 800 lines limit, so I left that for another sequel.

The change in test_hwdb_submission_processing.py: replace scsi_device_data by scsi_scanner_device_data may look a bit odd. There are two reasons for this change:

(1) I wanted a real-world SCSI vendor name that is shorter than 8 characters in order to have proper test data for UdevDevice.vendor_id_for_db, which right-pads vendor names with spaces to length 8.

(2) The old test device "MATSHITA DVD-RAM UJ-841S" is in fact an IDE device; it might show up as an IDE device later again in a test of BaseDevice.translateScsiBus().

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:
  lib/canonical/launchpad/scripts/hwdbsubmissions.py
  lib/canonical/launchpad/scripts/tests/test_hwdb_submi...

Read more...

Revision history for this message
Gavin Panella (allenap) wrote :

This all looks good.

As discussed on IRC, this is really meant for devel, not db-devel, so
I've attached the diff I actually reviewed.

Gavin.

=== modified file 'lib/canonical/launchpad/scripts/hwdbsubmissions.py'
--- lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-13 21:03:31 +0000
+++ lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-14 16:00:26 +0000
@@ -87,12 +87,14 @@
87 'pci': '0x%04x',87 'pci': '0x%04x',
88 'usb_device': '0x%04x',88 'usb_device': '0x%04x',
89 'scsi': '%-8s',89 'scsi': '%-8s',
90 'scsi_device': '%-8s',
90 }91 }
9192
92DB_FORMAT_FOR_PRODUCT_ID = {93DB_FORMAT_FOR_PRODUCT_ID = {
93 'pci': '0x%04x',94 'pci': '0x%04x',
94 'usb_device': '0x%04x',95 'usb_device': '0x%04x',
95 'scsi': '%-16s',96 'scsi': '%-16s',
97 'scsi_device': '%-16s',
96 }98 }
9799
98UDEV_USB_DEVICE_PROPERTIES = set(('DEVTYPE', 'PRODUCT', 'TYPE'))100UDEV_USB_DEVICE_PROPERTIES = set(('DEVTYPE', 'PRODUCT', 'TYPE'))
@@ -1609,6 +1611,11 @@
1609 """The name of the driver contolling this device. May be None."""1611 """The name of the driver contolling this device. May be None."""
1610 raise NotImplementedError1612 raise NotImplementedError
16111613
1614 @property
1615 def scsi_controller(self):
1616 """Return the SCSI host controller for this device."""
1617 raise NotImplementedError
1618
1612 def translateScsiBus(self):1619 def translateScsiBus(self):
1613 """Return the real bus of a device where raw_bus=='scsi'.1620 """Return the real bus of a device where raw_bus=='scsi'.
16141621
@@ -1617,37 +1624,27 @@
1617 for more details. This method determines the real bus1624 for more details. This method determines the real bus
1618 of a device accessed via the kernel's SCSI subsystem.1625 of a device accessed via the kernel's SCSI subsystem.
1619 """1626 """
1620 # While SCSI devices from valid submissions should have a1627 scsi_controller = self.scsi_controller
1621 # parent and a grandparent, we can't be sure for bogus or1628 if scsi_controller is None:
1622 # broken submissions.
1623 parent = self.parent
1624 if parent is None:
1625 self.parser._logWarning(
1626 'Found SCSI device without a parent: %s.' % self.device_id)
1627 return None
1628 grandparent = parent.parent
1629 if grandparent is None:
1630 self.parser._logWarning(
1631 'Found SCSI device without a grandparent: %s.'
1632 % self.device_id)
1633 return None1629 return None
16341630
1635 grandparent_bus = grandparent.raw_bus1631 scsi_controller_bus = scsi_controller.raw_bus
1636 if grandparent_bus == 'pci':1632 if scsi_controller_bus == 'pci':
1637 if (grandparent.pci_class != PCI_CLASS_STORAGE):1633 if (scsi_controller.pci_class != PCI_CLASS_STORAGE):
1638 # This is not a storage class PCI device? This1634 # This is not a storage class PCI device? This
1639 # indicates a bug somewhere in HAL or in the hwdb1635 # indicates a bug somewhere in HAL or in the hwdb
1640 # client, or a fake submission.1636 # client, or a fake submission.
1641 device_class = grandparent.pci_class1637 device_class = scsi_controller.pci_class
1642 self.parser._logWarning(1638 self.parser._logWarning(
1643 'A (possibly fake) SCSI device %s is connected to '1639 'A (possibly fake) SCSI device %s is connected to '
1644 'PCI device %s that has the PCI device class %s; '1640 'PCI device %s that has the PCI device class %s; '
1645 'expected class 1 (storage).'1641 'expected class 1 (storage).'
1646 % (self.device_id, grandparent.device_id, device_class))1642 % (self.device_id, scsi_controller.device_id,
1643 device_class))
1647 return None1644 return None
1648 pci_subclass = grandparent.pci_subclass1645 pci_subclass = scsi_controller.pci_subclass
1649 return self.pci_storage_subclass_hwbus.get(pci_subclass)1646 return self.pci_storage_subclass_hwbus.get(pci_subclass)
1650 elif grandparent_bus == 'usb':1647 elif scsi_controller_bus == 'usb':
1651 # USB storage devices have the following HAL device hierarchy:1648 # USB storage devices have the following HAL device hierarchy:
1652 # - HAL node for the USB device. info.bus == 'usb_device',1649 # - HAL node for the USB device. info.bus == 'usb_device',
1653 # device class == 0, device subclass == 01650 # device class == 0, device subclass == 0
@@ -2357,6 +2354,27 @@
2357 """See `BaseDevice`."""2354 """See `BaseDevice`."""
2358 return self.getVendorOrProductID('product')2355 return self.getVendorOrProductID('product')
23592356
2357 @property
2358 def scsi_controller(self):
2359 """See `BaseDevice`."""
2360 # While SCSI devices from valid submissions should have a
2361 # parent and a grandparent, we can't be sure for bogus or
2362 # broken submissions.
2363 if self.raw_bus != 'scsi':
2364 return None
2365 parent = self.parent
2366 if parent is None:
2367 self.parser._logWarning(
2368 'Found SCSI device without a parent: %s.' % self.device_id)
2369 return None
2370 grandparent = parent.parent
2371 if grandparent is None:
2372 self.parser._logWarning(
2373 'Found SCSI device without a grandparent: %s.'
2374 % self.device_id)
2375 return None
2376 return grandparent
2377
23602378
2361class UdevDevice(BaseDevice):2379class UdevDevice(BaseDevice):
2362 """The representation of a udev device node."""2380 """The representation of a udev device node."""
@@ -2617,6 +2635,11 @@
2617 """See `BaseDevice`."""2635 """See `BaseDevice`."""
2618 return self.getVendorOrProductID('product')2636 return self.getVendorOrProductID('product')
26192637
2638 @property
2639 def driver_name(self):
2640 """See `BaseDevice`."""
2641 return self.udev['E'].get('DRIVER')
2642
26202643
2621class ProcessingLoop(object):2644class ProcessingLoop(object):
2622 """An `ITunableLoop` for processing HWDB submissions."""2645 """An `ITunableLoop` for processing HWDB submissions."""
26232646
=== modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py'
--- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-13 21:02:35 +0000
+++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-14 16:00:26 +0000
@@ -539,6 +539,214 @@
539 'HAL property info.bus.')539 'HAL property info.bus.')
540540
541541
542 def test_HALDevice_scsi_controller_usb_storage_device(self):
543 """test of HALDevice.scsi_controller.
544
545 The physical device is a USB storage device.
546 """
547 devices = [
548 # The main node of the USB storage device.
549 {
550 'id': 1,
551 'udi': self.UDI_USB_STORAGE,
552 'properties': {
553 'info.bus': ('usb_device', 'str'),
554 },
555 },
556 # The storage interface of the USB device.
557 {
558 'id': 2,
559 'udi': self.UDI_USB_STORAGE_IF0,
560 'properties': {
561 'info.bus': ('usb', 'str'),
562 'info.parent': (self.UDI_USB_STORAGE, 'str'),
563 },
564 },
565 # The fake SCSI host of the storage device. Note that HAL does
566 # _not_ provide the info.bus property.
567 {
568 'id': 3,
569 'udi': self.UDI_USB_STORAGE_SCSI_HOST,
570 'properties': {
571 'info.parent': (self.UDI_USB_STORAGE_IF0, 'str'),
572 },
573 },
574 # The fake SCSI disk.
575 {
576 'id': 3,
577 'udi': self.UDI_USB_STORAGE_SCSI_DEVICE,
578 'properties': {
579 'info.bus': ('scsi', 'str'),
580 'info.parent': (self.UDI_USB_STORAGE_SCSI_HOST, 'str'),
581 },
582 },
583 ]
584 parsed_data = {
585 'hardware': {
586 'hal': {
587 'devices': devices,
588 },
589 },
590 }
591
592 parser = SubmissionParser()
593 parser.buildDeviceList(parsed_data)
594
595 usb_fake_scsi_disk = parser.hal_devices[
596 self.UDI_USB_STORAGE_SCSI_DEVICE]
597 usb_main_device = parser.hal_devices[self.UDI_USB_STORAGE_IF0]
598 self.assertEqual(usb_main_device, usb_fake_scsi_disk.scsi_controller)
599
600 def test_HALDevice_scsi_controller_pci_controller(self):
601 """test of HALDevice.scsi_controller.
602
603 Variant for a SCSI device connected to a PCI controller.
604 """
605 devices = [
606 # The PCI host controller.
607 {
608 'id': 1,
609 'udi': self.UDI_SATA_CONTROLLER,
610 'properties': {
611 'info.bus': ('pci', 'str'),
612 'pci.device_class': (PCI_CLASS_STORAGE, 'int'),
613 'pci.device_subclass': (PCI_SUBCLASS_STORAGE_SATA,
614 'int'),
615 },
616 },
617 # The (fake or real) SCSI host of the storage device.
618 {
619 'id': 2,
620 'udi': self.UDI_SATA_CONTROLLER_SCSI,
621 'properties': {
622 'info.parent': (self.UDI_SATA_CONTROLLER, 'str'),
623 },
624 },
625 # The (possibly fake) SCSI disk.
626 {
627 'id': 3,
628 'udi': self.UDI_SATA_DISK,
629 'properties': {
630 'info.bus': ('scsi', 'str'),
631 'info.parent': (self.UDI_SATA_CONTROLLER_SCSI, 'str'),
632 },
633 },
634 ]
635 parsed_data = {
636 'hardware': {
637 'hal': {
638 'devices': devices,
639 },
640 },
641 }
642
643 parser = SubmissionParser()
644 parser.buildDeviceList(parsed_data)
645
646 scsi_device = parser.hal_devices[self.UDI_SATA_DISK]
647 controller = parser.hal_devices[self.UDI_SATA_CONTROLLER]
648 self.assertEqual(controller, scsi_device.scsi_controller)
649
650 def test_HALDevice_scsi_controller_non_scsi_device(self):
651 """test of HALDevice.scsi_controller.
652
653 Variant for non-SCSI devices.
654 """
655 devices = [
656 {
657 'id': 1,
658 'udi': self.UDI_COMPUTER,
659 'properties': {},
660 },
661 ]
662 parsed_data = {
663 'hardware': {
664 'hal': {
665 'devices': devices,
666 },
667 },
668 }
669
670 parser = SubmissionParser()
671 parser.buildDeviceList(parsed_data)
672
673 device = parser.hal_devices[self.UDI_COMPUTER]
674 self.assertEqual(None, device.scsi_controller)
675
676 def test_HALDevice_scsi_controller_no_grandparent(self):
677 """test of HALDevice.scsi_controller.
678
679 Variant for a SCSI device without a grandparent device.
680 """
681 devices = [
682 # The (fake or real) SCSI host of the storage device.
683 {
684 'id': 1,
685 'udi': self.UDI_SATA_CONTROLLER_SCSI,
686 'properties': {},
687 },
688 # The (possibly fake) SCSI disk.
689 {
690 'id': 2,
691 'udi': self.UDI_SATA_DISK,
692 'properties': {
693 'info.bus': ('scsi', 'str'),
694 'info.parent': (self.UDI_SATA_CONTROLLER_SCSI, 'str'),
695 },
696 },
697 ]
698 parsed_data = {
699 'hardware': {
700 'hal': {
701 'devices': devices,
702 },
703 },
704 }
705
706 parser = SubmissionParser(self.log)
707 parser.submission_key = 'SCSI device without grandparent device'
708 parser.buildDeviceList(parsed_data)
709
710 scsi_device = parser.hal_devices[self.UDI_SATA_DISK]
711 self.assertEqual(None, scsi_device.scsi_controller)
712 self.assertWarningMessage(
713 parser.submission_key,
714 "Found SCSI device without a grandparent: %s."
715 % self.UDI_SATA_DISK)
716
717 def test_HALDevice_scsi_controller_no_parent(self):
718 """test of HALDevice.scsi_controller.
719
720 Variant for a SCSI device without a parent device.
721 """
722 devices = [
723 # The (possibly fake) SCSI disk.
724 {
725 'id': 1,
726 'udi': self.UDI_SATA_DISK,
727 'properties': {
728 'info.bus': ('scsi', 'str'),
729 },
730 },
731 ]
732 parsed_data = {
733 'hardware': {
734 'hal': {
735 'devices': devices,
736 },
737 },
738 }
739
740 parser = SubmissionParser(self.log)
741 parser.submission_key = 'SCSI device without parent device'
742 parser.buildDeviceList(parsed_data)
743
744 scsi_device = parser.hal_devices[self.UDI_SATA_DISK]
745 self.assertEqual(None, scsi_device.scsi_controller)
746 self.assertWarningMessage(
747 parser.submission_key,
748 "Found SCSI device without a parent: %s." % self.UDI_SATA_DISK)
749
542 def testHALDeviceGetRealBus(self):750 def testHALDeviceGetRealBus(self):
543 """Test of HALDevice.real_bus, generic case.751 """Test of HALDevice.real_bus, generic case.
544752
@@ -2613,6 +2821,7 @@
2613 'PCI_SUBSYS_ID': '10CF:1387',2821 'PCI_SUBSYS_ID': '10CF:1387',
2614 'PCI_SLOT_NAME': '0000:00:1f.2',2822 'PCI_SLOT_NAME': '0000:00:1f.2',
2615 'SUBSYSTEM': 'pci',2823 'SUBSYSTEM': 'pci',
2824 'DRIVER': 'ahci',
2616 }2825 }
2617 }2826 }
26182827
@@ -2623,21 +2832,23 @@
2623 'DEVTYPE': 'usb_device',2832 'DEVTYPE': 'usb_device',
2624 'PRODUCT': '46d/a01/1013',2833 'PRODUCT': '46d/a01/1013',
2625 'TYPE': '0/0/0',2834 'TYPE': '0/0/0',
2835 'DRIVER': 'usb',
2626 },2836 },
2627 }2837 }
26282838
2629 scsi_device_data = {2839 scsi_scanner_device_data = {
2630 'P': '/devices/pci0000:00/0000:00:1f.1/host4/target4:0:0/4:0:0:0',2840 'P': ('/devices/pci0000:00/0000:00:1e.0/0000:08:03.0/0000:09:00.0/'
2841 'host6/target6:0:1/6:0:1:0'),
2631 'E': {2842 'E': {
2843 'DEVTYPE': 'scsi_device',
2632 'SUBSYSTEM': 'scsi',2844 'SUBSYSTEM': 'scsi',
2633 'DEVTYPE': 'scsi_device',
2634 },2845 },
2635 }2846 }
26362847
2637 scsi_device_sysfs_data = {2848 scsi_scanner_device_sysfs_data = {
2638 'vendor': 'MATSHITA',2849 'vendor': 'FUJITSU',
2639 'model': 'DVD-RAM UJ-841S',2850 'model': 'fi-5120Cdj',
2640 'type': '5',2851 'type': '6',
2641 }2852 }
26422853
2643 no_subsystem_device_data = {2854 no_subsystem_device_data = {
@@ -2790,7 +3001,8 @@
2790 def test_is_scsi_device(self):3001 def test_is_scsi_device(self):
2791 """Test of UdevDevice.is_scsi_device."""3002 """Test of UdevDevice.is_scsi_device."""
2792 device = UdevDevice(3003 device = UdevDevice(
2793 None, self.scsi_device_data, self.scsi_device_sysfs_data)3004 None, self.scsi_scanner_device_data,
3005 self.scsi_scanner_device_sysfs_data)
2794 self.assertTrue(device.is_scsi_device)3006 self.assertTrue(device.is_scsi_device)
27953007
2796 device = UdevDevice(None, self.root_device)3008 device = UdevDevice(None, self.root_device)
@@ -2799,16 +3011,18 @@
2799 def test_scsi_vendor(self):3011 def test_scsi_vendor(self):
2800 """Test of UdevDevice.scsi_vendor."""3012 """Test of UdevDevice.scsi_vendor."""
2801 device = UdevDevice(3013 device = UdevDevice(
2802 None, self.scsi_device_data, self.scsi_device_sysfs_data, None)3014 None, self.scsi_scanner_device_data,
2803 self.assertEqual('MATSHITA', device.scsi_vendor)3015 self.scsi_scanner_device_sysfs_data)
3016 self.assertEqual('FUJITSU', device.scsi_vendor)
2804 device = UdevDevice(None, self.root_device)3017 device = UdevDevice(None, self.root_device)
2805 self.assertEqual(None, device.scsi_vendor)3018 self.assertEqual(None, device.scsi_vendor)
28063019
2807 def test_scsi_model(self):3020 def test_scsi_model(self):
2808 """Test of UdevDevice.scsi_model."""3021 """Test of UdevDevice.scsi_model."""
2809 device = UdevDevice(3022 device = UdevDevice(
2810 None, self.scsi_device_data, self.scsi_device_sysfs_data)3023 None, self.scsi_scanner_device_data,
2811 self.assertEqual('DVD-RAM UJ-841S', device.scsi_model)3024 self.scsi_scanner_device_sysfs_data)
3025 self.assertEqual('fi-5120Cdj', device.scsi_model)
28123026
2813 device = UdevDevice(None, self.root_device)3027 device = UdevDevice(None, self.root_device)
2814 self.assertEqual(None, device.scsi_model)3028 self.assertEqual(None, device.scsi_model)
@@ -2847,10 +3061,10 @@
2847 self.assertEqual('Unknown', device.getVendorOrProduct('product'))3061 self.assertEqual('Unknown', device.getVendorOrProduct('product'))
28483062
2849 device = UdevDevice(3063 device = UdevDevice(
2850 None, self.scsi_device_data, self.scsi_device_sysfs_data)3064 None, self.scsi_scanner_device_data,
2851 self.assertEqual('MATSHITA', device.getVendorOrProduct('vendor'))3065 self.scsi_scanner_device_sysfs_data)
2852 self.assertEqual(3066 self.assertEqual('FUJITSU', device.getVendorOrProduct('vendor'))
2853 'DVD-RAM UJ-841S', device.getVendorOrProduct('product'))3067 self.assertEqual('fi-5120Cdj', device.getVendorOrProduct('product'))
28543068
2855 device = UdevDevice(None, self.no_subsystem_device_data)3069 device = UdevDevice(None, self.no_subsystem_device_data)
2856 self.assertEqual(None, device.getVendorOrProduct('vendor'))3070 self.assertEqual(None, device.getVendorOrProduct('vendor'))
@@ -2888,10 +3102,10 @@
2888 self.assertEqual(0xa01, device.getVendorOrProductID('product'))3102 self.assertEqual(0xa01, device.getVendorOrProductID('product'))
28893103
2890 device = UdevDevice(3104 device = UdevDevice(
2891 None, self.scsi_device_data, self.scsi_device_sysfs_data)3105 None, self.scsi_scanner_device_data,
2892 self.assertEqual('MATSHITA', device.getVendorOrProductID('vendor'))3106 self.scsi_scanner_device_sysfs_data)
2893 self.assertEqual(3107 self.assertEqual('FUJITSU', device.getVendorOrProductID('vendor'))
2894 'DVD-RAM UJ-841S', device.getVendorOrProductID('product'))3108 self.assertEqual('fi-5120Cdj', device.getVendorOrProductID('product'))
28953109
2896 device = UdevDevice(3110 device = UdevDevice(
2897 None, self.no_subsystem_device_data)3111 None, self.no_subsystem_device_data)
@@ -2910,6 +3124,49 @@
2910 None, self.root_device, None, self.root_device_dmi_data)3124 None, self.root_device, None, self.root_device_dmi_data)
2911 self.assertEqual('LIFEBOOK E8210', device.product_id)3125 self.assertEqual('LIFEBOOK E8210', device.product_id)
29123126
3127 def test_vendor_id_for_db(self):
3128 """Test of UdevDevice.vendor_id_for_db."""
3129 device = UdevDevice(
3130 None, self.root_device, None, self.root_device_dmi_data)
3131 self.assertEqual('FUJITSU SIEMENS', device.vendor_id_for_db)
3132
3133 device = UdevDevice(None, self.pci_device_data)
3134 self.assertEqual('0x8086', device.vendor_id_for_db)
3135
3136 device = UdevDevice(None, self.usb_device_data)
3137 self.assertEqual('0x046d', device.vendor_id_for_db)
3138
3139 device = UdevDevice(
3140 None, self.scsi_scanner_device_data,
3141 self.scsi_scanner_device_sysfs_data)
3142 self.assertEqual('FUJITSU ', device.vendor_id_for_db)
3143
3144 def test_product_id_for_db(self):
3145 """Test of UdevDevice.product_id_for_db."""
3146 device = UdevDevice(
3147 None, self.root_device, None, self.root_device_dmi_data)
3148 self.assertEqual('LIFEBOOK E8210', device.product_id_for_db)
3149
3150 device = UdevDevice(None, self.pci_device_data)
3151 self.assertEqual('0x27c5', device.product_id_for_db)
3152
3153 device = UdevDevice(None, self.usb_device_data)
3154 self.assertEqual('0x0a01', device.product_id_for_db)
3155
3156 device = UdevDevice(
3157 None, self.scsi_scanner_device_data,
3158 self.scsi_scanner_device_sysfs_data)
3159 self.assertEqual('fi-5120Cdj ', device.product_id_for_db)
3160
3161 def test_driver_name(self):
3162 """Test of UdevDevice.driver_name."""
3163 device = UdevDevice(None, self.pci_device_data)
3164 self.assertEqual('ahci', device.driver_name)
3165
3166 device = UdevDevice(
3167 None, self.root_device, None, self.root_device_dmi_data)
3168 self.assertEqual(None, device.driver_name)
3169
29133170
2914class TestHWDBSubmissionTablePopulation(TestCaseHWDB):3171class TestHWDBSubmissionTablePopulation(TestCaseHWDB):
2915 """Tests of the HWDB popoluation with submitted data."""3172 """Tests of the HWDB popoluation with submitted data."""
Revision history for this message
Gavin Panella (allenap) wrote :

 review approve
 merge approve

review: Approve
Revision history for this message
Gavin Panella (allenap) wrote :

Review sent by email but not arrived yet... but it's all good :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/scripts/hwdbsubmissions.py'
--- lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-12 15:36:04 +0000
+++ lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-14 15:20:31 +0000
@@ -59,6 +59,7 @@
59 re.VERBOSE)59 re.VERBOSE)
6060
61ROOT_UDI = '/org/freedesktop/Hal/devices/computer'61ROOT_UDI = '/org/freedesktop/Hal/devices/computer'
62UDEV_ROOT_PATH = '/devices/LNXSYSTM:00'
6263
63# These UDIs appears in some submissions more than once.64# These UDIs appears in some submissions more than once.
64KNOWN_DUPLICATE_UDIS = set((65KNOWN_DUPLICATE_UDIS = set((
@@ -86,12 +87,14 @@
86 'pci': '0x%04x',87 'pci': '0x%04x',
87 'usb_device': '0x%04x',88 'usb_device': '0x%04x',
88 'scsi': '%-8s',89 'scsi': '%-8s',
90 'scsi_device': '%-8s',
89 }91 }
9092
91DB_FORMAT_FOR_PRODUCT_ID = {93DB_FORMAT_FOR_PRODUCT_ID = {
92 'pci': '0x%04x',94 'pci': '0x%04x',
93 'usb_device': '0x%04x',95 'usb_device': '0x%04x',
94 'scsi': '%-16s',96 'scsi': '%-16s',
97 'scsi_device': '%-16s',
95 }98 }
9699
97UDEV_USB_DEVICE_PROPERTIES = set(('DEVTYPE', 'PRODUCT', 'TYPE'))100UDEV_USB_DEVICE_PROPERTIES = set(('DEVTYPE', 'PRODUCT', 'TYPE'))
@@ -1606,6 +1609,12 @@
1606 @property1609 @property
1607 def driver_name(self):1610 def driver_name(self):
1608 """The name of the driver contolling this device. May be None."""1611 """The name of the driver contolling this device. May be None."""
1612 raise NotImplementedError
1613
1614 @property
1615 def scsi_controller(self):
1616 """Return the SCSI host controller for this device."""
1617 raise NotImplementedError
16091618
1610 def translateScsiBus(self):1619 def translateScsiBus(self):
1611 """Return the real bus of a device where raw_bus=='scsi'.1620 """Return the real bus of a device where raw_bus=='scsi'.
@@ -1615,37 +1624,27 @@
1615 for more details. This method determines the real bus1624 for more details. This method determines the real bus
1616 of a device accessed via the kernel's SCSI subsystem.1625 of a device accessed via the kernel's SCSI subsystem.
1617 """1626 """
1618 # While SCSI devices from valid submissions should have a1627 scsi_controller = self.scsi_controller
1619 # parent and a grandparent, we can't be sure for bogus or1628 if scsi_controller is None:
1620 # broken submissions.
1621 parent = self.parent
1622 if parent is None:
1623 self.parser._logWarning(
1624 'Found SCSI device without a parent: %s.' % self.device_id)
1625 return None
1626 grandparent = parent.parent
1627 if grandparent is None:
1628 self.parser._logWarning(
1629 'Found SCSI device without a grandparent: %s.'
1630 % self.device_id)
1631 return None1629 return None
16321630
1633 grandparent_bus = grandparent.raw_bus1631 scsi_controller_bus = scsi_controller.raw_bus
1634 if grandparent_bus == 'pci':1632 if scsi_controller_bus == 'pci':
1635 if (grandparent.pci_class != PCI_CLASS_STORAGE):1633 if (scsi_controller.pci_class != PCI_CLASS_STORAGE):
1636 # This is not a storage class PCI device? This1634 # This is not a storage class PCI device? This
1637 # indicates a bug somewhere in HAL or in the hwdb1635 # indicates a bug somewhere in HAL or in the hwdb
1638 # client, or a fake submission.1636 # client, or a fake submission.
1639 device_class = grandparent.pci_class1637 device_class = scsi_controller.pci_class
1640 self.parser._logWarning(1638 self.parser._logWarning(
1641 'A (possibly fake) SCSI device %s is connected to '1639 'A (possibly fake) SCSI device %s is connected to '
1642 'PCI device %s that has the PCI device class %s; '1640 'PCI device %s that has the PCI device class %s; '
1643 'expected class 1 (storage).'1641 'expected class 1 (storage).'
1644 % (self.device_id, grandparent.device_id, device_class))1642 % (self.device_id, scsi_controller.device_id,
1643 device_class))
1645 return None1644 return None
1646 pci_subclass = grandparent.pci_subclass1645 pci_subclass = scsi_controller.pci_subclass
1647 return self.pci_storage_subclass_hwbus.get(pci_subclass)1646 return self.pci_storage_subclass_hwbus.get(pci_subclass)
1648 elif grandparent_bus == 'usb':1647 elif scsi_controller_bus == 'usb':
1649 # USB storage devices have the following HAL device hierarchy:1648 # USB storage devices have the following HAL device hierarchy:
1650 # - HAL node for the USB device. info.bus == 'usb_device',1649 # - HAL node for the USB device. info.bus == 'usb_device',
1651 # device class == 0, device subclass == 01650 # device class == 0, device subclass == 0
@@ -2067,10 +2066,15 @@
2067 # it is hard to find a better heuristic to separate2066 # it is hard to find a better heuristic to separate
2068 # the vendor name from the product name.2067 # the vendor name from the product name.
2069 splitted_name = self.scsi_model.split(' ', 1)2068 splitted_name = self.scsi_model.split(' ', 1)
2070 if len(splitted_name) < 2:2069 if len(splitted_name) == 2:
2071 return 'ATA', splitted_name[0]2070 return {
2072 return splitted_name2071 'vendor': splitted_name[0],
2073 return (vendor, self.scsi_model)2072 'product': splitted_name[1],
2073 }
2074 return {
2075 'vendor': vendor,
2076 'product': self.scsi_model,
2077 }
20742078
2075 def getDriver(self):2079 def getDriver(self):
2076 """Return the HWDriver instance associated with this device.2080 """Return the HWDriver instance associated with this device.
@@ -2289,11 +2293,7 @@
2289 # below does not work properly.2293 # below does not work properly.
2290 return self.getProperty('system.hardware.' + type_)2294 return self.getProperty('system.hardware.' + type_)
2291 elif bus == 'scsi':2295 elif bus == 'scsi':
2292 vendor, product = self.getScsiVendorAndModelName()2296 return self.getScsiVendorAndModelName()[type_]
2293 if type_ == 'vendor':
2294 return vendor
2295 else:
2296 return product
2297 else:2297 else:
2298 result = self.getProperty('info.' + type_)2298 result = self.getProperty('info.' + type_)
2299 if result is None:2299 if result is None:
@@ -2354,11 +2354,32 @@
2354 """See `BaseDevice`."""2354 """See `BaseDevice`."""
2355 return self.getVendorOrProductID('product')2355 return self.getVendorOrProductID('product')
23562356
2357 @property
2358 def scsi_controller(self):
2359 """See `BaseDevice`."""
2360 # While SCSI devices from valid submissions should have a
2361 # parent and a grandparent, we can't be sure for bogus or
2362 # broken submissions.
2363 if self.raw_bus != 'scsi':
2364 return None
2365 parent = self.parent
2366 if parent is None:
2367 self.parser._logWarning(
2368 'Found SCSI device without a parent: %s.' % self.device_id)
2369 return None
2370 grandparent = parent.parent
2371 if grandparent is None:
2372 self.parser._logWarning(
2373 'Found SCSI device without a grandparent: %s.'
2374 % self.device_id)
2375 return None
2376 return grandparent
2377
23572378
2358class UdevDevice(BaseDevice):2379class UdevDevice(BaseDevice):
2359 """The representation of a udev device node."""2380 """The representation of a udev device node."""
23602381
2361 def __init__(self, udev_data, sysfs_data, parser):2382 def __init__(self, parser, udev_data, sysfs_data=None, dmi_data=None):
2362 """HALDevice constructor.2383 """HALDevice constructor.
23632384
2364 :param udevdata: The udev data for this device2385 :param udevdata: The udev data for this device
@@ -2369,6 +2390,7 @@
2369 super(UdevDevice, self).__init__(parser)2390 super(UdevDevice, self).__init__(parser)
2370 self.udev = udev_data2391 self.udev = udev_data
2371 self.sysfs = sysfs_data2392 self.sysfs = sysfs_data
2393 self.dmi = dmi_data
23722394
2373 @property2395 @property
2374 def device_id(self):2396 def device_id(self):
@@ -2376,6 +2398,14 @@
2376 return self.udev['P']2398 return self.udev['P']
23772399
2378 @property2400 @property
2401 def root_device_ids(self):
2402 """The vendor and product IDs of the root device."""
2403 return {
2404 'vendor': self.dmi.get('/sys/class/dmi/id/sys_vendor'),
2405 'product': self.dmi.get('/sys/class/dmi/id/product_name')
2406 }
2407
2408 @property
2379 def is_pci(self):2409 def is_pci(self):
2380 """True, if this is a PCI device, else False."""2410 """True, if this is a PCI device, else False."""
2381 return self.udev['E'].get('SUBSYSTEM') == 'pci'2411 return self.udev['E'].get('SUBSYSTEM') == 'pci'
@@ -2410,6 +2440,30 @@
2410 return self.pci_class_info[1]2440 return self.pci_class_info[1]
24112441
2412 @property2442 @property
2443 def pci_ids(self):
2444 """The PCI vendor and product IDs.
2445
2446 :return: A dictionary containing the vendor and product IDs.
2447 The IDs are set to None for Non-PCI devices.
2448 """
2449 if self.is_pci:
2450 # SubmissionParser.checkUdevPciProperties() ensures that
2451 # each PCI device has the property PCI_ID and that is
2452 # consists of two 4-digit hexadecimal numbers, separated
2453 # by a ':'.
2454 id_string = self.udev['E']['PCI_ID']
2455 ids = id_string.split(':')
2456 return {
2457 'vendor': int(ids[0], 16),
2458 'product': int(ids[1], 16),
2459 }
2460 else:
2461 return {
2462 'vendor': None,
2463 'product': None,
2464 }
2465
2466 @property
2413 def is_usb(self):2467 def is_usb(self):
2414 """True, if this is a USB device, else False."""2468 """True, if this is a USB device, else False."""
2415 return self.udev['E'].get('SUBSYSTEM') == 'usb'2469 return self.udev['E'].get('SUBSYSTEM') == 'usb'
@@ -2418,8 +2472,9 @@
2418 def usb_ids(self):2472 def usb_ids(self):
2419 """The vendor ID, product ID, product version for USB devices.2473 """The vendor ID, product ID, product version for USB devices.
24202474
2421 :return: [vendor_id, product_id, version] for USB devices2475 :return: A dictionary containing the vendor and product IDs and
2422 or [None, None, None] for other devices.2476 the product version for USB devices.
2477 The IDs are set to None for Non-USB devices.
2423 """2478 """
2424 if self.is_usb:2479 if self.is_usb:
2425 # udev represents USB device IDs as strings2480 # udev represents USB device IDs as strings
@@ -2428,19 +2483,27 @@
2428 # SubmissionParser.checkUdevUsbProperties() ensures that2483 # SubmissionParser.checkUdevUsbProperties() ensures that
2429 # the string PRODUCT is in the format required below.2484 # the string PRODUCT is in the format required below.
2430 product_info = self.udev['E']['PRODUCT'].split('/')2485 product_info = self.udev['E']['PRODUCT'].split('/')
2431 return [int(part, 16) for part in product_info]2486 return {
2487 'vendor': int(product_info[0], 16),
2488 'product': int(product_info[1], 16),
2489 'version': int(product_info[2], 16),
2490 }
2432 else:2491 else:
2433 return [None, None, None]2492 return {
2493 'vendor': None,
2494 'product': None,
2495 'version': None,
2496 }
24342497
2435 @property2498 @property
2436 def usb_vendor_id(self):2499 def usb_vendor_id(self):
2437 """See `BaseDevice`."""2500 """See `BaseDevice`."""
2438 return self.usb_ids[0]2501 return self.usb_ids['vendor']
24392502
2440 @property2503 @property
2441 def usb_product_id(self):2504 def usb_product_id(self):
2442 """See `BaseDevice`."""2505 """See `BaseDevice`."""
2443 return self.usb_ids[1]2506 return self.usb_ids['product']
24442507
2445 @property2508 @property
2446 def is_scsi_device(self):2509 def is_scsi_device(self):
@@ -2476,6 +2539,107 @@
2476 else:2539 else:
2477 return None2540 return None
24782541
2542 @property
2543 def raw_bus(self):
2544 """See `BaseDevice`."""
2545 # udev specifies the property SUBSYSTEM for most devices;
2546 # some devices have additionally the more specific property
2547 # DEVTYPE. DEVTYPE is preferable.
2548 # The root device has the subsystem/bus value "acpi", which
2549 # is a bit nonsensical.
2550 if self.device_id == UDEV_ROOT_PATH:
2551 return None
2552 properties = self.udev['E']
2553 devtype = properties.get('DEVTYPE')
2554 if devtype is not None:
2555 return devtype
2556 return properties.get('SUBSYSTEM')
2557
2558 def getVendorOrProduct(self, type_):
2559 """Return the vendor or product of this device.
2560
2561 :return: The vendor or product data for this device.
2562 :param type_: 'vendor' or 'product'
2563 """
2564 assert type_ in ('vendor', 'product'), (
2565 'Unexpected value of type_: %r' % type_)
2566
2567 bus = self.raw_bus
2568 if self.device_id == UDEV_ROOT_PATH:
2569 # udev does not known about any product information for
2570 # the root device. We use DMI data instead.
2571 return self.root_device_ids[type_]
2572 elif bus == 'scsi_device':
2573 return self.getScsiVendorAndModelName()[type_]
2574 elif bus in ('pci', 'usb_device'):
2575 # XXX Abel Deuring 2009-10-13, bug 450480: udev does not
2576 # provide human-readable vendor and product names for
2577 # USB and PCI devices. We should retrieve these from
2578 # http://www.linux-usb.org/usb.ids and
2579 # http://pciids.sourceforge.net/v2.2/pci.ids
2580 return 'Unknown'
2581 else:
2582 # We don't process yet other devices than complete systems,
2583 # PCI, USB devices and those devices that are represented
2584 # in udev as SCSI devices: real SCSI devices, and
2585 # IDE/ATA/SATA devices.
2586 return None
2587
2588 @property
2589 def vendor(self):
2590 """See `BaseDevice`."""
2591 return self.getVendorOrProduct('vendor')
2592
2593 @property
2594 def product(self):
2595 """See `BaseDevice`."""
2596 return self.getVendorOrProduct('product')
2597
2598 def getVendorOrProductID(self, type_):
2599 """Return the vendor or product ID of this device.
2600
2601 :return: The vendor or product ID for this device.
2602 :param type_: 'vendor' or 'product'
2603 """
2604 assert type_ in ('vendor', 'product'), (
2605 'Unexpected value of type_: %r' % type_)
2606
2607 bus = self.raw_bus
2608 if self.device_id == UDEV_ROOT_PATH:
2609 # udev does not known about any product information for
2610 # the root device. We use DMI data instead.
2611 if type_ == 'vendor':
2612 return self.dmi.get('/sys/class/dmi/id/sys_vendor')
2613 else:
2614 return self.dmi.get('/sys/class/dmi/id/product_name')
2615 elif bus == 'scsi_device':
2616 return self.getScsiVendorAndModelName()[type_]
2617 elif bus == 'pci':
2618 return self.pci_ids[type_]
2619 elif bus == 'usb_device':
2620 return self.usb_ids[type_]
2621 else:
2622 # We don't process yet other devices than complete systems,
2623 # PCI, USB devices and those devices that are represented
2624 # in udev as SCSI devices: real SCSI devices, and
2625 # IDE/ATA/SATA devices.
2626 return None
2627
2628 @property
2629 def vendor_id(self):
2630 """See `BaseDevice`."""
2631 return self.getVendorOrProductID('vendor')
2632
2633 @property
2634 def product_id(self):
2635 """See `BaseDevice`."""
2636 return self.getVendorOrProductID('product')
2637
2638 @property
2639 def driver_name(self):
2640 """See `BaseDevice`."""
2641 return self.udev['E'].get('DRIVER')
2642
24792643
2480class ProcessingLoop(object):2644class ProcessingLoop(object):
2481 """An `ITunableLoop` for processing HWDB submissions."""2645 """An `ITunableLoop` for processing HWDB submissions."""
24822646
=== modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py'
--- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-12 14:50:22 +0000
+++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-14 15:20:31 +0000
@@ -539,6 +539,214 @@
539 'HAL property info.bus.')539 'HAL property info.bus.')
540540
541541
542 def test_HALDevice_scsi_controller_usb_storage_device(self):
543 """test of HALDevice.scsi_controller.
544
545 The physical device is a USB storage device.
546 """
547 devices = [
548 # The main node of the USB storage device.
549 {
550 'id': 1,
551 'udi': self.UDI_USB_STORAGE,
552 'properties': {
553 'info.bus': ('usb_device', 'str'),
554 },
555 },
556 # The storage interface of the USB device.
557 {
558 'id': 2,
559 'udi': self.UDI_USB_STORAGE_IF0,
560 'properties': {
561 'info.bus': ('usb', 'str'),
562 'info.parent': (self.UDI_USB_STORAGE, 'str'),
563 },
564 },
565 # The fake SCSI host of the storage device. Note that HAL does
566 # _not_ provide the info.bus property.
567 {
568 'id': 3,
569 'udi': self.UDI_USB_STORAGE_SCSI_HOST,
570 'properties': {
571 'info.parent': (self.UDI_USB_STORAGE_IF0, 'str'),
572 },
573 },
574 # The fake SCSI disk.
575 {
576 'id': 3,
577 'udi': self.UDI_USB_STORAGE_SCSI_DEVICE,
578 'properties': {
579 'info.bus': ('scsi', 'str'),
580 'info.parent': (self.UDI_USB_STORAGE_SCSI_HOST, 'str'),
581 },
582 },
583 ]
584 parsed_data = {
585 'hardware': {
586 'hal': {
587 'devices': devices,
588 },
589 },
590 }
591
592 parser = SubmissionParser()
593 parser.buildDeviceList(parsed_data)
594
595 usb_fake_scsi_disk = parser.hal_devices[
596 self.UDI_USB_STORAGE_SCSI_DEVICE]
597 usb_main_device = parser.hal_devices[self.UDI_USB_STORAGE_IF0]
598 self.assertEqual(usb_main_device, usb_fake_scsi_disk.scsi_controller)
599
600 def test_HALDevice_scsi_controller_pci_controller(self):
601 """test of HALDevice.scsi_controller.
602
603 Variant for a SCSI device connected to a PCI controller.
604 """
605 devices = [
606 # The PCI host controller.
607 {
608 'id': 1,
609 'udi': self.UDI_SATA_CONTROLLER,
610 'properties': {
611 'info.bus': ('pci', 'str'),
612 'pci.device_class': (PCI_CLASS_STORAGE, 'int'),
613 'pci.device_subclass': (PCI_SUBCLASS_STORAGE_SATA,
614 'int'),
615 },
616 },
617 # The (fake or real) SCSI host of the storage device.
618 {
619 'id': 2,
620 'udi': self.UDI_SATA_CONTROLLER_SCSI,
621 'properties': {
622 'info.parent': (self.UDI_SATA_CONTROLLER, 'str'),
623 },
624 },
625 # The (possibly fake) SCSI disk.
626 {
627 'id': 3,
628 'udi': self.UDI_SATA_DISK,
629 'properties': {
630 'info.bus': ('scsi', 'str'),
631 'info.parent': (self.UDI_SATA_CONTROLLER_SCSI, 'str'),
632 },
633 },
634 ]
635 parsed_data = {
636 'hardware': {
637 'hal': {
638 'devices': devices,
639 },
640 },
641 }
642
643 parser = SubmissionParser()
644 parser.buildDeviceList(parsed_data)
645
646 scsi_device = parser.hal_devices[self.UDI_SATA_DISK]
647 controller = parser.hal_devices[self.UDI_SATA_CONTROLLER]
648 self.assertEqual(controller, scsi_device.scsi_controller)
649
650 def test_HALDevice_scsi_controller_non_scsi_device(self):
651 """test of HALDevice.scsi_controller.
652
653 Variant for non-SCSI devices.
654 """
655 devices = [
656 {
657 'id': 1,
658 'udi': self.UDI_COMPUTER,
659 'properties': {},
660 },
661 ]
662 parsed_data = {
663 'hardware': {
664 'hal': {
665 'devices': devices,
666 },
667 },
668 }
669
670 parser = SubmissionParser()
671 parser.buildDeviceList(parsed_data)
672
673 device = parser.hal_devices[self.UDI_COMPUTER]
674 self.assertEqual(None, device.scsi_controller)
675
676 def test_HALDevice_scsi_controller_no_grandparent(self):
677 """test of HALDevice.scsi_controller.
678
679 Variant for a SCSI device without a grandparent device.
680 """
681 devices = [
682 # The (fake or real) SCSI host of the storage device.
683 {
684 'id': 1,
685 'udi': self.UDI_SATA_CONTROLLER_SCSI,
686 'properties': {},
687 },
688 # The (possibly fake) SCSI disk.
689 {
690 'id': 2,
691 'udi': self.UDI_SATA_DISK,
692 'properties': {
693 'info.bus': ('scsi', 'str'),
694 'info.parent': (self.UDI_SATA_CONTROLLER_SCSI, 'str'),
695 },
696 },
697 ]
698 parsed_data = {
699 'hardware': {
700 'hal': {
701 'devices': devices,
702 },
703 },
704 }
705
706 parser = SubmissionParser(self.log)
707 parser.submission_key = 'SCSI device without grandparent device'
708 parser.buildDeviceList(parsed_data)
709
710 scsi_device = parser.hal_devices[self.UDI_SATA_DISK]
711 self.assertEqual(None, scsi_device.scsi_controller)
712 self.assertWarningMessage(
713 parser.submission_key,
714 "Found SCSI device without a grandparent: %s."
715 % self.UDI_SATA_DISK)
716
717 def test_HALDevice_scsi_controller_no_parent(self):
718 """test of HALDevice.scsi_controller.
719
720 Variant for a SCSI device without a parent device.
721 """
722 devices = [
723 # The (possibly fake) SCSI disk.
724 {
725 'id': 1,
726 'udi': self.UDI_SATA_DISK,
727 'properties': {
728 'info.bus': ('scsi', 'str'),
729 },
730 },
731 ]
732 parsed_data = {
733 'hardware': {
734 'hal': {
735 'devices': devices,
736 },
737 },
738 }
739
740 parser = SubmissionParser(self.log)
741 parser.submission_key = 'SCSI device without parent device'
742 parser.buildDeviceList(parsed_data)
743
744 scsi_device = parser.hal_devices[self.UDI_SATA_DISK]
745 self.assertEqual(None, scsi_device.scsi_controller)
746 self.assertWarningMessage(
747 parser.submission_key,
748 "Found SCSI device without a parent: %s." % self.UDI_SATA_DISK)
749
542 def testHALDeviceGetRealBus(self):750 def testHALDeviceGetRealBus(self):
543 """Test of HALDevice.real_bus, generic case.751 """Test of HALDevice.real_bus, generic case.
544752
@@ -1598,18 +1806,16 @@
1598 parser = SubmissionParser(self.log)1806 parser = SubmissionParser(self.log)
1599 parser.buildDeviceList(parsed_data)1807 parser.buildDeviceList(parsed_data)
1600 device = parser.hal_devices[self.UDI_SCSI_DISK]1808 device = parser.hal_devices[self.UDI_SCSI_DISK]
1601 vendor, model = device.getScsiVendorAndModelName()1809 vendor_model = device.getScsiVendorAndModelName()
1602 self.assertEqual(1810 self.assertEqual(
1603 vendor, 'SHARP',1811 {
1812 'vendor': 'SHARP',
1813 'product': 'JX250 SCSI',
1814 },
1815 vendor_model,
1604 'Unexpected result of HWDevice.getScsiVendorAndModelName '1816 'Unexpected result of HWDevice.getScsiVendorAndModelName '
1605 'for a regular SCSI device. Expected vendor name SHARP, got %r.'1817 'for a regular SCSI device. Expected vendor name SHARP, got %r.'
1606 % vendor)1818 % vendor_model)
1607 self.assertEqual(
1608 model, 'JX250 SCSI',
1609 'Unexpected result of HWDevice.getScsiVendorAndModelName '
1610 'for a regular SCSI device. Expected model name JX250 SCSI , '
1611 'got %r.'
1612 % model)
16131819
1614 def testHALDeviceSCSIVendorModelNameATADiskShortModelName(self):1820 def testHALDeviceSCSIVendorModelNameATADiskShortModelName(self):
1615 """Test of HALDevice.getScsiVendorAndModelName, ATA disk (1).1821 """Test of HALDevice.getScsiVendorAndModelName, ATA disk (1).
@@ -1639,18 +1845,16 @@
1639 parser = SubmissionParser(self.log)1845 parser = SubmissionParser(self.log)
1640 parser.buildDeviceList(parsed_data)1846 parser.buildDeviceList(parsed_data)
1641 device = parser.hal_devices[self.UDI_SCSI_DISK]1847 device = parser.hal_devices[self.UDI_SCSI_DISK]
1642 vendor, model = device.getScsiVendorAndModelName()1848 vendor_model = device.getScsiVendorAndModelName()
1643 self.assertEqual(1849 self.assertEqual(
1644 vendor, 'Hitachi',1850 {
1645 'Unexpected result of HWDevice.getScsiVendorAndModelName '1851 'vendor': 'Hitachi',
1646 'for an ATA SCSI device. Expected vendor name Hitachi, got %r.'1852 'product': 'HTS54161',
1647 % vendor)1853 },
1648 self.assertEqual(1854 vendor_model,
1649 model, 'HTS54161',1855 'Unexpected result of HWDevice.getScsiVendorAndModelName '
1650 'Unexpected result of HWDevice.getScsiVendorAndModelName '1856 'for an ATA SCSI device: %r.'
1651 'for a reguale SCSI device. Expected vendor name HTS54161, '1857 % vendor_model)
1652 'got %r.'
1653 % model)
16541858
1655 def testHALDeviceSCSIVendorModelNameATADiskLongModelName(self):1859 def testHALDeviceSCSIVendorModelNameATADiskLongModelName(self):
1656 """Test of HALDevice.getScsiVendorAndModelName, ATA disk (2).1860 """Test of HALDevice.getScsiVendorAndModelName, ATA disk (2).
@@ -1679,18 +1883,16 @@
1679 parser = SubmissionParser(self.log)1883 parser = SubmissionParser(self.log)
1680 parser.buildDeviceList(parsed_data)1884 parser.buildDeviceList(parsed_data)
1681 device = parser.hal_devices[self.UDI_SCSI_DISK]1885 device = parser.hal_devices[self.UDI_SCSI_DISK]
1682 vendor, model = device.getScsiVendorAndModelName()1886 vendor_product = device.getScsiVendorAndModelName()
1683 self.assertEqual(1887 self.assertEqual(
1684 vendor, 'ATA',1888 {
1685 'Unexpected result of HWDevice.getScsiVendorAndModelName '1889 'vendor': 'ATA',
1686 'for a reguale SCSI device. Expected vendor name ATA, got %r.'1890 'product': 'HTC426060G9AT00',
1687 % vendor)1891 },
1688 self.assertEqual(1892 vendor_product,
1689 model, 'HTC426060G9AT00',1893 'Unexpected result of HWDevice.getScsiVendorAndModelName '
1690 'Unexpected result of HWDevice.getScsiVendorAndModelName '1894 'for a reguale SCSI device: %r.'
1691 'for a reguale SCSI device. Expected vendor name '1895 % vendor_product)
1692 'HTC426060G9AT00 , got %r.'
1693 % model)
16941896
1695 def testHALDeviceVendorFromInfoVendor(self):1897 def testHALDeviceVendorFromInfoVendor(self):
1696 """Test of HALDevice.vendor, regular case.1898 """Test of HALDevice.vendor, regular case.
@@ -2606,6 +2808,11 @@
2606 }2808 }
2607 }2809 }
26082810
2811 root_device_dmi_data = {
2812 '/sys/class/dmi/id/sys_vendor': 'FUJITSU SIEMENS',
2813 '/sys/class/dmi/id/product_name': 'LIFEBOOK E8210',
2814 }
2815
2609 pci_device_data = {2816 pci_device_data = {
2610 'P': '/devices/pci0000:00/0000:00:1f.2',2817 'P': '/devices/pci0000:00/0000:00:1f.2',
2611 'E': {2818 'E': {
@@ -2614,6 +2821,7 @@
2614 'PCI_SUBSYS_ID': '10CF:1387',2821 'PCI_SUBSYS_ID': '10CF:1387',
2615 'PCI_SLOT_NAME': '0000:00:1f.2',2822 'PCI_SLOT_NAME': '0000:00:1f.2',
2616 'SUBSYSTEM': 'pci',2823 'SUBSYSTEM': 'pci',
2824 'DRIVER': 'ahci',
2617 }2825 }
2618 }2826 }
26192827
@@ -2624,114 +2832,168 @@
2624 'DEVTYPE': 'usb_device',2832 'DEVTYPE': 'usb_device',
2625 'PRODUCT': '46d/a01/1013',2833 'PRODUCT': '46d/a01/1013',
2626 'TYPE': '0/0/0',2834 'TYPE': '0/0/0',
2835 'DRIVER': 'usb',
2627 },2836 },
2628 }2837 }
26292838
2630 scsi_device_data = {2839 scsi_scanner_device_data = {
2631 'P': '/devices/pci0000:00/0000:00:1f.1/host4/target4:0:0/4:0:0:0',2840 'P': ('/devices/pci0000:00/0000:00:1e.0/0000:08:03.0/0000:09:00.0/'
2841 'host6/target6:0:1/6:0:1:0'),
2632 'E': {2842 'E': {
2843 'DEVTYPE': 'scsi_device',
2633 'SUBSYSTEM': 'scsi',2844 'SUBSYSTEM': 'scsi',
2634 'DEVTYPE': 'scsi_device',
2635 },2845 },
2636 }2846 }
26372847
2638 scsi_device_sysfs_data = {2848 scsi_scanner_device_sysfs_data = {
2639 'vendor': 'MATSHITA',2849 'vendor': 'FUJITSU',
2640 'model': 'DVD-RAM UJ-841S',2850 'model': 'fi-5120Cdj',
2641 'type': '5',2851 'type': '6',
2852 }
2853
2854 no_subsystem_device_data = {
2855 'P': '/devices/pnp0/00:00',
2856 'E': {}
2642 }2857 }
26432858
2644 def test_device_id(self):2859 def test_device_id(self):
2645 """Test of UdevDevice.device_id."""2860 """Test of UdevDevice.device_id."""
2646 device = UdevDevice(self.pci_device_data, None, None)2861 device = UdevDevice(None, self.pci_device_data)
2647 self.assertEqual(2862 self.assertEqual(
2648 '/devices/pci0000:00/0000:00:1f.2', device.device_id,2863 '/devices/pci0000:00/0000:00:1f.2', device.device_id,
2649 'Unexpected value of UdevDevice.device_id.')2864 'Unexpected value of UdevDevice.device_id.')
26502865
2866 def test_root_device_ids(self):
2867 device = UdevDevice(
2868 None, self.root_device, None, self.root_device_dmi_data)
2869 self.assertEqual(
2870 {
2871 'vendor': 'FUJITSU SIEMENS',
2872 'product': 'LIFEBOOK E8210',
2873 },
2874 device.root_device_ids)
2875
2876 device = UdevDevice(
2877 None, self.root_device, None, {})
2878 self.assertEqual(
2879 {
2880 'vendor': None,
2881 'product': None,
2882 },
2883 device.root_device_ids)
2884
2651 def test_is_pci(self):2885 def test_is_pci(self):
2652 """Test of UdevDevice.is_pci."""2886 """Test of UdevDevice.is_pci."""
2653 device = UdevDevice(self.pci_device_data, None, None)2887 device = UdevDevice(None, self.pci_device_data)
2654 self.assertTrue(device.is_pci)2888 self.assertTrue(device.is_pci)
26552889
2656 device = UdevDevice(self.root_device, None, None)2890 device = UdevDevice(None, self.root_device)
2657 self.assertFalse(device.is_pci)2891 self.assertFalse(device.is_pci)
26582892
2659 def test_pci_class_info(self):2893 def test_pci_class_info(self):
2660 """Test of UdevDevice.pci_class_info"""2894 """Test of UdevDevice.pci_class_info"""
2661 device = UdevDevice(self.pci_device_data, None, None)2895 device = UdevDevice(None, self.pci_device_data)
2662 self.assertEqual(2896 self.assertEqual(
2663 (1, 6, 2), device.pci_class_info,2897 (1, 6, 2), device.pci_class_info,
2664 'Invalid value of UdevDevice.pci_class_info for PCI device.')2898 'Invalid value of UdevDevice.pci_class_info for PCI device.')
26652899
2666 device = UdevDevice(self.root_device, None, None)2900 device = UdevDevice(None, self.root_device)
2667 self.assertEqual(2901 self.assertEqual(
2668 (None, None, None), device.pci_class_info,2902 (None, None, None), device.pci_class_info,
2669 'Invalid value of UdevDevice.pci_class_info for Non-PCI device.')2903 'Invalid value of UdevDevice.pci_class_info for Non-PCI device.')
26702904
2671 def test_pci_class(self):2905 def test_pci_class(self):
2672 """Test of UdevDevice.pci_class"""2906 """Test of UdevDevice.pci_class"""
2673 device = UdevDevice(self.pci_device_data, None, None)2907 device = UdevDevice(None, self.pci_device_data)
2674 self.assertEqual(2908 self.assertEqual(
2675 1, device.pci_class,2909 1, device.pci_class,
2676 'Invalid value of UdevDevice.pci_class for PCI device.')2910 'Invalid value of UdevDevice.pci_class for PCI device.')
26772911
2678 device = UdevDevice(self.root_device, None, None)2912 device = UdevDevice(None, self.root_device)
2679 self.assertEqual(2913 self.assertEqual(
2680 None, device.pci_class,2914 None, device.pci_class,
2681 'Invalid value of UdevDevice.pci_class for Non-PCI device.')2915 'Invalid value of UdevDevice.pci_class for Non-PCI device.')
26822916
2683 def test_pci_subclass(self):2917 def test_pci_subclass(self):
2684 """Test of UdevDevice.pci_subclass"""2918 """Test of UdevDevice.pci_subclass"""
2685 device = UdevDevice(self.pci_device_data, None, None)2919 device = UdevDevice(None, self.pci_device_data)
2686 self.assertEqual(2920 self.assertEqual(
2687 6, device.pci_subclass,2921 6, device.pci_subclass,
2688 'Invalid value of UdevDevice.pci_class for PCI device.')2922 'Invalid value of UdevDevice.pci_class for PCI device.')
26892923
2690 device = UdevDevice(self.root_device, None, None)2924 device = UdevDevice(None, self.root_device)
2691 self.assertEqual(2925 self.assertEqual(
2692 None, device.pci_class,2926 None, device.pci_class,
2693 'Invalid value of UdevDevice.pci_class for Non-PCI device.')2927 'Invalid value of UdevDevice.pci_class for Non-PCI device.')
26942928
2929 def test_pci_ids(self):
2930 """Test of UdevDevice.pci_ids"""
2931 device = UdevDevice(None, self.pci_device_data)
2932 self.assertEqual(
2933 {'vendor': 0x8086,
2934 'product': 0x27C5,
2935 },
2936 device.pci_ids,
2937 'Invalid value of UdevDevice.pci_ids for PCI device.')
2938
2939 device = UdevDevice(None, self.usb_device_data)
2940 self.assertEqual(
2941 {'vendor': None,
2942 'product': None,
2943 },
2944 device.pci_ids,
2945 'Invalid value of UdevDevice.pci_ids for Non-PCI device.')
2946
2695 def test_is_usb(self):2947 def test_is_usb(self):
2696 """Test of UdevDevice.is_usb"""2948 """Test of UdevDevice.is_usb"""
2697 device = UdevDevice(self.usb_device_data, None, None)2949 device = UdevDevice(None, self.usb_device_data)
2698 self.assertTrue(device.is_usb)2950 self.assertTrue(device.is_usb)
26992951
2700 device = UdevDevice(self.pci_device_data, None, None)2952 device = UdevDevice(None, self.pci_device_data)
2701 self.assertFalse(device.is_usb)2953 self.assertFalse(device.is_usb)
27022954
2703 def test_usb_ids(self):2955 def test_usb_ids(self):
2704 """Test of UdevDevice.usb_ids"""2956 """Test of UdevDevice.usb_ids"""
2705 device = UdevDevice(self.usb_device_data, None, None)2957 device = UdevDevice(None, self.usb_device_data)
2706 self.assertEqual(2958 self.assertEqual(
2707 [0x46d, 0xa01, 0x1013], device.usb_ids,2959 {
2960 'vendor': 0x46d,
2961 'product': 0xa01,
2962 'version': 0x1013,
2963 },
2964 device.usb_ids,
2708 'Invalid value of UdevDevice.usb_ids for USB device.')2965 'Invalid value of UdevDevice.usb_ids for USB device.')
27092966
2710 device = UdevDevice(self.root_device, None, None)2967 device = UdevDevice(None, self.root_device)
2711 self.assertEqual(2968 self.assertEqual(
2712 [None, None, None], device.usb_ids,2969 {
2970 'vendor': None,
2971 'product': None,
2972 'version': None,
2973 },
2974 device.usb_ids,
2713 'Invalid value of UdevDevice.usb_ids for Non-USB device.')2975 'Invalid value of UdevDevice.usb_ids for Non-USB device.')
27142976
2715 def test_usb_vendor_id(self):2977 def test_usb_vendor_id(self):
2716 """Test of UdevDevice.usb_vendor_id"""2978 """Test of UdevDevice.usb_vendor_id"""
2717 device = UdevDevice(self.usb_device_data, None, None)2979 device = UdevDevice(None, self.usb_device_data)
2718 self.assertEqual(2980 self.assertEqual(
2719 0x46d, device.usb_vendor_id,2981 0x46d, device.usb_vendor_id,
2720 'Invalid value of UdevDevice.usb_vendor_id for USB device.')2982 'Invalid value of UdevDevice.usb_vendor_id for USB device.')
27212983
2722 device = UdevDevice(self.root_device, None, None)2984 device = UdevDevice(None, self.root_device)
2723 self.assertEqual(2985 self.assertEqual(
2724 None, device.usb_vendor_id,2986 None, device.usb_vendor_id,
2725 'Invalid value of UdevDevice.usb_vendor_id for Non-USB device.')2987 'Invalid value of UdevDevice.usb_vendor_id for Non-USB device.')
27262988
2727 def test_usb_product_id(self):2989 def test_usb_product_id(self):
2728 """Test of UdevDevice.usb_product_id"""2990 """Test of UdevDevice.usb_product_id"""
2729 device = UdevDevice(self.usb_device_data, None, None)2991 device = UdevDevice(None, self.usb_device_data)
2730 self.assertEqual(2992 self.assertEqual(
2731 0xa01, device.usb_product_id,2993 0xa01, device.usb_product_id,
2732 'Invalid value of UdevDevice.usb_product_id for USB device.')2994 'Invalid value of UdevDevice.usb_product_id for USB device.')
27332995
2734 device = UdevDevice(self.root_device, None, None)2996 device = UdevDevice(None, self.root_device)
2735 self.assertEqual(2997 self.assertEqual(
2736 None, device.usb_product_id,2998 None, device.usb_product_id,
2737 'Invalid value of UdevDevice.usb_product_id for Non-USB device.')2999 'Invalid value of UdevDevice.usb_product_id for Non-USB device.')
@@ -2739,29 +3001,173 @@
2739 def test_is_scsi_device(self):3001 def test_is_scsi_device(self):
2740 """Test of UdevDevice.is_scsi_device."""3002 """Test of UdevDevice.is_scsi_device."""
2741 device = UdevDevice(3003 device = UdevDevice(
2742 self.scsi_device_data, self.scsi_device_sysfs_data, None)3004 None, self.scsi_scanner_device_data,
3005 self.scsi_scanner_device_sysfs_data)
2743 self.assertTrue(device.is_scsi_device)3006 self.assertTrue(device.is_scsi_device)
27443007
2745 device = UdevDevice(self.root_device, None, None)3008 device = UdevDevice(None, self.root_device)
2746 self.assertFalse(device.is_scsi_device)3009 self.assertFalse(device.is_scsi_device)
27473010
2748 def test_scsi_vendor(self):3011 def test_scsi_vendor(self):
2749 """Test of UdevDevice.scsi_vendor."""3012 """Test of UdevDevice.scsi_vendor."""
2750 device = UdevDevice(3013 device = UdevDevice(
2751 self.scsi_device_data, self.scsi_device_sysfs_data, None)3014 None, self.scsi_scanner_device_data,
2752 self.assertEqual('MATSHITA', device.scsi_vendor)3015 self.scsi_scanner_device_sysfs_data)
2753 device = UdevDevice(self.root_device, None, None)3016 self.assertEqual('FUJITSU', device.scsi_vendor)
3017 device = UdevDevice(None, self.root_device)
2754 self.assertEqual(None, device.scsi_vendor)3018 self.assertEqual(None, device.scsi_vendor)
27553019
2756 def test_scsi_model(self):3020 def test_scsi_model(self):
2757 """Test of UdevDevice.scsi_model."""3021 """Test of UdevDevice.scsi_model."""
2758 device = UdevDevice(3022 device = UdevDevice(
2759 self.scsi_device_data, self.scsi_device_sysfs_data, None)3023 None, self.scsi_scanner_device_data,
2760 self.assertEqual('DVD-RAM UJ-841S', device.scsi_model)3024 self.scsi_scanner_device_sysfs_data)
3025 self.assertEqual('fi-5120Cdj', device.scsi_model)
27613026
2762 device = UdevDevice(self.root_device, None, None)3027 device = UdevDevice(None, self.root_device)
2763 self.assertEqual(None, device.scsi_model)3028 self.assertEqual(None, device.scsi_model)
27643029
3030 def test_raw_bus(self):
3031 """Test of UdevDevice.raw_bus."""
3032 device = UdevDevice(None, self.root_device)
3033 self.assertEqual(None, device.raw_bus)
3034
3035 device = UdevDevice(None, self.pci_device_data)
3036 self.assertEqual('pci', device.raw_bus)
3037
3038 device = UdevDevice(None, self.usb_device_data)
3039 self.assertEqual('usb_device', device.raw_bus)
3040
3041 device = UdevDevice(None, self.no_subsystem_device_data)
3042 self.assertEqual(None, device.raw_bus)
3043
3044 def test_getVendorOrProduct(self):
3045 """Test of UdevDevice.getVendorOrProduct()."""
3046 device = UdevDevice(
3047 None, self.root_device, None, self.root_device_dmi_data)
3048 self.assertEqual(
3049 'FUJITSU SIEMENS', device.getVendorOrProduct('vendor'))
3050 self.assertEqual(
3051 'LIFEBOOK E8210', device.getVendorOrProduct('product'))
3052 self.assertRaises(
3053 AssertionError, device.getVendorOrProduct, 'nonsense')
3054
3055 device = UdevDevice(None, self.pci_device_data)
3056 self.assertEqual('Unknown', device.getVendorOrProduct('vendor'))
3057 self.assertEqual('Unknown', device.getVendorOrProduct('product'))
3058
3059 device = UdevDevice(None, self.usb_device_data)
3060 self.assertEqual('Unknown', device.getVendorOrProduct('vendor'))
3061 self.assertEqual('Unknown', device.getVendorOrProduct('product'))
3062
3063 device = UdevDevice(
3064 None, self.scsi_scanner_device_data,
3065 self.scsi_scanner_device_sysfs_data)
3066 self.assertEqual('FUJITSU', device.getVendorOrProduct('vendor'))
3067 self.assertEqual('fi-5120Cdj', device.getVendorOrProduct('product'))
3068
3069 device = UdevDevice(None, self.no_subsystem_device_data)
3070 self.assertEqual(None, device.getVendorOrProduct('vendor'))
3071 self.assertEqual(None, device.getVendorOrProduct('product'))
3072
3073 def test_vendor(self):
3074 """Test of UdevDevice.vendor."""
3075 device = UdevDevice(
3076 None, self.root_device, None, self.root_device_dmi_data)
3077 self.assertEqual('FUJITSU SIEMENS', device.vendor)
3078
3079 def test_product(self):
3080 """Test of UdevDevice.product."""
3081 device = UdevDevice(
3082 None, self.root_device, None, self.root_device_dmi_data)
3083 self.assertEqual('LIFEBOOK E8210', device.product)
3084
3085 def test_getVendorOrProductID(self):
3086 """Test of UdevDevice.getVendorOrProduct()."""
3087 device = UdevDevice(
3088 None, self.root_device, None, self.root_device_dmi_data)
3089 self.assertEqual(
3090 'FUJITSU SIEMENS', device.getVendorOrProductID('vendor'))
3091 self.assertEqual(
3092 'LIFEBOOK E8210', device.getVendorOrProductID('product'))
3093 self.assertRaises(
3094 AssertionError, device.getVendorOrProductID, 'nonsense')
3095
3096 device = UdevDevice(None, self.pci_device_data)
3097 self.assertEqual(0x8086, device.getVendorOrProductID('vendor'))
3098 self.assertEqual(0x27C5, device.getVendorOrProductID('product'))
3099
3100 device = UdevDevice(None, self.usb_device_data)
3101 self.assertEqual(0x46d, device.getVendorOrProductID('vendor'))
3102 self.assertEqual(0xa01, device.getVendorOrProductID('product'))
3103
3104 device = UdevDevice(
3105 None, self.scsi_scanner_device_data,
3106 self.scsi_scanner_device_sysfs_data)
3107 self.assertEqual('FUJITSU', device.getVendorOrProductID('vendor'))
3108 self.assertEqual('fi-5120Cdj', device.getVendorOrProductID('product'))
3109
3110 device = UdevDevice(
3111 None, self.no_subsystem_device_data)
3112 self.assertEqual(None, device.getVendorOrProductID('vendor'))
3113 self.assertEqual(None, device.getVendorOrProductID('product'))
3114
3115 def test_vendor_id(self):
3116 """Test of UdevDevice.vendor_id."""
3117 device = UdevDevice(
3118 None, self.root_device, None, self.root_device_dmi_data)
3119 self.assertEqual('FUJITSU SIEMENS', device.vendor_id)
3120
3121 def test_product_id(self):
3122 """Test of UdevDevice.product_id."""
3123 device = UdevDevice(
3124 None, self.root_device, None, self.root_device_dmi_data)
3125 self.assertEqual('LIFEBOOK E8210', device.product_id)
3126
3127 def test_vendor_id_for_db(self):
3128 """Test of UdevDevice.vendor_id_for_db."""
3129 device = UdevDevice(
3130 None, self.root_device, None, self.root_device_dmi_data)
3131 self.assertEqual('FUJITSU SIEMENS', device.vendor_id_for_db)
3132
3133 device = UdevDevice(None, self.pci_device_data)
3134 self.assertEqual('0x8086', device.vendor_id_for_db)
3135
3136 device = UdevDevice(None, self.usb_device_data)
3137 self.assertEqual('0x046d', device.vendor_id_for_db)
3138
3139 device = UdevDevice(
3140 None, self.scsi_scanner_device_data,
3141 self.scsi_scanner_device_sysfs_data)
3142 self.assertEqual('FUJITSU ', device.vendor_id_for_db)
3143
3144 def test_product_id_for_db(self):
3145 """Test of UdevDevice.product_id_for_db."""
3146 device = UdevDevice(
3147 None, self.root_device, None, self.root_device_dmi_data)
3148 self.assertEqual('LIFEBOOK E8210', device.product_id_for_db)
3149
3150 device = UdevDevice(None, self.pci_device_data)
3151 self.assertEqual('0x27c5', device.product_id_for_db)
3152
3153 device = UdevDevice(None, self.usb_device_data)
3154 self.assertEqual('0x0a01', device.product_id_for_db)
3155
3156 device = UdevDevice(
3157 None, self.scsi_scanner_device_data,
3158 self.scsi_scanner_device_sysfs_data)
3159 self.assertEqual('fi-5120Cdj ', device.product_id_for_db)
3160
3161 def test_driver_name(self):
3162 """Test of UdevDevice.driver_name."""
3163 device = UdevDevice(None, self.pci_device_data)
3164 self.assertEqual('ahci', device.driver_name)
3165
3166 device = UdevDevice(
3167 None, self.root_device, None, self.root_device_dmi_data)
3168 self.assertEqual(None, device.driver_name)
3169
3170
2765class TestHWDBSubmissionTablePopulation(TestCaseHWDB):3171class TestHWDBSubmissionTablePopulation(TestCaseHWDB):
2766 """Tests of the HWDB popoluation with submitted data."""3172 """Tests of the HWDB popoluation with submitted data."""
27673173

Subscribers

People subscribed via source and target branches

to status/vote changes: