qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH-for-7.0 v4 05/11] tests/unit/test-smp-parse: Split the 'gener


From: wangyanan (Y)
Subject: Re: [PATCH-for-7.0 v4 05/11] tests/unit/test-smp-parse: Split the 'generic' test in valid / invalid
Date: Tue, 16 Nov 2021 22:07:21 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0


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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]