]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fuzz: allow logging to be configured, disable in fuzz-unit-file
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 11 Mar 2018 08:22:28 +0000 (09:22 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 11 Mar 2018 15:33:59 +0000 (16:33 +0100)
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
src/fuzz/fuzz-unit-file.c

index 45e46907e245924e98d54dca27919507779a0d92..cace47ba22e9cc2248c687c6e9f6f7e8b3aadf3e 100644 (file)
@@ -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;
 }
index 87e0b10f008a434d7ffc8711e575bbf289980e43..45f1a72db2927e161b7c456caf51709e82ff77b7 100644 (file)
@@ -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));