From patchwork Tue Feb 2 12:43:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 577127 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 00330140AD9 for ; Tue, 2 Feb 2016 23:44:36 +1100 (AEDT) Received: from localhost ([::1]:56648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQaJv-0006GD-42 for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2016 07:44:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQaJA-00051q-2o for qemu-devel@nongnu.org; Tue, 02 Feb 2016 07:43:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQaJ8-0001zw-Qo for qemu-devel@nongnu.org; Tue, 02 Feb 2016 07:43:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32777) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQaJ8-0001zs-JT for qemu-devel@nongnu.org; Tue, 02 Feb 2016 07:43:46 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 3A49A8E919; Tue, 2 Feb 2016 12:43:46 +0000 (UTC) Received: from localhost (ovpn-113-82.phx2.redhat.com [10.3.113.82]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u12Chje8031724; Tue, 2 Feb 2016 07:43:45 -0500 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Tue, 2 Feb 2016 13:43:33 +0100 Message-Id: <1454417016-3913-6-git-send-email-marcandre.lureau@redhat.com> In-Reply-To: <1454417016-3913-1-git-send-email-marcandre.lureau@redhat.com> References: <1454417016-3913-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: claudio.fontana@huawei.com, armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [Qemu-devel] [PULL 5/8] ivshmem-test: test both msi & irq cases X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Marc-André Lureau Recent commit 660c97ee introduced a regression in irq case, make sure this code path is also tested. Signed-off-by: Marc-André Lureau Reviewed-by: Markus Armbruster --- 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; } -static void setup_vm_with_server(IVState *s, int nvectors) +static void setup_vm_with_server(IVState *s, int nvectors, bool msi) { char *cmd = g_strdup_printf("-chardev socket,id=chr0,path=%s,nowait " - "-device ivshmem,size=1M,chardev=chr0,vectors=%d", - tmpserver, nvectors); + "-device ivshmem,size=1M,chardev=chr0,vectors=%d,msi=%s", + tmpserver, nvectors, msi ? "true" : "false"); - setup_vm_cmd(s, cmd, true); + setup_vm_cmd(s, cmd, msi); g_free(cmd); } -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 = ivshmem_server_start(&server); g_assert_cmpint(ret, ==, 0); - setup_vm_with_server(&state1, nvectors); + setup_vm_with_server(&state1, nvectors, msi); s1 = &state1; - setup_vm_with_server(&state2, nvectors); + setup_vm_with_server(&state2, nvectors, msi); s2 = &state2; g_assert_cmpuint(in_reg(s1, IVPOSITION), ==, 0xffffffff); @@ -338,27 +338,37 @@ static void test_ivshmem_server(void) g_assert_cmpuint(vm1, !=, vm2); global_qtest = s1->qtest; - ret = qpci_msix_table_size(s1->dev); - g_assert_cmpuint(ret, ==, nvectors); + if (msi) { + ret = qpci_msix_table_size(s1->dev); + g_assert_cmpuint(ret, ==, nvectors); + } /* ping vm2 -> vm1 */ - ret = qpci_msix_pending(s1->dev, 0); - g_assert_cmpuint(ret, ==, 0); + if (msi) { + ret = qpci_msix_pending(s1->dev, 0); + g_assert_cmpuint(ret, ==, 0); + } else { + out_reg(s1, INTRSTATUS, 0); + } out_reg(s2, DOORBELL, vm1 << 16); do { g_usleep(10000); - ret = qpci_msix_pending(s1->dev, 0); + ret = msi ? qpci_msix_pending(s1->dev, 0) : in_reg(s1, INTRSTATUS); } while (ret == 0 && g_get_monotonic_time() < end_time); g_assert_cmpuint(ret, !=, 0); /* ping vm1 -> vm2 */ global_qtest = s2->qtest; - ret = qpci_msix_pending(s2->dev, 0); - g_assert_cmpuint(ret, ==, 0); + if (msi) { + ret = qpci_msix_pending(s2->dev, 0); + g_assert_cmpuint(ret, ==, 0); + } else { + out_reg(s2, INTRSTATUS, 0); + } out_reg(s1, DOORBELL, vm2 << 16); do { g_usleep(10000); - ret = qpci_msix_pending(s2->dev, 0); + ret = msi ? qpci_msix_pending(s2->dev, 0) : in_reg(s2, INTRSTATUS); } while (ret == 0 && g_get_monotonic_time() < end_time); g_assert_cmpuint(ret, !=, 0); @@ -376,6 +386,16 @@ static void test_ivshmem_server(void) close(thread.pipe[0]); } +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 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); } ret = g_test_run();