From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm61r-0004kf-Rq for qemu-devel@nongnu.org; Thu, 28 Nov 2013 13:09:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm61i-0002cI-Bn for qemu-devel@nongnu.org; Thu, 28 Nov 2013 13:09:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13775) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm61i-0002bj-4F for qemu-devel@nongnu.org; Thu, 28 Nov 2013 13:09:22 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rASI9K2X026840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Nov 2013 13:09:21 -0500 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-104.ams2.redhat.com [10.36.116.104]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rASI9HnJ029081 for ; Thu, 28 Nov 2013 13:09:20 -0500 From: Laszlo Ersek Date: Thu, 28 Nov 2013 19:09:13 +0100 Message-Id: <1385662155-15212-3-git-send-email-lersek@redhat.com> In-Reply-To: <1385662155-15212-1-git-send-email-lersek@redhat.com> References: <1385662155-15212-1-git-send-email-lersek@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/4] i440fx-test: give each GTest case its own qtest List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The current two GTest cases, /i440fx/defaults and /i440fx/pam can share a qemu process, but the next two cases will need dedicated instances. It is messy (and order-dependent) to dynamically configure GTest cases one by one to start, stop, or keep the current qtest (*); let's just have each GTest work with its own qtest. The performance difference should be negligible. (*) As g_test_run() can be invoked at most once per process startup, and it runs GTest cases in sequence, we'd need clumsy data structures to control each GTest case to start/stop/keep the qemu instance. Or, we'd have to code the same information into the test methods themselves, which would make them even more order-dependent. Signed-off-by: Laszlo Ersek --- tests/i440fx-test.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c index 6ac46bf..3962bca 100644 --- a/tests/i440fx-test.c +++ b/tests/i440fx-test.c @@ -28,16 +28,27 @@ typedef struct TestData { int num_cpus; - QPCIBus *bus; } TestData; +static QPCIBus *test_start_get_bus(const TestData *s) +{ + char *cmdline; + + cmdline = g_strdup_printf("-smp %d", s->num_cpus); + qtest_start(cmdline); + g_free(cmdline); + return qpci_init_pc(); +} + static void test_i440fx_defaults(gconstpointer opaque) { const TestData *s = opaque; + QPCIBus *bus; QPCIDevice *dev; uint32_t value; - dev = qpci_device_find(s->bus, QPCI_DEVFN(0, 0)); + bus = test_start_get_bus(s); + dev = qpci_device_find(bus, QPCI_DEVFN(0, 0)); g_assert(dev != NULL); /* 3.2.2 */ @@ -121,6 +132,8 @@ static void test_i440fx_defaults(gconstpointer opaque) g_assert_cmpint(qpci_config_readb(dev, 0x91), ==, 0x00); /* ERRSTS */ /* 3.2.26 */ g_assert_cmpint(qpci_config_readb(dev, 0x93), ==, 0x00); /* TRC */ + + qtest_end(); } #define PAM_RE 1 @@ -179,6 +192,7 @@ static void write_area(uint32_t start, uint32_t end, uint8_t value) static void test_i440fx_pam(gconstpointer opaque) { const TestData *s = opaque; + QPCIBus *bus; QPCIDevice *dev; int i; static struct { @@ -201,7 +215,8 @@ static void test_i440fx_pam(gconstpointer opaque) { 0xEC000, 0xEFFFF }, /* BIOS Extension */ }; - dev = qpci_device_find(s->bus, QPCI_DEVFN(0, 0)); + bus = test_start_get_bus(s); + dev = qpci_device_find(bus, QPCI_DEVFN(0, 0)); g_assert(dev != NULL); for (i = 0; i < ARRAY_SIZE(pam_area); i++) { @@ -254,30 +269,21 @@ static void test_i440fx_pam(gconstpointer opaque) /* Verify the area is not our new mask */ g_assert(!verify_area(pam_area[i].start, pam_area[i].end, 0x82)); } + qtest_end(); } int main(int argc, char **argv) { TestData data; - char *cmdline; int ret; g_test_init(&argc, &argv, NULL); data.num_cpus = 1; - cmdline = g_strdup_printf("-smp %d", data.num_cpus); - qtest_start(cmdline); - g_free(cmdline); - - data.bus = qpci_init_pc(); - g_test_add_data_func("/i440fx/defaults", &data, test_i440fx_defaults); g_test_add_data_func("/i440fx/pam", &data, test_i440fx_pam); ret = g_test_run(); - - qtest_end(); - return ret; } -- 1.8.3.1