QEMU-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Tao Tang <tangtao1634@phytium.com.cn>,
	Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	Peter Maydell <peter.maydell@linaro.org>,
	Chen Baozi <chenbaozi@phytium.com.cn>,
	Chao Liu <chao.liu@processmission.com>,
	Jim MacArthur <jim.macarthur@linaro.org>,
	Tao Tang <tangtao1634@phytium.com.cn>
Subject: Re: [RFC v5 3/5] tests/qtest: Add raw command response helper
Date: Wed, 19 Aug 2026 11:06:11 -0300	[thread overview]
Message-ID: <87wltmkxws.fsf@suse.de> (raw)
In-Reply-To: <20260814035628.3924513-4-tangtao1634@phytium.com.cn>

Tao Tang <tangtao1634@phytium.com.cn> writes:

> Split raw qtest response tokenization and qtest_raw_cmd() from the
> memory attributes helpers so this protocol support can be reviewed
> independently.
>
> Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
> ---
>  tests/qtest/libqtest.c | 27 +++++++++++++++++++++++++--
>  tests/qtest/libqtest.h | 13 +++++++++++++
>  2 files changed, 38 insertions(+), 2 deletions(-)
>
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index 453d0dddd09..37aa69e1297 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -746,11 +746,10 @@ static GString *qtest_client_socket_recv_line(QTestState *s)
>      return line;
>  }
>  
> -static gchar **qtest_rsp_args(QTestState *s, int expected_args)
> +static gchar **qtest_rsp_words(QTestState *s)
>  {
>      GString *line;
>      gchar **words;
> -    int i;
>  
>  redo:
>      line = s->ops.recv_line(s);
> @@ -780,6 +779,15 @@ redo:
>      }
>  
>      g_assert(words[0] != NULL);
> +
> +    return words;
> +}
> +
> +static gchar **qtest_rsp_args(QTestState *s, int expected_args)
> +{
> +    gchar **words = qtest_rsp_words(s);
> +    int i;
> +
>      g_assert_cmpstr(words[0], ==, "OK");
>  
>      for (i = 0; i < expected_args; i++) {
> @@ -789,6 +797,21 @@ redo:
>      return words;
>  }
>  
> +gchar **qtest_raw_cmd(QTestState *s, const char *fmt, ...)
> +{
> +    va_list ap;
> +    gchar *str;
> +
> +    va_start(ap, fmt);
> +    str = g_strdup_vprintf(fmt, ap);
> +    va_end(ap);
> +
> +    s->ops.send(s, str);
> +    g_free(str);
> +
> +    return qtest_rsp_words(s);
> +}
> +
>  static void qtest_rsp(QTestState *s)
>  {
>      gchar **words = qtest_rsp_args(s, 0);
> diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h
> index 7c0b239e5b5..715c363de30 100644
> --- a/tests/qtest/libqtest.h
> +++ b/tests/qtest/libqtest.h
> @@ -239,6 +239,19 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ...)
>  void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)
>      G_GNUC_PRINTF(2, 3);
>  
> +/**
> + * qtest_raw_cmd:
> + * @s: #QTestState instance to operate on.
> + * @fmt: raw qtest protocol text to send, formatted like sprintf().
> + *
> + * Sends a raw qtest command and returns the response split on spaces.
> + * The response is not required to start with ``OK``; callers can inspect
> + * ``args[0]`` for ``OK``, ``ERR``, or ``FAIL`` and must free the returned
> + * vector with g_strfreev().
> + */
> +gchar **qtest_raw_cmd(QTestState *s, const char *fmt, ...)
> +    G_GNUC_PRINTF(2, 3);
> +
>  /**
>   * qtest_socket_server:
>   * @socket_path: the UNIX domain socket path

Reviewed-by: Fabiano Rosas <farosas@suse.de>


  reply	other threads:[~2026-08-19 14:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14  3:56 [RFC v5 0/5] tests/qtest: Add memory-access attributes (secure/space) Tao Tang
2026-08-14  3:56 ` [RFC v5 1/5] tests/qtest: Add attrs support to qtest server memory commands Tao Tang
2026-08-19 13:32   ` Fabiano Rosas
2026-08-14  3:56 ` [RFC v5 2/5] tests/qtest: Add libqtest attrs helpers for memory accesses Tao Tang
2026-08-14  3:56 ` [RFC v5 3/5] tests/qtest: Add raw command response helper Tao Tang
2026-08-19 14:06   ` Fabiano Rosas [this message]
2026-08-14  3:56 ` [RFC v5 4/5] tests/qtest: Add qtest-attrs-test for memory access attrs Tao Tang
2026-08-19 14:14   ` Fabiano Rosas
2026-08-14  3:56 ` [RFC v5 5/5] [NOT-MERGE] tests/qtest: add q35 SMM-only x86 attrs coverage Tao Tang

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=87wltmkxws.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=chao.liu@processmission.com \
    --cc=chenbaozi@phytium.com.cn \
    --cc=jim.macarthur@linaro.org \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=tangtao1634@phytium.com.cn \
    /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