Message ID | 20211115145900.2531865-6-philmd@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | tests/unit: Fix test-smp-parse | expand |
On 11/15/21 3:58 PM, Philippe Mathieu-Daudé wrote: > Split the 'generic' test in two tests: 'valid' and 'invalid'. > This will allow us to remove the hack which modifies the > MachineClass internal state. > > Signed-off-by: Philippe Mathieu-Daudé<philmd@redhat.com> > --- > tests/unit/test-smp-parse.c | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
On 2021/11/15 22:58, Philippe Mathieu-Daudé wrote: > Split the 'generic' test in two tests: 'valid' and 'invalid'. > This will allow us to remove the hack which modifies the > MachineClass internal state. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > tests/unit/test-smp-parse.c | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) Reviewed-by: Yanan Wang <wangyanan55@huawei.com> Thanks, Yanan > diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c > index 37c6b4981db..e27aedad354 100644 > --- a/tests/unit/test-smp-parse.c > +++ b/tests/unit/test-smp-parse.c > @@ -487,7 +487,7 @@ static void machine_base_class_init(ObjectClass *oc, void *data) > mc->name = g_strdup(SMP_MACHINE_NAME); > } > > -static void test_generic(const void *opaque) > +static void test_generic_valid(const void *opaque) > { > const char *machine_type = opaque; > Object *obj = object_new(machine_type); > @@ -508,6 +508,19 @@ static void test_generic(const void *opaque) > smp_parse_test(ms, data, true); > } > > + object_unref(obj); > +} > + > +static void test_generic_invalid(const void *opaque) > +{ > + const char *machine_type = opaque; > + Object *obj = object_new(machine_type); > + MachineState *ms = MACHINE(obj); > + MachineClass *mc = MACHINE_GET_CLASS(obj); > + SMPTestData *data = &(SMPTestData){}; > + int i; > + > + > /* Force invalid min CPUs and max CPUs */ > mc->min_cpus = 2; > mc->max_cpus = 511; > @@ -601,9 +614,12 @@ int main(int argc, char *argv[]) > > g_test_init(&argc, &argv, NULL); > > - g_test_add_data_func("/test-smp-parse/generic", > + g_test_add_data_func("/test-smp-parse/generic/valid", > TYPE_MACHINE, > - test_generic); > + test_generic_valid); > + g_test_add_data_func("/test-smp-parse/generic/invalid", > + TYPE_MACHINE, > + test_generic_invalid); > g_test_add_data_func("/test-smp-parse/with_dies", > TYPE_MACHINE, > test_with_dies);
On 2021/11/15 22:58, Philippe Mathieu-Daudé wrote: > Split the 'generic' test in two tests: 'valid' and 'invalid'. > This will allow us to remove the hack which modifies the > MachineClass internal state. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > tests/unit/test-smp-parse.c | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) > > diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c > index 37c6b4981db..e27aedad354 100644 > --- a/tests/unit/test-smp-parse.c > +++ b/tests/unit/test-smp-parse.c > @@ -487,7 +487,7 @@ static void machine_base_class_init(ObjectClass *oc, void *data) > mc->name = g_strdup(SMP_MACHINE_NAME); > } > > -static void test_generic(const void *opaque) > +static void test_generic_valid(const void *opaque) > { > const char *machine_type = opaque; > Object *obj = object_new(machine_type); > @@ -508,6 +508,19 @@ static void test_generic(const void *opaque) > smp_parse_test(ms, data, true); > } > > + object_unref(obj); > +} > + > +static void test_generic_invalid(const void *opaque) > +{ > + const char *machine_type = opaque; > + Object *obj = object_new(machine_type); > + MachineState *ms = MACHINE(obj); > + MachineClass *mc = MACHINE_GET_CLASS(obj); > + SMPTestData *data = &(SMPTestData){}; > + int i; > + > + Ah, there is an extra empty line which should be deleted. Thanks, Yanan > /* Force invalid min CPUs and max CPUs */ > mc->min_cpus = 2; > mc->max_cpus = 511; > @@ -601,9 +614,12 @@ int main(int argc, char *argv[]) > > g_test_init(&argc, &argv, NULL); > > - g_test_add_data_func("/test-smp-parse/generic", > + g_test_add_data_func("/test-smp-parse/generic/valid", > TYPE_MACHINE, > - test_generic); > + test_generic_valid); > + g_test_add_data_func("/test-smp-parse/generic/invalid", > + TYPE_MACHINE, > + test_generic_invalid); > g_test_add_data_func("/test-smp-parse/with_dies", > TYPE_MACHINE, > test_with_dies);
On 11/16/21 3:07 PM, wangyanan (Y) wrote: >> + int i; >> + >> + > Ah, there is an extra empty line which should be deleted. I noticed that too, but it gets deleted in patch 7, so I let it be. ;-) r~
On 11/16/21 15:22, Richard Henderson wrote: > On 11/16/21 3:07 PM, wangyanan (Y) wrote: >>> + int i; >>> + >>> + >> Ah, there is an extra empty line which should be deleted. > > I noticed that too, but it gets deleted in patch 7, so I let it be. ;-) Oops sorry, I'll clean that once v7.0 is released.
diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 37c6b4981db..e27aedad354 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -487,7 +487,7 @@ static void machine_base_class_init(ObjectClass *oc, void *data) mc->name = g_strdup(SMP_MACHINE_NAME); } -static void test_generic(const void *opaque) +static void test_generic_valid(const void *opaque) { const char *machine_type = opaque; Object *obj = object_new(machine_type); @@ -508,6 +508,19 @@ static void test_generic(const void *opaque) smp_parse_test(ms, data, true); } + object_unref(obj); +} + +static void test_generic_invalid(const void *opaque) +{ + const char *machine_type = opaque; + Object *obj = object_new(machine_type); + MachineState *ms = MACHINE(obj); + MachineClass *mc = MACHINE_GET_CLASS(obj); + SMPTestData *data = &(SMPTestData){}; + int i; + + /* Force invalid min CPUs and max CPUs */ mc->min_cpus = 2; mc->max_cpus = 511; @@ -601,9 +614,12 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); - g_test_add_data_func("/test-smp-parse/generic", + g_test_add_data_func("/test-smp-parse/generic/valid", TYPE_MACHINE, - test_generic); + test_generic_valid); + g_test_add_data_func("/test-smp-parse/generic/invalid", + TYPE_MACHINE, + test_generic_invalid); g_test_add_data_func("/test-smp-parse/with_dies", TYPE_MACHINE, test_with_dies);
Split the 'generic' test in two tests: 'valid' and 'invalid'. This will allow us to remove the hack which modifies the MachineClass internal state. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- tests/unit/test-smp-parse.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)