[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 83/86] tests:numa-test: make top level args dynamic and g_auto
From: |
Igor Mammedov |
Subject: |
[PATCH v2 83/86] tests:numa-test: make top level args dynamic and g_autofree(cli) cleanups |
Date: |
Wed, 15 Jan 2020 16:07:38 +0100 |
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 <address@hidden>
---
PS:
made as a separate patch so it won't clutter followup testcase changes.
CC: address@hidden
CC: address@hidden
---
tests/qtest/numa-test.c | 38 ++++++++++++++------------------------
1 file changed, 14 insertions(+), 24 deletions(-)
diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
index 17dd807..a696dfd 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)
@@ -539,11 +529,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("");
const char *arch = qtest_get_arch();
if (strcmp(arch, "aarch64") == 0) {
- args = "-machine virt";
+ g_string_append(args, " -machine virt");
}
g_test_init(&argc, &argv, NULL);
--
2.7.4
- Re: [PATCH v2 82/86] numa: forbid '-numa node, mem' for 5.0 and newer machine types, (continued)
- [PATCH v2 85/86] numa: make exit() usage consistent, Igor Mammedov, 2020/01/15
- Re: [PATCH v2 85/86] numa: make exit() usage consistent, Philippe Mathieu-Daudé, 2020/01/16
- Re: [PATCH v2 85/86] numa: make exit() usage consistent, Thomas Huth, 2020/01/16
- Re: [PATCH v2 85/86] numa: make exit() usage consistent, Philippe Mathieu-Daudé, 2020/01/17
- Re: [PATCH v2 85/86] numa: make exit() usage consistent, Thomas Huth, 2020/01/17
- Re: [PATCH v2 85/86] numa: make exit() usage consistent, Thomas Huth, 2020/01/17
[PATCH v2 86/86] numa: remove deprecated implicit RAM distribution between nodes, Igor Mammedov, 2020/01/15
[PATCH v2 83/86] tests:numa-test: make top level args dynamic and g_autofree(cli) cleanups,
Igor Mammedov <=
- Re: [PATCH v2 83/86] tests:numa-test: make top level args dynamic and g_autofree(cli) cleanups, Thomas Huth, 2020/01/16
- Re: [PATCH v2 83/86] tests:numa-test: make top level args dynamic and g_autofree(cli) cleanups, Igor Mammedov, 2020/01/16
- Re: [PATCH v2 83/86] tests:numa-test: make top level args dynamic and g_autofree(cli) cleanups, Thomas Huth, 2020/01/17
- Re: [PATCH v2 83/86] tests:numa-test: make top level args dynamic and g_autofree(cli) cleanups, Igor Mammedov, 2020/01/17
- Re: [PATCH v2 83/86] tests:numa-test: make top level args dynamic and g_autofree(cli) cleanups, Thomas Huth, 2020/01/17
- Re: [PATCH v2 83/86] tests:numa-test: make top level args dynamic and g_autofree(cli) cleanups, Igor Mammedov, 2020/01/17
Re: [PATCH v2 00/86] refactor main RAM allocation to use hostmem backend, no-reply, 2020/01/15
Re: [PATCH v2 00/86] refactor main RAM allocation to use hostmem backend, no-reply, 2020/01/15