From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Simon Glass <sjg@chromium.org>,
U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
AKASHI Takahiro <akashi.tkhro@gmail.com>,
Bin Meng <bmeng.cn@gmail.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Ion Agorria <ion@agorria.com>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Svyatoslav Ryhel <clamor95@gmail.com>
Subject: Re: [PATCH 02/21] test: Fail when an empty line is expected but not present
Date: Tue, 20 Aug 2024 08:40:09 +0200 [thread overview]
Message-ID: <87bk1nwvcm.fsf@baylibre.com> (raw)
In-Reply-To: <20240810205205.3403177-3-sjg@chromium.org>
Hi Simon,
Thank you for the patch.
On sam., août 10, 2024 at 14:51, Simon Glass <sjg@chromium.org> wrote:
> The existing implementation of ut_assert_nextline_empty() cannot
> distinguish between an empty line and no line at all. It can in fact be
> called at the end of the recorded output and will happily return
> success.
>
> Adjust the logic so that this condition is detected. Show a failure
> message in this case.
>
> Fix the one test which falls foul of this fix.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Fixes: 400175b0a7d ("test: Add a way to check each line of console...")
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> ---
>
> common/console.c | 2 ++
> include/console.h | 2 +-
> test/boot/bootflow.c | 2 --
> test/ut.c | 8 +++++---
> 4 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/common/console.c b/common/console.c
> index 63f78004fdb..85f627297ed 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -845,6 +845,8 @@ int console_record_readline(char *str, int maxlen)
> {
> if (gd->flags & GD_FLG_RECORD_OVF)
> return -ENOSPC;
> + if (console_record_isempty())
> + return -ENOENT;
>
> return membuff_readline((struct membuff *)&gd->console_out, str,
> maxlen, '\0', false);
> diff --git a/include/console.h b/include/console.h
> index 2617e160073..6b6d0f9de73 100644
> --- a/include/console.h
> +++ b/include/console.h
> @@ -73,7 +73,7 @@ int console_record_reset_enable(void);
> * @str: Place to put string
> * @maxlen: Maximum length of @str including nul terminator
> * Return: length of string returned, or -ENOSPC if the console buffer was
> - * overflowed by the output
> + * overflowed by the output, or -ENOENT if there was nothing to read
> */
> int console_record_readline(char *str, int maxlen);
>
> diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
> index 8b46256fa48..8bfc2a1b9b4 100644
> --- a/test/boot/bootflow.c
> +++ b/test/boot/bootflow.c
> @@ -1151,8 +1151,6 @@ static int bootflow_cmdline(struct unit_test_state *uts)
>
> ut_asserteq(0, run_command("bootflow cmdline set mary abc", 0));
> ut_asserteq(0, run_command("bootflow cmdline set mary", 0));
> - ut_assert_nextline_empty();
> -
> ut_assert_console_end();
>
> return 0;
> diff --git a/test/ut.c b/test/ut.c
> index ae99831ac8f..7454da3e001 100644
> --- a/test/ut.c
> +++ b/test/ut.c
> @@ -59,9 +59,11 @@ static int readline_check(struct unit_test_state *uts)
> ut_fail(uts, __FILE__, __LINE__, __func__,
> "Console record buffer too small - increase CONFIG_CONSOLE_RECORD_OUT_SIZE");
> return ret;
> + } else if (ret == -ENOENT) {
> + strcpy(uts->actual_str, "<no-more-output>");
> }
>
> - return 0;
> + return ret;
> }
>
> int ut_check_console_line(struct unit_test_state *uts, const char *fmt, ...)
> @@ -79,8 +81,8 @@ int ut_check_console_line(struct unit_test_state *uts, const char *fmt, ...)
> return -EOVERFLOW;
> }
> ret = readline_check(uts);
> - if (ret < 0)
> - return ret;
> + if (ret == -ENOENT)
> + return 1;
>
> return strcmp(uts->expect_str, uts->actual_str);
> }
> --
> 2.34.1
next prev parent reply other threads:[~2024-08-20 6:40 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-10 20:51 [PATCH 00/21] Tidy up console recording in tests Simon Glass
2024-08-10 20:51 ` [PATCH 01/21] buildman: Make test_process_limit handle time.monotonic() Simon Glass
2024-08-10 20:51 ` [PATCH 02/21] test: Fail when an empty line is expected but not present Simon Glass
2024-08-20 6:40 ` Mattijs Korpershoek [this message]
2024-08-10 20:51 ` [PATCH 03/21] test: Rename unit-test flags Simon Glass
2024-08-10 20:51 ` [PATCH 04/21] test: Drop the blank line before test macros Simon Glass
2024-08-10 20:51 ` [PATCH 05/21] test: Rename UTF_CONSOLE_REC to UTF_CONSOLE Simon Glass
2024-08-20 6:48 ` Mattijs Korpershoek
2024-08-10 20:51 ` [PATCH 06/21] mmc: Drop the blank line before accesses Simon Glass
2024-08-15 17:01 ` Tom Rini
2024-08-15 20:34 ` Simon Glass
2024-08-16 3:47 ` Tom Rini
2024-08-10 20:51 ` [PATCH 07/21] Revert "net: wget: Support retransmission a dropped packet" Simon Glass
2024-08-11 2:47 ` Yasuharu Shibata
2024-08-11 14:50 ` Simon Glass
2024-08-12 18:46 ` Tom Rini
2024-08-13 3:48 ` Yasuharu Shibata
2024-08-13 12:20 ` Simon Glass
2024-08-13 15:12 ` Simon Glass
2024-08-14 13:05 ` Yasuharu Shibata
2024-08-13 12:16 ` Simon Glass
2024-08-10 20:51 ` [PATCH 08/21] sandbox: Enable wget command Simon Glass
2024-08-10 20:51 ` [PATCH 09/21] test: Update NAND test to avoid extra macros Simon Glass
2024-08-17 18:29 ` Sean Anderson
2024-08-10 20:51 ` [PATCH 10/21] test: bloblist: Use UTF_CONSOLE in tests Simon Glass
2024-08-10 20:51 ` [PATCH 11/21] test: boot: " Simon Glass
2024-08-20 7:02 ` Mattijs Korpershoek
2024-08-10 20:51 ` [PATCH 12/21] test: fdt: Check internal-function return values Simon Glass
2024-08-10 20:51 ` [PATCH 13/21] test: fdt: Move common code into the setup functions Simon Glass
2024-08-10 20:51 ` [PATCH 14/21] test: cmd: Use UTF_CONSOLE in tests Simon Glass
2024-08-10 20:51 ` [PATCH 15/21] test: cmd: Drop unnecessary console_record_reset_enable() Simon Glass
2024-08-10 20:52 ` [PATCH 16/21] test: dm: Use UTF_CONSOLE in tests Simon Glass
2024-08-10 20:52 ` [PATCH 17/21] test: hush: " Simon Glass
2024-08-20 7:08 ` Mattijs Korpershoek
2024-08-10 20:52 ` [PATCH 18/21] test: log: " Simon Glass
2024-08-10 20:52 ` [PATCH 19/21] test: Use UTF_CONSOLE in remaining tests Simon Glass
2024-08-10 20:52 ` [PATCH 20/21] test: Tidy up checking for console end Simon Glass
2024-08-10 20:52 ` [PATCH 21/21] doc: Add a few notes about how to use console checking Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bk1nwvcm.fsf@baylibre.com \
--to=mkorpershoek@baylibre.com \
--cc=akashi.tkhro@gmail.com \
--cc=bmeng.cn@gmail.com \
--cc=clamor95@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=ion@agorria.com \
--cc=patrice.chotard@foss.st.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.