qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: Stefan Berger <stefanb@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, marcandre.lureau@redhat.com
Cc: philmd@redhat.com
Subject: Re: [PATCH v4 10/10] tests: Use QMP to check whether a TPM device model is available
Date: Tue, 13 Jul 2021 08:12:01 -0400	[thread overview]
Message-ID: <c3ac33b0-f44f-05fc-810e-60d80b35efb4@linux.ibm.com> (raw)
In-Reply-To: <20210712204736.365349-11-stefanb@linux.vnet.ibm.com>


On 7/12/21 4:47 PM, Stefan Berger wrote:
> Use QMP to check whether a given TPM device model is available
> and if it is not the case then skip a test that requires it.
>
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
>
> +    rsp_tpm = qtest_qmp(qts, "{ 'execute': 'query-tpm'}");
> +    if (!qdict_haskey(rsp_tpm, "error")) {
> +        QDict *rsp_models = qtest_qmp(qts,
> +                                      "{ 'execute': 'query-tpm-models'}");
> +        if (qdict_haskey(rsp_models, "return")) {
> +            QList *models = qdict_get_qlist(rsp_models, "return");
> +            QListEntry *e;
> +
> +            QLIST_FOREACH_ENTRY(models, e) {
> +                QString *s = qobject_to(QString, qlist_entry_obj(e));
> +                const char *ename = qstring_get_str(s);
> +                if (!strcmp(ename, tpm_if)) {
> +                    ret = true;
> +                }
> +            }
> +            qobject_unref(models);

I think this unref was too much. It tipped off s390x but none other (?).

https://travis-ci.com/github/stefanberger/qemu-tpm/builds/232529861


I fixed this in v5 (https://travis-ci.com/github/stefanberger/qemu-tpm)


I think this is generally the right approach for this test case, isn't it?


> +        }
> +        qobject_unref(rsp_models);
> +    }
> +    qobject_unref(rsp_tpm);
> +    qtest_quit(qts);
> +
> +    return ret;
> +}
> diff --git a/tests/qtest/tpm-emu.h b/tests/qtest/tpm-emu.h
> index fcb5d7a1d6..c33d99af37 100644
> --- a/tests/qtest/tpm-emu.h
> +++ b/tests/qtest/tpm-emu.h
> @@ -22,6 +22,7 @@
>   #include "qemu/sockets.h"
>   #include "io/channel.h"
>   #include "sysemu/tpm.h"
> +#include "libqos/libqtest.h"
>   
>   struct tpm_hdr {
>       uint16_t tag;
> @@ -50,5 +51,6 @@ typedef struct TPMTestState {
>   
>   void tpm_emu_test_wait_cond(TPMTestState *s);
>   void *tpm_emu_ctrl_thread(void *data);
> +bool tpm_model_is_available(const char *args, const char *tpm_if);
>   
>   #endif /* TESTS_TPM_EMU_H */


  reply	other threads:[~2021-07-13 12:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12 20:47 [PATCH v4 00/10] tests: Add test cases for TPM 1.2 ACPI tables Stefan Berger
2021-07-12 20:47 ` [PATCH v4 01/10] tests: Rename TestState to TPMTestState Stefan Berger
2021-07-12 20:47 ` [PATCH v4 02/10] tests: Add tpm_version field to TPMTestState and fill it Stefan Berger
2021-07-12 20:47 ` [PATCH v4 03/10] tests: acpi: Prepare for renaming of TPM2 related ACPI files Stefan Berger
2021-07-12 20:47 ` [PATCH v4 04/10] tests: Add suffix 'tpm2' or 'tpm12' to ACPI table files Stefan Berger
2021-07-12 20:47 ` [PATCH v4 05/10] tests: acpi: tpm2: Add the renamed ACPI files and drop old ones Stefan Berger
2021-07-12 20:47 ` [PATCH v4 06/10] tests: tpm: Create TPM 1.2 response in TPM emulator Stefan Berger
2021-07-12 20:47 ` [PATCH v4 07/10] tests: acpi: prepare for new TPM 1.2 related tables Stefan Berger
2021-07-12 20:47 ` [PATCH v4 08/10] tests: acpi: Add test cases for TPM 1.2 with TCPA table Stefan Berger
2021-07-12 20:47 ` [PATCH v4 09/10] tests: acpi: tpm1.2: Add expected TPM 1.2 ACPI blobs Stefan Berger
2021-07-12 20:47 ` [PATCH v4 10/10] tests: Use QMP to check whether a TPM device model is available Stefan Berger
2021-07-13 12:12   ` Stefan Berger [this message]
2021-07-13 16:36   ` Philippe Mathieu-Daudé
2021-07-13 15:19 ` [PATCH v4 00/10] tests: Add test cases for TPM 1.2 ACPI tables Michael S. Tsirkin
2021-07-13 15:42   ` Stefan Berger

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=c3ac33b0-f44f-05fc-810e-60d80b35efb4@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.vnet.ibm.com \
    /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).