1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-27 03:21:32 +03:00

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-03-11 09:22:28 +01:00
parent af7bce4165
commit b872843c4d
2 changed files with 9 additions and 0 deletions

View 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;
}

View 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));