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 18:51:27 +0800 [thread overview]
Message-ID: <f4852ea6-ff3d-93bd-91eb-ed62041ad95e@huawei.com> (raw)
In-Reply-To: <32c42141-18e2-aa2c-8019-19aae50d4c24@redhat.com>
On 2021/11/17 16:08, Philippe Mathieu-Daudé wrote:
> Hi Yanan,
>
> On 11/17/21 08:37, wangyanan (Y) wrote:
>> 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.
> OK I modified it and will respin once v6.2 is released.
>
> Also test_with_dies() should be split in 2 tests: valid/invalid;
> then smp_parse_test() should split tests further regarding the
> socket preference. But I'll let that to you,
Sure, I can do this in an appropriate time. But IMHO, I don't see a
strong necessity to split test_with_dies for now, as the valid/invalid
scenarios share the same class properties. We can probably keep it
as is until we have to split it.
As for socket preference, I can foresee code duplication if we split
all the tests into two parts just regarding the socket preference.
Isn't it clear enough to use current smp_parse_test() for each
test data sample? Do we have other concern here?
> I wanted to 1/ fix
> our Windows CI and 2/ show you how to structure the tests.
Understood. The test architecture is indeed improved a lot.
Thanks for your education. 😉
Thanks,
Yanan
> Regards,
>
> Phil.
>
> .
next prev parent reply other threads:[~2021-11-17 10:54 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)
2021-11-17 8:08 ` Philippe Mathieu-Daudé
2021-11-17 10:51 ` wangyanan (Y) [this message]
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=f4852ea6-ff3d-93bd-91eb-ed62041ad95e@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).