Skip to content

Commit

Permalink
tests: Add NVMe controller type checks
Browse files Browse the repository at this point in the history
This one was missing in the tests. Also, reorder the checks
so that it matches order of the struct elements.
  • Loading branch information
tbzatek committed Mar 12, 2024
1 parent 252e33d commit 3bd52ac
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions tests/nvme_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ def test_ctrl_info(self):

info = BlockDev.nvme_get_controller_info(self.nvme_dev)
self.assertEqual(info.ctrl_id, 1)

self.assertEqual(info.pci_vendor_id, 0)
self.assertEqual(info.pci_subsys_vendor_id, 0)
self.assertIsNone(info.fguid)
self.assertIn("Linux", info.model_number)
self.assertGreater(len(info.serial_number), 0)
self.assertGreater(len(info.firmware_ver), 0)
self.assertGreater(len(info.nvme_ver), 0)
self.assertTrue (info.features & BlockDev.NVMEControllerFeature.MULTIPORT)
self.assertTrue (info.features & BlockDev.NVMEControllerFeature.MULTICTRL)
self.assertFalse(info.features & BlockDev.NVMEControllerFeature.SRIOV)
Expand All @@ -128,19 +134,13 @@ def test_ctrl_info(self):
self.assertFalse(info.features & BlockDev.NVMEControllerFeature.ENCLOSURE)
self.assertFalse(info.features & BlockDev.NVMEControllerFeature.MGMT_PCIE)
self.assertFalse(info.features & BlockDev.NVMEControllerFeature.MGMT_SMBUS)
self.assertIsNone(info.fguid)
self.assertEqual(info.pci_vendor_id, 0)
self.assertEqual(info.pci_subsys_vendor_id, 0)
self.assertIn("Linux", info.model_number)
self.assertGreater(len(info.serial_number), 0)
self.assertGreater(len(info.firmware_ver), 0)
self.assertGreater(len(info.nvme_ver), 0)
self.assertEqual(info.hmb_min_size, 0)
self.assertEqual(info.hmb_pref_size, 0)
self.assertEqual(info.num_namespaces, 1024)
self.assertEqual(info.controller_type, BlockDev.NVMEControllerType.IO)
self.assertEqual(info.selftest_ext_time, 0)
self.assertEqual(info.hmb_pref_size, 0)
self.assertEqual(info.hmb_min_size, 0)
self.assertEqual(info.size_total, 0)
self.assertEqual(info.size_unalloc, 0)
self.assertEqual(info.num_namespaces, 1024)
self.assertEqual(info.subsysnqn, "libblockdev_subnqn")

@tag_test(TestTags.CORE)
Expand Down Expand Up @@ -631,7 +631,13 @@ def test_persistent_dc(self):
# issue an IDENTIFY_CTRL command
info = BlockDev.nvme_get_controller_info(ctrls[0])
self.assertEqual(info.ctrl_id, 1)

self.assertEqual(info.pci_vendor_id, 0)
self.assertEqual(info.pci_subsys_vendor_id, 0)
self.assertIsNone(info.fguid)
self.assertIn("Linux", info.model_number)
self.assertGreater(len(info.serial_number), 0)
self.assertGreater(len(info.firmware_ver), 0)
self.assertGreater(len(info.nvme_ver), 0)
self.assertFalse(info.features & BlockDev.NVMEControllerFeature.MULTIPORT)
self.assertFalse(info.features & BlockDev.NVMEControllerFeature.MULTICTRL)
self.assertFalse(info.features & BlockDev.NVMEControllerFeature.SRIOV)
Expand All @@ -650,19 +656,13 @@ def test_persistent_dc(self):
self.assertFalse(info.features & BlockDev.NVMEControllerFeature.ENCLOSURE)
self.assertFalse(info.features & BlockDev.NVMEControllerFeature.MGMT_PCIE)
self.assertFalse(info.features & BlockDev.NVMEControllerFeature.MGMT_SMBUS)
self.assertIsNone(info.fguid)
self.assertEqual(info.pci_vendor_id, 0)
self.assertEqual(info.pci_subsys_vendor_id, 0)
self.assertIn("Linux", info.model_number)
self.assertGreater(len(info.serial_number), 0)
self.assertGreater(len(info.firmware_ver), 0)
self.assertGreater(len(info.nvme_ver), 0)
self.assertEqual(info.hmb_min_size, 0)
self.assertEqual(info.hmb_pref_size, 0)
self.assertEqual(info.num_namespaces, 0)
self.assertEqual(info.controller_type, BlockDev.NVMEControllerType.DISCOVERY)
self.assertEqual(info.selftest_ext_time, 0)
self.assertEqual(info.hmb_pref_size, 0)
self.assertEqual(info.hmb_min_size, 0)
self.assertEqual(info.size_total, 0)
self.assertEqual(info.size_unalloc, 0)
self.assertEqual(info.num_namespaces, 0)
self.assertEqual(info.subsysnqn, self.DISCOVERY_NQN)

# disconnect
Expand Down

0 comments on commit 3bd52ac

Please sign in to comment.