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); \
|
return virtTestMain(argc, argv, func); \
|
||||||
}
|
}
|
||||||
|
|
||||||
# define VIRT_TEST_MAIN_PRELOAD(func, lib) \
|
# define VIRT_TEST_PRELOAD(lib) \
|
||||||
int main(int argc, char **argv) { \
|
do { \
|
||||||
const char *preload = getenv("LD_PRELOAD"); \
|
const char *preload = getenv("LD_PRELOAD"); \
|
||||||
if (preload == NULL || strstr(preload, lib) == NULL) { \
|
if (preload == NULL || strstr(preload, lib) == NULL) { \
|
||||||
char *newenv; \
|
char *newenv; \
|
||||||
@ -128,6 +128,11 @@ int virtTestMain(int argc,
|
|||||||
setenv("LD_PRELOAD", newenv, 1); \
|
setenv("LD_PRELOAD", newenv, 1); \
|
||||||
execv(argv[0], argv); \
|
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); \
|
return virtTestMain(argc, argv, func); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user