diff mbox series

[2/2] test: log: test message continuation

Message ID 20200917121902.57403-3-xypron.glpk@gmx.de
State Deferred
Delegated to: Tom Rini
Headers show
Series log: allow for message continuation | expand

Commit Message

Heinrich Schuchardt Sept. 17, 2020, 12:19 p.m. UTC
Provide a unit test checking that a continuation message will use the same
log level and log category as the previous message.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 test/log/Makefile    |  4 +++-
 test/log/cont_test.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 test/log/cont_test.c

--
2.28.0

Comments

Simon Glass Sept. 22, 2020, 6:48 p.m. UTC | #1
On Thu, 17 Sep 2020 at 06:19, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Provide a unit test checking that a continuation message will use the same
> log level and log category as the previous message.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  test/log/Makefile    |  4 +++-
>  test/log/cont_test.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 55 insertions(+), 1 deletion(-)
>  create mode 100644 test/log/cont_test.c

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Oct. 10, 2020, 9:28 p.m. UTC | #2
On Thu, Sep 17, 2020 at 02:19:02PM +0200, Heinrich Schuchardt wrote:

> Provide a unit test checking that a continuation message will use the same
> log level and log category as the previous message.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>
[snip]
> +	log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);

These new values aren't defined, or I missed some other series.  Thanks!
Sean Anderson Oct. 10, 2020, 9:47 p.m. UTC | #3
On 10/10/20 5:28 PM, Tom Rini wrote:
> On Thu, Sep 17, 2020 at 02:19:02PM +0200, Heinrich Schuchardt wrote:
> 
>> Provide a unit test checking that a continuation message will use the same
>> log level and log category as the previous message.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
> [snip]
>> +	log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
> 
> These new values aren't defined, or I missed some other series.  Thanks!
> 

They should be defined in the first patch

On 9/17/20 8:19 AM, Heinrich Schuchardt wrote:
> diff --git a/include/log.h b/include/log.h
> index 2859ce1f2e..567cd32d34 100644
> --- a/include/log.h
> +++ b/include/log.h
> @@ -35,6 +35,7 @@ enum log_level_t {
> 
>  	LOGL_FIRST = LOGL_EMERG,
>  	LOGL_MAX = LOGL_DEBUG_IO,
> +	LOGL_CONT = -1,		/* Use same log level as in previous call */
>  };
> 
>  /**
> @@ -60,6 +61,7 @@ enum log_category_t {
> 
>  	LOGC_COUNT,	/* Number of log categories */
>  	LOGC_END,	/* Sentinel value for a list of log categories */
> +	LOGC_CONT = -1,	/* Use same category as in previous call */
>  };
> 
>  /* Helper to cast a uclass ID to a log category */
> --
> 2.28.0
>
Tom Rini Oct. 10, 2020, 9:51 p.m. UTC | #4
On Sat, Oct 10, 2020 at 05:47:26PM -0400, Sean Anderson wrote:
> On 10/10/20 5:28 PM, Tom Rini wrote:
> > On Thu, Sep 17, 2020 at 02:19:02PM +0200, Heinrich Schuchardt wrote:
> > 
> >> Provide a unit test checking that a continuation message will use the same
> >> log level and log category as the previous message.
> >>
> >> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> >> Reviewed-by: Simon Glass <sjg@chromium.org>
> > [snip]
> >> +	log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
> > 
> > These new values aren't defined, or I missed some other series.  Thanks!
> > 
> 
> They should be defined in the first patch

