diff mbox series

[4/4] log: Disable the syslog driver by default

Message ID 20200912122845.4.I3ff7a6d6f4e6d0b3556e10bac8f9feceae0eae60@changeid
State Accepted
Commit c7f5b850344b1bb620f603ab7df3ee92e1fa26cf
Delegated to: Tom Rini
Headers show
Series log: Fix the syslog spam when running tests | expand

Commit Message

Simon Glass Sept. 12, 2020, 6:28 p.m. UTC
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@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(-)

Comments

Heinrich Schuchardt Sept. 12, 2020, 8:16 p.m. UTC | #1
Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass <sjg@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@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@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@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@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@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@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@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;
> }
Simon Glass Sept. 12, 2020, 8:24 p.m. UTC | #2
Hi Heinrich,

On Sat, 12 Sep 2020 at 14:16, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass <sjg@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@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?

If this driver is to be used on a board, you must call log_device_set_enable().

Regards,
Simon
Heinrich Schuchardt Sept. 12, 2020, 8:34 p.m. UTC | #3
Am 12. September 2020 22:24:24 MESZ schrieb Simon Glass <sjg@chromium.org>:
>Hi Heinrich,
>
>On Sat, 12 Sep 2020 at 14:16, Heinrich Schuchardt <xypron.glpk@gmx.de>
>wrote:
>>
>> Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass
><sjg@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@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?
>
>If this driver is to be used on a board, you must call
>log_device_set_enable().

This would pervert the nice log driver system that you have provided. I definitively want syslog with vanilla code just by customizing.

If you want to mute the network stack, then move it to use log and filter on the network uclass.

Or simply adjust the test that has hickups.

Best regards

Heinrich

>
>Regards,
>Simon
Simon Glass Sept. 13, 2020, 1:24 a.m. UTC | #4
Hi Heinrich,

On Sat, 12 Sep 2020 at 14:34, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Am 12. September 2020 22:24:24 MESZ schrieb Simon Glass <sjg@chromium.org>:
> >Hi Heinrich,
> >
> >On Sat, 12 Sep 2020 at 14:16, Heinrich Schuchardt <xypron.glpk@gmx.de>
> >wrote:
> >>
> >> Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass
> ><sjg@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@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?
> >
> >If this driver is to be used on a board, you must call
> >log_device_set_enable().
>
> This would pervert the nice log driver system that you have provided. I definitively want syslog with vanilla code just by customizing.
>
> If you want to mute the network stack, then move it to use log and filter on the network uclass.

Well sandbox has a network but it fails to send syslog messages, which
is probably a good thing, at least without someone saying they want it
to happen.

>
> Or simply adjust the test that has hickups.

I don't like that idea because any test can produce log output.

Another option would be to only disable the device with sandbox, e.g.

#ifndef CONFIG_SANDBOX
   .flags  = LOGDF_ENABLE,
#endif

Regards,
Simon
Heinrich Schuchardt Sept. 13, 2020, 6:47 a.m. UTC | #5
Am 13. September 2020 03:24:02 MESZ schrieb Simon Glass <sjg@chromium.org>:
>Hi Heinrich,
>
>On Sat, 12 Sep 2020 at 14:34, Heinrich Schuchardt <xypron.glpk@gmx.de>
>wrote:
>>
>> Am 12. September 2020 22:24:24 MESZ schrieb Simon Glass
><sjg@chromium.org>:
>> >Hi Heinrich,
>> >
>> >On Sat, 12 Sep 2020 at 14:16, Heinrich Schuchardt
><xypron.glpk@gmx.de>
>> >wrote:
>> >>
>> >> Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass
>> ><sjg@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@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?
>> >
>> >If this driver is to be used on a board, you must call
>> >log_device_set_enable().
>>
>> This would pervert the nice log driver system that you have provided.
>I definitively want syslog with vanilla code just by customizing.
>>
>> If you want to mute the network stack, then move it to use log and
>filter on the network uclass.
>
>Well sandbox has a network but it fails to send syslog messages, which
>is probably a good thing, at least without someone saying they want it
>to happen.
>
>>
>> Or simply adjust the test that has hickups.
>
>I don't like that idea because any test can produce log output.
>
>Another option would be to only disable the device with sandbox, e.g.
>
>#ifndef CONFIG_SANDBOX
>   .flags  = LOGDF_ENABLE,
>#endif

The decision to send syslog messages is not board specific but application specific. This is why I think it must be customizable. I would be fine if you would simply remove log_syslog from sandbox_defconfig.

What I am missing most in the log command is the possibility to set the verbosity per log area/uclass. This would allow to see debug messages only from the area of interest. Especially network does not work when debugging messages are shown per packet, while the user might be interested in debug messages from other areas e.g. EFI.

Concerning your problem such a change would allow to selectively mute network messages.

Would such a change make sense to you?

Best regards

Heinrich

>
>Regards,
>Simon
Simon Glass Sept. 13, 2020, 1:26 p.m. UTC | #6
Hi Heinrich,

On Sun, 13 Sep 2020 at 00:47, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Am 13. September 2020 03:24:02 MESZ schrieb Simon Glass <sjg@chromium.org>:
> >Hi Heinrich,
> >
> >On Sat, 12 Sep 2020 at 14:34, Heinrich Schuchardt <xypron.glpk@gmx.de>
> >wrote:
> >>
> >> Am 12. September 2020 22:24:24 MESZ schrieb Simon Glass
> ><sjg@chromium.org>:
> >> >Hi Heinrich,
> >> >
> >> >On Sat, 12 Sep 2020 at 14:16, Heinrich Schuchardt
> ><xypron.glpk@gmx.de>
> >> >wrote:
> >> >>
> >> >> Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass
> >> ><sjg@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@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?
> >> >
> >> >If this driver is to be used on a board, you must call
> >> >log_device_set_enable().
> >>
> >> This would pervert the nice log driver system that you have provided.
> >I definitively want syslog with vanilla code just by customizing.
> >>
> >> If you want to mute the network stack, then move it to use log and
> >filter on the network uclass.
> >
> >Well sandbox has a network but it fails to send syslog messages, which
> >is probably a good thing, at least without someone saying they want it
> >to happen.
> >
> >>
> >> Or simply adjust the test that has hickups.
> >
> >I don't like that idea because any test can produce log output.
> >
> >Another option would be to only disable the device with sandbox, e.g.
> >
> >#ifndef CONFIG_SANDBOX
> >   .flags  = LOGDF_ENABLE,
> >#endif
>
> The decision to send syslog messages is not board specific but application specific. This is why I think it must be customizable. I would be fine if you would simply remove log_syslog from sandbox_defconfig.

But then we would lose test coverage for syslog. I agree that making
it customisable is a good thing. But what do you think is the solution
to the problem at hand? As above, the driver is disabled by default
only on sandbox, since it must be enabled for testing, but is
intrusive otherwise.

>
> What I am missing most in the log command is the possibility to set the verbosity per log area/uclass. This would allow to see debug messages only from the area of interest. Especially network does not work when debugging messages are shown per packet, while the user might be interested in debug messages from other areas e.g. EFI.
>
> Concerning your problem such a change would allow to selectively mute network messages.
>
> Would such a change make sense to you?

Yes, but I feel these are separate issues:
- add a command enabling / disabling a log driver
- add a command to add/remove log filters based on category/level/file

Regards,
Simon
Tom Rini Oct. 12, 2020, 1:15 a.m. UTC | #7
On Sat, Sep 12, 2020 at 12:28:50PM -0600, Simon Glass wrote:

> 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@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

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,
 };
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@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@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@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@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@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@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;
 }