* [Qemu-devel] [PATCH v2] tests: test-announce-self: fix memory leak
@ 2019-03-11 14:14 Li Qiang
2019-03-11 14:48 ` Thomas Huth
0 siblings, 1 reply; 2+ messages in thread
From: Li Qiang @ 2019-03-11 14:14 UTC (permalink / raw)
To: vyasevic, dgilbert, mst, jasowang, thuth
Cc: qemu-devel, philmd, liq3ea, Li Qiang
Spotted by ASAN while running 'make check'.
Fixes: 4b9b7000(tests: Add a test for qemu
self announcements)
Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Li Qiang <liq3ea@163.com>
---
Changes since v1: Use Thomas's patch
tests/test-announce-self.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/tests/test-announce-self.c b/tests/test-announce-self.c
index 1644d34a3f..662c3aaf06 100644
--- a/tests/test-announce-self.c
+++ b/tests/test-announce-self.c
@@ -21,18 +21,8 @@
#define ETH_P_RARP 0x8035
#endif
-static QTestState *test_init(int socket)
-{
- char *args;
-
- args = g_strdup_printf("-netdev socket,fd=%d,id=hs0 -device "
- "virtio-net-pci,netdev=hs0", socket);
-
- return qtest_start(args);
-}
-
-static void test_announce(int socket)
+static void test_announce(QTestState *qs, int socket)
{
char buffer[60];
int len;
@@ -40,7 +30,7 @@ static void test_announce(int socket)
int ret;
uint16_t *proto = (uint16_t *)&buffer[12];
- rsp = qmp("{ 'execute' : 'announce-self', "
+ rsp = qtest_qmp(qs, "{ 'execute' : 'announce-self', "
" 'arguments': {"
" 'initial': 50, 'max': 550,"
" 'rounds': 10, 'step': 50 } }");
@@ -59,14 +49,15 @@ static void test_announce(int socket)
static void setup(gconstpointer data)
{
QTestState *qs;
- void (*func) (int socket) = data;
+ void (*func) (QTestState *qs, int socket) = data;
int sv[2], ret;
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sv);
g_assert_cmpint(ret, !=, -1);
- qs = test_init(sv[1]);
- func(sv[0]);
+ qs = qtest_initf("-netdev socket,fd=%d,id=hs0 -device "
+ "virtio-net-pci,netdev=hs0", sv[1]);
+ func(qs, sv[0]);
/* End test */
close(sv[0]);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v2] tests: test-announce-self: fix memory leak
2019-03-11 14:14 [Qemu-devel] [PATCH v2] tests: test-announce-self: fix memory leak Li Qiang
@ 2019-03-11 14:48 ` Thomas Huth
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Huth @ 2019-03-11 14:48 UTC (permalink / raw)
To: Li Qiang, vyasevic, dgilbert, mst, jasowang; +Cc: qemu-devel, philmd, liq3ea
On 11/03/2019 15.14, Li Qiang wrote:
> Spotted by ASAN while running 'make check'.
>
> Fixes: 4b9b7000(tests: Add a test for qemu
> self announcements)
>
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
> Changes since v1: Use Thomas's patch
> tests/test-announce-self.c | 21 ++++++---------------
> 1 file changed, 6 insertions(+), 15 deletions(-)
Thanks, applied to the qtest-next branch:
https://gitlab.com/huth/qemu/commits/qtest-next
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-11 14:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-11 14:14 [Qemu-devel] [PATCH v2] tests: test-announce-self: fix memory leak Li Qiang
2019-03-11 14:48 ` Thomas Huth
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).