diff mbox series

[PATCH-for-7.0,v4,05/11] tests/unit/test-smp-parse: Split the 'generic' test in valid / invalid

Message ID 20211115145900.2531865-6-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series tests/unit: Fix test-smp-parse | expand

Commit Message

Philippe Mathieu-Daudé Nov. 15, 2021, 2:58 p.m. UTC
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(-)

Comments

Richard Henderson Nov. 16, 2021, 12:06 p.m. UTC | #1
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~
Yanan Wang Nov. 16, 2021, 1:58 p.m. UTC | #2
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);
Yanan Wang Nov. 16, 2021, 2:07 p.m. UTC | #3
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);
Richard Henderson Nov. 16, 2021, 2:22 p.m. UTC | #4
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~
Philippe Mathieu-Daudé Nov. 16, 2021, 3:15 p.m. UTC | #5
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 mbox series

Patch

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);