From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAyg3-0003fD-9u for qemu-devel@nongnu.org; Mon, 21 Dec 2015 06:30:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAyg2-0003dw-5z for qemu-devel@nongnu.org; Mon, 21 Dec 2015 06:30:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAyg1-0003do-VM for qemu-devel@nongnu.org; Mon, 21 Dec 2015 06:30:54 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A1D63C00124A for ; Mon, 21 Dec 2015 11:30:53 +0000 (UTC) From: marcandre.lureau@redhat.com Date: Mon, 21 Dec 2015 12:30:41 +0100 Message-Id: <1450697444-30119-6-git-send-email-marcandre.lureau@redhat.com> In-Reply-To: <1450697444-30119-1-git-send-email-marcandre.lureau@redhat.com> References: <1450697444-30119-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 5/8] ivshmem-test: test both msi & irq cases List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau Recent commit 660c97ee introduced a regression in irq case, make sure this code path is also tested. Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/ivshmem-test.c | 53 ++++++++++++++++++++++++++++++++++++----------= ------ 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c index d544d5e..705fece 100644 --- a/tests/ivshmem-test.c +++ b/tests/ivshmem-test.c @@ -277,18 +277,18 @@ static void *server_thread(void *data) return NULL; } =20 -static void setup_vm_with_server(IVState *s, int nvectors) +static void setup_vm_with_server(IVState *s, int nvectors, bool msi) { char *cmd =3D g_strdup_printf("-chardev socket,id=3Dchr0,path=3D%s,n= owait " - "-device ivshmem,size=3D1M,chardev=3Dchr= 0,vectors=3D%d", - tmpserver, nvectors); + "-device ivshmem,size=3D1M,chardev=3Dchr= 0,vectors=3D%d,msi=3D%s", + tmpserver, nvectors, msi ? "true" : "fal= se"); =20 - setup_vm_cmd(s, cmd, true); + setup_vm_cmd(s, cmd, msi); =20 g_free(cmd); } =20 -static void test_ivshmem_server(void) +static void test_ivshmem_server(bool msi) { IVState state1, state2, *s1, *s2; ServerThread thread; @@ -306,9 +306,9 @@ static void test_ivshmem_server(void) ret =3D ivshmem_server_start(&server); g_assert_cmpint(ret, =3D=3D, 0); =20 - setup_vm_with_server(&state1, nvectors); + setup_vm_with_server(&state1, nvectors, msi); s1 =3D &state1; - setup_vm_with_server(&state2, nvectors); + setup_vm_with_server(&state2, nvectors, msi); s2 =3D &state2; =20 g_assert_cmpuint(in_reg(s1, IVPOSITION), =3D=3D, 0xffffffff); @@ -338,27 +338,37 @@ static void test_ivshmem_server(void) g_assert_cmpuint(vm1, !=3D, vm2); =20 global_qtest =3D s1->qtest; - ret =3D qpci_msix_table_size(s1->dev); - g_assert_cmpuint(ret, =3D=3D, nvectors); + if (msi) { + ret =3D qpci_msix_table_size(s1->dev); + g_assert_cmpuint(ret, =3D=3D, nvectors); + } =20 /* ping vm2 -> vm1 */ - ret =3D qpci_msix_pending(s1->dev, 0); - g_assert_cmpuint(ret, =3D=3D, 0); + if (msi) { + ret =3D qpci_msix_pending(s1->dev, 0); + g_assert_cmpuint(ret, =3D=3D, 0); + } else { + out_reg(s1, INTRSTATUS, 0); + } out_reg(s2, DOORBELL, vm1 << 16); do { g_usleep(10000); - ret =3D qpci_msix_pending(s1->dev, 0); + ret =3D msi ? qpci_msix_pending(s1->dev, 0) : in_reg(s1, INTRSTA= TUS); } while (ret =3D=3D 0 && g_get_monotonic_time() < end_time); g_assert_cmpuint(ret, !=3D, 0); =20 /* ping vm1 -> vm2 */ global_qtest =3D s2->qtest; - ret =3D qpci_msix_pending(s2->dev, 0); - g_assert_cmpuint(ret, =3D=3D, 0); + if (msi) { + ret =3D qpci_msix_pending(s2->dev, 0); + g_assert_cmpuint(ret, =3D=3D, 0); + } else { + out_reg(s2, INTRSTATUS, 0); + } out_reg(s1, DOORBELL, vm2 << 16); do { g_usleep(10000); - ret =3D qpci_msix_pending(s2->dev, 0); + ret =3D msi ? qpci_msix_pending(s2->dev, 0) : in_reg(s2, INTRSTA= TUS); } while (ret =3D=3D 0 && g_get_monotonic_time() < end_time); g_assert_cmpuint(ret, !=3D, 0); =20 @@ -376,6 +386,16 @@ static void test_ivshmem_server(void) close(thread.pipe[0]); } =20 +static void test_ivshmem_server_msi(void) +{ + test_ivshmem_server(true); +} + +static void test_ivshmem_server_irq(void) +{ + test_ivshmem_server(false); +} + #define PCI_SLOT_HP 0x06 =20 static void test_ivshmem_hotplug(void) @@ -489,7 +509,8 @@ int main(int argc, char **argv) qtest_add_func("/ivshmem/memdev", test_ivshmem_memdev); if (g_test_slow()) { qtest_add_func("/ivshmem/pair", test_ivshmem_pair); - qtest_add_func("/ivshmem/server", test_ivshmem_server); + qtest_add_func("/ivshmem/server-msi", test_ivshmem_server_msi); + qtest_add_func("/ivshmem/server-irq", test_ivshmem_server_irq); } =20 ret =3D g_test_run(); --=20 2.5.0