tests: qmp-cmd-test: fix memory leak
PATCH 1/1 tests: qmp-cmd-test: fix memory leak
qmp/object-add-failure-modes"
--- tests/qtest/qmp-cmd-test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tests/qtest/qmp-cmd-test.c +13 -0
@@ -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':"
Signature · 1 line
2.17.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
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/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Hi Li,
Quoted 2 lines · Li Qiang
Fixes 5b88849e7b9("tests/qmp-cmd-test: Addqmp/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.
Quoted 89 lines
Signed-off-by Li Qiang <[email protected]>--- tests/qtest/qmp-cmd-test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)tests/qtest/qmp-cmd-test.c +12
-0@@ -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);
tests/qtest/qmp-cmd-test.c static void test_object_add_failure_modes(void) · line 321
Quoted 10 lines
tests/qtest/qmp-cmd-test.c +1
-0/* 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
Thanks
Eric