From patchwork Thu Oct 20 11:28:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Ma X-Patchwork-Id: 684557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t069N524tz9s3v for ; Thu, 20 Oct 2016 22:32:24 +1100 (AEDT) Received: from localhost ([::1]:53995 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxBa9-0007uz-9W for incoming@patchwork.ozlabs.org; Thu, 20 Oct 2016 07:32:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxBX2-0004by-8T for qemu-devel@nongnu.org; Thu, 20 Oct 2016 07:29:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxBWy-0008Ll-7O for qemu-devel@nongnu.org; Thu, 20 Oct 2016 07:29:08 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:36269 helo=prv3-mh.provo.novell.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bxBWx-0008Ku-Ur for qemu-devel@nongnu.org; Thu, 20 Oct 2016 07:29:04 -0400 Received: from linux-xpcv.apac.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Thu, 20 Oct 2016 05:28:54 -0600 From: Lin Ma To: qemu-devel@nongnu.org Date: Thu, 20 Oct 2016 19:28:27 +0800 Message-Id: <20161020112829.14589-4-lma@suse.com> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20161020112829.14589-1-lma@suse.com> References: <20161020112829.14589-1-lma@suse.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 137.65.250.26 Subject: [Qemu-devel] [PATCH v4 3/5] qapi: add test case for the generated enum value str X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, afaerber@suse.de, armbru@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Lin Ma --- tests/test-qmp-commands.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 81cbe54..9cd61b2 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -262,6 +262,23 @@ static void test_dealloc_partial(void) qapi_free_UserDefTwo(ud2); } +/* test generated enum value str */ +static void test_enum_value_str(void) +{ + EnumOne i; + char *expected_str = NULL; + + for (i = 0; i < ENUM_ONE__MAX; i++) { + if (i == 0) { + expected_str = g_strdup_printf("\'%s\'", EnumOne_lookup[i]); + } else { + expected_str = g_strdup_printf("%s, \'%s\'", + expected_str, EnumOne_lookup[i]); + } + } + g_assert_cmpstr(EnumOne_value_str, ==, expected_str); +} + int main(int argc, char **argv) { @@ -272,6 +289,7 @@ int main(int argc, char **argv) g_test_add_func("/0.15/dispatch_cmd_io", test_dispatch_cmd_io); g_test_add_func("/0.15/dealloc_types", test_dealloc_types); g_test_add_func("/0.15/dealloc_partial", test_dealloc_partial); + g_test_add_func("/0.15/enum_value_str", test_enum_value_str); module_call_init(MODULE_INIT_QAPI); g_test_run();