test: make assert_return() critical by default on fuzzer and unit tests
Several test cases intentionally trigger assert_return(). So, to avoid the entire test fails, this introduces several macros that tentatively make assert_return() not critical.
This commit is contained in:
@@ -114,6 +114,7 @@ bool slow_tests_enabled(void) {
|
||||
}
|
||||
|
||||
void test_setup_logging(int level) {
|
||||
log_set_assert_return_is_critical(true);
|
||||
log_set_max_level(level);
|
||||
log_parse_environment();
|
||||
log_open();
|
||||
|
||||
@@ -10,6 +10,27 @@
|
||||
#include "static-destruct.h"
|
||||
#include "strv.h"
|
||||
|
||||
static inline void log_set_assert_return_is_criticalp(bool *p) {
|
||||
log_set_assert_return_is_critical(*p);
|
||||
}
|
||||
|
||||
#define _SAVE_ASSERT_RETURN_IS_CRITICAL(b) \
|
||||
_unused_ _cleanup_(log_set_assert_return_is_criticalp) bool b = \
|
||||
log_get_assert_return_is_critical()
|
||||
|
||||
#define SAVE_ASSERT_RETURN_IS_CRITICAL \
|
||||
_SAVE_ASSERT_RETURN_IS_CRITICAL(UNIQ_T(saved, UNIQ))
|
||||
|
||||
#define ASSERT_RETURN_IS_CRITICAL(b, expr) \
|
||||
({ \
|
||||
SAVE_ASSERT_RETURN_IS_CRITICAL; \
|
||||
log_set_assert_return_is_critical(b); \
|
||||
expr; \
|
||||
})
|
||||
|
||||
#define ASSERT_RETURN_EXPECTED(expr) ASSERT_RETURN_IS_CRITICAL(false, expr)
|
||||
#define ASSERT_RETURN_EXPECTED_SE(expr) ASSERT_RETURN_EXPECTED(assert_se(expr));
|
||||
|
||||
static inline bool manager_errno_skip_test(int r) {
|
||||
return IN_SET(abs(r),
|
||||
EPERM,
|
||||
|
||||
Reference in New Issue
Block a user