diff mbox series

tests: qmp-cmd-test: fix memory leak

Message ID 20200714171531.83723-1-liq3ea@163.com (mailing list archive)
State New, archived
Headers show
Series tests: qmp-cmd-test: fix memory leak | expand

Commit Message

Li Qiang July 14, 2020, 5:15 p.m. UTC
Fixes: 5b88849e7b9("tests/qmp-cmd-test: Add
qmp/object-add-failure-modes"

Signed-off-by: Li Qiang <liq3ea@163.com>
---
 tests/qtest/qmp-cmd-test.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

no-reply@patchew.org July 14, 2020, 6 p.m. UTC | #1
Patchew URL: https://patchew.org/QEMU/20200714171531.83723-1-liq3ea@163.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

  TEST    check-unit: tests/test-crypto-secret
  TEST    check-unit: tests/test-char
**
ERROR:/tmp/qemu-test/src/tests/test-char.c:1204:char_serial_test: 'chr' should not be NULL
ERROR test-char - Bail out! ERROR:/tmp/qemu-test/src/tests/test-char.c:1204:char_serial_test: 'chr' should not be NULL
make: *** [check-unit] Error 1
make: *** Waiting for unfinished jobs....
  TEST    iotest-qcow2: 029
qemu-system-aarch64: -accel kvm: invalid accelerator kvm
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=40109892cb4947b592110f54dc387d3d', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-fj3d95lf/src/docker-src.2020-07-14-13.45.46.10433:/var/tmp/qemu:z,ro', 'qemu/centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=40109892cb4947b592110f54dc387d3d
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-fj3d95lf/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    15m6.204s
user    0m5.812s


The full log is available at
http://patchew.org/logs/20200714171531.83723-1-liq3ea@163.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Eric Auger July 15, 2020, 9:04 a.m. UTC | #2
Hi Li,

On 7/14/20 7:15 PM, Li Qiang wrote:


> Fixes: 5b88849e7b9("tests/qmp-cmd-test: Add
> qmp/object-add-failure-modes"
Thank you for fixing this.

Adding a commit message generally is welcome such as for example:
properly free each test response and separate qtest_qmp() calls with
spare lines, in a consistent manner.


> 
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>  tests/qtest/qmp-cmd-test.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
> index c68f99f659..f7b1aa7fdc 100644
> --- a/tests/qtest/qmp-cmd-test.c
> +++ b/tests/qtest/qmp-cmd-test.c
> @@ -230,6 +230,8 @@ static void test_object_add_failure_modes(void)
>                       " 'props': {'size': 1048576 } } }");
>      g_assert_nonnull(resp);
>      g_assert(qdict_haskey(resp, "return"));
> +    qobject_unref(resp);
> +
>      resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
>                       " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
>                       " 'props': {'size': 1048576 } } }");
> @@ -241,6 +243,7 @@ static void test_object_add_failure_modes(void)
>                       " {'id': 'ram1' } }");
>      g_assert_nonnull(resp);
>      g_assert(qdict_haskey(resp, "return"));
> +    qobject_unref(resp);
>  
>      /* attempt to create an object with a property of a wrong type */
>      resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
> @@ -249,17 +252,20 @@ static void test_object_add_failure_modes(void)
>      g_assert_nonnull(resp);
>      /* now do it right */
>      qmp_assert_error_class(resp, "GenericError");
> +
>      resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
>                       " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
>                       " 'props': {'size': 1048576 } } }");
>      g_assert_nonnull(resp);
>      g_assert(qdict_haskey(resp, "return"));
> +    qobject_unref(resp);
>  
>      /* delete ram1 object */
>      resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
>                       " {'id': 'ram1' } }");
>      g_assert_nonnull(resp);
>      g_assert(qdict_haskey(resp, "return"));
> +    qobject_unref(resp);
>  
>      /* attempt to create an object without the id */
>      resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
> @@ -267,18 +273,21 @@ static void test_object_add_failure_modes(void)
>                       " 'props': {'size': 1048576 } } }");
>      g_assert_nonnull(resp);
>      qmp_assert_error_class(resp, "GenericError");
> +
>      /* now do it right */
>      resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
>                       " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
>                       " 'props': {'size': 1048576 } } }");
>      g_assert_nonnull(resp);
>      g_assert(qdict_haskey(resp, "return"));
> +    qobject_unref(resp);
>  
>      /* delete ram1 object */
>      resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
>                       " {'id': 'ram1' } }");
>      g_assert_nonnull(resp);
>      g_assert(qdict_haskey(resp, "return"));
> +    qobject_unref(resp);
>  
>      /* attempt to set a non existing property */
>      resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
> @@ -286,23 +295,27 @@ static void test_object_add_failure_modes(void)
>                       " 'props': {'sized': 1048576 } } }");
>      g_assert_nonnull(resp);
>      qmp_assert_error_class(resp, "GenericError");
> +
>      /* now do it right */
>      resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
>                       " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
>                       " 'props': {'size': 1048576 } } }");
>      g_assert_nonnull(resp);
>      g_assert(qdict_haskey(resp, "return"));
> +    qobject_unref(resp);
>  
>      /* delete ram1 object without id */
>      resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
>                       " {'ida': 'ram1' } }");
>      g_assert_nonnull(resp);
> +    qobject_unref(resp);
>  
>      /* delete ram1 object */
>      resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
>                       " {'id': 'ram1' } }");
>      g_assert_nonnull(resp);
>      g_assert(qdict_haskey(resp, "return"));
> +    qobject_unref(resp);
>  
>      /* delete ram1 object that does not exist anymore*/
>      resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
> 
Besides
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric
diff mbox series

