提交 9f506fdb 编写于 作者: A Andrea Bolognani

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.
上级 18f231e6
...@@ -181,8 +181,8 @@ testVirHostdevPreparePCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED) ...@@ -181,8 +181,8 @@ testVirHostdevPreparePCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED)
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid, if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
hostdevs, nhostdevs, 0) < 0) hostdevs, nhostdevs, 0) < 0)
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + 3); CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + nhostdevs);
CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2 - 3); CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2 - nhostdevs);
/* Test conflict */ /* Test conflict */
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs); count1 = virPCIDeviceListCount(mgr->activePCIHostdevs);
...@@ -239,8 +239,8 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED) ...@@ -239,8 +239,8 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED)
VIR_DEBUG("Test >=1 unmanaged hostdevs"); VIR_DEBUG("Test >=1 unmanaged hostdevs");
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
hostdevs, nhostdevs, NULL); hostdevs, nhostdevs, NULL);
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 - 3); CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 - nhostdevs);
CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2 + 3); CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2 + nhostdevs);
ret = 0; ret = 0;
...@@ -266,7 +266,7 @@ testVirHostdevPreparePCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED) ...@@ -266,7 +266,7 @@ testVirHostdevPreparePCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED)
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid, if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
hostdevs, nhostdevs, 0) < 0) hostdevs, nhostdevs, 0) < 0)
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + 3); CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + nhostdevs);
/* Test conflict */ /* Test conflict */
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs); count1 = virPCIDeviceListCount(mgr->activePCIHostdevs);
...@@ -318,7 +318,7 @@ testVirHostdevReAttachPCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED) ...@@ -318,7 +318,7 @@ testVirHostdevReAttachPCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED)
VIR_DEBUG("Test >=1 hostdevs"); VIR_DEBUG("Test >=1 hostdevs");
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
hostdevs, nhostdevs, NULL); hostdevs, nhostdevs, NULL);
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 - 3); CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 - nhostdevs);
ret = 0; ret = 0;
...@@ -403,7 +403,7 @@ testVirHostdevUpdateActivePCIHostdevs(const void *opaque ATTRIBUTE_UNUSED) ...@@ -403,7 +403,7 @@ testVirHostdevUpdateActivePCIHostdevs(const void *opaque ATTRIBUTE_UNUSED)
if (virHostdevUpdateActivePCIDevices(mgr, hostdevs, nhostdevs, if (virHostdevUpdateActivePCIDevices(mgr, hostdevs, nhostdevs,
drv_name, dom_name) < 0) drv_name, dom_name) < 0)
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + 3); CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1 + nhostdevs);
ret = 0; ret = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册