diff options
author | Yang Hongyang <yanghy@cn.fujitsu.com> | 2014-12-19 11:38:06 +0800 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2015-01-16 13:06:17 +0530 |
commit | 8580b06498a5dffe554e7ac627726b1d7775c591 (patch) | |
tree | e64f30ae100d0dec1e94a6826ea9a65fd986e0c4 | |
parent | f018d8cd2123f495300935d5019931abbee4e5d9 (diff) | |
download | qemu-8580b06498a5dffe554e7ac627726b1d7775c591.zip qemu-8580b06498a5dffe554e7ac627726b1d7775c591.tar.gz qemu-8580b06498a5dffe554e7ac627726b1d7775c591.tar.bz2 |
Tests: QEMUSizedBuffer/QEMUBuffer
Modify some of tests/test-vmstate.c due to qemu_bufopen() change.
If you create a QEMUSizedBuffer yourself, you have to explicitly
free it.
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Cc: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r-- | tests/test-vmstate.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index 5e0fd13..39b7b01 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -60,16 +60,6 @@ static QEMUFile *open_test_file(bool write) return qemu_fdopen(fd, write ? "wb" : "rb"); } -/* Open a read-only qemu-file from an existing memory block */ -static QEMUFile *open_mem_file_read(const void *data, size_t len) -{ - /* The qsb gets freed by qemu_fclose */ - QEMUSizedBuffer *qsb = qsb_create(data, len); - g_assert(qsb); - - return qemu_bufopen("r", qsb); -} - /* * Check that the contents of the memory-buffered file f match * the given size/data. @@ -450,7 +440,9 @@ static void test_load_noskip(void) QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ }; - QEMUFile *loading = open_mem_file_read(buf, sizeof(buf)); + QEMUSizedBuffer *qsb = qsb_create(buf, sizeof(buf)); + g_assert(qsb); + QEMUFile *loading = qemu_bufopen("r", qsb); TestStruct obj = { .skip_c_e = false }; vmstate_load_state(loading, &vmstate_skipping, &obj, 2); g_assert(!qemu_file_get_error(loading)); @@ -461,6 +453,7 @@ static void test_load_noskip(void) g_assert_cmpint(obj.e, ==, 50); g_assert_cmpint(obj.f, ==, 60); qemu_fclose(loading); + qsb_free(qsb); } static void test_load_skip(void) @@ -473,7 +466,9 @@ static void test_load_skip(void) QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ }; - QEMUFile *loading = open_mem_file_read(buf, sizeof(buf)); + QEMUSizedBuffer *qsb = qsb_create(buf, sizeof(buf)); + g_assert(qsb); + QEMUFile *loading = qemu_bufopen("r", qsb); TestStruct obj = { .skip_c_e = true, .c = 300, .e = 500 }; vmstate_load_state(loading, &vmstate_skipping, &obj, 2); g_assert(!qemu_file_get_error(loading)); @@ -484,6 +479,7 @@ static void test_load_skip(void) g_assert_cmpint(obj.e, ==, 500); g_assert_cmpint(obj.f, ==, 60); qemu_fclose(loading); + qsb_free(qsb); } int main(int argc, char **argv) |