aboutsummaryrefslogtreecommitdiff
path: root/test/log
diff options
context:
space:
mode:
authorSimon Glass2020-09-12 12:28:50 -0600
committerTom Rini2020-10-10 16:50:11 -0400
commitc7f5b850344b1bb620f603ab7df3ee92e1fa26cf (patch)
tree967c6fd2d471c0eecae714b243bd1fdfb1bfa1e3 /test/log
parent3d03ab6361a4a2b60e84da46c547b8ace01a60eb (diff)
log: Disable the syslog driver by default
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>
Diffstat (limited to 'test/log')
-rw-r--r--test/log/syslog_test.c24
-rw-r--r--test/log/syslog_test.h16
-rw-r--r--test/log/syslog_test_ndebug.c2
3 files changed, 42 insertions, 0 deletions
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;
}