1
0
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:
Yu Watanabe 2022-02-02 11:06:41 +09:00 committed by Luca Boccassi
parent b0c7e3d0e1
commit e85fdacc8a
22 changed files with 44 additions and 43 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);