summaryrefslogtreecommitdiffstats
path: root/src/fuzz
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-03-11 09:22:28 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-03-11 16:33:59 +0100
commitb872843c4db1bb8677c9e1ed8c8c65167181adba (patch)
tree7bb9e07c15fd84fbac0b5d2f34384f5d4c8f2303 /src/fuzz
parentfuzz: skip bus error map in bus_error_name_to_errno() (diff)
downloadsystemd-b872843c4db1bb8677c9e1ed8c8c65167181adba.tar.xz
systemd-b872843c4db1bb8677c9e1ed8c8c65167181adba.zip
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.
Diffstat (limited to 'src/fuzz')
-rw-r--r--src/fuzz/fuzz-main.c4
-rw-r--r--src/fuzz/fuzz-unit-file.c5
2 files changed, 9 insertions, 0 deletions
diff --git a/src/fuzz/fuzz-main.c b/src/fuzz/fuzz-main.c
index 45e46907e2..cace47ba22 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 87e0b10f00..45f1a72db2 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));