mirror of
https://github.com/systemd/systemd.git
synced 2025-05-29 01:05:59 +03:00
test: allow to set NULL to intro or outro
Addresses https://github.com/systemd/systemd/pull/22338#discussion_r796741033.
This commit is contained in:
parent
b0c7e3d0e1
commit
e85fdacc8a
@ -110,27 +110,28 @@ static inline int run_test_table(void) {
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline int test_nop(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#define DEFINE_CUSTOM_TEST_MAIN(log_level, intro, outro) \
|
||||
int main(int argc, char *argv[]) { \
|
||||
int _r, _q; \
|
||||
test_setup_logging(log_level); \
|
||||
save_argc_argv(argc, argv); \
|
||||
_r = intro(); \
|
||||
if (_r == EXIT_SUCCESS) \
|
||||
_r = run_test_table(); \
|
||||
_q = outro(); \
|
||||
static_destruct(); \
|
||||
if (_r < 0) \
|
||||
return EXIT_FAILURE; \
|
||||
if (_r != EXIT_SUCCESS) \
|
||||
return _r; \
|
||||
if (_q < 0) \
|
||||
return EXIT_FAILURE; \
|
||||
return _q; \
|
||||
#define DEFINE_TEST_MAIN_FULL(log_level, intro, outro) \
|
||||
int main(int argc, char *argv[]) { \
|
||||
int (*_intro)(void) = intro; \
|
||||
int (*_outro)(void) = outro; \
|
||||
int _r, _q; \
|
||||
test_setup_logging(log_level); \
|
||||
save_argc_argv(argc, argv); \
|
||||
_r = _intro ? _intro() : EXIT_SUCCESS; \
|
||||
if (_r == EXIT_SUCCESS) \
|
||||
_r = run_test_table(); \
|
||||
_q = _outro ? _outro() : EXIT_SUCCESS; \
|
||||
static_destruct(); \
|
||||
if (_r < 0) \
|
||||
return EXIT_FAILURE; \
|
||||
if (_r != EXIT_SUCCESS) \
|
||||
return _r; \
|
||||
if (_q < 0) \
|
||||
return EXIT_FAILURE; \
|
||||
return _q; \
|
||||
}
|
||||
|
||||
#define DEFINE_TEST_MAIN(log_level) DEFINE_CUSTOM_TEST_MAIN(log_level, test_nop, test_nop)
|
||||
#define DEFINE_TEST_MAIN_WITH_INTRO(log_level, intro) \
|
||||
DEFINE_TEST_MAIN_FULL(log_level, intro, NULL)
|
||||
#define DEFINE_TEST_MAIN(log_level) \
|
||||
DEFINE_TEST_MAIN_FULL(log_level, NULL, NULL)
|
||||
|
@ -444,4 +444,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -71,4 +71,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_DEBUG, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_DEBUG, intro);
|
||||
|
@ -156,4 +156,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_DEBUG, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_DEBUG, intro);
|
||||
|
@ -535,4 +535,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -973,4 +973,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -169,4 +169,4 @@ static int outro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, outro);
|
||||
DEFINE_TEST_MAIN_FULL(LOG_INFO, intro, outro);
|
||||
|
@ -1272,4 +1272,4 @@ static int intro(void) {
|
||||
}
|
||||
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -970,4 +970,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -309,4 +309,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_DEBUG, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_DEBUG, intro);
|
||||
|
@ -228,4 +228,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -254,4 +254,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -900,4 +900,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -63,4 +63,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_DEBUG, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_DEBUG, intro);
|
||||
|
@ -195,4 +195,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -125,4 +125,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_DEBUG, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_DEBUG, intro);
|
||||
|
@ -241,4 +241,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -607,4 +607,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -107,4 +107,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_DEBUG, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_DEBUG, intro);
|
||||
|
@ -856,4 +856,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
@ -60,4 +60,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_DEBUG, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_DEBUG, intro);
|
||||
|
@ -236,4 +236,4 @@ static int intro(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);
|
||||
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
||||
|
Loading…
x
Reference in New Issue
Block a user