* [PULL 0/3] Machine-next patches for 2021-11-15
@ 2021-11-15 22:47 Philippe Mathieu-Daudé
2021-11-15 22:48 ` [PULL 1/3] tests/unit/test-smp-parse: Restore MachineClass fields after modifying Philippe Mathieu-Daudé
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-15 22:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Eduardo Habkost
The following changes since commit 42f6c9179be4401974dd3a75ee72defd16b5092d:
Merge tag 'pull-ppc-20211112' of https://github.com/legoater/qemu into staging (2021-11-12 12:28:25 +0100)
are available in the Git repository at:
https://github.com/philmd/qemu.git tags/machine-core-20211115
for you to fetch changes up to 7b6d1bc9629f3dd45647ec3418e0606a92dddd48:
tests/unit/test-smp-parse: Explicit MachineClass name (2021-11-15 21:49:16 +0100)
----------------------------------------------------------------
Machine core patches
- Rework SMP parsing unit test to work on WinGW:
https://github.com/qemu/qemu/runs/4078386652
This fixes:
Test smp_parse failed!
Expected error report: Invalid SMP CPUs 1. The min CPUs supported by machine '(null)' is 2
Output error report: Invalid SMP CPUs 1. The min CPUs supported by machine '(NULL)' is 2
----------------------------------------------------------------
Philippe Mathieu-Daudé (3):
tests/unit/test-smp-parse: Restore MachineClass fields after modifying
tests/unit/test-smp-parse: QOM'ify smp_machine_class_init()
tests/unit/test-smp-parse: Explicit MachineClass name
tests/unit/test-smp-parse.c | 52 +++++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 19 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PULL 1/3] tests/unit/test-smp-parse: Restore MachineClass fields after modifying
2021-11-15 22:47 [PULL 0/3] Machine-next patches for 2021-11-15 Philippe Mathieu-Daudé
@ 2021-11-15 22:48 ` Philippe Mathieu-Daudé
2021-11-15 22:48 ` [PULL 2/3] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init() Philippe Mathieu-Daudé
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-15 22:48 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Eduardo Habkost, Richard Henderson, Yanan Wang,
Philippe Mathieu-Daudé
There is a single MachineClass object, registered with
type_register_static(&smp_machine_info). Since the same
object is used multiple times (an MachineState object
is instantiated in both test_generic and test_with_dies),
we should restore its internal state after modifying for
the test purpose.
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
Tested-by: Yanan Wang <wangyanan55@huawei.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20211115145900.2531865-2-philmd@redhat.com>
---
tests/unit/test-smp-parse.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c
index cbe0c990494..47774c1ee2a 100644
--- a/tests/unit/test-smp-parse.c
+++ b/tests/unit/test-smp-parse.c
@@ -512,7 +512,7 @@ static void test_generic(void)
smp_parse_test(ms, data, true);
}
- /* Reset the supported min CPUs and max CPUs */
+ /* Force invalid min CPUs and max CPUs */
mc->min_cpus = 2;
mc->max_cpus = 511;
@@ -523,6 +523,10 @@ static void test_generic(void)
smp_parse_test(ms, data, false);
}
+ /* Reset the supported min CPUs and max CPUs */
+ mc->min_cpus = MIN_CPUS;
+ mc->max_cpus = MAX_CPUS;
+
object_unref(obj);
}
@@ -536,6 +540,7 @@ static void test_with_dies(void)
int i;
smp_machine_class_init(mc);
+ /* Force the SMP compat properties */
mc->smp_props.dies_supported = true;
for (i = 0; i < ARRAY_SIZE(data_generic_valid); i++) {
@@ -575,6 +580,9 @@ static void test_with_dies(void)
smp_parse_test(ms, data, false);
}
+ /* Restore the SMP compat properties */
+ mc->smp_props.dies_supported = false;
+
object_unref(obj);
}
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PULL 2/3] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init()
2021-11-15 22:47 [PULL 0/3] Machine-next patches for 2021-11-15 Philippe Mathieu-Daudé
2021-11-15 22:48 ` [PULL 1/3] tests/unit/test-smp-parse: Restore MachineClass fields after modifying Philippe Mathieu-Daudé
@ 2021-11-15 22:48 ` Philippe Mathieu-Daudé
2021-11-15 22:48 ` [PULL 3/3] tests/unit/test-smp-parse: Explicit MachineClass name Philippe Mathieu-Daudé
2021-11-16 13:19 ` [PULL 0/3] Machine-next patches for 2021-11-15 Richard Henderson
3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-15 22:48 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Eduardo Habkost, Richard Henderson, Yanan Wang,
Philippe Mathieu-Daudé
smp_machine_class_init() is the actual TypeInfo::class_init().
Declare it as such in smp_machine_info, and avoid to call it
manually in each test. Move smp_machine_info definition just
before we register the type to avoid a forward declaration.
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
Tested-by: Yanan Wang <wangyanan55@huawei.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20211115145900.2531865-3-philmd@redhat.com>
---
tests/unit/test-smp-parse.c | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c
index 47774c1ee2a..3fff2af4e27 100644
--- a/tests/unit/test-smp-parse.c
+++ b/tests/unit/test-smp-parse.c
@@ -75,14 +75,6 @@ typedef struct SMPTestData {
const char *expect_error;
} SMPTestData;
-/* Type info of the tested machine */
-static const TypeInfo smp_machine_info = {
- .name = TYPE_MACHINE,
- .parent = TYPE_OBJECT,
- .class_size = sizeof(MachineClass),
- .instance_size = sizeof(MachineState),
-};
-
/*
* List all the possible valid sub-collections of the generic 5
* topology parameters (i.e. cpus/maxcpus/sockets/cores/threads),
@@ -480,9 +472,10 @@ static void unsupported_params_init(MachineClass *mc, SMPTestData *data)
}
}
-/* Reset the related machine properties before each sub-test */
-static void smp_machine_class_init(MachineClass *mc)
+static void machine_base_class_init(ObjectClass *oc, void *data)
{
+ MachineClass *mc = MACHINE_CLASS(oc);
+
mc->min_cpus = MIN_CPUS;
mc->max_cpus = MAX_CPUS;
@@ -498,8 +491,6 @@ static void test_generic(void)
SMPTestData *data = &(SMPTestData){{ }};
int i;
- smp_machine_class_init(mc);
-
for (i = 0; i < ARRAY_SIZE(data_generic_valid); i++) {
*data = data_generic_valid[i];
unsupported_params_init(mc, data);
@@ -539,7 +530,6 @@ static void test_with_dies(void)
unsigned int num_dies = 2;
int i;
- smp_machine_class_init(mc);
/* Force the SMP compat properties */
mc->smp_props.dies_supported = true;
@@ -586,12 +576,24 @@ static void test_with_dies(void)
object_unref(obj);
}
+/* Type info of the tested machine */
+static const TypeInfo smp_machine_types[] = {
+ {
+ .name = TYPE_MACHINE,
+ .parent = TYPE_OBJECT,
+ .class_init = machine_base_class_init,
+ .class_size = sizeof(MachineClass),
+ .instance_size = sizeof(MachineState),
+ }
+};
+
+DEFINE_TYPES(smp_machine_types)
+
int main(int argc, char *argv[])
{
- g_test_init(&argc, &argv, NULL);
-
module_call_init(MODULE_INIT_QOM);
- type_register_static(&smp_machine_info);
+
+ g_test_init(&argc, &argv, NULL);
g_test_add_func("/test-smp-parse/generic", test_generic);
g_test_add_func("/test-smp-parse/with_dies", test_with_dies);
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PULL 3/3] tests/unit/test-smp-parse: Explicit MachineClass name
2021-11-15 22:47 [PULL 0/3] Machine-next patches for 2021-11-15 Philippe Mathieu-Daudé
2021-11-15 22:48 ` [PULL 1/3] tests/unit/test-smp-parse: Restore MachineClass fields after modifying Philippe Mathieu-Daudé
2021-11-15 22:48 ` [PULL 2/3] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init() Philippe Mathieu-Daudé
@ 2021-11-15 22:48 ` Philippe Mathieu-Daudé
2021-11-16 13:19 ` [PULL 0/3] Machine-next patches for 2021-11-15 Richard Henderson
3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-15 22:48 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Eduardo Habkost, Richard Henderson, Yanan Wang,
Philippe Mathieu-Daudé
If the MachineClass::name pointer is not explicitly set, it is NULL.
Per the C standard, passing a NULL pointer to printf "%s" format is
undefined. Some implementations display it as 'NULL', other as 'null'.
Since we are comparing the formatted output, we need a stable value.
The easiest is to explicit a machine name string.
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
Tested-by: Yanan Wang <wangyanan55@huawei.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20211115145900.2531865-4-philmd@redhat.com>
---
tests/unit/test-smp-parse.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c
index 3fff2af4e27..b02450e25a3 100644
--- a/tests/unit/test-smp-parse.c
+++ b/tests/unit/test-smp-parse.c
@@ -23,6 +23,8 @@
#define MIN_CPUS 1 /* set the min CPUs supported by the machine as 1 */
#define MAX_CPUS 512 /* set the max CPUs supported by the machine as 512 */
+#define SMP_MACHINE_NAME "TEST-SMP"
+
/*
* Used to define the generic 3-level CPU topology hierarchy
* -sockets/cores/threads
@@ -307,13 +309,13 @@ static struct SMPTestData data_generic_invalid[] = {
* should tweak the supported min CPUs to 2 for testing */
.config = SMP_CONFIG_GENERIC(T, 1, F, 0, F, 0, F, 0, F, 0),
.expect_error = "Invalid SMP CPUs 1. The min CPUs supported "
- "by machine '(null)' is 2",
+ "by machine '" SMP_MACHINE_NAME "' is 2",
}, {
/* config: -smp 512
* should tweak the supported max CPUs to 511 for testing */
.config = SMP_CONFIG_GENERIC(T, 512, F, 0, F, 0, F, 0, F, 0),
.expect_error = "Invalid SMP CPUs 512. The max CPUs supported "
- "by machine '(null)' is 511",
+ "by machine '" SMP_MACHINE_NAME "' is 511",
},
};
@@ -481,6 +483,8 @@ static void machine_base_class_init(ObjectClass *oc, void *data)
mc->smp_props.prefer_sockets = true;
mc->smp_props.dies_supported = false;
+
+ mc->name = g_strdup(SMP_MACHINE_NAME);
}
static void test_generic(void)
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PULL 0/3] Machine-next patches for 2021-11-15
2021-11-15 22:47 [PULL 0/3] Machine-next patches for 2021-11-15 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2021-11-15 22:48 ` [PULL 3/3] tests/unit/test-smp-parse: Explicit MachineClass name Philippe Mathieu-Daudé
@ 2021-11-16 13:19 ` Richard Henderson
3 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2021-11-16 13:19 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Eduardo Habkost
On 11/15/21 11:47 PM, Philippe Mathieu-Daudé wrote:
> The following changes since commit 42f6c9179be4401974dd3a75ee72defd16b5092d:
>
> Merge tag 'pull-ppc-20211112' of https://github.com/legoater/qemu into staging (2021-11-12 12:28:25 +0100)
>
> are available in the Git repository at:
>
> https://github.com/philmd/qemu.git tags/machine-core-20211115
>
> for you to fetch changes up to 7b6d1bc9629f3dd45647ec3418e0606a92dddd48:
>
> tests/unit/test-smp-parse: Explicit MachineClass name (2021-11-15 21:49:16 +0100)
>
> ----------------------------------------------------------------
> Machine core patches
>
> - Rework SMP parsing unit test to work on WinGW:
>
> https://github.com/qemu/qemu/runs/4078386652
>
> This fixes:
>
> Test smp_parse failed!
> Expected error report: Invalid SMP CPUs 1. The min CPUs supported by machine '(null)' is 2
> Output error report: Invalid SMP CPUs 1. The min CPUs supported by machine '(NULL)' is 2
>
> ----------------------------------------------------------------
>
> Philippe Mathieu-Daudé (3):
> tests/unit/test-smp-parse: Restore MachineClass fields after modifying
> tests/unit/test-smp-parse: QOM'ify smp_machine_class_init()
> tests/unit/test-smp-parse: Explicit MachineClass name
>
> tests/unit/test-smp-parse.c | 52 +++++++++++++++++++++++--------------
> 1 file changed, 33 insertions(+), 19 deletions(-)
Applied, thanks.
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-16 13:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 22:47 [PULL 0/3] Machine-next patches for 2021-11-15 Philippe Mathieu-Daudé
2021-11-15 22:48 ` [PULL 1/3] tests/unit/test-smp-parse: Restore MachineClass fields after modifying Philippe Mathieu-Daudé
2021-11-15 22:48 ` [PULL 2/3] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init() Philippe Mathieu-Daudé
2021-11-15 22:48 ` [PULL 3/3] tests/unit/test-smp-parse: Explicit MachineClass name Philippe Mathieu-Daudé
2021-11-16 13:19 ` [PULL 0/3] Machine-next patches for 2021-11-15 Richard Henderson
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).