mirror of https://github.com/xqemu/xqemu.git
tests: test-announce-self: fix memory leak
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>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
377b155bde
commit
6415c2d0b6
|
@ -21,18 +21,8 @@
|
||||||
#define ETH_P_RARP 0x8035
|
#define ETH_P_RARP 0x8035
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QTestState *test_init(int socket)
|
|
||||||
{
|
|
||||||
char *args;
|
|
||||||
|
|
||||||
args = g_strdup_printf("-netdev socket,fd=%d,id=hs0 -device "
|
static void test_announce(QTestState *qs, int socket)
|
||||||
"virtio-net-pci,netdev=hs0", socket);
|
|
||||||
|
|
||||||
return qtest_start(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void test_announce(int socket)
|
|
||||||
{
|
{
|
||||||
char buffer[60];
|
char buffer[60];
|
||||||
int len;
|
int len;
|
||||||
|
@ -40,7 +30,7 @@ static void test_announce(int socket)
|
||||||
int ret;
|
int ret;
|
||||||
uint16_t *proto = (uint16_t *)&buffer[12];
|
uint16_t *proto = (uint16_t *)&buffer[12];
|
||||||
|
|
||||||
rsp = qmp("{ 'execute' : 'announce-self', "
|
rsp = qtest_qmp(qs, "{ 'execute' : 'announce-self', "
|
||||||
" 'arguments': {"
|
" 'arguments': {"
|
||||||
" 'initial': 50, 'max': 550,"
|
" 'initial': 50, 'max': 550,"
|
||||||
" 'rounds': 10, 'step': 50 } }");
|
" 'rounds': 10, 'step': 50 } }");
|
||||||
|
@ -59,14 +49,15 @@ static void test_announce(int socket)
|
||||||
static void setup(gconstpointer data)
|
static void setup(gconstpointer data)
|
||||||
{
|
{
|
||||||
QTestState *qs;
|
QTestState *qs;
|
||||||
void (*func) (int socket) = data;
|
void (*func) (QTestState *qs, int socket) = data;
|
||||||
int sv[2], ret;
|
int sv[2], ret;
|
||||||
|
|
||||||
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sv);
|
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sv);
|
||||||
g_assert_cmpint(ret, !=, -1);
|
g_assert_cmpint(ret, !=, -1);
|
||||||
|
|
||||||
qs = test_init(sv[1]);
|
qs = qtest_initf("-netdev socket,fd=%d,id=hs0 -device "
|
||||||
func(sv[0]);
|
"virtio-net-pci,netdev=hs0", sv[1]);
|
||||||
|
func(qs, sv[0]);
|
||||||
|
|
||||||
/* End test */
|
/* End test */
|
||||||
close(sv[0]);
|
close(sv[0]);
|
||||||
|
|
Loading…
Reference in New Issue