From: Zbigniew Jędrzejewski-Szmek Date: Sun, 11 Mar 2018 08:22:28 +0000 (+0100) Subject: fuzz: allow logging to be configured, disable in fuzz-unit-file X-Git-Tag: v239~552^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b872843c4db1bb8677c9e1ed8c8c65167181adba;p=thirdparty%2Fsystemd.git 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. --- 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));