From: Laurent Vivier <lvivier@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>,
pbonzini@redhat.com, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, agraf@suse.de, stefanha@redhat.com,
mst@redhat.com, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com,
groug@kaod.org, thuth@redhat.com
Subject: Re: [Qemu-devel] [PATCH 7/8] tests: Use qpci_mem{read, write} in ivshmem-test
Date: Tue, 18 Oct 2016 18:14:09 +0200 [thread overview]
Message-ID: <c6baf7ee-aec7-963c-323c-5fac64e5e7c4@redhat.com> (raw)
In-Reply-To: <1476787933-7180-8-git-send-email-david@gibson.dropbear.id.au>
On 18/10/2016 12:52, David Gibson wrote:
> ivshmem implements a block of shared memory in a PCI BAR. Currently our
> test case accesses this using qtest_mem{read,write}. However, deducing
> the correct addresses for these requires making assumptions about the
> internel format returned by qpci_iomap(), along with some ugly casts.
>
> This patch changes the test to use the new qpci_mem{read,write} interfaces
> which is neater.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
I think your changes break this test.
There is two guest, so we need to access them through two sockets,
defined in s1->qtest and s2->qtest.
But qpci_memXXX() always use memread(...) and thus
qtest_memread(global_qtest, ...) , so always test the last guest started.
You must swap global_qtest as it is done in in_reg()/out_reg() before
your qpci_memXXX() in test_ivshmem_pair().
Laurent
> ---
> tests/ivshmem-test.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
> index f36bfe7..97a887e 100644
> --- a/tests/ivshmem-test.c
> +++ b/tests/ivshmem-test.c
> @@ -169,7 +169,7 @@ static void test_ivshmem_single(void)
> for (i = 0; i < G_N_ELEMENTS(data); i++) {
> data[i] = i;
> }
> - qtest_memwrite(s->qtest, (uintptr_t)s->mem_base, data, sizeof(data));
> + qpci_memwrite(s->dev, s->mem_base, data, sizeof(data));
>
> /* verify write */
> for (i = 0; i < G_N_ELEMENTS(data); i++) {
> @@ -178,7 +178,7 @@ static void test_ivshmem_single(void)
>
> /* read it back and verify read */
> memset(data, 0, sizeof(data));
> - qtest_memread(s->qtest, (uintptr_t)s->mem_base, data, sizeof(data));
> + qpci_memread(s->dev, s->mem_base, data, sizeof(data));
> for (i = 0; i < G_N_ELEMENTS(data); i++) {
> g_assert_cmpuint(data[i], ==, i);
> }
> @@ -201,29 +201,29 @@ static void test_ivshmem_pair(void)
>
> /* host write, guest 1 & 2 read */
> memset(tmpshmem, 0x42, TMPSHMSIZE);
> - qtest_memread(s1->qtest, (uintptr_t)s1->mem_base, data, TMPSHMSIZE);
> + qpci_memread(s1->dev, s1->mem_base, data, TMPSHMSIZE);
> for (i = 0; i < TMPSHMSIZE; i++) {
> g_assert_cmpuint(data[i], ==, 0x42);
> }
> - qtest_memread(s2->qtest, (uintptr_t)s2->mem_base, data, TMPSHMSIZE);
> + qpci_memread(s2->dev, s2->mem_base, data, TMPSHMSIZE);
> for (i = 0; i < TMPSHMSIZE; i++) {
> g_assert_cmpuint(data[i], ==, 0x42);
> }
>
> /* guest 1 write, guest 2 read */
> memset(data, 0x43, TMPSHMSIZE);
> - qtest_memwrite(s1->qtest, (uintptr_t)s1->mem_base, data, TMPSHMSIZE);
> + qpci_memwrite(s1->dev, s1->mem_base, data, TMPSHMSIZE);
> memset(data, 0, TMPSHMSIZE);
> - qtest_memread(s2->qtest, (uintptr_t)s2->mem_base, data, TMPSHMSIZE);
> + qpci_memread(s2->dev, s2->mem_base, data, TMPSHMSIZE);
> for (i = 0; i < TMPSHMSIZE; i++) {
> g_assert_cmpuint(data[i], ==, 0x43);
> }
>
> /* guest 2 write, guest 1 read */
> memset(data, 0x44, TMPSHMSIZE);
> - qtest_memwrite(s2->qtest, (uintptr_t)s2->mem_base, data, TMPSHMSIZE);
> + qpci_memwrite(s2->dev, s2->mem_base, data, TMPSHMSIZE);
> memset(data, 0, TMPSHMSIZE);
> - qtest_memread(s1->qtest, (uintptr_t)s2->mem_base, data, TMPSHMSIZE);
> + qpci_memread(s1->dev, s2->mem_base, data, TMPSHMSIZE);
> for (i = 0; i < TMPSHMSIZE; i++) {
> g_assert_cmpuint(data[i], ==, 0x44);
> }
>
next prev parent reply other threads:[~2016-10-18 16:14 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-18 10:52 [Qemu-devel] [PATCH 0/8] Cleanups to qtest PCI handling David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 1/8] libqos: Give qvirtio_config_read*() consistent semantics David Gibson
2016-10-18 12:41 ` Laurent Vivier
2016-10-18 13:27 ` Greg Kurz
2016-10-19 2:41 ` David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 2/8] libqos: Handle PCI IO de-multiplexing in common code David Gibson
2016-10-18 13:28 ` Laurent Vivier
2016-10-19 2:59 ` David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 3/8] libqos: Move BAR assignment to " David Gibson
2016-10-18 15:00 ` Laurent Vivier
2016-10-19 3:07 ` David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 4/8] tests: Better handle legacy IO addresses in tco-test David Gibson
2016-10-18 15:14 ` Laurent Vivier
2016-10-18 16:28 ` Laurent Vivier
2016-10-19 3:19 ` David Gibson
2016-10-19 3:09 ` David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 5/8] libqos: Add streaming accessors for PCI MMIO David Gibson
2016-10-18 15:17 ` Laurent Vivier
2016-10-18 10:52 ` [Qemu-devel] [PATCH 6/8] libqos: Implement mmio accessors in terms of mem{read, write} David Gibson
2016-10-18 16:04 ` Laurent Vivier
2016-10-18 10:52 ` [Qemu-devel] [PATCH 7/8] tests: Use qpci_mem{read, write} in ivshmem-test David Gibson
2016-10-18 16:14 ` Laurent Vivier [this message]
2016-10-19 4:13 ` David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 8/8] libqos: Change PCI accessors to take opaque BAR handle David Gibson
2016-10-18 16:48 ` Laurent Vivier
2016-10-19 4:06 ` David Gibson
2016-10-18 11:56 ` [Qemu-devel] [PATCH 0/8] Cleanups to qtest PCI handling Laurent Vivier
2016-10-19 1:11 ` David Gibson
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=c6baf7ee-aec7-963c-323c-5fac64e5e7c4@redhat.com \
--to=lvivier@redhat.com \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.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).