From: "wangyanan (Y)" <wangyanan55@huawei.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>, Andrew Jones <drjones@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [PATCH-for-7.0 v4 08/11] tests/unit/test-smp-parse: Add 'smp-without-dies-valid' machine type
Date: Wed, 17 Nov 2021 15:37:16 +0800 [thread overview]
Message-ID: <06bcb095-66f5-6c11-0cd2-fa9defce799e@huawei.com> (raw)
In-Reply-To: <20211115145900.2531865-9-philmd@redhat.com>
Hi Philippe,
On 2021/11/15 22:58, Philippe Mathieu-Daudé wrote:
> Keep the common TYPE_MACHINE class initialization in
> machine_base_class_init(), make it abstract, and move
> the non-common code to a new class: "smp-without-dies-valid".
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> tests/unit/test-smp-parse.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c
> index dfe7f1313b0..90a249fe8c8 100644
> --- a/tests/unit/test-smp-parse.c
> +++ b/tests/unit/test-smp-parse.c
> @@ -478,13 +478,19 @@ static void machine_base_class_init(ObjectClass *oc, void *data)
> {
> MachineClass *mc = MACHINE_CLASS(oc);
>
> + mc->smp_props.prefer_sockets = true;
> +
> + mc->name = g_strdup(SMP_MACHINE_NAME);
> +}
> +
> +static void machine_without_dies_valid_class_init(ObjectClass *oc, void *data)
> +{
> + MachineClass *mc = MACHINE_CLASS(oc);
> +
> mc->min_cpus = MIN_CPUS;
> mc->max_cpus = MAX_CPUS;
>
> - mc->smp_props.prefer_sockets = true;
> mc->smp_props.dies_supported = false;
> -
> - mc->name = g_strdup(SMP_MACHINE_NAME);
> }
>
> static void machine_without_dies_invalid_class_init(ObjectClass *oc, void *data)
> @@ -606,9 +612,14 @@ static const TypeInfo smp_machine_types[] = {
> {
> .name = TYPE_MACHINE,
> .parent = TYPE_OBJECT,
> + .abstract = true,
> .class_init = machine_base_class_init,
> .class_size = sizeof(MachineClass),
> .instance_size = sizeof(MachineState),
> + }, {
> + .name = MACHINE_TYPE_NAME("smp-without-dies-valid"),
> + .parent = TYPE_MACHINE,
> + .class_init = machine_without_dies_valid_class_init,
> }, {
> .name = MACHINE_TYPE_NAME("smp-without-dies-invalid"),
> .parent = TYPE_MACHINE,
> @@ -629,7 +640,7 @@ int main(int argc, char *argv[])
> g_test_init(&argc, &argv, NULL);
>
> g_test_add_data_func("/test-smp-parse/generic/valid",
> - TYPE_MACHINE,
> + MACHINE_TYPE_NAME("smp-without-dies-valid"),
> test_generic_valid);
> g_test_add_data_func("/test-smp-parse/generic/invalid",
> MACHINE_TYPE_NAME("smp-without-dies-invalid"),
After patch #7 and #8, we will have sub-tests as below. It looks nice,
but it will
probably be better to tweak "smp-without-dies-valid" to "smp-generic-valid",
and "smp-without-dies-invalid" to "smp-generic-invalid", which will be more
consistent with the corresponding sub-test name.
It's Ok now as we only have dies currently besides generic
sockets/cores/threads,
but "smp-without-dies-xxx" will become a bit confusing when new topology
members are introduced and tested here.
int main(int argc, char *argv[])
{
module_call_init(MODULE_INIT_QOM);
g_test_init(&argc, &argv, NULL);
g_test_add_data_func("/test-smp-parse/generic/valid",
MACHINE_TYPE_NAME("smp-without-dies-valid"),
test_generic_valid);
g_test_add_data_func("/test-smp-parse/generic/invalid",
MACHINE_TYPE_NAME("smp-without-dies-invalid"),
test_generic_invalid);
g_test_add_data_func("/test-smp-parse/with_dies",
MACHINE_TYPE_NAME("smp-with-dies"),
test_with_dies);
g_test_run();
return 0;
}
Otherwise, #7 and #8 look nice. Thanks for your work!
Thanks,
Yanan
next prev parent reply other threads:[~2021-11-17 7:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 14:58 [PATCH v4 00/11] tests/unit: Fix test-smp-parse Philippe Mathieu-Daudé
2021-11-15 14:58 ` [PATCH-for-6.2 v4 01/11] tests/unit/test-smp-parse: Restore MachineClass fields after modifying Philippe Mathieu-Daudé
2021-11-15 14:58 ` [PATCH-for-6.2 v4 02/11] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init() Philippe Mathieu-Daudé
2021-11-15 14:58 ` [PATCH-for-6.2 v4 03/11] tests/unit/test-smp-parse: Explicit MachineClass name Philippe Mathieu-Daudé
2021-11-15 14:58 ` [PATCH-for-7.0 v4 04/11] tests/unit/test-smp-parse: Pass machine type as argument to tests Philippe Mathieu-Daudé
2021-11-16 12:05 ` Richard Henderson
2021-11-16 13:57 ` wangyanan (Y)
2021-11-15 14:58 ` [PATCH-for-7.0 v4 05/11] tests/unit/test-smp-parse: Split the 'generic' test in valid / invalid Philippe Mathieu-Daudé
2021-11-16 12:06 ` Richard Henderson
2021-11-16 13:58 ` wangyanan (Y)
2021-11-16 14:07 ` wangyanan (Y)
2021-11-16 14:22 ` Richard Henderson
2021-11-16 15:15 ` Philippe Mathieu-Daudé
2021-11-15 14:58 ` [PATCH-for-7.0 v4 06/11] tests/unit/test-smp-parse: Add 'smp-with-dies' machine type Philippe Mathieu-Daudé
2021-11-16 12:07 ` Richard Henderson
2021-11-16 14:10 ` wangyanan (Y)
2021-11-15 14:58 ` [PATCH-for-7.0 v4 07/11] tests/unit/test-smp-parse: Add 'smp-without-dies-invalid' " Philippe Mathieu-Daudé
2021-11-16 12:07 ` Richard Henderson
2021-11-15 14:58 ` [PATCH-for-7.0 v4 08/11] tests/unit/test-smp-parse: Add 'smp-without-dies-valid' " Philippe Mathieu-Daudé
2021-11-16 12:08 ` Richard Henderson
2021-11-17 7:37 ` wangyanan (Y) [this message]
2021-11-17 8:08 ` Philippe Mathieu-Daudé
2021-11-17 10:51 ` wangyanan (Y)
2021-11-15 14:58 ` [PATCH-for-7.0 v4 09/11] tests/unit/test-smp-parse: Simplify pointer to compound literal use Philippe Mathieu-Daudé
2021-11-15 14:58 ` [PATCH-for-7.0 v4 10/11] tests/unit/test-smp-parse: Constify some pointer/struct Philippe Mathieu-Daudé
2021-11-15 14:59 ` [PATCH-for-7.0 v4 11/11] hw/core: Rename smp_parse() -> machine_parse_smp_config() Philippe Mathieu-Daudé
2021-11-15 22:49 ` [PATCH v4 00/11] tests/unit: Fix test-smp-parse 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=06bcb095-66f5-6c11-0cd2-fa9defce799e@huawei.com \
--to=wangyanan55@huawei.com \
--cc=armbru@redhat.com \
--cc=drjones@redhat.com \
--cc=ehabkost@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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).