From nobody Fri May 3 07:21:37 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508336591443199.3715220819039; Wed, 18 Oct 2017 07:23:11 -0700 (PDT) Received: from localhost ([::1]:44937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4pFA-00044c-GD for importer@patchew.org; Wed, 18 Oct 2017 10:22:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4pDQ-000363-D9 for qemu-devel@nongnu.org; Wed, 18 Oct 2017 10:21:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4pDN-00020t-7J for qemu-devel@nongnu.org; Wed, 18 Oct 2017 10:21:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54598) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e4pDM-0001yj-TT; Wed, 18 Oct 2017 10:20:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D205D4ACCA; Wed, 18 Oct 2017 14:20:53 +0000 (UTC) Received: from thh440s.str.redhat.com (dhcp-192-189.str.redhat.com [10.33.192.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29F156A529; Wed, 18 Oct 2017 14:20:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D205D4ACCA Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=thuth@redhat.com From: Thomas Huth To: qemu-devel@nongnu.org Date: Wed, 18 Oct 2017 16:20:27 +0200 Message-Id: <1508336428-20511-2-git-send-email-thuth@redhat.com> In-Reply-To: <1508336428-20511-1-git-send-email-thuth@redhat.com> References: <1508336428-20511-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 18 Oct 2017 14:20:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/2] libqtest: Add qtest_[v]startf() 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: qemu-s390x@nongnu.org, cohuck@redhat.com, Amit Shah , Michael S Tsirkin Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake We have several callers that were formatting the argument strings themselves; consolidate this effort by adding new convenience functions directly in libqtest, and update some call-sites that can benefit from it. Note that the new functions qtest_startf() and qtest_vstartf() behave more like qtest_init() (the caller must assign global_qtest after the fact, rather than getting it implicitly set). This helps us prepare for future patches that get rid of the global variable, by explicitly highlighting which tests still depend on it now. Signed-off-by: Eric Blake [thuth: Dropped the hunks that do not apply cleanly to qemu master yet and added the missing g_free(args) in qtest_vstartf()] Signed-off-by: Thomas Huth Acked-by: Michael S. Tsirkin --- tests/boot-order-test.c | 11 +++------ tests/boot-serial-test.c | 12 +++------ tests/endianness-test.c | 33 +++++++++---------------- tests/ipmi-bt-test.c | 11 +++------ tests/libqtest.c | 22 +++++++++++++++++ tests/libqtest.h | 25 +++++++++++++++++++ tests/m25p80-test.c | 9 +++---- tests/pnv-xscom-test.c | 16 +++--------- tests/prom-env-test.c | 13 ++++------ tests/tco-test.c | 10 +++----- tests/test-filter-mirror.c | 14 +++++------ tests/test-filter-redirector.c | 56 ++++++++++++++++++++------------------= ---- tests/virtio-blk-test.c | 5 +--- tests/vmgenid-test.c | 29 ++++++---------------- 14 files changed, 128 insertions(+), 138 deletions(-) diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c index fc1e794..60c5545 100644 --- a/tests/boot-order-test.c +++ b/tests/boot-order-test.c @@ -28,14 +28,12 @@ static void test_a_boot_order(const char *machine, uint64_t expected_boot, uint64_t expected_reboot) { - char *args; uint64_t actual; =20 - args =3D g_strdup_printf("-nodefaults%s%s %s", - machine ? " -M " : "", - machine ?: "", - test_args); - qtest_start(args); + global_qtest =3D qtest_startf("-nodefaults%s%s %s", + machine ? " -M " : "", + machine ?: "", + test_args); actual =3D read_boot_order(); g_assert_cmphex(actual, =3D=3D, expected_boot); qmp_discard_response("{ 'execute': 'system_reset' }"); @@ -47,7 +45,6 @@ static void test_a_boot_order(const char *machine, actual =3D read_boot_order(); g_assert_cmphex(actual, =3D=3D, expected_reboot); qtest_quit(global_qtest); - g_free(args); } =20 static void test_boot_orders(const char *machine, diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index b95c5e7..c935d69 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -71,7 +71,6 @@ done: static void test_machine(const void *data) { const testdef_t *test =3D data; - char *args; char tmpname[] =3D "/tmp/qtest-boot-serial-XXXXXX"; int fd; =20 @@ -82,18 +81,15 @@ static void test_machine(const void *data) * Make sure that this test uses tcg if available: It is used as a * fast-enough smoketest for that. */ - args =3D g_strdup_printf("-M %s,accel=3Dtcg:kvm " - "-chardev file,id=3Dserial0,path=3D%s " - "-no-shutdown -serial chardev:serial0 %s", - test->machine, tmpname, test->extra); - - qtest_start(args); + global_qtest =3D qtest_startf("-M %s,accel=3Dtcg:kvm " + "-chardev file,id=3Dserial0,path=3D%s " + "-no-shutdown -serial chardev:serial0 %s", + test->machine, tmpname, test->extra); unlink(tmpname); =20 check_guest_output(test, fd); qtest_quit(global_qtest); =20 - g_free(args); close(fd); } =20 diff --git a/tests/endianness-test.c b/tests/endianness-test.c index ed0bf52..546e096 100644 --- a/tests/endianness-test.c +++ b/tests/endianness-test.c @@ -114,13 +114,11 @@ static void isa_outl(const TestCase *test, uint16_t a= ddr, uint32_t value) static void test_endianness(gconstpointer data) { const TestCase *test =3D data; - char *args; =20 - args =3D g_strdup_printf("-M %s%s%s -device pc-testdev", - test->machine, - test->superio ? " -device " : "", - test->superio ?: ""); - qtest_start(args); + global_qtest =3D qtest_startf("-M %s%s%s -device pc-testdev", + test->machine, + test->superio ? " -device " : "", + test->superio ?: ""); isa_outl(test, 0xe0, 0x87654321); g_assert_cmphex(isa_inl(test, 0xe0), =3D=3D, 0x87654321); g_assert_cmphex(isa_inw(test, 0xe2), =3D=3D, 0x8765); @@ -183,19 +181,16 @@ static void test_endianness(gconstpointer data) g_assert_cmphex(isa_inb(test, 0xe1), =3D=3D, 0x43); g_assert_cmphex(isa_inb(test, 0xe0), =3D=3D, 0x21); qtest_quit(global_qtest); - g_free(args); } =20 static void test_endianness_split(gconstpointer data) { const TestCase *test =3D data; - char *args; =20 - args =3D g_strdup_printf("-M %s%s%s -device pc-testdev", - test->machine, - test->superio ? " -device " : "", - test->superio ?: ""); - qtest_start(args); + global_qtest =3D qtest_startf("-M %s%s%s -device pc-testdev", + test->machine, + test->superio ? " -device " : "", + test->superio ?: ""); isa_outl(test, 0xe8, 0x87654321); g_assert_cmphex(isa_inl(test, 0xe0), =3D=3D, 0x87654321); g_assert_cmphex(isa_inw(test, 0xe2), =3D=3D, 0x8765); @@ -230,19 +225,16 @@ static void test_endianness_split(gconstpointer data) g_assert_cmphex(isa_inw(test, 0xe2), =3D=3D, 0x8765); g_assert_cmphex(isa_inw(test, 0xe0), =3D=3D, 0x4321); qtest_quit(global_qtest); - g_free(args); } =20 static void test_endianness_combine(gconstpointer data) { const TestCase *test =3D data; - char *args; =20 - args =3D g_strdup_printf("-M %s%s%s -device pc-testdev", - test->machine, - test->superio ? " -device " : "", - test->superio ?: ""); - qtest_start(args); + global_qtest =3D qtest_startf("-M %s%s%s -device pc-testdev", + test->machine, + test->superio ? " -device " : "", + test->superio ?: ""); isa_outl(test, 0xe0, 0x87654321); g_assert_cmphex(isa_inl(test, 0xe8), =3D=3D, 0x87654321); g_assert_cmphex(isa_inw(test, 0xea), =3D=3D, 0x8765); @@ -277,7 +269,6 @@ static void test_endianness_combine(gconstpointer data) g_assert_cmphex(isa_inw(test, 0xea), =3D=3D, 0x8765); g_assert_cmphex(isa_inw(test, 0xe8), =3D=3D, 0x4321); qtest_quit(global_qtest); - g_free(args); } =20 int main(int argc, char **argv) diff --git a/tests/ipmi-bt-test.c b/tests/ipmi-bt-test.c index 7e21a9b..8be18e3 100644 --- a/tests/ipmi-bt-test.c +++ b/tests/ipmi-bt-test.c @@ -401,7 +401,6 @@ static void open_socket(void) int main(int argc, char **argv) { const char *arch =3D qtest_get_arch(); - char *cmdline; int ret; =20 /* Check architecture */ @@ -415,12 +414,10 @@ int main(int argc, char **argv) /* Run the tests */ g_test_init(&argc, &argv, NULL); =20 - cmdline =3D g_strdup_printf( - " -chardev socket,id=3Dipmi0,host=3Dlocalhost,port=3D%d,reconnec= t=3D10" - " -device ipmi-bmc-extern,chardev=3Dipmi0,id=3Dbmc0" - " -device isa-ipmi-bt,bmc=3Dbmc0", emu_port); - qtest_start(cmdline); - g_free(cmdline); + global_qtest =3D qtest_startf( + " -chardev socket,id=3Dipmi0,host=3Dlocalhost,port=3D%d,reconnect= =3D10" + " -device ipmi-bmc-extern,chardev=3Dipmi0,id=3Dbmc0" + " -device isa-ipmi-bt,bmc=3Dbmc0", emu_port); qtest_irq_intercept_in(global_qtest, "ioapic"); qtest_add_func("/ipmi/extern/connect", test_connect); qtest_add_func("/ipmi/extern/bt_base", test_bt_base); diff --git a/tests/libqtest.c b/tests/libqtest.c index adf7118..0ec8af2 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -244,6 +244,28 @@ QTestState *qtest_init(const char *extra_args) return s; } =20 +QTestState *qtest_vstartf(const char *fmt, va_list ap) +{ + char *args =3D g_strdup_vprintf(fmt, ap); + QTestState *s; + + s =3D qtest_start(args); + g_free(args); + global_qtest =3D NULL; + return s; +} + +QTestState *qtest_startf(const char *fmt, ...) +{ + va_list ap; + QTestState *s; + + va_start(ap, fmt); + s =3D qtest_vstartf(fmt, ap); + va_end(ap); + return s; +} + void qtest_quit(QTestState *s) { g_hook_destroy_link(&abrt_hooks, g_hook_find_data(&abrt_hooks, TRUE, s= )); diff --git a/tests/libqtest.h b/tests/libqtest.h index 86b3a3b..fe7847c 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -24,6 +24,31 @@ typedef struct QTestState QTestState; extern QTestState *global_qtest; =20 /** + * qtest_startf: + * @fmt...: Format for creating other arguments to pass to QEMU, formatted + * like sprintf(). + * + * Start QEMU and return the resulting #QTestState (but unlike qtest_start= (), + * #global_qtest is left at NULL). + * + * Returns: #QTestState instance. + */ +QTestState *qtest_startf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); + +/** + * qtest_vstartf: + * @fmt: Format for creating other arguments to pass to QEMU, formatted + * like vsprintf(). + * @ap: Format arguments. + * + * Start QEMU and return the resulting #QTestState (but unlike qtest_start= (), + * #global_qtest is left at NULL). + * + * Returns: #QTestState instance. + */ +QTestState *qtest_vstartf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); + +/** * qtest_init: * @extra_args: other arguments to pass to QEMU. * diff --git a/tests/m25p80-test.c b/tests/m25p80-test.c index 244aa33..c276e73 100644 --- a/tests/m25p80-test.c +++ b/tests/m25p80-test.c @@ -354,7 +354,6 @@ int main(int argc, char **argv) { int ret; int fd; - char *args; =20 g_test_init(&argc, &argv, NULL); =20 @@ -364,10 +363,9 @@ int main(int argc, char **argv) g_assert(ret =3D=3D 0); close(fd); =20 - args =3D g_strdup_printf("-m 256 -machine palmetto-bmc " - "-drive file=3D%s,format=3Draw,if=3Dmtd", - tmp_path); - qtest_start(args); + global_qtest =3D qtest_startf("-m 256 -machine palmetto-bmc " + "-drive file=3D%s,format=3Draw,if=3Dmtd", + tmp_path); =20 qtest_add_func("/m25p80/read_jedec", test_read_jedec); qtest_add_func("/m25p80/erase_sector", test_erase_sector); @@ -380,6 +378,5 @@ int main(int argc, char **argv) =20 qtest_quit(global_qtest); unlink(tmp_path); - g_free(args); return ret; } diff --git a/tests/pnv-xscom-test.c b/tests/pnv-xscom-test.c index 5adc3fd..89fa628 100644 --- a/tests/pnv-xscom-test.c +++ b/tests/pnv-xscom-test.c @@ -81,16 +81,12 @@ static void test_xscom_cfam_id(const PnvChip *chip) =20 static void test_cfam_id(const void *data) { - char *args; const PnvChip *chip =3D data; =20 - args =3D g_strdup_printf("-M powernv,accel=3Dtcg -cpu %s", chip->cpu_m= odel); - - qtest_start(args); + global_qtest =3D qtest_startf("-M powernv,accel=3Dtcg -cpu %s", + chip->cpu_model); test_xscom_cfam_id(chip); qtest_quit(global_qtest); - - g_free(args); } =20 #define PNV_XSCOM_EX_CORE_BASE(chip, i) \ @@ -109,16 +105,12 @@ static void test_xscom_core(const PnvChip *chip) =20 static void test_core(const void *data) { - char *args; const PnvChip *chip =3D data; =20 - args =3D g_strdup_printf("-M powernv,accel=3Dtcg -cpu %s", chip->cpu_m= odel); - - qtest_start(args); + global_qtest =3D qtest_startf("-M powernv,accel=3Dtcg -cpu %s", + chip->cpu_model); test_xscom_core(chip); qtest_quit(global_qtest); - - g_free(args); } =20 static void add_test(const char *name, void (*test)(const void *data)) diff --git a/tests/prom-env-test.c b/tests/prom-env-test.c index bc8b616..8c867e6 100644 --- a/tests/prom-env-test.c +++ b/tests/prom-env-test.c @@ -44,21 +44,18 @@ static void check_guest_memory(void) =20 static void test_machine(const void *machine) { - char *args; const char *extra_args; =20 /* The pseries firmware boots much faster without the default devices = */ extra_args =3D strcmp(machine, "pseries") =3D=3D 0 ? "-nodefaults" : "= "; =20 - args =3D g_strdup_printf("-M %s,accel=3Dtcg %s -prom-env 'use-nvramrc?= =3Dtrue' " - "-prom-env 'nvramrc=3D%x %x l!' ", - (const char *)machine, extra_args, MAGIC, ADDRE= SS); - - qtest_start(args); + global_qtest =3D qtest_startf("-M %s,accel=3Dtcg %s " + "-prom-env 'use-nvramrc?=3Dtrue' " + "-prom-env 'nvramrc=3D%x %x l!' ", + (const char *)machine, extra_args, + MAGIC, ADDRESS); check_guest_memory(); qtest_quit(global_qtest); - - g_free(args); } =20 static void add_tests(const char *machines[]) diff --git a/tests/tco-test.c b/tests/tco-test.c index c4c264e..2616d33 100644 --- a/tests/tco-test.c +++ b/tests/tco-test.c @@ -55,14 +55,12 @@ static void test_end(TestData *d) static void test_init(TestData *d) { QTestState *qs; - char *s; =20 - s =3D g_strdup_printf("-machine q35 %s %s", - d->noreboot ? "" : "-global ICH9-LPC.noreboot=3Dfa= lse", - !d->args ? "" : d->args); - qs =3D qtest_start(s); + qs =3D qtest_startf("-machine q35 %s %s", + d->noreboot ? "" : "-global ICH9-LPC.noreboot=3Dfals= e", + !d->args ? "" : d->args); + global_qtest =3D qs; qtest_irq_intercept_in(qs, "ioapic"); - g_free(s); =20 d->bus =3D qpci_init_pc(NULL); d->dev =3D qpci_device_find(d->bus, QPCI_DEVFN(0x1f, 0x00)); diff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c index d569d27..6c6f710 100644 --- a/tests/test-filter-mirror.c +++ b/tests/test-filter-mirror.c @@ -18,7 +18,6 @@ static void test_mirror(void) { int send_sock[2], recv_sock; - char *cmdline; uint32_t ret =3D 0, len =3D 0; char send_buf[] =3D "Hello! filter-mirror~"; char sock_path[] =3D "filter-mirror.XXXXXX"; @@ -37,13 +36,12 @@ static void test_mirror(void) ret =3D mkstemp(sock_path); g_assert_cmpint(ret, !=3D, -1); =20 - cmdline =3D g_strdup_printf("-netdev socket,id=3Dqtest-bn0,fd=3D%d " - "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " - "-chardev socket,id=3Dmirror0,path=3D%s,server,nowait " - "-object filter-mirror,id=3Dqtest-f0,netdev=3Dqtest-bn0,q= ueue=3Dtx,outdev=3Dmirror0 " - , send_sock[1], devstr, sock_path); - qtest_start(cmdline); - g_free(cmdline); + global_qtest =3D qtest_startf( + "-netdev socket,id=3Dqtest-bn0,fd=3D%d " + "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " + "-chardev socket,id=3Dmirror0,path=3D%s,server,nowait " + "-object filter-mirror,id=3Dqtest-f0,netdev=3Dqtest-bn0,queue=3Dtx= ,outdev=3Dmirror0 " + , send_sock[1], devstr, sock_path); =20 recv_sock =3D unix_connect(sock_path, NULL); g_assert_cmpint(recv_sock, !=3D, -1); diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c index 3afd411..f256614 100644 --- a/tests/test-filter-redirector.c +++ b/tests/test-filter-redirector.c @@ -70,7 +70,6 @@ static const char *get_devstr(void) static void test_redirector_tx(void) { int backend_sock[2], recv_sock; - char *cmdline; uint32_t ret =3D 0, len =3D 0; char send_buf[] =3D "Hello!!"; char sock_path0[] =3D "filter-redirector0.XXXXXX"; @@ -87,20 +86,19 @@ static void test_redirector_tx(void) ret =3D mkstemp(sock_path1); g_assert_cmpint(ret, !=3D, -1); =20 - cmdline =3D g_strdup_printf("-netdev socket,id=3Dqtest-bn0,fd=3D%d " - "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " - "-chardev socket,id=3Dredirector0,path=3D%s,server,nowait " - "-chardev socket,id=3Dredirector1,path=3D%s,server,nowait " - "-chardev socket,id=3Dredirector2,path=3D%s,nowait " - "-object filter-redirector,id=3Dqtest-f0,netdev=3Dqtest-bn= 0," - "queue=3Dtx,outdev=3Dredirector0 " - "-object filter-redirector,id=3Dqtest-f1,netdev=3Dqtest-bn= 0," - "queue=3Dtx,indev=3Dredirector2 " - "-object filter-redirector,id=3Dqtest-f2,netdev=3Dqtest-bn= 0," - "queue=3Dtx,outdev=3Dredirector1 ", backend_sock[1], get_d= evstr(), - sock_path0, sock_path1, sock_path0); - qtest_start(cmdline); - g_free(cmdline); + global_qtest =3D qtest_startf( + "-netdev socket,id=3Dqtest-bn0,fd=3D%d " + "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " + "-chardev socket,id=3Dredirector0,path=3D%s,server,nowait " + "-chardev socket,id=3Dredirector1,path=3D%s,server,nowait " + "-chardev socket,id=3Dredirector2,path=3D%s,nowait " + "-object filter-redirector,id=3Dqtest-f0,netdev=3Dqtest-bn0," + "queue=3Dtx,outdev=3Dredirector0 " + "-object filter-redirector,id=3Dqtest-f1,netdev=3Dqtest-bn0," + "queue=3Dtx,indev=3Dredirector2 " + "-object filter-redirector,id=3Dqtest-f2,netdev=3Dqtest-bn0," + "queue=3Dtx,outdev=3Dredirector1 ", backend_sock[1], get_devstr(), + sock_path0, sock_path1, sock_path0); =20 recv_sock =3D unix_connect(sock_path1, NULL); g_assert_cmpint(recv_sock, !=3D, -1); @@ -141,7 +139,6 @@ static void test_redirector_tx(void) static void test_redirector_rx(void) { int backend_sock[2], send_sock; - char *cmdline; uint32_t ret =3D 0, len =3D 0; char send_buf[] =3D "Hello!!"; char sock_path0[] =3D "filter-redirector0.XXXXXX"; @@ -158,20 +155,19 @@ static void test_redirector_rx(void) ret =3D mkstemp(sock_path1); g_assert_cmpint(ret, !=3D, -1); =20 - cmdline =3D g_strdup_printf("-netdev socket,id=3Dqtest-bn0,fd=3D%d " - "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " - "-chardev socket,id=3Dredirector0,path=3D%s,server,nowait " - "-chardev socket,id=3Dredirector1,path=3D%s,server,nowait " - "-chardev socket,id=3Dredirector2,path=3D%s,nowait " - "-object filter-redirector,id=3Dqtest-f0,netdev=3Dqtest-bn= 0," - "queue=3Drx,indev=3Dredirector0 " - "-object filter-redirector,id=3Dqtest-f1,netdev=3Dqtest-bn= 0," - "queue=3Drx,outdev=3Dredirector2 " - "-object filter-redirector,id=3Dqtest-f2,netdev=3Dqtest-bn= 0," - "queue=3Drx,indev=3Dredirector1 ", backend_sock[1], get_de= vstr(), - sock_path0, sock_path1, sock_path0); - qtest_start(cmdline); - g_free(cmdline); + global_qtest =3D qtest_startf( + "-netdev socket,id=3Dqtest-bn0,fd=3D%d " + "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " + "-chardev socket,id=3Dredirector0,path=3D%s,server,nowait " + "-chardev socket,id=3Dredirector1,path=3D%s,server,nowait " + "-chardev socket,id=3Dredirector2,path=3D%s,nowait " + "-object filter-redirector,id=3Dqtest-f0,netdev=3Dqtest-bn0," + "queue=3Drx,indev=3Dredirector0 " + "-object filter-redirector,id=3Dqtest-f1,netdev=3Dqtest-bn0," + "queue=3Drx,outdev=3Dredirector2 " + "-object filter-redirector,id=3Dqtest-f2,netdev=3Dqtest-bn0," + "queue=3Drx,indev=3Dredirector1 ", backend_sock[1], get_devstr(), + sock_path0, sock_path1, sock_path0); =20 struct iovec iov[] =3D { { diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 0576cb1..e6fb9ba 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -84,19 +84,16 @@ static QOSState *pci_test_start(void) =20 static void arm_test_start(void) { - char *cmdline; char *tmp_path; =20 tmp_path =3D drive_create(); =20 - cmdline =3D g_strdup_printf("-machine virt " + global_qtest =3D qtest_startf("-machine virt " "-drive if=3Dnone,id=3Ddrive0,file=3D%s,fo= rmat=3Draw " "-device virtio-blk-device,drive=3Ddrive0", tmp_path); - qtest_start(cmdline); unlink(tmp_path); g_free(tmp_path); - g_free(cmdline); } =20 static void test_end(void) diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 918c82c..b6e7b3b 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -130,41 +130,32 @@ static void read_guid_from_monitor(QemuUUID *guid) =20 static char disk[] =3D "tests/vmgenid-test-disk-XXXXXX"; =20 -static char *guid_cmd_strdup(const char *guid) -{ - return g_strdup_printf("-machine accel=3Dkvm:tcg " - "-device vmgenid,id=3Dtestvgid,guid=3D%s " - "-drive id=3Dhd0,if=3Dnone,file=3D%s,format=3Dr= aw " - "-device ide-hd,drive=3Dhd0 ", - guid, disk); -} - +#define GUID_CMD(guid) \ + "-machine accel=3Dkvm:tcg " \ + "-device vmgenid,id=3Dtestvgid,guid=3D%s " \ + "-drive id=3Dhd0,if=3Dnone,file=3D%s,format=3Draw " \ + "-device ide-hd,drive=3Dhd0 ", guid, disk =20 static void vmgenid_set_guid_test(void) { QemuUUID expected, measured; - gchar *cmd; =20 g_assert(qemu_uuid_parse(VGID_GUID, &expected) =3D=3D 0); =20 - cmd =3D guid_cmd_strdup(VGID_GUID); - qtest_start(cmd); + global_qtest =3D qtest_startf(GUID_CMD(VGID_GUID)); =20 /* Read the GUID from accessing guest memory */ read_guid_from_memory(&measured); g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) = =3D=3D 0); =20 qtest_quit(global_qtest); - g_free(cmd); } =20 static void vmgenid_set_guid_auto_test(void) { - char *cmd; QemuUUID measured; =20 - cmd =3D guid_cmd_strdup("auto"); - qtest_start(cmd); + global_qtest =3D qtest_startf(GUID_CMD("auto")); =20 read_guid_from_memory(&measured); =20 @@ -172,25 +163,21 @@ static void vmgenid_set_guid_auto_test(void) g_assert(!qemu_uuid_is_null(&measured)); =20 qtest_quit(global_qtest); - g_free(cmd); } =20 static void vmgenid_query_monitor_test(void) { QemuUUID expected, measured; - gchar *cmd; =20 g_assert(qemu_uuid_parse(VGID_GUID, &expected) =3D=3D 0); =20 - cmd =3D guid_cmd_strdup(VGID_GUID); - qtest_start(cmd); + global_qtest =3D qtest_startf(GUID_CMD(VGID_GUID)); =20 /* Read the GUID via the monitor */ read_guid_from_monitor(&measured); g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) = =3D=3D 0); =20 qtest_quit(global_qtest); - g_free(cmd); } =20 int main(int argc, char **argv) --=20 1.8.3.1 From nobody Fri May 3 07:21:37 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508336579734834.5006217167249; Wed, 18 Oct 2017 07:22:59 -0700 (PDT) Received: from localhost ([::1]:44936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4pF5-00041G-U0 for importer@patchew.org; Wed, 18 Oct 2017 10:22:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4pDS-000370-CG for qemu-devel@nongnu.org; Wed, 18 Oct 2017 10:21:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4pDQ-00023C-UZ for qemu-devel@nongnu.org; Wed, 18 Oct 2017 10:21:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e4pDQ-00022Z-Lq; Wed, 18 Oct 2017 10:21:00 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B0963C47; Wed, 18 Oct 2017 14:20:59 +0000 (UTC) Received: from thh440s.str.redhat.com (dhcp-192-189.str.redhat.com [10.33.192.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 174346A513; Wed, 18 Oct 2017 14:20:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8B0963C47 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=thuth@redhat.com From: Thomas Huth To: qemu-devel@nongnu.org Date: Wed, 18 Oct 2017 16:20:28 +0200 Message-Id: <1508336428-20511-3-git-send-email-thuth@redhat.com> In-Reply-To: <1508336428-20511-1-git-send-email-thuth@redhat.com> References: <1508336428-20511-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 18 Oct 2017 14:20:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] tests: Enable the very simple virtio tests on s390x, too 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: qemu-s390x@nongnu.org, cohuck@redhat.com, Amit Shah , Michael S Tsirkin Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These tests can easily be used on s390x, too. We just have to make sure to use the virtio-xxx-ccw devices instead of virtio-xxx-pci. Signed-off-by: Thomas Huth Acked-by: Christian Borntraeger Acked-by: Michael S. Tsirkin Reviewed-by: Eric Blake --- tests/Makefile.include | 9 ++++++--- tests/virtio-balloon-test.c | 8 +++++--- tests/virtio-console-test.c | 19 +++++++++++-------- tests/virtio-serial-test.c | 10 ++++++---- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 4ca15e6..70dc711 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -367,6 +367,9 @@ check-qtest-s390x-$(CONFIG_SLIRP) +=3D tests/test-netfi= lter$(EXESUF) check-qtest-s390x-$(CONFIG_POSIX) +=3D tests/test-filter-mirror$(EXESUF) check-qtest-s390x-$(CONFIG_POSIX) +=3D tests/test-filter-redirector$(EXESU= F) check-qtest-s390x-y +=3D tests/drive_del-test$(EXESUF) +check-qtest-s390x-y +=3D tests/virtio-balloon-test$(EXESUF) +check-qtest-s390x-y +=3D tests/virtio-console-test$(EXESUF) +check-qtest-s390x-y +=3D tests/virtio-serial-test$(EXESUF) =20 check-qtest-generic-y +=3D tests/qom-test$(EXESUF) check-qtest-generic-y +=3D tests/test-hmp$(EXESUF) @@ -754,14 +757,14 @@ tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o tests/ne2000-test$(EXESUF): tests/ne2000-test.o tests/wdt_ib700-test$(EXESUF): tests/wdt_ib700-test.o tests/tco-test$(EXESUF): tests/tco-test.o $(libqos-pc-obj-y) -tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o +tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o $(libqos-v= irtio-obj-y) tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o $(libqos-virtio-ob= j-y) tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o $(libqos-pc-obj-y)= $(libqos-virtio-obj-y) tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o $(libqos-pc-obj-y) tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o $(libqos-virtio-= obj-y) tests/virtio-9p-test$(EXESUF): tests/virtio-9p-test.o $(libqos-virtio-obj-= y) -tests/virtio-serial-test$(EXESUF): tests/virtio-serial-test.o -tests/virtio-console-test$(EXESUF): tests/virtio-console-test.o +tests/virtio-serial-test$(EXESUF): tests/virtio-serial-test.o $(libqos-vir= tio-obj-y) +tests/virtio-console-test$(EXESUF): tests/virtio-console-test.o $(libqos-v= irtio-obj-y) tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/display-vga-test$(EXESUF): tests/display-vga-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o diff --git a/tests/virtio-balloon-test.c b/tests/virtio-balloon-test.c index 0d0046b..0a07e03 100644 --- a/tests/virtio-balloon-test.c +++ b/tests/virtio-balloon-test.c @@ -9,9 +9,10 @@ =20 #include "qemu/osdep.h" #include "libqtest.h" +#include "libqos/virtio.h" =20 /* Tests only initialization so far. TODO: Replace with functional tests */ -static void pci_nop(void) +static void balloon_nop(void) { } =20 @@ -20,9 +21,10 @@ int main(int argc, char **argv) int ret; =20 g_test_init(&argc, &argv, NULL); - qtest_add_func("/virtio/balloon/pci/nop", pci_nop); + qtest_add_func("/virtio/balloon/nop", balloon_nop); =20 - qtest_start("-device virtio-balloon-pci"); + global_qtest =3D qtest_startf("-device virtio-balloon-%s", + qvirtio_get_dev_type()); ret =3D g_test_run(); =20 qtest_end(); diff --git a/tests/virtio-console-test.c b/tests/virtio-console-test.c index 1c3de07..945bae5 100644 --- a/tests/virtio-console-test.c +++ b/tests/virtio-console-test.c @@ -9,27 +9,30 @@ =20 #include "qemu/osdep.h" #include "libqtest.h" +#include "libqos/virtio.h" =20 /* Tests only initialization so far. TODO: Replace with functional tests */ -static void console_pci_nop(void) +static void console_nop(void) { - qtest_start("-device virtio-serial-pci,id=3Dvser0 " - "-device virtconsole,bus=3Dvser0.0"); + global_qtest =3D qtest_startf("-device virtio-serial-%s,id=3Dvser0 " + "-device virtconsole,bus=3Dvser0.0", + qvirtio_get_dev_type()); qtest_end(); } =20 -static void serialport_pci_nop(void) +static void serialport_nop(void) { - qtest_start("-device virtio-serial-pci,id=3Dvser0 " - "-device virtserialport,bus=3Dvser0.0"); + global_qtest =3D qtest_startf("-device virtio-serial-%s,id=3Dvser0 " + "-device virtserialport,bus=3Dvser0.0", + qvirtio_get_dev_type()); qtest_end(); } =20 int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); - qtest_add_func("/virtio/console/pci/nop", console_pci_nop); - qtest_add_func("/virtio/serialport/pci/nop", serialport_pci_nop); + qtest_add_func("/virtio/console/nop", console_nop); + qtest_add_func("/virtio/serialport/nop", serialport_nop); =20 return g_test_run(); } diff --git a/tests/virtio-serial-test.c b/tests/virtio-serial-test.c index 7d1517d..7cc7060 100644 --- a/tests/virtio-serial-test.c +++ b/tests/virtio-serial-test.c @@ -9,9 +9,10 @@ =20 #include "qemu/osdep.h" #include "libqtest.h" +#include "libqos/virtio.h" =20 /* Tests only initialization so far. TODO: Replace with functional tests */ -static void pci_nop(void) +static void virtio_serial_nop(void) { } =20 @@ -27,10 +28,11 @@ int main(int argc, char **argv) int ret; =20 g_test_init(&argc, &argv, NULL); - qtest_add_func("/virtio/serial/pci/nop", pci_nop); - qtest_add_func("/virtio/serial/pci/hotplug", hotplug); + qtest_add_func("/virtio/serial/nop", virtio_serial_nop); + qtest_add_func("/virtio/serial/hotplug", hotplug); =20 - qtest_start("-device virtio-serial-pci"); + global_qtest =3D qtest_startf("-device virtio-serial-%s", + qvirtio_get_dev_type()); ret =3D g_test_run(); =20 qtest_end(); --=20 1.8.3.1