mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 04:25:19 +00:00
tests: Add macOS support to qemuxml2*test
The new DO_TEST_MACOS() macro makes it possible to create test cases that verify the behavior of libvirt on a macOS machine with HVF support available. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Tested-by: Brad Laue <brad@brad-x.com> Tested-by: Christophe Fergeau <cfergeau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
5fd9ddfa1f
commit
ebb921cb37
@ -39,6 +39,8 @@
|
|||||||
# define VIR_FROM_THIS VIR_FROM_QEMU
|
# define VIR_FROM_THIS VIR_FROM_QEMU
|
||||||
|
|
||||||
static virQEMUDriver driver;
|
static virQEMUDriver driver;
|
||||||
|
static virCaps *linuxCaps;
|
||||||
|
static virCaps *macOSCaps;
|
||||||
|
|
||||||
static unsigned char *
|
static unsigned char *
|
||||||
fakeSecretGetValue(virSecretPtr obj G_GNUC_UNUSED,
|
fakeSecretGetValue(virSecretPtr obj G_GNUC_UNUSED,
|
||||||
@ -716,12 +718,18 @@ testCompareXMLToArgv(const void *data)
|
|||||||
g_autofree char *archstr = NULL;
|
g_autofree char *archstr = NULL;
|
||||||
virArch arch = VIR_ARCH_NONE;
|
virArch arch = VIR_ARCH_NONE;
|
||||||
g_autoptr(virIdentity) sysident = virIdentityGetSystem();
|
g_autoptr(virIdentity) sysident = virIdentityGetSystem();
|
||||||
|
int rc;
|
||||||
|
|
||||||
memset(&monitor_chr, 0, sizeof(monitor_chr));
|
memset(&monitor_chr, 0, sizeof(monitor_chr));
|
||||||
|
|
||||||
if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0)
|
if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (info->args.hostOS == HOST_OS_MACOS)
|
||||||
|
driver.caps = macOSCaps;
|
||||||
|
else
|
||||||
|
driver.caps = linuxCaps;
|
||||||
|
|
||||||
if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
|
if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
|
||||||
qemuTestSetHostArch(&driver, info->arch);
|
qemuTestSetHostArch(&driver, info->arch);
|
||||||
|
|
||||||
@ -771,7 +779,11 @@ testCompareXMLToArgv(const void *data)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
|
if (info->args.hostOS == HOST_OS_MACOS)
|
||||||
|
rc = qemuTestCapsCacheInsertMacOS(driver.qemuCapsCache, info->qemuCaps);
|
||||||
|
else
|
||||||
|
rc = qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps);
|
||||||
|
if (rc < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (info->migrateFrom &&
|
if (info->migrateFrom &&
|
||||||
@ -934,6 +946,13 @@ mymain(void)
|
|||||||
if (qemuTestDriverInit(&driver) < 0)
|
if (qemuTestDriverInit(&driver) < 0)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
/* By default, the driver gets a virCaps instance that's suitable for
|
||||||
|
* tests that expect Linux as the host OS. We create another one for
|
||||||
|
* macOS and keep around pointers to both: this allows us to later
|
||||||
|
* pick the appropriate one for each test case */
|
||||||
|
linuxCaps = driver.caps;
|
||||||
|
macOSCaps = testQemuCapsInitMacOS();
|
||||||
|
|
||||||
driver.privileged = true;
|
driver.privileged = true;
|
||||||
|
|
||||||
VIR_FREE(driver.config->defaultTLSx509certdir);
|
VIR_FREE(driver.config->defaultTLSx509certdir);
|
||||||
@ -1074,6 +1093,10 @@ mymain(void)
|
|||||||
DO_TEST_FULL(name, "", \
|
DO_TEST_FULL(name, "", \
|
||||||
ARG_GIC, gic, \
|
ARG_GIC, gic, \
|
||||||
ARG_QEMU_CAPS, __VA_ARGS__, QEMU_CAPS_LAST, ARG_END)
|
ARG_QEMU_CAPS, __VA_ARGS__, QEMU_CAPS_LAST, ARG_END)
|
||||||
|
# define DO_TEST_MACOS(name, ...) \
|
||||||
|
DO_TEST_FULL(name, "", \
|
||||||
|
ARG_HOST_OS, HOST_OS_MACOS, \
|
||||||
|
ARG_QEMU_CAPS, __VA_ARGS__, QEMU_CAPS_LAST, ARG_END)
|
||||||
|
|
||||||
# define DO_TEST_FAILURE(name, ...) \
|
# define DO_TEST_FAILURE(name, ...) \
|
||||||
DO_TEST_FULL(name, "", \
|
DO_TEST_FULL(name, "", \
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
static virQEMUDriver driver;
|
static virQEMUDriver driver;
|
||||||
|
static virCaps *linuxCaps;
|
||||||
|
static virCaps *macOSCaps;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
WHEN_INACTIVE = 1,
|
WHEN_INACTIVE = 1,
|
||||||
@ -32,13 +34,24 @@ enum {
|
|||||||
static int
|
static int
|
||||||
testXML2XMLCommon(const struct testQemuInfo *info)
|
testXML2XMLCommon(const struct testQemuInfo *info)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0)
|
if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (info->args.hostOS == HOST_OS_MACOS)
|
||||||
|
driver.caps = macOSCaps;
|
||||||
|
else
|
||||||
|
driver.caps = linuxCaps;
|
||||||
|
|
||||||
if (!(info->flags & FLAG_REAL_CAPS))
|
if (!(info->flags & FLAG_REAL_CAPS))
|
||||||
virQEMUCapsInitQMPBasicArch(info->qemuCaps);
|
virQEMUCapsInitQMPBasicArch(info->qemuCaps);
|
||||||
|
|
||||||
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
|
if (info->args.hostOS == HOST_OS_MACOS)
|
||||||
|
rc = qemuTestCapsCacheInsertMacOS(driver.qemuCapsCache, info->qemuCaps);
|
||||||
|
else
|
||||||
|
rc = qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps);
|
||||||
|
if (rc < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -143,6 +156,13 @@ mymain(void)
|
|||||||
if (qemuTestDriverInit(&driver) < 0)
|
if (qemuTestDriverInit(&driver) < 0)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
/* By default, the driver gets a virCaps instance that's suitable for
|
||||||
|
* tests that expect Linux as the host OS. We create another one for
|
||||||
|
* macOS and keep around pointers to both: this allows us to later
|
||||||
|
* pick the appropriate one for each test case */
|
||||||
|
linuxCaps = driver.caps;
|
||||||
|
macOSCaps = testQemuCapsInitMacOS();
|
||||||
|
|
||||||
cfg = virQEMUDriverGetConfig(&driver);
|
cfg = virQEMUDriverGetConfig(&driver);
|
||||||
driver.privileged = true;
|
driver.privileged = true;
|
||||||
|
|
||||||
@ -206,6 +226,11 @@ mymain(void)
|
|||||||
#define DO_TEST_NOCAPS(name) \
|
#define DO_TEST_NOCAPS(name) \
|
||||||
DO_TEST_FULL(name, "", WHEN_BOTH, ARG_END)
|
DO_TEST_FULL(name, "", WHEN_BOTH, ARG_END)
|
||||||
|
|
||||||
|
#define DO_TEST_MACOS(name, ...) \
|
||||||
|
DO_TEST_FULL(name, "", WHEN_BOTH, \
|
||||||
|
ARG_HOST_OS, HOST_OS_MACOS, \
|
||||||
|
ARG_QEMU_CAPS, __VA_ARGS__, QEMU_CAPS_LAST, ARG_END)
|
||||||
|
|
||||||
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
|
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
|
||||||
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
||||||
* values for these envvars */
|
* values for these envvars */
|
||||||
|
@ -870,6 +870,10 @@ testQemuInfoSetArgs(struct testQemuInfo *info,
|
|||||||
info->args.capsver = va_arg(argptr, char *);
|
info->args.capsver = va_arg(argptr, char *);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ARG_HOST_OS:
|
||||||
|
info->args.hostOS = va_arg(argptr, int);
|
||||||
|
break;
|
||||||
|
|
||||||
case ARG_END:
|
case ARG_END:
|
||||||
default:
|
default:
|
||||||
info->args.invalidarg = true;
|
info->args.invalidarg = true;
|
||||||
|
@ -47,6 +47,7 @@ typedef enum {
|
|||||||
ARG_PARSEFLAGS,
|
ARG_PARSEFLAGS,
|
||||||
ARG_CAPS_ARCH,
|
ARG_CAPS_ARCH,
|
||||||
ARG_CAPS_VER,
|
ARG_CAPS_VER,
|
||||||
|
ARG_HOST_OS,
|
||||||
ARG_END,
|
ARG_END,
|
||||||
} testQemuInfoArgName;
|
} testQemuInfoArgName;
|
||||||
|
|
||||||
@ -72,6 +73,7 @@ struct testQemuArgs {
|
|||||||
char *capsver;
|
char *capsver;
|
||||||
char *capsarch;
|
char *capsarch;
|
||||||
int gic;
|
int gic;
|
||||||
|
testQemuHostOS hostOS;
|
||||||
bool invalidarg;
|
bool invalidarg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user