mirror of
https://github.com/systemd/systemd.git
synced 2024-10-30 14:55:37 +03:00
test: Slightly rework DEFINE_TEST_MAIN macros
- A lot of tests want a different log level - Provides saved_argc/saved_argv to tests - Separate intro/outro is more flexible
This commit is contained in:
parent
9df247da28
commit
a40b728e11
@ -6,6 +6,7 @@
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "macro.h"
|
||||
#include "util.h"
|
||||
|
||||
static inline bool manager_errno_skip_test(int r) {
|
||||
return IN_SET(abs(r),
|
||||
@ -77,16 +78,14 @@ static inline void run_test_table(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFINE_TEST_MAIN \
|
||||
int main(int argc, char *argv[]) { \
|
||||
test_setup_logging(LOG_INFO); \
|
||||
run_test_table(); \
|
||||
return EXIT_SUCCESS; \
|
||||
#define DEFINE_CUSTOM_TEST_MAIN(log_level, intro, outro) \
|
||||
int main(int argc, char *argv[]) { \
|
||||
test_setup_logging(log_level); \
|
||||
save_argc_argv(argc, argv); \
|
||||
intro; \
|
||||
run_test_table(); \
|
||||
outro; \
|
||||
return EXIT_SUCCESS; \
|
||||
}
|
||||
|
||||
#define DEFINE_CUSTOM_TEST_MAIN(impl) \
|
||||
int main(int argc, char *argv[]) { \
|
||||
test_setup_logging(LOG_INFO); \
|
||||
run_test_table(); \
|
||||
return impl(); \
|
||||
}
|
||||
#define DEFINE_TEST_MAIN(log_level) DEFINE_CUSTOM_TEST_MAIN(log_level, , )
|
||||
|
@ -387,4 +387,4 @@ TEST(flags) {
|
||||
assert_se(f == F2);
|
||||
}
|
||||
|
||||
DEFINE_TEST_MAIN;
|
||||
DEFINE_TEST_MAIN(LOG_INFO);
|
||||
|
Loading…
Reference in New Issue
Block a user