From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
berrange@redhat.com
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH v3] tests/unit: add unit test for qemu_hexdump()
Date: Thu, 13 Nov 2025 22:01:38 +0100 [thread overview]
Message-ID: <a40731d0-7add-4d09-9a89-902f75e2eede@linaro.org> (raw)
In-Reply-To: <20251113064935.342018-1-vsementsov@yandex-team.ru>
On 13/11/25 07:49, Vladimir Sementsov-Ogievskiy wrote:
> Test, that fix in previous commit make sense.
>
> To not break compilation when we build without
> 'block', move hexdump.c out of "if have_block"
> in meson.build.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>
> v3: change meson.build to compile hexdump.c always
>
> tests/unit/test-cutils.c | 43 ++++++++++++++++++++++++++++++++++++++++
> util/meson.build | 2 +-
> 2 files changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/tests/unit/test-cutils.c b/tests/unit/test-cutils.c
> index 227acc5995..24fef16a7f 100644
> --- a/tests/unit/test-cutils.c
> +++ b/tests/unit/test-cutils.c
> @@ -3626,6 +3626,44 @@ static void test_si_prefix(void)
> g_assert_cmpstr(si_prefix(18), ==, "E");
> }
>
> +static void test_qemu_hexdump_alignment(void)
> +{
> + /*
> + * Test that ASCII part is properly aligned for incomplete lines.
> + * This test catches the bug that was fixed in previous commit
> + * "util/hexdump: fix QEMU_HEXDUMP_LINE_WIDTH logic".
> + *
> + * We use data that is not aligned to 16 bytes, so last line
> + * is incomplete.
> + */
> + const uint8_t data[] = {
> + /* First line: 16 bytes */
> + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, /* "Hello Wo" */
> + 0x72, 0x6c, 0x64, 0x21, 0x20, 0x54, 0x68, 0x69, /* "rld! Thi" */
> + /* Second line: 5 bytes (incomplete) */
> + 0x73, 0x20, 0x69, 0x73, 0x20 /* "s is " */
> + };
> + char *output = NULL;
> + size_t size;
> + FILE *stream = open_memstream(&output, &size);
> +
> + g_assert_nonnull(stream);
> +
> + qemu_hexdump(stream, "test", data, sizeof(data));
> + fclose(stream);
> +
> + g_assert_nonnull(output);
> +
> + /* We expect proper alignment of "s is" part on the second line */
> + const char *expected =
> + "test: 0000: 48 65 6c 6c 6f 20 57 6f 72 6c 64 21 20 54 68 69 Hello World! Thi\n"
> + "test: 0010: 73 20 69 73 20 s is \n";
Thanks, queued wrapping the long lines to pass checkpatch.pl,
as in:
https://lore.kernel.org/qemu-devel/20251031211518.38503-9-philmd@linaro.org/
prev parent reply other threads:[~2025-11-13 21:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 6:49 [PATCH v3] tests/unit: add unit test for qemu_hexdump() Vladimir Sementsov-Ogievskiy
2025-11-13 9:10 ` Daniel P. Berrangé
2025-11-13 10:20 ` Vladimir Sementsov-Ogievskiy
2025-11-13 10:33 ` Daniel P. Berrangé
2025-11-13 10:44 ` Vladimir Sementsov-Ogievskiy
2025-11-13 10:46 ` Peter Maydell
2025-11-13 11:35 ` Daniel P. Berrangé
2025-11-13 13:03 ` Vladimir Sementsov-Ogievskiy
2025-11-13 13:56 ` Eric Blake
2025-11-13 17:39 ` Vladimir Sementsov-Ogievskiy
2025-11-13 21:01 ` Philippe Mathieu-Daudé [this message]
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=a40731d0-7add-4d09-9a89-902f75e2eede@linaro.org \
--to=philmd@linaro.org \
--cc=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).