From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PATCH v4 79/80] tests/numa-test: make top level args dynamic and g_autofree(cli) cleanups
Date: Fri, 31 Jan 2020 16:09:49 +0100 [thread overview]
Message-ID: <1580483390-131164-80-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1580483390-131164-1-git-send-email-imammedo@redhat.com>
Use GString to pass argument to make_cli() so that it would be easy
to dynamically change test case arguments from main(). The follow up
patch will use it to change RAM size options depending on target.
While at it cleanup 'cli' freeing, using g_autofree annotation.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
v3:
* s/strcmp/g_str_equal/
(Thomas Huth <thuth@redhat.com>)
* use pair make_cli/qtest_init instead of qtest_initf
PS:
made as a separate patch so it won't clutter followup testcase changes.
v4:
* use g_string_new(NULL) instead of g_string_new("")
(Thomas Huth <thuth@redhat.com>)
---
tests/qtest/numa-test.c | 108 ++++++++++++++++++++++++------------------------
1 file changed, 54 insertions(+), 54 deletions(-)
diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
index 17dd807..35999ea 100644
--- a/tests/qtest/numa-test.c
+++ b/tests/qtest/numa-test.c
@@ -14,16 +14,16 @@
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlist.h"
-static char *make_cli(const char *generic_cli, const char *test_cli)
+static char *make_cli(const GString *generic_cli, const char *test_cli)
{
- return g_strdup_printf("%s %s", generic_cli ? generic_cli : "", test_cli);
+ return g_strdup_printf("%s %s", generic_cli->str, test_cli);
}
static void test_mon_explicit(const void *data)
{
- char *s;
- char *cli;
QTestState *qts;
+ g_autofree char *s = NULL;
+ g_autofree char *cli = NULL;
cli = make_cli(data, "-smp 8 "
"-numa node,nodeid=0,cpus=0-3 "
@@ -33,17 +33,15 @@ static void test_mon_explicit(const void *data)
s = qtest_hmp(qts, "info numa");
g_assert(strstr(s, "node 0 cpus: 0 1 2 3"));
g_assert(strstr(s, "node 1 cpus: 4 5 6 7"));
- g_free(s);
qtest_quit(qts);
- g_free(cli);
}
static void test_mon_default(const void *data)
{
- char *s;
- char *cli;
QTestState *qts;
+ g_autofree char *s = NULL;
+ g_autofree char *cli = NULL;
cli = make_cli(data, "-smp 8 -numa node -numa node");
qts = qtest_init(cli);
@@ -51,17 +49,15 @@ static void test_mon_default(const void *data)
s = qtest_hmp(qts, "info numa");
g_assert(strstr(s, "node 0 cpus: 0 2 4 6"));
g_assert(strstr(s, "node 1 cpus: 1 3 5 7"));
- g_free(s);
qtest_quit(qts);
- g_free(cli);
}
static void test_mon_partial(const void *data)
{
- char *s;
- char *cli;
QTestState *qts;
+ g_autofree char *s = NULL;
+ g_autofree char *cli = NULL;
cli = make_cli(data, "-smp 8 "
"-numa node,nodeid=0,cpus=0-1 "
@@ -71,10 +67,8 @@ static void test_mon_partial(const void *data)
s = qtest_hmp(qts, "info numa");
g_assert(strstr(s, "node 0 cpus: 0 1 2 3 6 7"));
g_assert(strstr(s, "node 1 cpus: 4 5"));
- g_free(s);
qtest_quit(qts);
- g_free(cli);
}
static QList *get_cpus(QTestState *qts, QDict **resp)
@@ -87,11 +81,11 @@ static QList *get_cpus(QTestState *qts, QDict **resp)
static void test_query_cpus(const void *data)
{
- char *cli;
QDict *resp;
QList *cpus;
QObject *e;
QTestState *qts;
+ g_autofree char *cli = NULL;
cli = make_cli(data, "-smp 8 -numa node,cpus=0-3 -numa node,cpus=4-7");
qts = qtest_init(cli);
@@ -120,16 +114,15 @@ static void test_query_cpus(const void *data)
qobject_unref(resp);
qtest_quit(qts);
- g_free(cli);
}
static void pc_numa_cpu(const void *data)
{
- char *cli;
QDict *resp;
QList *cpus;
QObject *e;
QTestState *qts;
+ g_autofree char *cli = NULL;
cli = make_cli(data, "-cpu pentium -smp 8,sockets=2,cores=2,threads=2 "
"-numa node,nodeid=0 -numa node,nodeid=1 "
@@ -174,16 +167,15 @@ static void pc_numa_cpu(const void *data)
qobject_unref(resp);
qtest_quit(qts);
- g_free(cli);
}
static void spapr_numa_cpu(const void *data)
{
- char *cli;
QDict *resp;
QList *cpus;
QObject *e;
QTestState *qts;
+ g_autofree char *cli = NULL;
cli = make_cli(data, "-smp 4,cores=4 "
"-numa node,nodeid=0 -numa node,nodeid=1 "
@@ -220,16 +212,15 @@ static void spapr_numa_cpu(const void *data)
qobject_unref(resp);
qtest_quit(qts);
- g_free(cli);
}
static void aarch64_numa_cpu(const void *data)
{
- char *cli;
QDict *resp;
QList *cpus;
QObject *e;
QTestState *qts;
+ g_autofree char *cli = NULL;
cli = make_cli(data, "-smp 2 "
"-numa node,nodeid=0 -numa node,nodeid=1 "
@@ -264,7 +255,6 @@ static void aarch64_numa_cpu(const void *data)
qobject_unref(resp);
qtest_quit(qts);
- g_free(cli);
}
static void pc_dynamic_cpu_cfg(const void *data)
@@ -273,9 +263,10 @@ static void pc_dynamic_cpu_cfg(const void *data)
QDict *resp;
QList *cpus;
QTestState *qs;
+ g_autofree char *cli = NULL;
- qs = qtest_initf("%s -nodefaults --preconfig -smp 2",
- data ? (char *)data : "");
+ cli = make_cli(data, "-nodefaults --preconfig -smp 2");
+ qs = qtest_init(cli);
/* create 2 numa nodes */
g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
@@ -329,16 +320,19 @@ static void pc_dynamic_cpu_cfg(const void *data)
static void pc_hmat_build_cfg(const void *data)
{
- QTestState *qs = qtest_initf("%s -nodefaults --preconfig -machine hmat=on "
- "-smp 2,sockets=2 "
- "-m 128M,slots=2,maxmem=1G "
- "-object memory-backend-ram,size=64M,id=m0 "
- "-object memory-backend-ram,size=64M,id=m1 "
- "-numa node,nodeid=0,memdev=m0 "
- "-numa node,nodeid=1,memdev=m1,initiator=0 "
- "-numa cpu,node-id=0,socket-id=0 "
- "-numa cpu,node-id=0,socket-id=1",
- data ? (char *)data : "");
+ QTestState *qs;
+ g_autofree char *cli = NULL;
+
+ cli = make_cli(data, "-nodefaults --preconfig -machine hmat=on "
+ "-smp 2,sockets=2 "
+ "-m 128M,slots=2,maxmem=1G "
+ "-object memory-backend-ram,size=64M,id=m0 "
+ "-object memory-backend-ram,size=64M,id=m1 "
+ "-numa node,nodeid=0,memdev=m0 "
+ "-numa node,nodeid=1,memdev=m1,initiator=0 "
+ "-numa cpu,node-id=0,socket-id=0 "
+ "-numa cpu,node-id=0,socket-id=1");
+ qs = qtest_init(cli);
/* Fail: Initiator should be less than the number of nodes */
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
@@ -455,13 +449,16 @@ static void pc_hmat_build_cfg(const void *data)
static void pc_hmat_off_cfg(const void *data)
{
- QTestState *qs = qtest_initf("%s -nodefaults --preconfig "
- "-smp 2,sockets=2 "
- "-m 128M,slots=2,maxmem=1G "
- "-object memory-backend-ram,size=64M,id=m0 "
- "-object memory-backend-ram,size=64M,id=m1 "
- "-numa node,nodeid=0,memdev=m0",
- data ? (char *)data : "");
+ QTestState *qs;
+ g_autofree char *cli = NULL;
+
+ cli = make_cli(data, "-nodefaults --preconfig "
+ "-smp 2,sockets=2 "
+ "-m 128M,slots=2,maxmem=1G "
+ "-object memory-backend-ram,size=64M,id=m0 "
+ "-object memory-backend-ram,size=64M,id=m1 "
+ "-numa node,nodeid=0,memdev=m0");
+ qs = qtest_init(cli);
/*
* Fail: Enable HMAT with -machine hmat=on
@@ -491,16 +488,19 @@ static void pc_hmat_off_cfg(const void *data)
static void pc_hmat_erange_cfg(const void *data)
{
- QTestState *qs = qtest_initf("%s -nodefaults --preconfig -machine hmat=on "
- "-smp 2,sockets=2 "
- "-m 128M,slots=2,maxmem=1G "
- "-object memory-backend-ram,size=64M,id=m0 "
- "-object memory-backend-ram,size=64M,id=m1 "
- "-numa node,nodeid=0,memdev=m0 "
- "-numa node,nodeid=1,memdev=m1,initiator=0 "
- "-numa cpu,node-id=0,socket-id=0 "
- "-numa cpu,node-id=0,socket-id=1",
- data ? (char *)data : "");
+ QTestState *qs;
+ g_autofree char *cli = NULL;
+
+ cli = make_cli(data, "-nodefaults --preconfig -machine hmat=on "
+ "-smp 2,sockets=2 "
+ "-m 128M,slots=2,maxmem=1G "
+ "-object memory-backend-ram,size=64M,id=m0 "
+ "-object memory-backend-ram,size=64M,id=m1 "
+ "-numa node,nodeid=0,memdev=m0 "
+ "-numa node,nodeid=1,memdev=m1,initiator=0 "
+ "-numa cpu,node-id=0,socket-id=0 "
+ "-numa cpu,node-id=0,socket-id=1");
+ qs = qtest_init(cli);
/* Can't store the compressed latency */
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
@@ -539,11 +539,11 @@ static void pc_hmat_erange_cfg(const void *data)
int main(int argc, char **argv)
{
- const char *args = NULL;
+ g_autoptr(GString) args = g_string_new(NULL);
const char *arch = qtest_get_arch();
- if (strcmp(arch, "aarch64") == 0) {
- args = "-machine virt";
+ if (g_str_equal(arch, "aarch64")) {
+ g_string_append(args, " -machine virt");
}
g_test_init(&argc, &argv, NULL);
--
2.7.4
next prev parent reply other threads:[~2020-01-31 15:53 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-31 15:08 [PATCH v4 00/80] refactor main RAM allocation to use hostmem backend Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 01/80] numa: remove deprecated -mem-path fallback to anonymous RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 02/80] machine: introduce memory-backend property Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 03/80] machine: alias -mem-path and -mem-prealloc into memory-foo backend Igor Mammedov
2020-02-03 9:04 ` Michael S. Tsirkin
2020-02-03 9:27 ` Igor Mammedov
2020-02-03 9:42 ` Michael S. Tsirkin
2020-02-03 10:40 ` Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 04/80] machine: introduce convenience MachineState::ram Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 05/80] initialize MachineState::ram in NUMA case Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 06/80] vl.c: move -m parsing after memory backends has been processed Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 07/80] vl.c: ensure that ram_size matches size of machine.memory-backend Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 08/80] alpha/dp264: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 09/80] arm/aspeed: actually check RAM size Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 10/80] arm/aspeed: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 11/80] arm/collie: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 12/80] arm/cubieboard: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 13/80] arm/digic_boards: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 14/80] arm/highbank: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 15/80] arm/imx25_pdk: drop RAM size fixup Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 16/80] arm/imx25_pdk: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 17/80] arm/integratorcp: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 18/80] arm/kzm: drop RAM size fixup Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 19/80] arm/kzm: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 20/80] arm/mcimx6ul-evk: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 21/80] arm/mcimx7d-sabre: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 22/80] arm/mps2-tz: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 23/80] arm/mps2: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 24/80] arm/musicpal: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 25/80] arm/nseries: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 26/80] arm/omap_sx1: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 27/80] arm/palm: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 28/80] arm/raspi: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 29/80] arm/sabrelite: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 30/80] arm/sbsa-ref: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 31/80] arm/versatilepb: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 32/80] arm/vexpress: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 33/80] arm/virt: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 34/80] arm/xilinx_zynq: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 35/80] arm/xilinx_zynq: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 36/80] arm/xlnx-versal-virt: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 37/80] arm/xlnx-zcu102: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 38/80] s390x/s390-virtio-ccw: " Igor Mammedov
2020-02-05 20:11 ` Halil Pasic
2020-02-06 13:15 ` Igor Mammedov
2020-02-10 19:33 ` Halil Pasic
2020-01-31 15:09 ` [PATCH v4 39/80] null-machine: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 40/80] cris/axis_dev88: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 41/80] hppa: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 42/80] x86/microvm: " Igor Mammedov
2020-02-03 8:58 ` Michael S. Tsirkin
2020-01-31 15:09 ` [PATCH v4 43/80] x86/pc: " Igor Mammedov
2020-02-03 9:07 ` Michael S. Tsirkin
2020-02-03 9:45 ` Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 44/80] lm32/lm32_boards: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 45/80] lm32/milkymist: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 46/80] m68k/an5206: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 47/80] m68k/q800: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 48/80] m68k/mcf5208: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 49/80] m68k/next-cube: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 50/80] mips/boston: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 51/80] mips/mips_fulong2e: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 52/80] mips/mips_fulong2e: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 53/80] mips/mips_jazz: " Igor Mammedov
2020-02-09 16:41 ` Philippe Mathieu-Daudé
2020-02-10 15:06 ` [PATCH v5 81/80] mips/mips_jazz: add max ram size check Igor Mammedov
2020-02-10 17:04 ` Philippe Mathieu-Daudé
2020-01-31 15:09 ` [PATCH v4 54/80] mips/mips_malta: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 55/80] mips/mips_mipssim: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 56/80] mips/mips_r4k: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 57/80] ppc/e500: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 58/80] ppc/e500: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 59/80] ppc/mac_newworld: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 60/80] ppc/mac_oldworld: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 61/80] ppc/pnv: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 62/80] ppc/ppc405_boards: add RAM size checks Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 63/80] ppc/ppc405_boards: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 64/80] ppc/{ppc440_bamboo, sam460ex}: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 65/80] ppc/{ppc440_bamboo, sam460ex}: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 66/80] ppc/prep: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 67/80] ppc/spapr: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 68/80] ppc/virtex_ml507: remove unused arguments Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 69/80] ppc/virtex_ml507: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 70/80] sparc/leon3: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 71/80] sparc/sun4m: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 72/80] sparc/niagara: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 73/80] remove no longer used memory_region_allocate_system_memory() Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 74/80] exec: cleanup qemu_minrampagesize()/qemu_maxrampagesize() Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 75/80] exec: drop bogus mem_path from qemu_ram_alloc_from_fd() Igor Mammedov
2020-02-07 14:42 ` Marc-André Lureau
2020-01-31 15:09 ` [PATCH v4 76/80] make mem_path local variable Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 77/80] hostmem: introduce "prealloc-threads" property Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 78/80] hostmem: fix strict bind policy Igor Mammedov
2020-01-31 15:09 ` Igor Mammedov [this message]
2020-01-31 15:09 ` [PATCH v4 80/80] tests:numa-test: use explicit memdev to specify node RAM Igor Mammedov
2020-01-31 16:16 ` [PATCH v4 00/80] refactor main RAM allocation to use hostmem backend no-reply
2020-01-31 16:28 ` no-reply
2020-02-03 9:49 ` Igor Mammedov
2020-02-04 15:08 ` Igor Mammedov
2020-02-04 15:39 ` Igor Mammedov
2020-02-04 22:05 ` Paolo Bonzini
2020-02-05 13:20 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1580483390-131164-80-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).