[PATCH 4/4] log: Disable the syslog driver by default
Heinrich Schuchardt
xypron.glpk at gmx.de
Sat Sep 12 22:16:40 CEST 2020
Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass <sjg at chromium.org>:
>This driver interferes with other sandbox tests since it causes log
>output
>to be interspersed with "No ethernet found." messages. Disable this
>driver
>by default.
>
>Enable it for the syslog tests so that they still pass.
>
>Signed-off-by: Simon Glass <sjg at chromium.org>
>---
>
> common/log_syslog.c | 1 -
> test/log/syslog_test.c | 24 ++++++++++++++++++++++++
> test/log/syslog_test.h | 16 ++++++++++++++++
> test/log/syslog_test_ndebug.c | 2 ++
> 4 files changed, 42 insertions(+), 1 deletion(-)
>
>diff --git a/common/log_syslog.c b/common/log_syslog.c
>index cf0dbba9bf5..149ff5af310 100644
>--- a/common/log_syslog.c
>+++ b/common/log_syslog.c
>@@ -115,5 +115,4 @@ out:
> LOG_DRIVER(syslog) = {
> .name = "syslog",
> .emit = log_syslog_emit,
>- .flags = LOGDF_ENABLE,
What does the flag removal change outside Python testing?
Best regards
Heinrich
> };
>diff --git a/test/log/syslog_test.c b/test/log/syslog_test.c
>index abcb9ffd28b..febaca68e8d 100644
>--- a/test/log/syslog_test.c
>+++ b/test/log/syslog_test.c
>@@ -56,6 +56,20 @@ int sb_log_tx_handler(struct udevice *dev, void
>*packet, unsigned int len)
> return 0;
> }
>
>+int syslog_test_setup(struct unit_test_state *uts)
>+{
>+ ut_assertok(log_device_set_enable(LOG_GET_DRIVER(syslog), true));
>+
>+ return 0;
>+}
>+
>+int syslog_test_finish(struct unit_test_state *uts)
>+{
>+ ut_assertok(log_device_set_enable(LOG_GET_DRIVER(syslog), false));
>+
>+ return 0;
>+}
>+
> /**
> * log_test_syslog_err() - test log_err() function
> *
>@@ -67,6 +81,7 @@ static int log_test_syslog_err(struct unit_test_state
>*uts)
> int old_log_level = gd->default_log_level;
> struct sb_log_env env;
>
>+ ut_assertok(syslog_test_setup(uts));
> gd->log_fmt = LOGF_TEST;
> gd->default_log_level = LOGL_INFO;
> env_set("ethact", "eth at 10002000");
>@@ -82,6 +97,7 @@ static int log_test_syslog_err(struct unit_test_state
>*uts)
> sandbox_eth_set_tx_handler(0, NULL);
> gd->default_log_level = old_log_level;
> gd->log_fmt = log_get_default_format();
>+ ut_assertok(syslog_test_finish(uts));
>
> return 0;
> }
>@@ -98,6 +114,7 @@ static int log_test_syslog_warning(struct
>unit_test_state *uts)
> int old_log_level = gd->default_log_level;
> struct sb_log_env env;
>
>+ ut_assertok(syslog_test_setup(uts));
> gd->log_fmt = LOGF_TEST;
> gd->default_log_level = LOGL_INFO;
> env_set("ethact", "eth at 10002000");
>@@ -114,6 +131,7 @@ static int log_test_syslog_warning(struct
>unit_test_state *uts)
> ut_assertnull(env.expected);
> gd->default_log_level = old_log_level;
> gd->log_fmt = log_get_default_format();
>+ ut_assertok(syslog_test_finish(uts));
>
> return 0;
> }
>@@ -130,6 +148,7 @@ static int log_test_syslog_notice(struct
>unit_test_state *uts)
> int old_log_level = gd->default_log_level;
> struct sb_log_env env;
>
>+ ut_assertok(syslog_test_setup(uts));
> gd->log_fmt = LOGF_TEST;
> gd->default_log_level = LOGL_INFO;
> env_set("ethact", "eth at 10002000");
>@@ -146,6 +165,7 @@ static int log_test_syslog_notice(struct
>unit_test_state *uts)
> ut_assertnull(env.expected);
> gd->default_log_level = old_log_level;
> gd->log_fmt = log_get_default_format();
>+ ut_assertok(syslog_test_finish(uts));
>
> return 0;
> }
>@@ -162,6 +182,7 @@ static int log_test_syslog_info(struct
>unit_test_state *uts)
> int old_log_level = gd->default_log_level;
> struct sb_log_env env;
>
>+ ut_assertok(syslog_test_setup(uts));
> gd->log_fmt = LOGF_TEST;
> gd->default_log_level = LOGL_INFO;
> env_set("ethact", "eth at 10002000");
>@@ -178,6 +199,7 @@ static int log_test_syslog_info(struct
>unit_test_state *uts)
> ut_assertnull(env.expected);
> gd->default_log_level = old_log_level;
> gd->log_fmt = log_get_default_format();
>+ ut_assertok(syslog_test_finish(uts));
>
> return 0;
> }
>@@ -194,6 +216,7 @@ static int log_test_syslog_debug(struct
>unit_test_state *uts)
> int old_log_level = gd->default_log_level;
> struct sb_log_env env;
>
>+ ut_assertok(syslog_test_setup(uts));
> gd->log_fmt = LOGF_TEST;
> gd->default_log_level = LOGL_DEBUG;
> env_set("ethact", "eth at 10002000");
>@@ -210,6 +233,7 @@ static int log_test_syslog_debug(struct
>unit_test_state *uts)
> ut_assertnull(env.expected);
> gd->default_log_level = old_log_level;
> gd->log_fmt = log_get_default_format();
>+ ut_assertok(syslog_test_finish(uts));
>
> return 0;
> }
>diff --git a/test/log/syslog_test.h b/test/log/syslog_test.h
>index 75900f3aad3..1310257bfe1 100644
>--- a/test/log/syslog_test.h
>+++ b/test/log/syslog_test.h
>@@ -47,4 +47,20 @@ struct sb_log_env {
> */
>int sb_log_tx_handler(struct udevice *dev, void *packet, unsigned int
>len);
>
>+/**
>+ * syslog_test_setup() - Enable syslog logging ready for tests
>+ *
>+ * @uts: Test state
>+ * @return 0 if OK, -ENOENT if the syslog log driver is not found
>+ */
>+int syslog_test_setup(struct unit_test_state *uts);
>+
>+/**
>+ * syslog_test_finish() - Disable syslog logging after tests
>+ *
>+ * @uts: Test state
>+ * @return 0 if OK, -ENOENT if the syslog log driver is not found
>+ */
>+int syslog_test_finish(struct unit_test_state *uts);
>+
> #endif
>diff --git a/test/log/syslog_test_ndebug.c
>b/test/log/syslog_test_ndebug.c
>index 7815977ea27..c7f5a60861f 100644
>--- a/test/log/syslog_test_ndebug.c
>+++ b/test/log/syslog_test_ndebug.c
>@@ -33,6 +33,7 @@ static int log_test_syslog_nodebug(struct
>unit_test_state *uts)
> int old_log_level = gd->default_log_level;
> struct sb_log_env env;
>
>+ ut_assertok(syslog_test_setup(uts));
> gd->log_fmt = LOGF_TEST;
> gd->default_log_level = LOGL_INFO;
> env_set("ethact", "eth at 10002000");
>@@ -49,6 +50,7 @@ static int log_test_syslog_nodebug(struct
>unit_test_state *uts)
> ut_assertnonnull(env.expected);
> gd->default_log_level = old_log_level;
> gd->log_fmt = log_get_default_format();
>+ ut_assertok(syslog_test_finish(uts));
>
> return 0;
> }
More information about the U-Boot
mailing list