qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [QEMU PATCH v10 3/3] tests/migration: Add test for QTAI


From: Halil Pasic
Subject: Re: [Qemu-devel] [QEMU PATCH v10 3/3] tests/migration: Add test for QTAILQ migration
Date: Thu, 3 Nov 2016 13:22:00 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0


On 11/02/2016 11:47 AM, Juan Quintela wrote:
> Jianjun Duan <address@hidden> wrote:
>> Add a test for QTAILQ migration to tests/test-vmstate.c.
>>
>> Signed-off-by: Jianjun Duan <address@hidden>
> 
> Reviewed-by: Juan Quintela <address@hidden>
> 

Empty QTAILQ seems to be broken. Have written a small
test to prove my point. It May even make sense to have such
a test in the test-suite (some prettyfication might be
necessary though).

Halil

-----------------------8<-------------------------------------

>From 4323c308c5f56ed86eb0a5bb6027bca4617ecc8c Mon Sep 17 00:00:00 2001
From: Halil Pasic <address@hidden>
Date: Thu, 3 Nov 2016 13:07:05 +0100
Subject: [PATCH] tests/test-vmstate.c: add test empty qtailq

Add test for empty qtailq.

Signed-off-by: Halil Pasic <address@hidden>

--

For fixup.
---
 tests/test-vmstate.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index a992408..789f07a 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -126,6 +126,14 @@ static int load_vmstate_one(const VMStateDescription 
*desc, void *obj,
     return ret;
 }
 
+static void load_vmstate_one_obj(const VMStateDescription *vmsd, void *obj,
+        int version_id)
+{
+        QEMUFile *fload = open_test_file(false);
+
+        SUCCESS(vmstate_load_state(fload, vmsd, obj, version_id));
+        qemu_fclose(fload);
+}
 
 static int load_vmstate(const VMStateDescription *desc,
                         void *obj, void *obj_clone,
@@ -633,6 +641,25 @@ static void test_load_q(void)
     qemu_fclose(fload);
 }
 
+
+static void test_sl_empty_q(void)
+{
+    TestQtailq obj_q = {
+        .i16 = -512,
+        .i32 = 70000,
+    };
+    TestQtailq tgt = {.q = {.tqh_first = (void *)1}};
+
+    QTAILQ_INIT(&obj_q.q);
+
+    save_vmstate(&vmstate_q, &obj_q);
+    load_vmstate_one_obj(&vmstate_q, &tgt, 1);
+    g_assert_cmpint(tgt.i16, ==, obj_q.i16);
+    g_assert_cmpint(tgt.i32, ==, obj_q.i32);
+    g_assert_cmpint(QTAILQ_EMPTY(&(tgt.q)),!=, false);
+     
+}
+
 int main(int argc, char **argv)
 {
     temp_fd = mkstemp(temp_file);
@@ -649,6 +676,7 @@ int main(int argc, char **argv)
     g_test_add_func("/vmstate/field_exists/save/skip", test_save_skip);
     g_test_add_func("/vmstate/qtailq/save/saveq", test_save_q);
     g_test_add_func("/vmstate/qtailq/load/loadq", test_load_q);
+    g_test_add_func("/vmstate/qtailq/empty", test_sl_empty_q);
     g_test_run();
 
     close(temp_fd);
-- 
1.7.1




reply via email to

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