qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Yang Hongyang <yanghy@cn.fujitsu.com>
Cc: amit.shah@redhat.com, qemu-devel@nongnu.org,
	Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/2] Tests: QEMUSizedBuffer/QEMUBuffer
Date: Tue, 16 Dec 2014 13:37:25 +0000	[thread overview]
Message-ID: <20141216133724.GF5467@work-vm> (raw)
In-Reply-To: <1418378027-19830-2-git-send-email-yanghy@cn.fujitsu.com>

* Yang Hongyang (yanghy@cn.fujitsu.com) wrote:
> 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: Eric Blake <eblake@redhat.com>
> Cc: Juan Quintela <quintela@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>  tests/test-vmstate.c | 20 ++++++++------------
>  1 file 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)
> -- 
> 1.9.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2014-12-16 13:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-12  9:53 [Qemu-devel] [PATCH 1/2] QEMUSizedBuffer: only free qsb that qemu_bufopen allocated Yang Hongyang
2014-12-12  9:53 ` [Qemu-devel] [PATCH 2/2] Tests: QEMUSizedBuffer/QEMUBuffer Yang Hongyang
2014-12-16 13:37   ` Dr. David Alan Gilbert [this message]
2014-12-16  2:20 ` [Qemu-devel] [PATCH 1/2] QEMUSizedBuffer: only free qsb that qemu_bufopen allocated Hongyang Yang
2014-12-16 13:34 ` Dr. David Alan Gilbert
  -- strict thread matches above, loose matches on Subject: below --
2014-08-06 17:30 [Qemu-devel] [PATCH 0/2] In memory QEMUFile Dr. David Alan Gilbert (git)
2014-08-06 17:30 ` [Qemu-devel] [PATCH 2/2] Tests: QEMUSizedBuffer/QEMUBuffer Dr. David Alan Gilbert (git)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141216133724.GF5467@work-vm \
    --to=dgilbert@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=yanghy@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).