mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 10:10:06 +00:00
fix macOS build for plugin unit test
MR !10753 breaks macOS build for plugin unit test as its linker doesn't supports `--wrap` option, which is used in in order to mock the function `isc_file_exits()`. To work around the problem, a mocked `isc_file_exits()` is implemented inside the plugin test as a static function before inlining the file using it, which effectively links to this version rather than the isclib one.
This commit is contained in:
parent
c28b1436b9
commit
1b6347483e
@ -14,12 +14,6 @@ foreach unit : [
|
|||||||
'plugin',
|
'plugin',
|
||||||
'query',
|
'query',
|
||||||
]
|
]
|
||||||
linkargs = ''
|
|
||||||
if unit == 'plugin'
|
|
||||||
linkargs = [
|
|
||||||
'-Wl,--wrap=isc_file_exists',
|
|
||||||
]
|
|
||||||
endif
|
|
||||||
test_bin = executable(
|
test_bin = executable(
|
||||||
unit,
|
unit,
|
||||||
files(f'@unit@_test.c', 'netmgr_wrap.c'),
|
files(f'@unit@_test.c', 'netmgr_wrap.c'),
|
||||||
@ -37,7 +31,6 @@ foreach unit : [
|
|||||||
cmocka_dep,
|
cmocka_dep,
|
||||||
nghttp2_dep,
|
nghttp2_dep,
|
||||||
],
|
],
|
||||||
link_args: linkargs,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
test(
|
test(
|
||||||
|
@ -34,17 +34,18 @@
|
|||||||
|
|
||||||
#include <dns/lib.h>
|
#include <dns/lib.h>
|
||||||
|
|
||||||
#include "../ns/hooks.c"
|
/*
|
||||||
|
* Mocking isc_file_exists() as it's used inside the tested
|
||||||
bool
|
* ns_plugin_expandpath() function defined in lib/ns/hooks.c
|
||||||
__wrap_isc_file_exists(const char *pathname);
|
*/
|
||||||
|
static bool
|
||||||
bool
|
isc_file_exists(const char *pathname) {
|
||||||
__wrap_isc_file_exists(const char *pathname) {
|
|
||||||
UNUSED(pathname);
|
UNUSED(pathname);
|
||||||
return mock();
|
return mock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "../ns/hooks.c"
|
||||||
|
|
||||||
#include <tests/ns.h>
|
#include <tests/ns.h>
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
@ -75,7 +76,7 @@ run_full_path_test(const ns_plugin_expandpath_test_params_t *test,
|
|||||||
REQUIRE(test->result != ISC_R_SUCCESS || test->output != NULL);
|
REQUIRE(test->result != ISC_R_SUCCESS || test->output != NULL);
|
||||||
|
|
||||||
if (test->result == ISC_R_SUCCESS) {
|
if (test->result == ISC_R_SUCCESS) {
|
||||||
will_return(__wrap_isc_file_exists, test->exists);
|
will_return(isc_file_exists, test->exists);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user