From nobody Sun Dec 22 02:06:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685027808; cv=none; d=zohomail.com; s=zohoarc; b=QTWHhSeDvoLqQiZK6rSDFrvKrnRXJLgRpgG8NhdbSIWYvw23X422YPn+NaAuJrRQ3kx43xp2YO4Ohna+Y9zrYifdy+ib/sCW63QfJHzvAnPMdaPJ+VWwBPJQjZpaCf7bePUsW5L9shGwWNWLErMbLEq77ZTzYsY8+ihIcO+Afpw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685027808; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1JunrW9ZUDrTXktiVo4hqN8qhElfPn8MqFs3Q1n4Y5s=; b=HUN4P1hOBP/ICVrSmDbVPBf6ohDbuGZlWRfXH0Ev1V0Q/7QJgR1rrea8wjxhYNJjSgyg+55yCtImyi79+l4izOA7Jk8BQ4C1IIMipzW2GLcLwh7HnUWqZ2gBFV15yuZb0dkf2lomMFTwCjU2o5fhVOe8Bb91FfVJ//5dKuCDGXA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1685027808119476.7324511381131; Thu, 25 May 2023 08:16:48 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-190-BdCHp4bKPYaZ97O6cs-BNw-1; Thu, 25 May 2023 11:16:43 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED6B13C0D19F; Thu, 25 May 2023 15:16:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C96C5C0004B; Thu, 25 May 2023 15:16:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CDF0819451C2; Thu, 25 May 2023 15:16:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 06C4819465BD for ; Thu, 25 May 2023 15:14:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9509340D1C0; Thu, 25 May 2023 15:13:56 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DABB40F6A5 for ; Thu, 25 May 2023 15:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685027805; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1JunrW9ZUDrTXktiVo4hqN8qhElfPn8MqFs3Q1n4Y5s=; b=XGO3sO89GEwlFKLwbg1p9BerkfKCwrnd376J8JnD0jasGAnl1TbPm5Lxzq1JNJw7m/uASc TK8lkyaW4FuMte0oA0efyOtvmid/xKTtXnj1q/VFzSZMG6FqgMlkDPLHdRIe/+i+A2TwJy vKla7nou+Co+LxP0FWkeusBfiWBhKBM= X-MC-Unique: BdCHp4bKPYaZ97O6cs-BNw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/18] Drop unused qemuMonitorTestAddItemParams Date: Thu, 25 May 2023 17:13:38 +0200 Message-Id: <8a844bd526b0bf06dc308c1a56fdbe9c82215cf6.1685027511.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685027808590100001 Content-Type: text/plain; charset="utf-8" Using qemuMonitorTestAddItemVerbatim is more universal and that helper also does QMP schema validation. Remove the now unused helper. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitortestutils.c | 132 ----------------------------------- tests/qemumonitortestutils.h | 7 -- 2 files changed, 139 deletions(-) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 9e6da78a8b..8b8b02a790 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -469,19 +469,10 @@ qemuMonitorTestItemGetPrivateData(qemuMonitorTestItem= *item) } -typedef struct _qemuMonitorTestCommandArgs qemuMonitorTestCommandArgs; -struct _qemuMonitorTestCommandArgs { - char *argname; - char *argval; -}; - - struct qemuMonitorTestHandlerData { char *command_name; char *cmderr; char *response; - size_t nargs; - qemuMonitorTestCommandArgs *args; char *expectArgs; }; @@ -489,20 +480,13 @@ static void qemuMonitorTestHandlerDataFree(void *opaque) { struct qemuMonitorTestHandlerData *data =3D opaque; - size_t i; if (!data) return; - for (i =3D 0; i < data->nargs; i++) { - g_free(data->args[i].argname); - g_free(data->args[i].argval); - } - g_free(data->command_name); g_free(data->cmderr); g_free(data->response); - g_free(data->args); g_free(data->expectArgs); g_free(data); } @@ -743,122 +727,6 @@ qemuMonitorTestAddAgentSyncResponse(qemuMonitorTest *= test) } -static int -qemuMonitorTestProcessCommandWithArgs(qemuMonitorTest *test, - qemuMonitorTestItem *item, - const char *cmdstr) -{ - struct qemuMonitorTestHandlerData *data =3D item->opaque; - g_autoptr(virJSONValue) val =3D NULL; - virJSONValue *args; - virJSONValue *argobj; - const char *cmdname; - size_t i; - - if (!(val =3D virJSONValueFromString(cmdstr))) - return -1; - - if (!(cmdname =3D virJSONValueObjectGetString(val, "execute"))) { - qemuMonitorTestError("Missing command name in %s", cmdstr); - return -1; - } - - if (data->command_name && - STRNEQ(data->command_name, cmdname)) { - qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname); - return -1; - } - - if (!(args =3D virJSONValueObjectGet(val, "arguments"))) { - qemuMonitorTestError("Missing arguments section for command '%s'", - NULLSTR(data->command_name)); - return -1; - } - - /* validate the args */ - for (i =3D 0; i < data->nargs; i++) { - qemuMonitorTestCommandArgs *arg =3D &data->args[i]; - g_autofree char *argstr =3D NULL; - - if (!(argobj =3D virJSONValueObjectGet(args, arg->argname))) { - qemuMonitorTestError("Missing argument '%s' for command '%s'", - arg->argname, - NULLSTR(data->command_name)); - return -1; - } - - /* convert the argument to string */ - if (!(argstr =3D virJSONValueToString(argobj, false))) - return -1; - - /* verify that the argument value is expected */ - if (STRNEQ(argstr, arg->argval)) { - qemuMonitorTestError("Invalid value of argument '%s' of comman= d '%s': " - "expected '%s' got '%s'", - arg->argname, - NULLSTR(data->command_name), - arg->argval, argstr); - return -1; - } - } - - /* arguments checked out, return the response */ - return qemuMonitorTestAddResponse(test, data->response); -} - - - -/* this allows to add a responder that is able to check - * a (shallow) structure of arguments for a command */ -int -qemuMonitorTestAddItemParams(qemuMonitorTest *test, - const char *cmdname, - const char *response, - ...) -{ - struct qemuMonitorTestHandlerData *data; - const char *argname; - const char *argval; - va_list args; - - va_start(args, response); - - data =3D g_new0(struct qemuMonitorTestHandlerData, 1); - - data->command_name =3D g_strdup(cmdname); - data->response =3D g_strdup(response); - - while ((argname =3D va_arg(args, char *))) { - size_t i; - if (!(argval =3D va_arg(args, char *))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "Missing argument value for argument '%s'", - argname); - goto error; - } - - i =3D data->nargs; - VIR_EXPAND_N(data->args, data->nargs, 1); - data->args[i].argname =3D g_strdup(argname); - data->args[i].argval =3D g_strdup(argval); - } - - va_end(args); - - qemuMonitorTestAddHandler(test, - cmdname, - qemuMonitorTestProcessCommandWithArgs, - data, qemuMonitorTestHandlerDataFree); - - return 0; - - error: - va_end(args); - qemuMonitorTestHandlerDataFree(data); - return -1; -} - - static void qemuMonitorTestEOFNotify(qemuMonitor *mon G_GNUC_UNUSED, virDomainObj *vm G_GNUC_UNUSED) diff --git a/tests/qemumonitortestutils.h b/tests/qemumonitortestutils.h index 5de55172be..eddd8294bb 100644 --- a/tests/qemumonitortestutils.h +++ b/tests/qemumonitortestutils.h @@ -74,13 +74,6 @@ qemuMonitorTestAddItemVerbatim(qemuMonitorTest *test, int qemuMonitorTestAddAgentSyncResponse(qemuMonitorTest *test); -int -qemuMonitorTestAddItemParams(qemuMonitorTest *test, - const char *cmdname, - const char *response, - ...) - G_GNUC_NULL_TERMINATED; - #define qemuMonitorTestNewSimple(xmlopt) \ qemuMonitorTestNew(xmlopt, NULL, NULL, NULL) #define qemuMonitorTestNewSchema(xmlopt, schema) \ --=20 2.40.1