Received: from eggs.gnu.org ([2001:4830:134:3::10]:46606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byhJd-0004u2-5E for qemu-devel@nongnu.org; Mon, 24 Oct 2016 11:37:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byhJZ-0006bn-Cv for qemu-devel@nongnu.org; Mon, 24 Oct 2016 11:37:33 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:60525) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1byhJZ-0006af-6t for qemu-devel@nongnu.org; Mon, 24 Oct 2016 11:37:29 -0400 From: Eric Blake Date: Mon, 24 Oct 2016 10:36:23 -0500 Message-Id: <1477323383-12380-3-git-send-email-eblake@redhat.com> In-Reply-To: <1477323383-12380-1-git-send-email-eblake@redhat.com> References: <1477323383-12380-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH 2/2] tests: Enhance qmp output to cover partial visit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: ptoscano@redhat.com, armbru@redhat.com, Michael Roth Add a test that proves (at least when run under valgrind) that we are correctly handling allocated memory even when a visit is aborted in the middle for whatever other reason. See commit f24582d "qapi: fix double free in qmp_output_visitor_cleanup()" for a fix that was lacking testsuite exposure prior to this patch. Signed-off-by: Eric Blake --- tests/test-qmp-output-visitor.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index f7213d2..2368171 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -254,6 +254,16 @@ static void test_visitor_out_struct_errors(TestOutputVisitorData *data, } +static void test_visitor_out_partial_visit(TestOutputVisitorData *data, + const void *unused) +{ + /* Check that aborting mid-visit doesn't leak or double-free */ + visit_start_struct(data->ov, NULL, NULL, 0, &error_abort); + visit_start_struct(data->ov, "nested", NULL, 0, &error_abort); + visitor_reset(data); +} + + static void test_visitor_out_list(TestOutputVisitorData *data, const void *unused) { @@ -817,6 +827,8 @@ int main(int argc, char **argv) &out_visitor_data, test_visitor_out_struct_nested); output_visitor_test_add("/visitor/output/struct-errors", &out_visitor_data, test_visitor_out_struct_errors); + output_visitor_test_add("/visitor/output/partial-visit", + &out_visitor_data, test_visitor_out_partial_visit); output_visitor_test_add("/visitor/output/list", &out_visitor_data, test_visitor_out_list); output_visitor_test_add("/visitor/output/any", -- 2.7.4