From nobody Wed Jan 15 13:05:41 2025 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1705422071338410.68124936377967; Tue, 16 Jan 2024 08:21:11 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 462AB1CE5; Tue, 16 Jan 2024 11:21:10 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CEFE31E28; Tue, 16 Jan 2024 11:13:20 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B1AF01D33; Tue, 16 Jan 2024 11:12:57 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 01B541C9B for ; Tue, 16 Jan 2024 11:12:53 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-353-g4CNSkuLOb2oaxBXEUThBA-1; Tue, 16 Jan 2024 11:12:51 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4C403C1E9C0 for ; Tue, 16 Jan 2024 16:12:51 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 051591C060AF for ; Tue, 16 Jan 2024 16:12:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: g4CNSkuLOb2oaxBXEUThBA-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 04/10] tests: Remove 'qemucapabilitiesnumbering' test Date: Tue, 16 Jan 2024 17:12:38 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: U326TJU7GIU6SXVFWQEIJ2YFXHLPDOQN X-Message-ID-Hash: U326TJU7GIU6SXVFWQEIJ2YFXHLPDOQN X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1705422072765100001 The test case was completely replaced by the 'qemu-replies-tool.py' script in default mode. Signed-off-by: Peter Krempa Reviewed-by: Andrea Bolognani --- tests/meson.build | 1 - tests/qemucapabilitiesnumbering.c | 267 ------------------------------ 2 files changed, 268 deletions(-) delete mode 100644 tests/qemucapabilitiesnumbering.c diff --git a/tests/meson.build b/tests/meson.build index bef3ed3260..7c37342e1a 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -441,7 +441,6 @@ if conf.has('WITH_QEMU') { 'name': 'qemuagenttest', 'link_with': [ test_qemu_driver_lib, test_u= tils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] }, { 'name': 'qemublocktest', 'include': [ storage_file_inc_dir ], 'link_= with': [ test_qemu_driver_lib, test_utils_qemu_monitor_lib ], 'link_whole':= [ test_utils_qemu_lib ] }, { 'name': 'qemucapabilitiestest', 'link_with': [ test_qemu_driver_lib,= test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] }, - { 'name': 'qemucapabilitiesnumbering', 'link_with': [ test_qemu_driver= _lib, test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] = }, { 'name': 'qemucaps2xmltest', 'link_with': [ test_qemu_driver_lib ], '= link_whole': [ test_utils_qemu_lib ] }, { 'name': 'qemucommandutiltest', 'link_with': [ test_qemu_driver_lib, = test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] }, { 'name': 'qemudomaincheckpointxml2xmltest', 'link_with': [ test_qemu_= driver_lib ], 'link_whole': [ test_utils_qemu_lib ] }, diff --git a/tests/qemucapabilitiesnumbering.c b/tests/qemucapabilitiesnumb= ering.c deleted file mode 100644 index 2aabdf72c7..0000000000 --- a/tests/qemucapabilitiesnumbering.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * qemucapabilitiesnumbering.c: swiss-army knife for qemu capability data = manipulation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ -#include - -#include "testutils.h" -#include "testutilsqemu.h" -#include "qemumonitortestutils.h" - -struct qmpTuple { - virJSONValue *command; - virJSONValue *reply; -}; - -struct qmpCommandList { - struct qmpTuple *items; - size_t nitems; -}; - -typedef struct qmpCommandList qmpCommandList; - - -static int -modify(struct qmpCommandList *list G_GNUC_UNUSED) -{ - /* in case you want to programmatically modify the replies file enable= the - * following block and modify it to your needs. After compiling run th= is - * with: - * - * VIR_TEST_REGENERATE_OUTPUT=3D1 tests/qemucapabilitiesnumbering - * - * This applies the modification along with updating the files. Use gi= t to - * your advantage to roll back mistakes. - */ -#if 0 - struct qmpTuple tmptuple =3D { NULL, NULL }; - size_t found =3D 0; - size_t i; - - for (i =3D 0; i < list->nitems; i++) { - struct qmpTuple *item =3D list->items + i; - const char *cmdname =3D virJSONValueObjectGetString(item->command,= "execute"); - - if (STREQ_NULLABLE(cmdname, "qom-list-properties")) { - found =3D i; - // break; /* uncomment if you want to find the first occurrenc= e */ - } - } - - if (found =3D=3D 0) { - fprintf(stderr, "entry not found!!!\n"); - return -1; - } - - tmptuple.command =3D virJSONValueFromString("{\"execute\":\"dummy\"}"); - tmptuple.reply =3D virJSONValueFromString("{\"return\":{}}"); - // tmptuple.reply =3D virTestLoadFileJSON("path/", "to/", "file.json"); - - ignore_value(VIR_INSERT_ELEMENT(list->items, found + 1, list->nitems, = tmptuple)); -#endif - - return 0; -} - - -static void -qmpCommandListFree(qmpCommandList* list) -{ - size_t i; - - if (!list) - return; - - for (i =3D 0; i < list->nitems; i++) { - struct qmpTuple *item =3D list->items + i; - - virJSONValueFree(item->command); - virJSONValueFree(item->reply); - } - - g_free(list->items); - g_free(list); -} - - -G_DEFINE_AUTOPTR_CLEANUP_FUNC(qmpCommandList, qmpCommandListFree); - - -static qmpCommandList * -loadReplies(const char *filename) -{ - g_autofree char *replies =3D NULL; - g_autofree struct qemuMonitorTestCommandReplyTuple *items =3D NULL; - size_t nitems =3D 0; - g_autoptr(qmpCommandList) list =3D NULL; - size_t i; - - if (virTestLoadFile(filename, &replies) < 0) { - fprintf(stderr, "Failed to load '%s'\n", filename); - return NULL; - } - - if (qemuMonitorTestProcessFileEntries(replies, filename, &items, &nite= ms) < 0) - return NULL; - - list =3D g_new0(qmpCommandList, 1); - list->items =3D g_new0(struct qmpTuple, nitems); - - for (i =3D 0; i < nitems; i++) { - struct qemuMonitorTestCommandReplyTuple *item =3D items + i; - - if (!(list->items[list->nitems].command =3D virJSONValueFromString= (item->command)) || - !(list->items[list->nitems++].reply =3D virJSONValueFromString= (item->reply))) - return NULL; - } - - return g_steal_pointer(&list); -} - -/* see printLineSkipEmpty in tests/qemucapsprobemock.c */ -static void -printLineSkipEmpty(const char *p, - virBuffer *buf) -{ - for (; *p; p++) { - virBufferAddChar(buf, *p); - - /* YAJL formats empty objects and arrays in a weird way: - * - * { - * "emptyarray": [ - * - * ], - * "emptyobject": { - * - * } - * } - * - * We want to use empty lines to separate commands and replies as - * well as be compatible with python's 'json.dump' method, thus we= drop - * any whitespace between array/object braces. - */ - if ((p[0] =3D=3D '{' || p[0] =3D=3D '[') && p[1] =3D=3D '\n') { - const char *l =3D p + 1; - - while (*l && g_ascii_isspace(*l)) - l++; - - if (*l =3D=3D '}' || *l =3D=3D ']') - p =3D l - 1; - } - } -} - - -static void -renumberItem(virJSONValue *val, - size_t num) -{ - g_autoptr(virJSONValue) label =3D virJSONValueNewString(g_strdup_print= f("libvirt-%zu", num)); - - virJSONValueObjectReplaceValue(val, "id", &label); -} - - -static int -output(virBuffer *buf, - qmpCommandList *list) -{ - size_t commandindex =3D 1; - size_t i; - - for (i =3D 0; i < list->nitems; i++) { - struct qmpTuple *item =3D list->items + i; - g_autofree char *jsoncommand =3D NULL; - g_autofree char *jsonreply =3D NULL; - - if (STREQ_NULLABLE(virJSONValueObjectGetString(item->command, "exe= cute"), "qmp_capabilities")) - commandindex =3D 1; - - /* fix numbering */ - renumberItem(item->command, commandindex); - renumberItem(item->reply, commandindex); - commandindex++; - - /* output formatting */ - if (!(jsoncommand =3D virJSONValueToString(item->command, true)) || - !(jsonreply =3D virJSONValueToString(item->reply, true))) - return -1; - - printLineSkipEmpty(jsoncommand, buf); - virBufferAddLit(buf, "\n"); - printLineSkipEmpty(jsonreply, buf); - virBufferAddLit(buf, "\n"); - } - - virBufferTrim(buf, "\n"); - - return 0; -} - - -static int -testCapsFile(const void *opaque) -{ - const char *repliesFile =3D opaque; - g_autoptr(qmpCommandList) list =3D NULL; - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - - if (!(list =3D loadReplies(repliesFile))) - return -1; - - if (virTestGetRegenerate() > 0) { - if (modify(list) < 0) - return -1; - } - - output(&buf, list); - - if (virTestCompareToFile(virBufferCurrentContent(&buf), repliesFile) <= 0) - return -1; - - return 0; -} - - -static int -iterateCapsFile(const char *inputDir, - const char *prefix, - const char *version, - const char *archName, - const char *variant, - const char *suffix, - void *opaque G_GNUC_UNUSED) -{ - g_autofree char *repliesFile =3D g_strdup_printf("%s/%s_%s_%s%s.%s", - inputDir, prefix, versi= on, - archName, variant, suff= ix); - - return virTestRun(repliesFile, testCapsFile, repliesFile); -} - - -static int -testmain(void) -{ - if (testQemuCapsIterate(".replies", iterateCapsFile, NULL) < 0) - return EXIT_FAILURE; - - return EXIT_SUCCESS; -} - -VIR_TEST_MAIN(testmain) --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org