mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
assert-util: introduce log_set_assert_return_is_critical_from_env()
It will be used for testing nss modules.
This commit is contained in:
@@ -454,6 +454,9 @@ systemd tests:
|
|||||||
causes all non-matching test functions to be skipped. Only applies to tests
|
causes all non-matching test functions to be skipped. Only applies to tests
|
||||||
using our regular test boilerplate.
|
using our regular test boilerplate.
|
||||||
|
|
||||||
|
* `$SYSTEMD_ASSERT_RETURN_IS_CRITICAL` — Takes a boolean to control if
|
||||||
|
`assert_return()` and friends call `abort()`.
|
||||||
|
|
||||||
fuzzers:
|
fuzzers:
|
||||||
|
|
||||||
* `$SYSTEMD_FUZZ_OUTPUT` — A boolean that specifies whether to write output to
|
* `$SYSTEMD_FUZZ_OUTPUT` — A boolean that specifies whether to write output to
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "assert-util.h"
|
#include "assert-util.h"
|
||||||
|
#include "env-util.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
@@ -17,6 +18,22 @@ void log_set_assert_return_is_critical(bool b) {
|
|||||||
assert_return_is_critical = b;
|
assert_return_is_critical = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log_set_assert_return_is_critical_from_env(void) {
|
||||||
|
static int cached = INT_MIN;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (cached == INT_MIN) {
|
||||||
|
r = secure_getenv_bool("SYSTEMD_ASSERT_RETURN_IS_CRITICAL");
|
||||||
|
if (r < 0 && r != -ENXIO)
|
||||||
|
log_debug_errno(r, "Failed to parse $SYSTEMD_ASSERT_RETURN_IS_CRITICAL, ignoring: %m");
|
||||||
|
|
||||||
|
cached = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cached >= 0)
|
||||||
|
log_set_assert_return_is_critical(cached);
|
||||||
|
}
|
||||||
|
|
||||||
bool log_get_assert_return_is_critical(void) {
|
bool log_get_assert_return_is_critical(void) {
|
||||||
return assert_return_is_critical;
|
return assert_return_is_critical;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
/* Logging for various assertions */
|
/* Logging for various assertions */
|
||||||
|
|
||||||
void log_set_assert_return_is_critical(bool b);
|
void log_set_assert_return_is_critical(bool b);
|
||||||
|
void log_set_assert_return_is_critical_from_env(void);
|
||||||
bool log_get_assert_return_is_critical(void) _pure_;
|
bool log_get_assert_return_is_critical(void) _pure_;
|
||||||
|
|
||||||
void log_assert_failed_return(const char *text, const char *file, int line, const char *func);
|
void log_assert_failed_return(const char *text, const char *file, int line, const char *func);
|
||||||
|
|||||||
Reference in New Issue
Block a user