tests: fix incorrect indentation in function body by checking first line

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
This commit is contained in:
Shi Lei 2018-09-13 16:55:21 +08:00 committed by Michal Privoznik
parent ab9a145926
commit a618b06493
5 changed files with 112 additions and 112 deletions

View File

@ -66,7 +66,7 @@ virNumaIsAvailable(void)
int int
virNumaGetMaxNode(void) virNumaGetMaxNode(void)
{ {
return 7; return 7;
} }
/* We shouldn't need to mock virNumaNodeIsAvailable() and *definitely* not /* We shouldn't need to mock virNumaNodeIsAvailable() and *definitely* not

View File

@ -21,37 +21,37 @@ static virDomainXMLOptionPtr xmlopt;
static int static int
testCompareFiles(const char *xml, const char *sexpr) testCompareFiles(const char *xml, const char *sexpr)
{ {
char *sexprData = NULL; char *sexprData = NULL;
char *gotxml = NULL; char *gotxml = NULL;
int ret = -1; int ret = -1;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
if (virTestLoadFile(sexpr, &sexprData) < 0) if (virTestLoadFile(sexpr, &sexprData) < 0)
goto fail; goto fail;
if (!(def = xenParseSxprString(sexprData, if (!(def = xenParseSxprString(sexprData,
NULL, -1, caps, xmlopt))) NULL, -1, caps, xmlopt)))
goto fail; goto fail;
if (!virDomainDefCheckABIStability(def, def, xmlopt)) { if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
fprintf(stderr, "ABI stability check failed on %s", xml); fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail; goto fail;
} }
if (!(gotxml = virDomainDefFormat(def, caps, 0))) if (!(gotxml = virDomainDefFormat(def, caps, 0)))
goto fail; goto fail;
if (virTestCompareToFile(gotxml, xml) < 0) if (virTestCompareToFile(gotxml, xml) < 0)
goto fail; goto fail;
ret = 0; ret = 0;
fail: fail:
VIR_FREE(sexprData); VIR_FREE(sexprData);
VIR_FREE(gotxml); VIR_FREE(gotxml);
virDomainDefFree(def); virDomainDefFree(def);
return ret; return ret;
} }
struct testInfo { struct testInfo {

View File

@ -126,19 +126,19 @@ static void testTLSDerEncode(ASN1_TYPE src,
const char *src_name, const char *src_name,
gnutls_datum_t * res) gnutls_datum_t * res)
{ {
int size; int size;
char *data = NULL; char *data = NULL;
size = 0; size = 0;
asn1_der_coding(src, src_name, NULL, &size, NULL); asn1_der_coding(src, src_name, NULL, &size, NULL);
if (VIR_ALLOC_N(data, size) < 0) if (VIR_ALLOC_N(data, size) < 0)
abort(); abort();
asn1_der_coding(src, src_name, data, &size, NULL); asn1_der_coding(src, src_name, data, &size, NULL);
res->data = (unsigned char *)data; res->data = (unsigned char *)data;
res->size = size; res->size = size;
} }

View File

@ -44,18 +44,18 @@ static const char *domstate_fc4 = "running\n\n";
static int testFilterLine(char *buffer, static int testFilterLine(char *buffer,
const char *toRemove) const char *toRemove)
{ {
char *start; char *start;
char *end; char *end;
if (!(start = strstr(buffer, toRemove))) if (!(start = strstr(buffer, toRemove)))
return -1; return -1;
if (!(end = strstr(start+1, "\n"))) { if (!(end = strstr(start+1, "\n"))) {
*start = '\0'; *start = '\0';
} else { } else {
memmove(start, end, strlen(end)+1); memmove(start, end, strlen(end)+1);
} }
return 0; return 0;
} }
static int static int
@ -96,31 +96,31 @@ static char *custom_uri;
static int testCompareListDefault(const void *data ATTRIBUTE_UNUSED) static int testCompareListDefault(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_DEFAULT, "list", NULL }; const char *const argv[] = { VIRSH_DEFAULT, "list", NULL };
const char *exp = "\ const char *exp = "\
Id Name State \n\ Id Name State \n\
----------------------\n\ ----------------------\n\
1 test running \n\ 1 test running \n\
\n"; \n";
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareListCustom(const void *data ATTRIBUTE_UNUSED) static int testCompareListCustom(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "list", NULL }; const char *const argv[] = { VIRSH_CUSTOM, "list", NULL };
const char *exp = "\ const char *exp = "\
Id Name State \n\ Id Name State \n\
----------------------\n\ ----------------------\n\
1 fv0 running \n\ 1 fv0 running \n\
2 fc4 running \n\ 2 fc4 running \n\
\n"; \n";
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareNodeinfoDefault(const void *data ATTRIBUTE_UNUSED) static int testCompareNodeinfoDefault(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_DEFAULT, "nodeinfo", NULL }; const char *const argv[] = { VIRSH_DEFAULT, "nodeinfo", NULL };
const char *exp = "\ const char *exp = "\
CPU model: i686\n\ CPU model: i686\n\
CPU(s): 16\n\ CPU(s): 16\n\
CPU frequency: 1400 MHz\n\ CPU frequency: 1400 MHz\n\
@ -130,17 +130,17 @@ Thread(s) per core: 2\n\
NUMA cell(s): 2\n\ NUMA cell(s): 2\n\
Memory size: 3145728 KiB\n\ Memory size: 3145728 KiB\n\
\n"; \n";
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareNodeinfoCustom(const void *data ATTRIBUTE_UNUSED) static int testCompareNodeinfoCustom(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { const char *const argv[] = {
VIRSH_CUSTOM, VIRSH_CUSTOM,
"nodeinfo", "nodeinfo",
NULL NULL
}; };
const char *exp = "\ const char *exp = "\
CPU model: i986\n\ CPU model: i986\n\
CPU(s): 50\n\ CPU(s): 50\n\
CPU frequency: 6000 MHz\n\ CPU frequency: 6000 MHz\n\
@ -150,91 +150,91 @@ Thread(s) per core: 2\n\
NUMA cell(s): 4\n\ NUMA cell(s): 4\n\
Memory size: 8192000 KiB\n\ Memory size: 8192000 KiB\n\
\n"; \n";
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareDominfoByID(const void *data ATTRIBUTE_UNUSED) static int testCompareDominfoByID(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "2", NULL }; const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "2", NULL };
const char *exp = dominfo_fc4; const char *exp = dominfo_fc4;
return testCompareOutputLit(exp, "\nCPU time:", argv); return testCompareOutputLit(exp, "\nCPU time:", argv);
} }
static int testCompareDominfoByUUID(const void *data ATTRIBUTE_UNUSED) static int testCompareDominfoByUUID(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", DOM_UUID, NULL }; const char *const argv[] = { VIRSH_CUSTOM, "dominfo", DOM_UUID, NULL };
const char *exp = dominfo_fc4; const char *exp = dominfo_fc4;
return testCompareOutputLit(exp, "\nCPU time:", argv); return testCompareOutputLit(exp, "\nCPU time:", argv);
} }
static int testCompareDominfoByName(const void *data ATTRIBUTE_UNUSED) static int testCompareDominfoByName(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "fc4", NULL }; const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "fc4", NULL };
const char *exp = dominfo_fc4; const char *exp = dominfo_fc4;
return testCompareOutputLit(exp, "\nCPU time:", argv); return testCompareOutputLit(exp, "\nCPU time:", argv);
} }
static int testCompareDomuuidByID(const void *data ATTRIBUTE_UNUSED) static int testCompareDomuuidByID(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "2", NULL }; const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "2", NULL };
const char *exp = domuuid_fc4; const char *exp = domuuid_fc4;
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareDomuuidByName(const void *data ATTRIBUTE_UNUSED) static int testCompareDomuuidByName(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "fc4", NULL }; const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "fc4", NULL };
const char *exp = domuuid_fc4; const char *exp = domuuid_fc4;
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareDomidByName(const void *data ATTRIBUTE_UNUSED) static int testCompareDomidByName(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "domid", "fc4", NULL }; const char *const argv[] = { VIRSH_CUSTOM, "domid", "fc4", NULL };
const char *exp = domid_fc4; const char *exp = domid_fc4;
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareDomidByUUID(const void *data ATTRIBUTE_UNUSED) static int testCompareDomidByUUID(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "domid", DOM_UUID, NULL }; const char *const argv[] = { VIRSH_CUSTOM, "domid", DOM_UUID, NULL };
const char *exp = domid_fc4; const char *exp = domid_fc4;
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareDomnameByID(const void *data ATTRIBUTE_UNUSED) static int testCompareDomnameByID(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "domname", "2", NULL }; const char *const argv[] = { VIRSH_CUSTOM, "domname", "2", NULL };
const char *exp = domname_fc4; const char *exp = domname_fc4;
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareDomnameByUUID(const void *data ATTRIBUTE_UNUSED) static int testCompareDomnameByUUID(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "domname", DOM_UUID, NULL }; const char *const argv[] = { VIRSH_CUSTOM, "domname", DOM_UUID, NULL };
const char *exp = domname_fc4; const char *exp = domname_fc4;
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareDomstateByID(const void *data ATTRIBUTE_UNUSED) static int testCompareDomstateByID(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "domstate", "2", NULL }; const char *const argv[] = { VIRSH_CUSTOM, "domstate", "2", NULL };
const char *exp = domstate_fc4; const char *exp = domstate_fc4;
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareDomstateByUUID(const void *data ATTRIBUTE_UNUSED) static int testCompareDomstateByUUID(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "domstate", DOM_UUID, NULL }; const char *const argv[] = { VIRSH_CUSTOM, "domstate", DOM_UUID, NULL };
const char *exp = domstate_fc4; const char *exp = domstate_fc4;
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
static int testCompareDomstateByName(const void *data ATTRIBUTE_UNUSED) static int testCompareDomstateByName(const void *data ATTRIBUTE_UNUSED)
{ {
const char *const argv[] = { VIRSH_CUSTOM, "domstate", "fc4", NULL }; const char *const argv[] = { VIRSH_CUSTOM, "domstate", "fc4", NULL };
const char *exp = domstate_fc4; const char *exp = domstate_fc4;
return testCompareOutputLit(exp, NULL, argv); return testCompareOutputLit(exp, NULL, argv);
} }
struct testInfo { struct testInfo {

View File

@ -22,32 +22,32 @@ static virDomainXMLOptionPtr xmlopt;
static int static int
testCompareFiles(const char *xml, const char *sexpr) testCompareFiles(const char *xml, const char *sexpr)
{ {
char *gotsexpr = NULL; char *gotsexpr = NULL;
int ret = -1; int ret = -1;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
if (!(def = virDomainDefParseFile(xml, caps, xmlopt, NULL, if (!(def = virDomainDefParseFile(xml, caps, xmlopt, NULL,
VIR_DOMAIN_DEF_PARSE_INACTIVE))) VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto fail; goto fail;
if (!virDomainDefCheckABIStability(def, def, xmlopt)) { if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
fprintf(stderr, "ABI stability check failed on %s", xml); fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail; goto fail;
} }
if (!(gotsexpr = xenFormatSxpr(NULL, def))) if (!(gotsexpr = xenFormatSxpr(NULL, def)))
goto fail; goto fail;
if (virTestCompareToFile(gotsexpr, sexpr) < 0) if (virTestCompareToFile(gotsexpr, sexpr) < 0)
goto fail; goto fail;
ret = 0; ret = 0;
fail: fail:
VIR_FREE(gotsexpr); VIR_FREE(gotsexpr);
virDomainDefFree(def); virDomainDefFree(def);
return ret; return ret;
} }
struct testInfo { struct testInfo {