Patch

diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index c68f99f659..f7b1aa7fdc 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -230,6 +230,8 @@  static void test_object_add_failure_modes(void)
                      " 'props': {'size': 1048576 } } }");
     g_assert_nonnull(resp);
     g_assert(qdict_haskey(resp, "return"));
+    qobject_unref(resp);
+
     resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
                      " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
                      " 'props': {'size': 1048576 } } }");
@@ -241,6 +243,7 @@  static void test_object_add_failure_modes(void)
                      " {'id': 'ram1' } }");
     g_assert_nonnull(resp);
     g_assert(qdict_haskey(resp, "return"));
+    qobject_unref(resp);
 
     /* attempt to create an object with a property of a wrong type */
     resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
@@ -249,17 +252,20 @@  static void test_object_add_failure_modes(void)
     g_assert_nonnull(resp);
     /* now do it right */
     qmp_assert_error_class(resp, "GenericError");
+
     resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
                      " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
                      " 'props': {'size': 1048576 } } }");
     g_assert_nonnull(resp);
     g_assert(qdict_haskey(resp, "return"));
+    qobject_unref(resp);
 
     /* delete ram1 object */
     resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
                      " {'id': 'ram1' } }");
     g_assert_nonnull(resp);
     g_assert(qdict_haskey(resp, "return"));
+    qobject_unref(resp);
 
     /* attempt to create an object without the id */
     resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
@@ -267,18 +273,21 @@  static void test_object_add_failure_modes(void)
                      " 'props': {'size': 1048576 } } }");
     g_assert_nonnull(resp);
     qmp_assert_error_class(resp, "GenericError");
+
     /* now do it right */
     resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
                      " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
                      " 'props': {'size': 1048576 } } }");
     g_assert_nonnull(resp);
     g_assert(qdict_haskey(resp, "return"));
+    qobject_unref(resp);
 
     /* delete ram1 object */
     resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
                      " {'id': 'ram1' } }");
     g_assert_nonnull(resp);
     g_assert(qdict_haskey(resp, "return"));
+    qobject_unref(resp);
 
     /* attempt to set a non existing property */
     resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
@@ -286,23 +295,27 @@  static void test_object_add_failure_modes(void)
                      " 'props': {'sized': 1048576 } } }");
     g_assert_nonnull(resp);
     qmp_assert_error_class(resp, "GenericError");
+
     /* now do it right */
     resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
                      " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
                      " 'props': {'size': 1048576 } } }");
     g_assert_nonnull(resp);
     g_assert(qdict_haskey(resp, "return"));
+    qobject_unref(resp);
 
     /* delete ram1 object without id */
     resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
                      " {'ida': 'ram1' } }");
     g_assert_nonnull(resp);
+    qobject_unref(resp);
 
     /* delete ram1 object */
     resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
                      " {'id': 'ram1' } }");
     g_assert_nonnull(resp);
     g_assert(qdict_haskey(resp, "return"));
+    qobject_unref(resp);
 
     /* delete ram1 object that does not exist anymore*/
     resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"