mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
tests: Introduce chxml2xmlmock
As of previous commit, the CH driver checks for /dev/kvm and/or
/dev/mshv presence. In order to make chxml2xmltest work
regardless of host configuration, introduce a mock that pretends
both of these files are accessible.
Fixes: 51c14df967
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
f432114d9c
commit
0be6e26469
20
tests/chxml2xmlmock.c
Normal file
20
tests/chxml2xmlmock.c
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Red Hat, Inc.
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
#include "virfile.h"
|
||||||
|
|
||||||
|
bool
|
||||||
|
virFileExists(const char *path)
|
||||||
|
{
|
||||||
|
if (STREQ(path, "/dev/kvm"))
|
||||||
|
return true;
|
||||||
|
if (STREQ(path, "/dev/mshv"))
|
||||||
|
return true;
|
||||||
|
return access(path, F_OK) == 0;
|
||||||
|
}
|
@ -74,4 +74,4 @@ mymain(void)
|
|||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_TEST_MAIN(mymain)
|
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("chxml2xml"))
|
||||||
|
@ -350,6 +350,9 @@ if conf.has('WITH_CH')
|
|||||||
tests += [
|
tests += [
|
||||||
{ 'name': 'chxml2xmltest', 'link_with': [ ch_driver_impl ] },
|
{ 'name': 'chxml2xmltest', 'link_with': [ ch_driver_impl ] },
|
||||||
]
|
]
|
||||||
|
mock_libs += [
|
||||||
|
{ 'name': 'chxml2xmlmock' },
|
||||||
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if conf.has('WITH_ESX')
|
if conf.has('WITH_ESX')
|
||||||
|
Loading…
Reference in New Issue
Block a user