mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
tests: Decouple preload code from main()
The new VIRT_TEST_PRELOAD macro does not force the caller to create a special main function which would need to be called through virtTestMain(). Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
dd214b5fb6
commit
18f63c17a4
@ -110,8 +110,8 @@ int virtTestMain(int argc,
|
||||
return virtTestMain(argc, argv, func); \
|
||||
}
|
||||
|
||||
# define VIRT_TEST_MAIN_PRELOAD(func, lib) \
|
||||
int main(int argc, char **argv) { \
|
||||
# define VIRT_TEST_PRELOAD(lib) \
|
||||
do { \
|
||||
const char *preload = getenv("LD_PRELOAD"); \
|
||||
if (preload == NULL || strstr(preload, lib) == NULL) { \
|
||||
char *newenv; \
|
||||
@ -128,6 +128,11 @@ int virtTestMain(int argc,
|
||||
setenv("LD_PRELOAD", newenv, 1); \
|
||||
execv(argv[0], argv); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
# define VIRT_TEST_MAIN_PRELOAD(func, lib) \
|
||||
int main(int argc, char **argv) { \
|
||||
VIRT_TEST_PRELOAD(lib); \
|
||||
return virtTestMain(argc, argv, func); \
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user