mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:03:48 +03:00
tests: remove unneeded cleanup labels
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
adf9c3f952
commit
3a085d221e
@ -943,12 +943,11 @@ test23(const void *unused G_GNUC_UNUSED)
|
|||||||
/* Not strictly a virCommand test, but this is the easiest place
|
/* Not strictly a virCommand test, but this is the easiest place
|
||||||
* to test this lower-level interface. It takes a double fork to
|
* to test this lower-level interface. It takes a double fork to
|
||||||
* test virProcessExitWithStatus. */
|
* test virProcessExitWithStatus. */
|
||||||
int ret = -1;
|
|
||||||
int status = -1;
|
int status = -1;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
if ((pid = virFork()) < 0)
|
if ((pid = virFork()) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
if ((pid = virFork()) < 0)
|
if ((pid = virFork()) < 0)
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
@ -961,14 +960,14 @@ test23(const void *unused G_GNUC_UNUSED)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virProcessWait(pid, &status, true) < 0)
|
if (virProcessWait(pid, &status, true) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 42) {
|
if (!WIFEXITED(status) || WEXITSTATUS(status) != 42) {
|
||||||
printf("Unexpected status %d\n", status);
|
printf("Unexpected status %d\n", status);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pid = virFork()) < 0)
|
if ((pid = virFork()) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
if ((pid = virFork()) < 0)
|
if ((pid = virFork()) < 0)
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
@ -983,15 +982,13 @@ test23(const void *unused G_GNUC_UNUSED)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virProcessWait(pid, &status, true) < 0)
|
if (virProcessWait(pid, &status, true) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGKILL) {
|
if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGKILL) {
|
||||||
printf("Unexpected status %d\n", status);
|
printf("Unexpected status %d\n", status);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test25(const void *unused G_GNUC_UNUSED)
|
static int test25(const void *unused G_GNUC_UNUSED)
|
||||||
|
@ -160,16 +160,13 @@ mymain(void)
|
|||||||
return EXIT_AM_SKIP;
|
return EXIT_AM_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = -1;
|
return EXIT_FAILURE;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
basefile = g_strdup_printf("%s/networkxml2firewalldata/base.args", abs_srcdir);
|
basefile = g_strdup_printf("%s/networkxml2firewalldata/base.args", abs_srcdir);
|
||||||
|
|
||||||
if (virTestLoadFile(basefile, &baseargs) < 0) {
|
if (virTestLoadFile(basefile, &baseargs) < 0)
|
||||||
ret = -1;
|
return EXIT_FAILURE;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
DO_TEST("nat-default");
|
DO_TEST("nat-default");
|
||||||
DO_TEST("nat-tftp");
|
DO_TEST("nat-tftp");
|
||||||
@ -178,7 +175,6 @@ mymain(void)
|
|||||||
DO_TEST("nat-ipv6");
|
DO_TEST("nat-ipv6");
|
||||||
DO_TEST("route-default");
|
DO_TEST("route-default");
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ testGetHostByName(const void *opaque)
|
|||||||
{
|
{
|
||||||
const struct testNSSData *data = opaque;
|
const struct testNSSData *data = opaque;
|
||||||
const bool existent = data->hostname && data->ipAddr && data->ipAddr[0];
|
const bool existent = data->hostname && data->ipAddr && data->ipAddr[0];
|
||||||
int ret = -1;
|
|
||||||
struct hostent resolved;
|
struct hostent resolved;
|
||||||
char buf[BUF_SIZE] = { 0 };
|
char buf[BUF_SIZE] = { 0 };
|
||||||
char **addrList;
|
char **addrList;
|
||||||
@ -64,16 +63,16 @@ testGetHostByName(const void *opaque)
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Resolving of %s failed due to internal error",
|
"Resolving of %s failed due to internal error",
|
||||||
data->hostname);
|
data->hostname);
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else if (rv == NSS_STATUS_NOTFOUND) {
|
} else if (rv == NSS_STATUS_NOTFOUND) {
|
||||||
/* Resolving failed. Should it? */
|
/* Resolving failed. Should it? */
|
||||||
if (!existent)
|
if (!existent)
|
||||||
ret = 0;
|
return 0;
|
||||||
else
|
else
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Resolving of %s failed",
|
"Resolving of %s failed",
|
||||||
data->hostname);
|
data->hostname);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Resolving succeeded. Should it? */
|
/* Resolving succeeded. Should it? */
|
||||||
@ -81,7 +80,7 @@ testGetHostByName(const void *opaque)
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Resolving of %s succeeded but was expected to fail",
|
"Resolving of %s succeeded but was expected to fail",
|
||||||
data->hostname);
|
data->hostname);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now lets see if resolved address match our expectations. */
|
/* Now lets see if resolved address match our expectations. */
|
||||||
@ -89,7 +88,7 @@ testGetHostByName(const void *opaque)
|
|||||||
if (!resolved.h_name) {
|
if (!resolved.h_name) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"resolved.h_name empty");
|
"resolved.h_name empty");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->af != AF_UNSPEC &&
|
if (data->af != AF_UNSPEC &&
|
||||||
@ -97,7 +96,7 @@ testGetHostByName(const void *opaque)
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Expected AF_INET (%d) got %d",
|
"Expected AF_INET (%d) got %d",
|
||||||
data->af, resolved.h_addrtype);
|
data->af, resolved.h_addrtype);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((resolved.h_addrtype == AF_INET && resolved.h_length != 4) ||
|
if ((resolved.h_addrtype == AF_INET && resolved.h_length != 4) ||
|
||||||
@ -107,13 +106,13 @@ testGetHostByName(const void *opaque)
|
|||||||
"Expected %d bytes long address, got %d",
|
"Expected %d bytes long address, got %d",
|
||||||
resolved.h_addrtype == AF_INET ? 4 : 16,
|
resolved.h_addrtype == AF_INET ? 4 : 16,
|
||||||
resolved.h_length);
|
resolved.h_length);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resolved.h_addr_list) {
|
if (!resolved.h_addr_list) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"resolved.h_addr_list empty");
|
"resolved.h_addr_list empty");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
addrList = resolved.h_addr_list;
|
addrList = resolved.h_addr_list;
|
||||||
@ -133,7 +132,7 @@ testGetHostByName(const void *opaque)
|
|||||||
|
|
||||||
if (!(ipAddr = virSocketAddrFormat(&sa))) {
|
if (!(ipAddr = virSocketAddrFormat(&sa))) {
|
||||||
/* error reported by helper */
|
/* error reported by helper */
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(data->ipAddr[i], ipAddr)) {
|
if (STRNEQ_NULLABLE(data->ipAddr[i], ipAddr)) {
|
||||||
@ -141,7 +140,7 @@ testGetHostByName(const void *opaque)
|
|||||||
"Unexpected address %s, expecting %s",
|
"Unexpected address %s, expecting %s",
|
||||||
ipAddr, NULLSTR(data->ipAddr[i]));
|
ipAddr, NULLSTR(data->ipAddr[i]));
|
||||||
VIR_FREE(ipAddr);
|
VIR_FREE(ipAddr);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
VIR_FREE(ipAddr);
|
VIR_FREE(ipAddr);
|
||||||
|
|
||||||
@ -153,12 +152,10 @@ testGetHostByName(const void *opaque)
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Expected %s address, got NULL",
|
"Expected %s address, got NULL",
|
||||||
data->ipAddr[i]);
|
data->ipAddr[i]);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -518,8 +518,7 @@ mymain(void)
|
|||||||
return EXIT_AM_SKIP;
|
return EXIT_AM_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = -1;
|
return EXIT_FAILURE;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virTestRun("ebiptablesAllTeardown",
|
if (virTestRun("ebiptablesAllTeardown",
|
||||||
@ -557,7 +556,6 @@ mymain(void)
|
|||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,24 +327,22 @@ static int testSetOneParameter(virHashTablePtr vars,
|
|||||||
const char *name,
|
const char *name,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
virNWFilterVarValuePtr val;
|
virNWFilterVarValuePtr val;
|
||||||
|
|
||||||
if ((val = virHashLookup(vars, name)) == NULL) {
|
if ((val = virHashLookup(vars, name)) == NULL) {
|
||||||
val = virNWFilterVarValueCreateSimpleCopyValue(value);
|
val = virNWFilterVarValueCreateSimpleCopyValue(value);
|
||||||
if (!val)
|
if (!val)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virHashUpdateEntry(vars, name, val) < 0) {
|
if (virHashUpdateEntry(vars, name, val) < 0) {
|
||||||
virNWFilterVarValueFree(val);
|
virNWFilterVarValueFree(val);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (virNWFilterVarValueAddValueCopy(val, value) < 0)
|
if (virNWFilterVarValueAddValueCopy(val, value) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = 0;
|
|
||||||
cleanup:
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testSetDefaultParameters(virHashTablePtr vars)
|
static int testSetDefaultParameters(virHashTablePtr vars)
|
||||||
@ -468,8 +466,7 @@ mymain(void)
|
|||||||
fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
|
fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
|
||||||
return EXIT_AM_SKIP;
|
return EXIT_AM_SKIP;
|
||||||
}
|
}
|
||||||
ret = -1;
|
return EXIT_FAILURE;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DO_TEST("ah");
|
DO_TEST("ah");
|
||||||
@ -512,7 +509,6 @@ mymain(void)
|
|||||||
DO_TEST("udplite-ipv6");
|
DO_TEST("udplite-ipv6");
|
||||||
DO_TEST("vlan");
|
DO_TEST("vlan");
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,17 +60,16 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
|
|||||||
virDomainObjPtr *vm,
|
virDomainObjPtr *vm,
|
||||||
const char *domxml)
|
const char *domxml)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
qemuDomainObjPrivatePtr priv = NULL;
|
qemuDomainObjPrivatePtr priv = NULL;
|
||||||
const unsigned int parseFlags = 0;
|
const unsigned int parseFlags = 0;
|
||||||
|
|
||||||
if (!(*vm = virDomainObjNew(xmlopt)))
|
if (!(*vm = virDomainObjNew(xmlopt)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
priv = (*vm)->privateData;
|
priv = (*vm)->privateData;
|
||||||
|
|
||||||
if (!(priv->qemuCaps = virQEMUCapsNew()))
|
if (!(priv->qemuCaps = virQEMUCapsNew()))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_SCSI);
|
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_SCSI);
|
||||||
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE);
|
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE);
|
||||||
@ -85,31 +84,29 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
|
|||||||
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA);
|
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA);
|
||||||
|
|
||||||
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0)
|
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!((*vm)->def = virDomainDefParseString(domxml,
|
if (!((*vm)->def = virDomainDefParseString(domxml,
|
||||||
driver.caps,
|
driver.caps,
|
||||||
driver.xmlopt,
|
driver.xmlopt,
|
||||||
NULL,
|
NULL,
|
||||||
parseFlags)))
|
parseFlags)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps,
|
if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps,
|
||||||
&driver, *vm, true) < 0) {
|
&driver, *vm, true) < 0) {
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuAssignDeviceAliases((*vm)->def, priv->qemuCaps) < 0)
|
if (qemuAssignDeviceAliases((*vm)->def, priv->qemuCaps) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
(*vm)->def->id = QEMU_HOTPLUG_TEST_DOMAIN_ID;
|
(*vm)->def->id = QEMU_HOTPLUG_TEST_DOMAIN_ID;
|
||||||
|
|
||||||
if (qemuDomainSetPrivatePaths(&driver, *vm) < 0)
|
if (qemuDomainSetPrivatePaths(&driver, *vm) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -359,10 +359,8 @@ testUpdateQEMUCaps(const struct testQemuInfo *info,
|
|||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
virCapsPtr caps)
|
virCapsPtr caps)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!caps)
|
if (!caps)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);
|
virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);
|
||||||
|
|
||||||
@ -370,17 +368,14 @@ testUpdateQEMUCaps(const struct testQemuInfo *info,
|
|||||||
|
|
||||||
if (testAddCPUModels(info->qemuCaps,
|
if (testAddCPUModels(info->qemuCaps,
|
||||||
!!(info->flags & FLAG_SKIP_LEGACY_CPUS)) < 0)
|
!!(info->flags & FLAG_SKIP_LEGACY_CPUS)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
|
virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
|
||||||
VIR_DOMAIN_VIRT_KVM);
|
VIR_DOMAIN_VIRT_KVM);
|
||||||
virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
|
virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
|
||||||
VIR_DOMAIN_VIRT_QEMU);
|
VIR_DOMAIN_VIRT_QEMU);
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ struct ConfigLookupData {
|
|||||||
|
|
||||||
static int testAuthLookup(const void *args)
|
static int testAuthLookup(const void *args)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
const struct ConfigLookupData *data = args;
|
const struct ConfigLookupData *data = args;
|
||||||
const char *actual = NULL;
|
const char *actual = NULL;
|
||||||
int rv;
|
int rv;
|
||||||
@ -53,7 +52,7 @@ static int testAuthLookup(const void *args)
|
|||||||
&actual);
|
&actual);
|
||||||
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (data->expect) {
|
if (data->expect) {
|
||||||
if (!actual ||
|
if (!actual ||
|
||||||
@ -62,7 +61,7 @@ static int testAuthLookup(const void *args)
|
|||||||
data->expect, data->hostname,
|
data->expect, data->hostname,
|
||||||
data->service, data->credname,
|
data->service, data->credname,
|
||||||
NULLSTR(actual));
|
NULLSTR(actual));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (actual) {
|
if (actual) {
|
||||||
@ -70,13 +69,11 @@ static int testAuthLookup(const void *args)
|
|||||||
data->hostname,
|
data->hostname,
|
||||||
data->service, data->credname,
|
data->service, data->credname,
|
||||||
actual);
|
actual);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,7 +104,6 @@ static int make_file(const char *path,
|
|||||||
|
|
||||||
static int make_controller_v1(const char *path, mode_t mode)
|
static int make_controller_v1(const char *path, mode_t mode)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
const char *controller;
|
const char *controller;
|
||||||
|
|
||||||
if (!STRPREFIX(path, fakesysfscgroupdir)) {
|
if (!STRPREFIX(path, fakesysfscgroupdir)) {
|
||||||
@ -119,12 +118,12 @@ static int make_controller_v1(const char *path, mode_t mode)
|
|||||||
return symlink("cpu,cpuacct", path);
|
return symlink("cpu,cpuacct", path);
|
||||||
|
|
||||||
if (real_mkdir(path, mode) < 0)
|
if (real_mkdir(path, mode) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
# define MAKE_FILE(name, value) \
|
# define MAKE_FILE(name, value) \
|
||||||
do { \
|
do { \
|
||||||
if (make_file(path, name, value) < 0) \
|
if (make_file(path, name, value) < 0) \
|
||||||
goto cleanup; \
|
return -1; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
if (STRPREFIX(controller, "cpu,cpuacct")) {
|
if (STRPREFIX(controller, "cpu,cpuacct")) {
|
||||||
@ -225,14 +224,12 @@ static int make_controller_v1(const char *path, mode_t mode)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# undef MAKE_FILE
|
# undef MAKE_FILE
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,38 +30,35 @@ test1(const void *data G_GNUC_UNUSED)
|
|||||||
* unaligned access. */
|
* unaligned access. */
|
||||||
char array[] = { 1, 2, 3, 4, 5, 6, 7, 8,
|
char array[] = { 1, 2, 3, 4, 5, 6, 7, 8,
|
||||||
0x89, 0x8a, 0x8b, 0x8c, 0x8d };
|
0x89, 0x8a, 0x8b, 0x8c, 0x8d };
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (virReadBufInt64BE(array) != 0x0102030405060708ULL)
|
if (virReadBufInt64BE(array) != 0x0102030405060708ULL)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt64BE(array + 5) != 0x060708898a8b8c8dULL)
|
if (virReadBufInt64BE(array + 5) != 0x060708898a8b8c8dULL)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt64LE(array) != 0x0807060504030201ULL)
|
if (virReadBufInt64LE(array) != 0x0807060504030201ULL)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt64LE(array + 5) != 0x8d8c8b8a89080706ULL)
|
if (virReadBufInt64LE(array + 5) != 0x8d8c8b8a89080706ULL)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virReadBufInt32BE(array) != 0x01020304U)
|
if (virReadBufInt32BE(array) != 0x01020304U)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt32BE(array + 9) != 0x8a8b8c8dU)
|
if (virReadBufInt32BE(array + 9) != 0x8a8b8c8dU)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt32LE(array) != 0x04030201U)
|
if (virReadBufInt32LE(array) != 0x04030201U)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt32LE(array + 9) != 0x8d8c8b8aU)
|
if (virReadBufInt32LE(array + 9) != 0x8d8c8b8aU)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virReadBufInt16BE(array) != 0x0102U)
|
if (virReadBufInt16BE(array) != 0x0102U)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt16BE(array + 11) != 0x8c8dU)
|
if (virReadBufInt16BE(array + 11) != 0x8c8dU)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt16LE(array) != 0x0201U)
|
if (virReadBufInt16LE(array) != 0x0201U)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt16LE(array + 11) != 0x8d8cU)
|
if (virReadBufInt16LE(array + 11) != 0x8d8cU)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -70,38 +67,35 @@ test2(const void *data G_GNUC_UNUSED)
|
|||||||
/* Unsigned char should work without cast, even if unaligned access. */
|
/* Unsigned char should work without cast, even if unaligned access. */
|
||||||
unsigned char array[] = { 1, 2, 3, 4, 5, 6, 7, 8,
|
unsigned char array[] = { 1, 2, 3, 4, 5, 6, 7, 8,
|
||||||
0x89, 0x8a, 0x8b, 0x8c, 0x8d };
|
0x89, 0x8a, 0x8b, 0x8c, 0x8d };
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (virReadBufInt64BE(array) != 0x0102030405060708ULL)
|
if (virReadBufInt64BE(array) != 0x0102030405060708ULL)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt64BE(array + 5) != 0x060708898a8b8c8dULL)
|
if (virReadBufInt64BE(array + 5) != 0x060708898a8b8c8dULL)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt64LE(array) != 0x0807060504030201ULL)
|
if (virReadBufInt64LE(array) != 0x0807060504030201ULL)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt64LE(array + 5) != 0x8d8c8b8a89080706ULL)
|
if (virReadBufInt64LE(array + 5) != 0x8d8c8b8a89080706ULL)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virReadBufInt32BE(array) != 0x01020304U)
|
if (virReadBufInt32BE(array) != 0x01020304U)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt32BE(array + 9) != 0x8a8b8c8dU)
|
if (virReadBufInt32BE(array + 9) != 0x8a8b8c8dU)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt32LE(array) != 0x04030201U)
|
if (virReadBufInt32LE(array) != 0x04030201U)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt32LE(array + 9) != 0x8d8c8b8aU)
|
if (virReadBufInt32LE(array + 9) != 0x8d8c8b8aU)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virReadBufInt16BE(array) != 0x0102U)
|
if (virReadBufInt16BE(array) != 0x0102U)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt16BE(array + 11) != 0x8c8dU)
|
if (virReadBufInt16BE(array + 11) != 0x8c8dU)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt16LE(array) != 0x0201U)
|
if (virReadBufInt16LE(array) != 0x0201U)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virReadBufInt16LE(array + 11) != 0x8d8cU)
|
if (virReadBufInt16LE(array + 11) != 0x8d8cU)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -35,7 +35,6 @@ VIR_LOG_INIT("tests.keycodetest");
|
|||||||
|
|
||||||
static int testKeycodeMapping(const void *data G_GNUC_UNUSED)
|
static int testKeycodeMapping(const void *data G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
int got;
|
int got;
|
||||||
|
|
||||||
#define TRANSLATE(from, to, val, want) \
|
#define TRANSLATE(from, to, val, want) \
|
||||||
@ -45,7 +44,7 @@ static int testKeycodeMapping(const void *data G_GNUC_UNUSED)
|
|||||||
val)) != want) { \
|
val)) != want) { \
|
||||||
fprintf(stderr, "Translating %d from %s to %s, got %d want %d\n", \
|
fprintf(stderr, "Translating %d from %s to %s, got %d want %d\n", \
|
||||||
val, #from, #to, got, want); \
|
val, #from, #to, got, want); \
|
||||||
goto cleanup; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@ -60,15 +59,12 @@ static int testKeycodeMapping(const void *data G_GNUC_UNUSED)
|
|||||||
|
|
||||||
#undef TRANSLATE
|
#undef TRANSLATE
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testKeycodeStrings(const void *data G_GNUC_UNUSED)
|
static int testKeycodeStrings(const void *data G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
int got;
|
int got;
|
||||||
|
|
||||||
#define TRANSLATE(from, str, want) \
|
#define TRANSLATE(from, str, want) \
|
||||||
@ -77,7 +73,7 @@ static int testKeycodeStrings(const void *data G_GNUC_UNUSED)
|
|||||||
str)) != want) { \
|
str)) != want) { \
|
||||||
fprintf(stderr, "Converting %s from %s, got %d want %d\n", \
|
fprintf(stderr, "Converting %s from %s, got %d want %d\n", \
|
||||||
str, #from, got, want); \
|
str, #from, got, want); \
|
||||||
goto cleanup; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@ -90,9 +86,7 @@ static int testKeycodeStrings(const void *data G_GNUC_UNUSED)
|
|||||||
|
|
||||||
#undef TRANSLATE
|
#undef TRANSLATE
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -164,8 +164,7 @@ mymain(void)
|
|||||||
#define DO_TEST_FLUSH_PROLOGUE \
|
#define DO_TEST_FLUSH_PROLOGUE \
|
||||||
do { \
|
do { \
|
||||||
if (!(mgr = virMacMapNew(NULL))) { \
|
if (!(mgr = virMacMapNew(NULL))) { \
|
||||||
ret = -1; \
|
return EXIT_FAILURE; \
|
||||||
goto cleanup; \
|
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@ -222,7 +221,7 @@ mymain(void)
|
|||||||
DO_TEST_FLUSH("dom1", "9e:89:49:99:51:0e", "89:b4:3f:08:88:2c", "54:0b:4c:e2:0a:39");
|
DO_TEST_FLUSH("dom1", "9e:89:49:99:51:0e", "89:b4:3f:08:88:2c", "54:0b:4c:e2:0a:39");
|
||||||
DO_TEST_FLUSH("dom1", "bb:88:07:19:51:9d", "b7:f1:1a:40:a2:95", "88:94:39:a3:90:b4");
|
DO_TEST_FLUSH("dom1", "bb:88:07:19:51:9d", "b7:f1:1a:40:a2:95", "88:94:39:a3:90:b4");
|
||||||
DO_TEST_FLUSH_EPILOGUE("complex");
|
DO_TEST_FLUSH_EPILOGUE("complex");
|
||||||
cleanup:
|
|
||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,31 +35,28 @@ struct testVirNetDevGetLinkInfoData {
|
|||||||
static int
|
static int
|
||||||
testVirNetDevGetLinkInfo(const void *opaque)
|
testVirNetDevGetLinkInfo(const void *opaque)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
const struct testVirNetDevGetLinkInfoData *data = opaque;
|
const struct testVirNetDevGetLinkInfoData *data = opaque;
|
||||||
virNetDevIfLink lnk;
|
virNetDevIfLink lnk;
|
||||||
|
|
||||||
if (virNetDevGetLinkInfo(data->ifname, &lnk) < 0)
|
if (virNetDevGetLinkInfo(data->ifname, &lnk) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (lnk.state != data->state) {
|
if (lnk.state != data->state) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Fetched link state (%s) doesn't match the expected one (%s)",
|
"Fetched link state (%s) doesn't match the expected one (%s)",
|
||||||
virNetDevIfStateTypeToString(lnk.state),
|
virNetDevIfStateTypeToString(lnk.state),
|
||||||
virNetDevIfStateTypeToString(data->state));
|
virNetDevIfStateTypeToString(data->state));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lnk.speed != data->speed) {
|
if (lnk.speed != data->speed) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Fetched link speed (%u) doesn't match the expected one (%u)",
|
"Fetched link speed (%u) doesn't match the expected one (%u)",
|
||||||
lnk.speed, data->speed);
|
lnk.speed, data->speed);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -298,7 +298,6 @@ find_fd(int fd, size_t *indx)
|
|||||||
static int
|
static int
|
||||||
add_fd(int fd, const char *path)
|
add_fd(int fd, const char *path)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (find_fd(fd, &i)) {
|
if (find_fd(fd, &i)) {
|
||||||
@ -309,38 +308,34 @@ add_fd(int fd, const char *path)
|
|||||||
|
|
||||||
if (VIR_REALLOC_N_QUIET(callbacks, nCallbacks + 1) < 0) {
|
if (VIR_REALLOC_N_QUIET(callbacks, nCallbacks + 1) < 0) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
callbacks[nCallbacks].path = g_strdup(path);
|
callbacks[nCallbacks].path = g_strdup(path);
|
||||||
callbacks[nCallbacks++].fd = fd;
|
callbacks[nCallbacks++].fd = fd;
|
||||||
ret = 0;
|
|
||||||
cleanup:
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
remove_fd(int fd)
|
remove_fd(int fd)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (find_fd(fd, &i)) {
|
if (find_fd(fd, &i)) {
|
||||||
struct fdCallback cb = callbacks[i];
|
struct fdCallback cb = callbacks[i];
|
||||||
|
|
||||||
if (pci_driver_handle_change(cb.fd, cb.path) < 0)
|
if (pci_driver_handle_change(cb.fd, cb.path) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
VIR_FREE(cb.path);
|
VIR_FREE(cb.path);
|
||||||
if (VIR_DELETE_ELEMENT(callbacks, i, nCallbacks) < 0) {
|
if (VIR_DELETE_ELEMENT(callbacks, i, nCallbacks) < 0) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -907,36 +902,30 @@ pci_driver_handle_change(int fd G_GNUC_UNUSED, const char *path)
|
|||||||
static int
|
static int
|
||||||
pci_driver_handle_bind(const char *path)
|
pci_driver_handle_bind(const char *path)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
struct pciDevice *dev = pci_device_find_by_content(path);
|
struct pciDevice *dev = pci_device_find_by_content(path);
|
||||||
struct pciDriver *driver = pci_driver_find_by_path(path);
|
struct pciDriver *driver = pci_driver_find_by_path(path);
|
||||||
|
|
||||||
if (!driver || !dev) {
|
if (!driver || !dev) {
|
||||||
/* No driver, no device or failing driver requested */
|
/* No driver, no device or failing driver requested */
|
||||||
errno = ENODEV;
|
errno = ENODEV;
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pci_driver_bind(driver, dev);
|
return pci_driver_bind(driver, dev);
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pci_driver_handle_unbind(const char *path)
|
pci_driver_handle_unbind(const char *path)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
struct pciDevice *dev = pci_device_find_by_content(path);
|
struct pciDevice *dev = pci_device_find_by_content(path);
|
||||||
|
|
||||||
if (!dev || !dev->driver) {
|
if (!dev || !dev->driver) {
|
||||||
/* No device, device not binded or failing driver requested */
|
/* No device, device not binded or failing driver requested */
|
||||||
errno = ENODEV;
|
errno = ENODEV;
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pci_driver_unbind(dev->driver, dev);
|
return pci_driver_unbind(dev->driver, dev);
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,13 +224,12 @@ testVirPCIDeviceIsAssignable(const void *opaque)
|
|||||||
virPCIDevicePtr dev;
|
virPCIDevicePtr dev;
|
||||||
|
|
||||||
if (!(dev = virPCIDeviceNew(data->domain, data->bus, data->slot, data->function)))
|
if (!(dev = virPCIDeviceNew(data->domain, data->bus, data->slot, data->function)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virPCIDeviceIsAssignable(dev, true))
|
if (virPCIDeviceIsAssignable(dev, true))
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
virPCIDeviceFree(dev);
|
virPCIDeviceFree(dev);
|
||||||
cleanup:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,26 +145,20 @@ VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_and_block,
|
|||||||
|
|
||||||
static int testPolkitAuthSuccess(const void *opaque G_GNUC_UNUSED)
|
static int testPolkitAuthSuccess(const void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (virPolkitCheckAuth("org.libvirt.test.success",
|
if (virPolkitCheckAuth("org.libvirt.test.success",
|
||||||
THE_PID,
|
THE_PID,
|
||||||
THE_TIME,
|
THE_TIME,
|
||||||
THE_UID,
|
THE_UID,
|
||||||
NULL,
|
NULL,
|
||||||
true) < 0)
|
true) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testPolkitAuthDenied(const void *opaque G_GNUC_UNUSED)
|
static int testPolkitAuthDenied(const void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
int rv;
|
int rv;
|
||||||
virErrorPtr err;
|
virErrorPtr err;
|
||||||
|
|
||||||
@ -177,28 +171,24 @@ static int testPolkitAuthDenied(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
fprintf(stderr, "Unexpected auth success\n");
|
fprintf(stderr, "Unexpected auth success\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else if (rv != -2) {
|
} else if (rv != -2) {
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = virGetLastError();
|
err = virGetLastError();
|
||||||
if (!err || !strstr(err->message,
|
if (!err || !strstr(err->message,
|
||||||
_("access denied by policy"))) {
|
_("access denied by policy"))) {
|
||||||
fprintf(stderr, "Incorrect error response\n");
|
fprintf(stderr, "Incorrect error response\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testPolkitAuthChallenge(const void *opaque G_GNUC_UNUSED)
|
static int testPolkitAuthChallenge(const void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
int rv;
|
int rv;
|
||||||
virErrorPtr err;
|
virErrorPtr err;
|
||||||
|
|
||||||
@ -211,9 +201,9 @@ static int testPolkitAuthChallenge(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
fprintf(stderr, "Unexpected auth success\n");
|
fprintf(stderr, "Unexpected auth success\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else if (rv != -2) {
|
} else if (rv != -2) {
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = virGetLastError();
|
err = virGetLastError();
|
||||||
@ -221,19 +211,15 @@ static int testPolkitAuthChallenge(const void *opaque G_GNUC_UNUSED)
|
|||||||
err->code != VIR_ERR_AUTH_UNAVAILABLE ||
|
err->code != VIR_ERR_AUTH_UNAVAILABLE ||
|
||||||
!strstr(err->message, _("no polkit agent available to authenticate"))) {
|
!strstr(err->message, _("no polkit agent available to authenticate"))) {
|
||||||
fprintf(stderr, "Incorrect error response\n");
|
fprintf(stderr, "Incorrect error response\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testPolkitAuthCancelled(const void *opaque G_GNUC_UNUSED)
|
static int testPolkitAuthCancelled(const void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
int rv;
|
int rv;
|
||||||
virErrorPtr err;
|
virErrorPtr err;
|
||||||
|
|
||||||
@ -246,28 +232,24 @@ static int testPolkitAuthCancelled(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
fprintf(stderr, "Unexpected auth success\n");
|
fprintf(stderr, "Unexpected auth success\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else if (rv != -2) {
|
} else if (rv != -2) {
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = virGetLastError();
|
err = virGetLastError();
|
||||||
if (!err || !strstr(err->message,
|
if (!err || !strstr(err->message,
|
||||||
_("user cancelled authentication process"))) {
|
_("user cancelled authentication process"))) {
|
||||||
fprintf(stderr, "Incorrect error response\n");
|
fprintf(stderr, "Incorrect error response\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testPolkitAuthDetailsSuccess(const void *opaque G_GNUC_UNUSED)
|
static int testPolkitAuthDetailsSuccess(const void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
const char *details[] = {
|
const char *details[] = {
|
||||||
"org.libvirt.test.person", "Fred",
|
"org.libvirt.test.person", "Fred",
|
||||||
NULL,
|
NULL,
|
||||||
@ -279,18 +261,14 @@ static int testPolkitAuthDetailsSuccess(const void *opaque G_GNUC_UNUSED)
|
|||||||
THE_UID,
|
THE_UID,
|
||||||
details,
|
details,
|
||||||
true) < 0)
|
true) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testPolkitAuthDetailsDenied(const void *opaque G_GNUC_UNUSED)
|
static int testPolkitAuthDetailsDenied(const void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
int rv;
|
int rv;
|
||||||
virErrorPtr err;
|
virErrorPtr err;
|
||||||
const char *details[] = {
|
const char *details[] = {
|
||||||
@ -307,22 +285,19 @@ static int testPolkitAuthDetailsDenied(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
fprintf(stderr, "Unexpected auth success\n");
|
fprintf(stderr, "Unexpected auth success\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else if (rv != -2) {
|
} else if (rv != -2) {
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = virGetLastError();
|
err = virGetLastError();
|
||||||
if (!err || !strstr(err->message,
|
if (!err || !strstr(err->message,
|
||||||
_("access denied by policy"))) {
|
_("access denied by policy"))) {
|
||||||
fprintf(stderr, "Incorrect error response\n");
|
fprintf(stderr, "Incorrect error response\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ struct testStreqData {
|
|||||||
static int testStreq(const void *args)
|
static int testStreq(const void *args)
|
||||||
{
|
{
|
||||||
const struct testStreqData *data = args;
|
const struct testStreqData *data = args;
|
||||||
int ret = -1;
|
|
||||||
bool equal = true;
|
bool equal = true;
|
||||||
bool streq_rv, strneq_rv;
|
bool streq_rv, strneq_rv;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -63,19 +62,17 @@ static int testStreq(const void *args)
|
|||||||
virFilePrintf(stderr,
|
virFilePrintf(stderr,
|
||||||
"STREQ not working correctly. Expected %d got %d",
|
"STREQ not working correctly. Expected %d got %d",
|
||||||
(int) equal, (int) streq_rv);
|
(int) equal, (int) streq_rv);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strneq_rv == equal) {
|
if (strneq_rv == equal) {
|
||||||
virFilePrintf(stderr,
|
virFilePrintf(stderr,
|
||||||
"STRNEQ not working correctly. Expected %d got %d",
|
"STRNEQ not working correctly. Expected %d got %d",
|
||||||
(int) equal, (int) strneq_rv);
|
(int) equal, (int) strneq_rv);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct testSplitData {
|
struct testSplitData {
|
||||||
@ -381,7 +378,6 @@ testStringSortCompare(const void *opaque G_GNUC_UNUSED)
|
|||||||
const char *sortrlist[] = {
|
const char *sortrlist[] = {
|
||||||
"turducken", "tasty", "goat", "chicken", "astro",
|
"turducken", "tasty", "goat", "chicken", "astro",
|
||||||
};
|
};
|
||||||
int ret = -1;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
qsort(randlist, G_N_ELEMENTS(randlist), sizeof(randlist[0]),
|
qsort(randlist, G_N_ELEMENTS(randlist), sizeof(randlist[0]),
|
||||||
@ -393,18 +389,16 @@ testStringSortCompare(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (STRNEQ(randlist[i], sortlist[i])) {
|
if (STRNEQ(randlist[i], sortlist[i])) {
|
||||||
fprintf(stderr, "sortlist[%zu] '%s' != randlist[%zu] '%s'\n",
|
fprintf(stderr, "sortlist[%zu] '%s' != randlist[%zu] '%s'\n",
|
||||||
i, sortlist[i], i, randlist[i]);
|
i, sortlist[i], i, randlist[i]);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (STRNEQ(randrlist[i], sortrlist[i])) {
|
if (STRNEQ(randrlist[i], sortrlist[i])) {
|
||||||
fprintf(stderr, "sortrlist[%zu] '%s' != randrlist[%zu] '%s'\n",
|
fprintf(stderr, "sortrlist[%zu] '%s' != randrlist[%zu] '%s'\n",
|
||||||
i, sortrlist[i], i, randrlist[i]);
|
i, sortrlist[i], i, randrlist[i]);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user