From b872843c4db1bb8677c9e1ed8c8c65167181adba Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 11 Mar 2018 09:22:28 +0100 Subject: [PATCH] fuzz: allow logging to be configured, disable in fuzz-unit-file fuzz-unit-file generated too much logs about invalid config lines. This just slows things down and fills the logs. If necessary, it's better to rerun the interesting cases with SYSTEMD_LOG_LEVEL=debug. --- src/fuzz/fuzz-main.c | 4 ++++ src/fuzz/fuzz-unit-file.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/fuzz/fuzz-main.c b/src/fuzz/fuzz-main.c index 45e46907e24..cace47ba22e 100644 --- a/src/fuzz/fuzz-main.c +++ b/src/fuzz/fuzz-main.c @@ -33,6 +33,9 @@ int main(int argc, char **argv) { char *name; log_set_max_level(LOG_DEBUG); + log_parse_environment(); + log_open(); + for (i = 1; i < argc; i++) { _cleanup_free_ char *buf = NULL; @@ -47,5 +50,6 @@ int main(int argc, char **argv) { (void) LLVMFuzzerTestOneInput((uint8_t*)buf, size); printf("ok\n"); } + return EXIT_SUCCESS; } diff --git a/src/fuzz/fuzz-unit-file.c b/src/fuzz/fuzz-unit-file.c index 87e0b10f008..45f1a72db29 100644 --- a/src/fuzz/fuzz-unit-file.c +++ b/src/fuzz/fuzz-unit-file.c @@ -35,6 +35,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (!unit_vtable[t]->load) return 0; + /* 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); + assert_se(manager_new(UNIT_FILE_SYSTEM, MANAGER_TEST_RUN_MINIMAL, &m) >= 0); name = strjoina("a.", unit_type_to_string(t)); -- 2.47.3