summaryrefslogtreecommitdiff
path: root/tests/virhostdevtest.c
diff options
context:
space:
mode:
authorAndrea Bolognani <abologna@redhat.com>2016-03-02 13:17:08 +0100
committerAndrea Bolognani <abologna@redhat.com>2016-03-08 10:16:43 +0100
commit9f506fdb6be8a2d7b6b52b28eb65bfac7e040eb1 (patch)
tree21f7cef07329c4573539a62c8798ce0d4f919432 /tests/virhostdevtest.c
parent18f231e6ff953c014f4ef0a75da7bf20c4f35de9 (diff)
downloadlibvirt-9f506fdb6be8a2d7b6b52b28eb65bfac7e040eb1.tar.gz
tests: hostdev: Remove magic numbers
When checking the number of devices added to a device list, use the nhostdevs variable instead of its value, so that the test can keep working even if more hostdevs are added.
Diffstat (limited to 'tests/virhostdevtest.c')
-rw-r--r--tests/virhostdevtest.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c
index cadb66abc6..fa6a4fbbba 100644
--- a/tests/virhostdevtest.c
+++ b/tests/virhostdevtest.c
@@ -181,8 +181,8 @@ testVirHostdevPreparePCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED)
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
hostdevs, nhostdevs, 0) < 0)
goto cleanup;
- CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + 3);
- CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2 - 3);
+ CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + nhostdevs);
+ CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2 - nhostdevs);
/* Test conflict */
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs);
@@ -239,8 +239,8 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED)
VIR_DEBUG("Test >=1 unmanaged hostdevs");
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
hostdevs, nhostdevs, NULL);
- CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 - 3);
- CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2 + 3);
+ CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 - nhostdevs);
+ CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2 + nhostdevs);
ret = 0;
@@ -266,7 +266,7 @@ testVirHostdevPreparePCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED)
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
hostdevs, nhostdevs, 0) < 0)
goto cleanup;
- CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + 3);
+ CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + nhostdevs);
/* Test conflict */
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs);
@@ -318,7 +318,7 @@ testVirHostdevReAttachPCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED)
VIR_DEBUG("Test >=1 hostdevs");
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
hostdevs, nhostdevs, NULL);
- CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 - 3);
+ CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 - nhostdevs);
ret = 0;
@@ -403,7 +403,7 @@ testVirHostdevUpdateActivePCIHostdevs(const void *opaque ATTRIBUTE_UNUSED)
if (virHostdevUpdateActivePCIDevices(mgr, hostdevs, nhostdevs,
drv_name, dom_name) < 0)
goto cleanup;
- CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + 3);
+ CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + nhostdevs);
ret = 0;