From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wes1-so2.wedos.net (wes1-so2.wedos.net [46.28.106.16]) by dpdk.org (Postfix) with ESMTP id 2A8165A0C for ; Fri, 6 May 2016 12:50:50 +0200 (CEST) Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz [147.229.13.147]) by wes1-so2.wedos.net (Postfix) with ESMTPSA id 3r1T8S1HGtz1wY; Fri, 6 May 2016 12:50:48 +0200 (CEST) From: Jan Viktorin To: dev@dpdk.org Cc: Jan Viktorin , Bruce Richardson , Thomas Monjalon , David Marchand Date: Fri, 6 May 2016 12:48:36 +0200 Message-Id: <1462531720-26217-7-git-send-email-viktorin@rehivetech.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1462531720-26217-1-git-send-email-viktorin@rehivetech.com> References: <1462531720-26217-1-git-send-email-viktorin@rehivetech.com> In-Reply-To: <1461935496-20367-1-git-send-email-viktorin@rehivetech.com> References: <1461935496-20367-1-git-send-email-viktorin@rehivetech.com> Subject: [dpdk-dev] [PATCH v1 06/10] app/test: extract test_pci_setup and test_pci_cleanup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2016 10:50:50 -0000 Signed-off-by: Jan Viktorin --- app/test/test_pci.c | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/app/test/test_pci.c b/app/test/test_pci.c index cf82373..9d53ba5 100644 --- a/app/test/test_pci.c +++ b/app/test/test_pci.c @@ -148,21 +148,46 @@ static void free_devargs_list(void) struct pci_driver_list real_pci_driver_list = TAILQ_HEAD_INITIALIZER(real_pci_driver_list); +static int +test_pci_setup(void) +{ + struct rte_pci_driver *dr; + + /* Unregister original driver list */ + while (!TAILQ_EMPTY(&pci_driver_list)) { + dr = TAILQ_FIRST(&pci_driver_list); + rte_eal_pci_unregister(dr); + TAILQ_INSERT_TAIL(&real_pci_driver_list, dr, next); + } + + return 0; +} + +static int +test_pci_cleanup(void) +{ + struct rte_pci_driver *dr; + + /* Restore original driver list */ + while (!TAILQ_EMPTY(&real_pci_driver_list)) { + dr = TAILQ_FIRST(&real_pci_driver_list); + TAILQ_REMOVE(&real_pci_driver_list, dr, next); + rte_eal_pci_register(dr); + } + + return 0; +} + int test_pci(void) { struct rte_devargs_list save_devargs_list; - struct rte_pci_driver *dr = NULL; printf("Dump all devices\n"); rte_eal_pci_dump(stdout); - /* Unregister all previous drivers */ - while (!TAILQ_EMPTY(&pci_driver_list)) { - dr = TAILQ_FIRST(&pci_driver_list); - rte_eal_pci_unregister(dr); - TAILQ_INSERT_TAIL(&real_pci_driver_list, dr, next); - } + if (test_pci_setup()) + return -1; rte_eal_pci_register(&my_driver); rte_eal_pci_register(&my_driver2); @@ -199,12 +224,8 @@ test_pci(void) rte_eal_pci_unregister(&my_driver); rte_eal_pci_unregister(&my_driver2); - /* Restore original driver list */ - while (!TAILQ_EMPTY(&real_pci_driver_list)) { - dr = TAILQ_FIRST(&real_pci_driver_list); - TAILQ_REMOVE(&real_pci_driver_list, dr, next); - rte_eal_pci_register(dr); - } + if (test_pci_cleanup()) + return -1; return 0; } -- 2.8.0