From patchwork Mon Aug 20 12:02:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Giuseppe Esposito X-Patchwork-Id: 959639 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="c7TWIjv8"; dkim-atps=neutral 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 41vCBm3FF8z9s3C for ; Mon, 20 Aug 2018 22:03:44 +1000 (AEST) Received: from localhost ([::1]:46658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1friuM-00069t-33 for incoming@patchwork.ozlabs.org; Mon, 20 Aug 2018 08:03:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fritL-0005si-Ns for qemu-devel@nongnu.org; Mon, 20 Aug 2018 08:02:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fritJ-0002Wz-Kx for qemu-devel@nongnu.org; Mon, 20 Aug 2018 08:02:39 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:33205) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fritJ-0002Wg-DI; Mon, 20 Aug 2018 08:02:37 -0400 Received: by mail-ed1-x52e.google.com with SMTP id h9-v6so897897edr.0; Mon, 20 Aug 2018 05:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=H2t12HhRMXUkLxCxah5OGJ4PxzIcdFv6zaqIdbsPNPY=; b=c7TWIjv8xEhP6VhVJeJyHZ/2VqN4IJJ/qVjimHUozGV3f4mvSkzIXkMByDr/v7cW82 eeW6hG6BAKgapRKZ1Vy84p5OpR20+ajXkERboALlN7giJmKU9hwDdinXEsqEREJ/BcCq UCyms6xMxONOFUtjdQ0f7c5hoCzfScLIS0RebFxiuo1gG6KraVDOt239mdGxsGVVl4Xn ZY/PFJv/dH9nT6O1Ipk4s6S7QIEMsr95vZGS3MnC436CjUaxu0z0oxyqs0SUa7iWWRvt fJbk9ZWhvlMgs9ElPSTE0waZXvEGr0E4pLpKvNRliht1OKkYWb/dxa6Novwa8ja2Uxmm lHVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H2t12HhRMXUkLxCxah5OGJ4PxzIcdFv6zaqIdbsPNPY=; b=d7EI+JW4ZoKt5oRBNPBGvOkrCUR/jJk7QjLa/3rtmWJcNnFM+Pc9G5R4X1lz5ybvf/ g/QCKh7TiB+aEjbSEddAYY6+luNIxUXkjCLyY6k38TX9vksi0BODNDBTjXAr4ay2AkM/ bOpUp1ehbNfP3dLirjOOuK9bCKRX9dHye7bSnG1C05c5MSaPZXr7BRn4NRy2SXIBL8Z7 BQ2+sFEFZAcUZ3q7+nGQpM6DwdTSJp/j7raXzxmElI4xhGCTgtxYS88N8JeNiIrBtifA OYZBgI+GdzBBM2at/vjhMfXHEjVN/9XDzNHYojAHLT12k4TBJUp79iK9d4n4aj7A8uF5 bvrQ== X-Gm-Message-State: AOUpUlGPghfOdEh/up0nnUxu7ooXsng6MRlKgOkGmrU8Ff9b5tUpJ9bb dS+VceUZX4rkkwYG1tDbpQM/DemupmE= X-Google-Smtp-Source: AA+uWPzXcKdYHCBBDPJKMd/DPP29ajmr3lq/h3eSZAOzpXL2LuCNLT4GBcSb9fppm6+cwNqBgHI6Hw== X-Received: by 2002:aa7:d299:: with SMTP id w25-v6mr2261333edq.295.1534766556050; Mon, 20 Aug 2018 05:02:36 -0700 (PDT) Received: from emanuele-MacBookPro.mobile.usilu.net ([194.230.159.211]) by smtp.gmail.com with ESMTPSA id b20-v6sm1348486edc.30.2018.08.20.05.02.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 05:02:35 -0700 (PDT) From: Emanuele Giuseppe Esposito To: qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 14:02:06 +0200 Message-Id: <20180820120213.11095-10-e.emanuelegiuseppe@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180820120213.11095-1-e.emanuelegiuseppe@gmail.com> References: <20180820120213.11095-1-e.emanuelegiuseppe@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::52e Subject: [Qemu-devel] [PATCH 09/16] test/qgraph: nvme test node X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Dmitry Fleytman , Fam Zheng , =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Amit Shah , Jason Wang , "Michael S. Tsirkin" , Emanuele Giuseppe Esposito , Alexander Graf , Greg Kurz , Keith Busch , qemu-ppc@nongnu.org, Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , John Snow , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Convert tests/nvme-test in qgraph test node, nvme-test. Since it's a nop test, node creation and initialization is made in the same file. Signed-off-by: Emanuele Giuseppe Esposito --- tests/Makefile.include | 3 +-- tests/nvme-test.c | 43 ++++++++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index dea79797c5..62e74b28d1 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -213,7 +213,6 @@ gcov-files-pci-y += hw/net/pcnet-pci.c check-qtest-pci-y += tests/eepro100-test$(EXESUF) gcov-files-pci-y += hw/net/eepro100.c gcov-files-pci-y += hw/net/ne2000.c -check-qtest-pci-y += tests/nvme-test$(EXESUF) gcov-files-pci-y += hw/block/nvme.c gcov-files-pci-y += hw/audio/ac97.c check-qtest-pci-y += tests/es1370-test$(EXESUF) @@ -793,6 +792,7 @@ libqgraph-tests-obj-y += tests/ac97-test.o libqgraph-tests-obj-y += tests/tpci200-test.o libqgraph-tests-obj-y += tests/ipoctal232-test.o libqgraph-tests-obj-y += tests/ne2000-test.o +libqgraph-tests-obj-y += tests/nvme-test.o check-unit-y += tests/test-qgraph$(EXESUF) tests/test-qgraph$(EXESUF): tests/test-qgraph.o $(libqgraph-obj-y) @@ -841,7 +841,6 @@ tests/test-hmp$(EXESUF): tests/test-hmp.o tests/machine-none-test$(EXESUF): tests/machine-none-test.o tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-virtio-obj-y) tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y) -tests/nvme-test$(EXESUF): tests/nvme-test.o tests/pvpanic-test$(EXESUF): tests/pvpanic-test.o tests/i82801b11-test$(EXESUF): tests/i82801b11-test.o tests/es1370-test$(EXESUF): tests/es1370-test.o diff --git a/tests/nvme-test.c b/tests/nvme-test.c index 7674a446e4..f6209e45cb 100644 --- a/tests/nvme-test.c +++ b/tests/nvme-test.c @@ -9,24 +9,47 @@ #include "qemu/osdep.h" #include "libqtest.h" +#include "libqos/qgraph.h" + +typedef struct QNvme QNvme; + +struct QNvme { + QOSGraphObject obj; +}; /* Tests only initialization so far. TODO: Replace with functional tests */ -static void nop(void) +static void nop(void *obj, void *data, QGuestAllocator *alloc) +{ +} + +static void nvme_destructor(QOSGraphObject *obj) { + QNvme *nvme = (QNvme *)obj; + g_free(nvme); } -int main(int argc, char **argv) +static void *nvme_create(void *pci_bus, QGuestAllocator *alloc, void *addr) { - int ret; + QNvme *nvme = g_new0(QNvme, 1); + nvme->obj.destructor = nvme_destructor; - g_test_init(&argc, &argv, NULL); - qtest_add_func("/nvme/nop", nop); + return &nvme->obj; +} - qtest_start("-drive id=drv0,if=none,file=null-co://,format=raw " - "-device nvme,drive=drv0,serial=foo"); - ret = g_test_run(); +static void nvme_register_nodes(void) +{ + qos_node_create_driver("nvme", nvme_create); + qos_node_consumes("nvme", "pci-bus", &(QOSGraphEdgeOptions) { + .extra_device_opts = "drive=drv0,serial=foo", + .before_cmd_line = "-drive id=drv0,if=none,file=null-co://,format=raw", + }); +} - qtest_end(); +libqos_init(nvme_register_nodes); - return ret; +static void register_nvme_test(void) +{ + qos_add_test("nvme-test", "nvme", nop, NULL); } + +libqos_init(register_nvme_test);