提交 dd9f8e02 编写于 作者: A Andrea Bolognani

tests: hostdev: Use better variable names

Change the extremely generic count1 and count2 to the more
descriptive active_count and inactive_count.
上级 9f506fdb
...@@ -161,52 +161,52 @@ testVirHostdevPreparePCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED) ...@@ -161,52 +161,52 @@ testVirHostdevPreparePCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED)
{ {
int ret = -1; int ret = -1;
size_t i; size_t i;
int count, count1, count2; int count, active_count, inactive_count;
for (i = 0; i < nhostdevs; i++) for (i = 0; i < nhostdevs; i++)
hostdevs[i]->managed = false; hostdevs[i]->managed = false;
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs); active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
count2 = virPCIDeviceListCount(mgr->inactivePCIHostdevs); inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
/* Test normal functionality */ /* Test normal functionality */
VIR_DEBUG("Test 0 hostdevs"); VIR_DEBUG("Test 0 hostdevs");
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid, if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
NULL, 0, 0) < 0) NULL, 0, 0) < 0)
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count);
/* Test unmanaged hostdevs */ /* Test unmanaged hostdevs */
VIR_DEBUG("Test >=1 unmanaged hostdevs"); VIR_DEBUG("Test >=1 unmanaged hostdevs");
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 + nhostdevs); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count + nhostdevs);
CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2 - nhostdevs); CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count - nhostdevs);
/* Test conflict */ /* Test conflict */
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs); active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
count2 = virPCIDeviceListCount(mgr->inactivePCIHostdevs); inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
VIR_DEBUG("Test: prepare same hostdevs for same driver/domain again"); VIR_DEBUG("Test: prepare same hostdevs for same driver/domain again");
if (!virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid, if (!virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
&hostdevs[0], 1, 0)) &hostdevs[0], 1, 0))
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2); CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
VIR_DEBUG("Test: prepare same hostdevs for same driver, diff domain again"); VIR_DEBUG("Test: prepare same hostdevs for same driver, diff domain again");
if (!virHostdevPreparePCIDevices(mgr, drv_name, "test_domain1", uuid, if (!virHostdevPreparePCIDevices(mgr, drv_name, "test_domain1", uuid,
&hostdevs[1], 1, 0)) &hostdevs[1], 1, 0))
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2); CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
VIR_DEBUG("Test: prepare same hostdevs for diff driver/domain again"); VIR_DEBUG("Test: prepare same hostdevs for diff driver/domain again");
if (!virHostdevPreparePCIDevices(mgr, "test_driver1", dom_name, uuid, if (!virHostdevPreparePCIDevices(mgr, "test_driver1", dom_name, uuid,
&hostdevs[2], 1, 0)) &hostdevs[2], 1, 0))
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2); CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
ret = 0; ret = 0;
...@@ -220,7 +220,7 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED) ...@@ -220,7 +220,7 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED)
{ {
int ret = -1; int ret = -1;
size_t i; size_t i;
int count, count1, count2; int count, active_count, inactive_count;
for (i = 0; i < nhostdevs; i++) { for (i = 0; i < nhostdevs; i++) {
if (hostdevs[i]->managed != false) { if (hostdevs[i]->managed != false) {
...@@ -229,18 +229,18 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED) ...@@ -229,18 +229,18 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED)
} }
} }
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs); active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
count2 = virPCIDeviceListCount(mgr->inactivePCIHostdevs); inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
VIR_DEBUG("Test 0 hostdevs"); VIR_DEBUG("Test 0 hostdevs");
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, NULL, 0, NULL); virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, NULL, 0, NULL);
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count);
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 - nhostdevs); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count - nhostdevs);
CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count2 + nhostdevs); CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count + nhostdevs);
ret = 0; ret = 0;
...@@ -254,39 +254,39 @@ testVirHostdevPreparePCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED) ...@@ -254,39 +254,39 @@ testVirHostdevPreparePCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED)
{ {
int ret = -1; int ret = -1;
size_t i; size_t i;
int count, count1; int count, active_count;
for (i = 0; i < nhostdevs; i++) for (i = 0; i < nhostdevs; i++)
hostdevs[i]->managed = true; hostdevs[i]->managed = true;
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs); active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
/* Test normal functionality */ /* Test normal functionality */
VIR_DEBUG("Test >=1 hostdevs"); VIR_DEBUG("Test >=1 hostdevs");
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 + nhostdevs); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count + nhostdevs);
/* Test conflict */ /* Test conflict */
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs); active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
VIR_DEBUG("Test: prepare same hostdevs for same driver/domain again"); VIR_DEBUG("Test: prepare same hostdevs for same driver/domain again");
if (!virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid, if (!virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
&hostdevs[0], 1, 0)) &hostdevs[0], 1, 0))
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count);
VIR_DEBUG("Test: prepare same hostdevs for same driver, diff domain again"); VIR_DEBUG("Test: prepare same hostdevs for same driver, diff domain again");
if (!virHostdevPreparePCIDevices(mgr, drv_name, "test_domain1", uuid, if (!virHostdevPreparePCIDevices(mgr, drv_name, "test_domain1", uuid,
&hostdevs[1], 1, 0)) &hostdevs[1], 1, 0))
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count);
VIR_DEBUG("Test: prepare same hostdevs for diff driver/domain again"); VIR_DEBUG("Test: prepare same hostdevs for diff driver/domain again");
if (!virHostdevPreparePCIDevices(mgr, "test_driver1", dom_name, uuid, if (!virHostdevPreparePCIDevices(mgr, "test_driver1", dom_name, uuid,
&hostdevs[2], 1, 0)) &hostdevs[2], 1, 0))
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count);
ret = 0; ret = 0;
...@@ -300,7 +300,7 @@ testVirHostdevReAttachPCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED) ...@@ -300,7 +300,7 @@ testVirHostdevReAttachPCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED)
{ {
int ret = -1; int ret = -1;
size_t i; size_t i;
int count, count1; int count, active_count;
for (i = 0; i < nhostdevs; i++) { for (i = 0; i < nhostdevs; i++) {
if (hostdevs[i]->managed != true) { if (hostdevs[i]->managed != true) {
...@@ -309,16 +309,16 @@ testVirHostdevReAttachPCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED) ...@@ -309,16 +309,16 @@ testVirHostdevReAttachPCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED)
} }
} }
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs); active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
VIR_DEBUG("Test 0 hostdevs"); VIR_DEBUG("Test 0 hostdevs");
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, NULL, 0, NULL); virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, NULL, 0, NULL);
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count);
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 - nhostdevs); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count - nhostdevs);
ret = 0; ret = 0;
...@@ -332,13 +332,13 @@ testVirHostdevDetachPCINodeDevice(const void *opaque ATTRIBUTE_UNUSED) ...@@ -332,13 +332,13 @@ testVirHostdevDetachPCINodeDevice(const void *opaque ATTRIBUTE_UNUSED)
{ {
int ret = -1; int ret = -1;
size_t i; size_t i;
int count, count1; int count, inactive_count;
for (i = 0; i < nhostdevs; i++) { for (i = 0; i < nhostdevs; i++) {
count1 = virPCIDeviceListCount(mgr->inactivePCIHostdevs); inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
if (virHostdevPCINodeDeviceDetach(mgr, dev[i]) < 0) if (virHostdevPCINodeDeviceDetach(mgr, dev[i]) < 0)
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count1 + 1); CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count + 1);
} }
ret = 0; ret = 0;
...@@ -369,13 +369,13 @@ testVirHostdevReAttachPCINodeDevice(const void *opaque ATTRIBUTE_UNUSED) ...@@ -369,13 +369,13 @@ testVirHostdevReAttachPCINodeDevice(const void *opaque ATTRIBUTE_UNUSED)
{ {
int ret = -1; int ret = -1;
size_t i; size_t i;
int count, count1; int count, inactive_count;
for (i = 0; i < nhostdevs; i++) { for (i = 0; i < nhostdevs; i++) {
count1 = virPCIDeviceListCount(mgr->inactivePCIHostdevs); inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
if (virHostdevPCINodeDeviceReAttach(mgr, dev[i]) < 0) if (virHostdevPCINodeDeviceReAttach(mgr, dev[i]) < 0)
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, count1 - 1); CHECK_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count - 1);
} }
ret = 0; ret = 0;
...@@ -389,21 +389,21 @@ static int ...@@ -389,21 +389,21 @@ static int
testVirHostdevUpdateActivePCIHostdevs(const void *opaque ATTRIBUTE_UNUSED) testVirHostdevUpdateActivePCIHostdevs(const void *opaque ATTRIBUTE_UNUSED)
{ {
int ret = -1; int ret = -1;
int count, count1; int count, active_count;
count1 = virPCIDeviceListCount(mgr->activePCIHostdevs); active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
VIR_DEBUG("Test 0 hostdevs"); VIR_DEBUG("Test 0 hostdevs");
if (virHostdevUpdateActivePCIDevices(mgr, NULL, 0, if (virHostdevUpdateActivePCIDevices(mgr, NULL, 0,
drv_name, dom_name) < 0) drv_name, dom_name) < 0)
goto cleanup; goto cleanup;
CHECK_LIST_COUNT(mgr->activePCIHostdevs, count1); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count);
VIR_DEBUG("Test >=1 hostdevs"); VIR_DEBUG("Test >=1 hostdevs");
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 + nhostdevs); CHECK_LIST_COUNT(mgr->activePCIHostdevs, active_count + nhostdevs);
ret = 0; ret = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册