diff --git a/tests/chxml2xmlmock.c b/tests/chxml2xmlmock.c new file mode 100644 index 0000000000..d4d7b34947 --- /dev/null +++ b/tests/chxml2xmlmock.c @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Red Hat, Inc. + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include +#include + +#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; +} diff --git a/tests/chxml2xmltest.c b/tests/chxml2xmltest.c index 97b485dc4a..a5a75a1505 100644 --- a/tests/chxml2xmltest.c +++ b/tests/chxml2xmltest.c @@ -74,4 +74,4 @@ mymain(void) return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("chxml2xml")) diff --git a/tests/meson.build b/tests/meson.build index 4fc00e27da..3fcfa6b1e0 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -350,6 +350,9 @@ if conf.has('WITH_CH') tests += [ { 'name': 'chxml2xmltest', 'link_with': [ ch_driver_impl ] }, ] + mock_libs += [ + { 'name': 'chxml2xmlmock' }, + ] endif if conf.has('WITH_ESX')