and I see 1/2 has changes requested, so I shoulda deferred this one.
Thanks!
Heinrich Schuchardt Oct. 11, 2020, 8:09 a.m. UTC | #5
On 10/10/20 11:51 PM, Tom Rini wrote:
> On Sat, Oct 10, 2020 at 05:47:26PM -0400, Sean Anderson wrote:
>> On 10/10/20 5:28 PM, Tom Rini wrote:
>>> On Thu, Sep 17, 2020 at 02:19:02PM +0200, Heinrich Schuchardt wrote:
>>>
>>>> Provide a unit test checking that a continuation message will use the same
>>>> log level and log category as the previous message.
>>>>
>>>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>> [snip]
>>>> +	log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
>>>
>>> These new values aren't defined, or I missed some other series.  Thanks!
>>>
>>
>> They should be defined in the first patch
>
> and I see 1/2 has changes requested, so I shoulda deferred this one.
> Thanks!
>
Hello Tom,

I am still waiting on the "doc: global data pointer" series to be merged
as this will be the basis for adjusting the log continuation series.

https://patchwork.ozlabs.org/project/uboot/list/?series=205937

But I will be patient as it seems that you have been drowned in patches
assigned to you.

Best regards

Heinrich
Heinrich Schuchardt Oct. 11, 2020, 8:11 a.m. UTC | #6
On 10/10/20 11:28 PM, Tom Rini wrote:
> On Thu, Sep 17, 2020 at 02:19:02PM +0200, Heinrich Schuchardt wrote:
>
>> Provide a unit test checking that a continuation message will use the same
>> log level and log category as the previous message.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
> [snip]
>> +	log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
>
> These new values aren't defined, or I missed some other series.  Thanks!
>

See here:

https://patchwork.ozlabs.org/project/uboot/patch/20200917121902.57403-2-xypron.glpk@gmx.de/

But the series has to be reworked.

Best regards

Heinrich
diff mbox series

Patch

diff --git a/test/log/Makefile b/test/log/Makefile
index 4c92550f6e..1f91c90422 100644
--- a/test/log/Makefile
+++ b/test/log/Makefile
@@ -12,7 +12,9 @@  ifdef CONFIG_SANDBOX
 obj-$(CONFIG_LOG_SYSLOG) += syslog_test.o
 endif

-ifndef CONFIG_LOG
+ifdef CONFIG_LOG
+obj-$(CONFIG_CONSOLE_RECORD) += cont_test.o
+else
 obj-$(CONFIG_CONSOLE_RECORD) += nolog_test.o
 endif

diff --git a/test/log/cont_test.c b/test/log/cont_test.c
new file mode 100644
index 0000000000..68ca1d262c
--- /dev/null
+++ b/test/log/cont_test.c
@@ -0,0 +1,52 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * Test continuation of log messages.
+ */
+
+#include <common.h>
+#include <console.h>
+#include <test/log.h>
+#include <test/test.h>
+#include <test/suites.h>
+#include <test/ut.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define BUFFSIZE 64
+
+static int log_test_cont(struct unit_test_state *uts)
+{
+	int log_fmt;
+	int log_level;
+
+	log_fmt = gd->log_fmt;
+	log_level = gd->default_log_level;
+
+	/* Write two messages, the second continuing the first */
+	gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
+	gd->default_log_level = LOGL_INFO;
+	console_record_reset_enable();
+	log(LOGC_ARCH, LOGL_ERR, "ea%d ", 1);
+	log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
+	gd->default_log_level = log_level;
+	gd->log_fmt = log_fmt;
+	gd->flags &= ~GD_FLG_RECORD;
+	ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1 ERR.arch, cc2"));
+	ut_assertok(ut_check_console_end(uts));
+
+	/* Write a third message which is not a continuation */
+	gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
+	gd->default_log_level = LOGL_INFO;
+	console_record_reset_enable();
+	log(LOGC_EFI, LOGL_INFO, "ie%d\n", 3);
+	gd->default_log_level = log_level;
+	gd->log_fmt = log_fmt;
+	gd->flags &= ~GD_FLG_RECORD;
+	ut_assertok(ut_check_console_line(uts, "INFO.efi, ie3"));
+	ut_assertok(ut_check_console_end(uts));
+
+	return 0;
+}
+LOG_TEST(log_test_cont);