提交 f5e65e4b 编写于 作者: M Martin Kletzander

Remove unnecessary curly brackets in tests/

Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 91cc3d95
...@@ -70,9 +70,8 @@ int main(int argc, char **argv) { ...@@ -70,9 +70,8 @@ int main(int argc, char **argv) {
if (!log) if (!log)
goto cleanup; goto cleanup;
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++)
fprintf(log, "ARG:%s\n", argv[i]); fprintf(log, "ARG:%s\n", argv[i]);
}
origenv = environ; origenv = environ;
n = 0; n = 0;
......
...@@ -54,9 +54,8 @@ testParseDatastorePath(const void *data ATTRIBUTE_UNUSED) ...@@ -54,9 +54,8 @@ testParseDatastorePath(const void *data ATTRIBUTE_UNUSED)
goto failure; goto failure;
} }
if (paths[i].result < 0) { if (paths[i].result < 0)
continue; continue;
}
if (STRNEQ(paths[i].datastoreName, datastoreName)) { if (STRNEQ(paths[i].datastoreName, datastoreName)) {
virtTestDifference(stderr, paths[i].datastoreName, datastoreName); virtTestDifference(stderr, paths[i].datastoreName, datastoreName);
...@@ -138,9 +137,8 @@ testConvertDateTimeToCalendarTime(const void *data ATTRIBUTE_UNUSED) ...@@ -138,9 +137,8 @@ testConvertDateTimeToCalendarTime(const void *data ATTRIBUTE_UNUSED)
return -1; return -1;
} }
if (times[i].calendarTime != calendarTime) { if (times[i].calendarTime != calendarTime)
return -1; return -1;
}
} }
return 0; return 0;
...@@ -186,9 +184,8 @@ testEscapeDatastoreItem(const void *data ATTRIBUTE_UNUSED) ...@@ -186,9 +184,8 @@ testEscapeDatastoreItem(const void *data ATTRIBUTE_UNUSED)
escaped = esxUtil_EscapeDatastoreItem(datastoreItems[i].string); escaped = esxUtil_EscapeDatastoreItem(datastoreItems[i].string);
if (escaped == NULL) { if (escaped == NULL)
return -1; return -1;
}
if (STRNEQ(datastoreItems[i].escaped, escaped)) { if (STRNEQ(datastoreItems[i].escaped, escaped)) {
VIR_FREE(escaped); VIR_FREE(escaped);
...@@ -228,9 +225,8 @@ testConvertWindows1252ToUTF8(const void *data ATTRIBUTE_UNUSED) ...@@ -228,9 +225,8 @@ testConvertWindows1252ToUTF8(const void *data ATTRIBUTE_UNUSED)
utf8 = virVMXConvertToUTF8("Windows-1252", utf8 = virVMXConvertToUTF8("Windows-1252",
windows1252ToUTF8[i].windows1252); windows1252ToUTF8[i].windows1252);
if (utf8 == NULL) { if (utf8 == NULL)
return -1; return -1;
}
if (STRNEQ(windows1252ToUTF8[i].utf8, utf8)) { if (STRNEQ(windows1252ToUTF8[i].utf8, utf8)) {
VIR_FREE(utf8); VIR_FREE(utf8);
......
...@@ -124,9 +124,8 @@ static int eventThreadJobDone; ...@@ -124,9 +124,8 @@ static int eventThreadJobDone;
ATTRIBUTE_NORETURN static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) { ATTRIBUTE_NORETURN static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) {
while (1) { while (1) {
pthread_mutex_lock(&eventThreadMutex); pthread_mutex_lock(&eventThreadMutex);
while (!eventThreadRunOnce) { while (!eventThreadRunOnce)
pthread_cond_wait(&eventThreadRunCond, &eventThreadMutex); pthread_cond_wait(&eventThreadRunCond, &eventThreadMutex);
}
eventThreadRunOnce = 0; eventThreadRunOnce = 0;
pthread_mutex_unlock(&eventThreadMutex); pthread_mutex_unlock(&eventThreadMutex);
......
...@@ -42,9 +42,8 @@ testReadConfigParam(const void *data ATTRIBUTE_UNUSED) ...@@ -42,9 +42,8 @@ testReadConfigParam(const void *data ATTRIBUTE_UNUSED)
char *conf = NULL; char *conf = NULL;
char *value = NULL; char *value = NULL;
if (virAsprintf(&conf, "%s/openvzutilstest.conf", abs_srcdir) < 0) { if (virAsprintf(&conf, "%s/openvzutilstest.conf", abs_srcdir) < 0)
return -1; return -1;
}
for (i = 0; i < ARRAY_CARDINALITY(configParams); ++i) { for (i = 0; i < ARRAY_CARDINALITY(configParams); ++i) {
if (openvzReadConfigParam(conf, configParams[i].param, if (openvzReadConfigParam(conf, configParams[i].param,
...@@ -52,9 +51,8 @@ testReadConfigParam(const void *data ATTRIBUTE_UNUSED) ...@@ -52,9 +51,8 @@ testReadConfigParam(const void *data ATTRIBUTE_UNUSED)
goto cleanup; goto cleanup;
} }
if (configParams[i].ret != 1) { if (configParams[i].ret != 1)
continue; continue;
}
if (STRNEQ(configParams[i].value, value)) { if (STRNEQ(configParams[i].value, value)) {
virtTestDifference(stderr, configParams[i].value, value); virtTestDifference(stderr, configParams[i].value, value);
......
...@@ -120,9 +120,8 @@ testSELinuxLoadFileList(const char *testname, ...@@ -120,9 +120,8 @@ testSELinuxLoadFileList(const char *testname,
abs_srcdir, testname) < 0) abs_srcdir, testname) < 0)
goto cleanup; goto cleanup;
if (!(fp = fopen(path, "r"))) { if (!(fp = fopen(path, "r")))
goto cleanup; goto cleanup;
}
if (VIR_ALLOC_N(line, 1024) < 0) if (VIR_ALLOC_N(line, 1024) < 0)
goto cleanup; goto cleanup;
...@@ -191,9 +190,8 @@ testSELinuxLoadDef(const char *testname) ...@@ -191,9 +190,8 @@ testSELinuxLoadDef(const char *testname)
abs_srcdir, testname) < 0) abs_srcdir, testname) < 0)
goto cleanup; goto cleanup;
if (virFileReadAll(xmlfile, 1024*1024, &xmlstr) < 0) { if (virFileReadAll(xmlfile, 1024*1024, &xmlstr) < 0)
goto cleanup; goto cleanup;
}
if (!(def = virDomainDefParseString(xmlstr, caps, xmlopt, if (!(def = virDomainDefParseString(xmlstr, caps, xmlopt,
QEMU_EXPECTED_VIRT_TYPES, QEMU_EXPECTED_VIRT_TYPES,
......
...@@ -74,9 +74,8 @@ static void *threadMain(void *arg) ...@@ -74,9 +74,8 @@ static void *threadMain(void *arg)
pthread_cond_signal(&cond); pthread_cond_signal(&cond);
} }
while (!quit) { while (!quit)
pthread_cond_wait(&cond, &lock); pthread_cond_wait(&cond, &lock);
}
pthread_mutex_unlock(&lock); pthread_mutex_unlock(&lock);
return NULL; return NULL;
...@@ -126,9 +125,8 @@ int main(int argc ATTRIBUTE_UNUSED, char **argv) ...@@ -126,9 +125,8 @@ int main(int argc ATTRIBUTE_UNUSED, char **argv)
/* Wait for the thread to start and call libvirt */ /* Wait for the thread to start and call libvirt */
pthread_mutex_lock(&lock); pthread_mutex_lock(&lock);
while (!running && !failstart) { while (!running && !failstart)
pthread_cond_wait(&cond, &lock); pthread_cond_wait(&cond, &lock);
}
/* Close the shared library (and thus make libvirt.so /* Close the shared library (and thus make libvirt.so
* non-resident */ * non-resident */
......
...@@ -124,9 +124,8 @@ testParseVersionString(const void *data ATTRIBUTE_UNUSED) ...@@ -124,9 +124,8 @@ testParseVersionString(const void *data ATTRIBUTE_UNUSED)
return -1; return -1;
} }
if (result < 0) { if (result < 0)
continue; continue;
}
if (version != versions[i].version) { if (version != versions[i].version) {
if (virTestGetDebug() > 0) { if (virTestGetDebug() > 0) {
......
...@@ -38,9 +38,8 @@ static int testBufInfiniteLoop(const void *data) ...@@ -38,9 +38,8 @@ static int testBufInfiniteLoop(const void *data)
* which was the case after the above addchar at the time of the bug. * which was the case after the above addchar at the time of the bug.
* This test is a bit fragile, since it relies on virBuffer internals. * This test is a bit fragile, since it relies on virBuffer internals.
*/ */
if (virAsprintf(&addstr, "%*s", buf->a - buf->b - 1, "a") < 0) { if (virAsprintf(&addstr, "%*s", buf->a - buf->b - 1, "a") < 0)
goto out; goto out;
}
if (info->doEscape) if (info->doEscape)
virBufferEscapeString(buf, "%s", addstr); virBufferEscapeString(buf, "%s", addstr);
......
...@@ -531,17 +531,15 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED) ...@@ -531,17 +531,15 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED)
virHashAddEntry(hash, keya, value3) < 0 || virHashAddEntry(hash, keya, value3) < 0 ||
virHashAddEntry(hash, keyc, value1) < 0 || virHashAddEntry(hash, keyc, value1) < 0 ||
virHashAddEntry(hash, keyb, value2) < 0) { virHashAddEntry(hash, keyb, value2) < 0) {
if (virTestGetVerbose()) { if (virTestGetVerbose())
testError("\nfailed to create hash"); testError("\nfailed to create hash");
}
goto cleanup; goto cleanup;
} }
if (!(array = virHashGetItems(hash, NULL)) || if (!(array = virHashGetItems(hash, NULL)) ||
array[3].key || array[3].value) { array[3].key || array[3].value) {
if (virTestGetVerbose()) { if (virTestGetVerbose())
testError("\nfailed to get items with NULL sort"); testError("\nfailed to get items with NULL sort");
}
goto cleanup; goto cleanup;
} }
VIR_FREE(array); VIR_FREE(array);
...@@ -554,9 +552,8 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED) ...@@ -554,9 +552,8 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED)
STRNEQ(array[2].key, "c") || STRNEQ(array[2].key, "c") ||
STRNEQ(array[2].value, "1") || STRNEQ(array[2].value, "1") ||
array[3].key || array[3].value) { array[3].key || array[3].value) {
if (virTestGetVerbose()) { if (virTestGetVerbose())
testError("\nfailed to get items with key sort"); testError("\nfailed to get items with key sort");
}
goto cleanup; goto cleanup;
} }
VIR_FREE(array); VIR_FREE(array);
...@@ -569,9 +566,8 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED) ...@@ -569,9 +566,8 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED)
STRNEQ(array[2].key, "a") || STRNEQ(array[2].key, "a") ||
STRNEQ(array[2].value, "3") || STRNEQ(array[2].value, "3") ||
array[3].key || array[3].value) { array[3].key || array[3].value) {
if (virTestGetVerbose()) { if (virTestGetVerbose())
testError("\nfailed to get items with value sort"); testError("\nfailed to get items with value sort");
}
goto cleanup; goto cleanup;
} }
...@@ -612,44 +608,38 @@ testHashEqual(const void *data ATTRIBUTE_UNUSED) ...@@ -612,44 +608,38 @@ testHashEqual(const void *data ATTRIBUTE_UNUSED)
virHashAddEntry(hash1, keyc, value3_l) < 0 || virHashAddEntry(hash1, keyc, value3_l) < 0 ||
virHashAddEntry(hash2, keya, value1_u) < 0 || virHashAddEntry(hash2, keya, value1_u) < 0 ||
virHashAddEntry(hash2, keyb, value2_u) < 0) { virHashAddEntry(hash2, keyb, value2_u) < 0) {
if (virTestGetVerbose()) { if (virTestGetVerbose())
testError("\nfailed to create hashes"); testError("\nfailed to create hashes");
}
goto cleanup; goto cleanup;
} }
if (virHashEqual(hash1, hash2, testHashEqualCompValue)) { if (virHashEqual(hash1, hash2, testHashEqualCompValue)) {
if (virTestGetVerbose()) { if (virTestGetVerbose())
testError("\nfailed equal test for different number of elements"); testError("\nfailed equal test for different number of elements");
}
goto cleanup; goto cleanup;
} }
if (virHashAddEntry(hash2, keyc, value4_u) < 0) { if (virHashAddEntry(hash2, keyc, value4_u) < 0) {
if (virTestGetVerbose()) { if (virTestGetVerbose())
testError("\nfailed to add element to hash2"); testError("\nfailed to add element to hash2");
}
goto cleanup; goto cleanup;
} }
if (virHashEqual(hash1, hash2, testHashEqualCompValue)) { if (virHashEqual(hash1, hash2, testHashEqualCompValue)) {
if (virTestGetVerbose()) { if (virTestGetVerbose())
testError("\nfailed equal test for same number of elements"); testError("\nfailed equal test for same number of elements");
}
goto cleanup; goto cleanup;
} }
if (virHashUpdateEntry(hash2, keyc, value3_u) < 0) { if (virHashUpdateEntry(hash2, keyc, value3_u) < 0) {
if (virTestGetVerbose()) { if (virTestGetVerbose())
testError("\nfailed to update element in hash2"); testError("\nfailed to update element in hash2");
}
goto cleanup; goto cleanup;
} }
if (!virHashEqual(hash1, hash2, testHashEqualCompValue)) { if (!virHashEqual(hash1, hash2, testHashEqualCompValue)) {
if (virTestGetVerbose()) { if (virTestGetVerbose())
testError("\nfailed equal test for equal hash tables"); testError("\nfailed equal test for equal hash tables");
}
goto cleanup; goto cleanup;
} }
......
...@@ -88,9 +88,8 @@ testTimeLocalOffset(const void *args) ...@@ -88,9 +88,8 @@ testTimeLocalOffset(const void *args)
} }
tzset(); tzset();
if (virTimeLocalOffsetFromUTC(&actual) < 0) { if (virTimeLocalOffsetFromUTC(&actual) < 0)
return -1; return -1;
}
if (data->offset != actual) { if (data->offset != actual) {
VIR_DEBUG("Expect Offset %ld got %ld\n", VIR_DEBUG("Expect Offset %ld got %ld\n",
......
...@@ -27,9 +27,8 @@ testCapsInit(void) ...@@ -27,9 +27,8 @@ testCapsInit(void)
caps = virCapabilitiesNew(VIR_ARCH_I686, true, true); caps = virCapabilitiesNew(VIR_ARCH_I686, true, true);
if (caps == NULL) { if (caps == NULL)
return; return;
}
virCapabilitiesAddHostMigrateTransport(caps, "esx"); virCapabilitiesAddHostMigrateTransport(caps, "esx");
...@@ -39,9 +38,8 @@ testCapsInit(void) ...@@ -39,9 +38,8 @@ testCapsInit(void)
VIR_ARCH_I686, VIR_ARCH_I686,
NULL, NULL, 0, NULL); NULL, NULL, 0, NULL);
if (guest == NULL) { if (guest == NULL)
goto failure; goto failure;
}
if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
NULL) == NULL) { NULL) == NULL) {
...@@ -54,9 +52,8 @@ testCapsInit(void) ...@@ -54,9 +52,8 @@ testCapsInit(void)
VIR_ARCH_X86_64, VIR_ARCH_X86_64,
NULL, NULL, 0, NULL); NULL, NULL, 0, NULL);
if (guest == NULL) { if (guest == NULL)
goto failure; goto failure;
}
if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
NULL) == NULL) { NULL) == NULL) {
...@@ -201,9 +198,8 @@ mymain(void) ...@@ -201,9 +198,8 @@ mymain(void)
testCapsInit(); testCapsInit();
if (caps == NULL) { if (caps == NULL)
return EXIT_FAILURE; return EXIT_FAILURE;
}
if (!(xmlopt = virVMXDomainXMLConfInit())) if (!(xmlopt = virVMXDomainXMLConfInit()))
return EXIT_FAILURE; return EXIT_FAILURE;
......
...@@ -27,9 +27,8 @@ testCapsInit(void) ...@@ -27,9 +27,8 @@ testCapsInit(void)
caps = virCapabilitiesNew(VIR_ARCH_I686, true, true); caps = virCapabilitiesNew(VIR_ARCH_I686, true, true);
if (caps == NULL) { if (caps == NULL)
return; return;
}
virCapabilitiesAddHostMigrateTransport(caps, "esx"); virCapabilitiesAddHostMigrateTransport(caps, "esx");
...@@ -40,9 +39,8 @@ testCapsInit(void) ...@@ -40,9 +39,8 @@ testCapsInit(void)
VIR_ARCH_I686, VIR_ARCH_I686,
NULL, NULL, 0, NULL); NULL, NULL, 0, NULL);
if (guest == NULL) { if (guest == NULL)
goto failure; goto failure;
}
if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
NULL) == NULL) { NULL) == NULL) {
...@@ -55,9 +53,8 @@ testCapsInit(void) ...@@ -55,9 +53,8 @@ testCapsInit(void)
VIR_ARCH_X86_64, VIR_ARCH_X86_64,
NULL, NULL, 0, NULL); NULL, NULL, 0, NULL);
if (guest == NULL) { if (guest == NULL)
goto failure; goto failure;
}
if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
NULL) == NULL) { NULL) == NULL) {
...@@ -81,21 +78,18 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) ...@@ -81,21 +78,18 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
char *formatted = NULL; char *formatted = NULL;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
if (virtTestLoadFile(xml, &xmlData) < 0) { if (virtTestLoadFile(xml, &xmlData) < 0)
goto failure; goto failure;
}
if (virtTestLoadFile(vmx, &vmxData) < 0) { if (virtTestLoadFile(vmx, &vmxData) < 0)
goto failure; goto failure;
}
def = virDomainDefParseString(xmlData, caps, xmlopt, def = virDomainDefParseString(xmlData, caps, xmlopt,
1 << VIR_DOMAIN_VIRT_VMWARE, 1 << VIR_DOMAIN_VIRT_VMWARE,
VIR_DOMAIN_XML_INACTIVE); VIR_DOMAIN_XML_INACTIVE);
if (def == NULL) { if (def == NULL)
goto failure; goto failure;
}
if (!virDomainDefCheckABIStability(def, def)) { if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", xml); fprintf(stderr, "ABI stability check failed on %s", xml);
...@@ -104,9 +98,8 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) ...@@ -104,9 +98,8 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
formatted = virVMXFormatConfig(&ctx, xmlopt, def, virtualHW_version); formatted = virVMXFormatConfig(&ctx, xmlopt, def, virtualHW_version);
if (formatted == NULL) { if (formatted == NULL)
goto failure; goto failure;
}
if (STRNEQ(vmxData, formatted)) { if (STRNEQ(vmxData, formatted)) {
virtTestDifference(stderr, vmxData, formatted); virtTestDifference(stderr, vmxData, formatted);
...@@ -207,9 +200,8 @@ testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED) ...@@ -207,9 +200,8 @@ testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED)
success = true; success = true;
cleanup: cleanup:
if (! success) { if (! success)
VIR_FREE(absolutePath); VIR_FREE(absolutePath);
}
VIR_FREE(copyOfDatastorePath); VIR_FREE(copyOfDatastorePath);
...@@ -233,9 +225,8 @@ mymain(void) ...@@ -233,9 +225,8 @@ mymain(void)
testCapsInit(); testCapsInit();
if (caps == NULL) { if (caps == NULL)
return EXIT_FAILURE; return EXIT_FAILURE;
}
if (!(xmlopt = virVMXDomainXMLConfInit())) if (!(xmlopt = virVMXDomainXMLConfInit()))
return EXIT_FAILURE; return EXIT_FAILURE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册