fuzz: unify logging setup

Make sure we don't log anything when running in "fuzzing" mode. Also,
when at it, unify the setup logic into a helper, pretty similar to
the test_setup_logging() one.

Addresses:
  - https://github.com/systemd/systemd/pull/29558#pullrequestreview-1676060607
  - https://github.com/systemd/systemd/pull/29558#discussion_r1358940663
This commit is contained in:
Frantisek Sumsal
2023-10-19 10:05:20 +01:00
committed by Luca Boccassi
parent 47174dc054
commit 4820c9d417
43 changed files with 60 additions and 99 deletions
+1 -4
View File
@@ -15,10 +15,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
f = data_to_file(data, size);
assert_se(f);
/* We don't want to fill the logs with messages about parse errors.
* Disable most logging if not running standalone */
if (!getenv("SYSTEMD_LOG_LEVEL"))
log_set_max_level(LOG_CRIT);
fuzz_setup_logging();
(void) oci_load(f, "/dev/null", &s);
+1 -4
View File
@@ -15,10 +15,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
f = data_to_file(data, size);
assert_se(f);
/* We don't want to fill the logs with messages about parse errors.
* Disable most logging if not running standalone */
if (!getenv("SYSTEMD_LOG_LEVEL"))
log_set_max_level(LOG_CRIT);
fuzz_setup_logging();
(void) settings_load(f, "/dev/null", &s);