From nobody Thu Jan 2 14:41:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1685027821; cv=none; d=zohomail.com; s=zohoarc; b=P+yGkl8W41LkePBGMhsUrQkY0xB2JuykXbip2Ifox/4s16gdpUcR7D3kwASrQ2tK+OSxTXWjmlj3ydMBdbMjZkBCUUphdpExijEIwbN2qUZVwWXZucynVZQkBa/TKQbY/xfyXXt3To3Ux3y+zvXPHI+1FYQAMnsmcvRALODtr9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685027821; 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=K9DETZEAlSf6ChDSHRfpZAtLhGfTWsWFv49ZlmPatB8=; b=HooUC8WAsUkjUqXmyinmDMjxwhse8YMMHvDnm2XM0Dyu0+ae0oXheb1JzDlCzXzENar7gG/BoK+vwWjeddb/5LTZy1+0QTO/QoebjeT97JRxgVnsbVUE0t3SbRW3zfIvEZ2Kd6L5Pc0bJBot+CGzR0q16k3mQE9kuct3nE98xrw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1685027821102353.3155745967765; Thu, 25 May 2023 08:17:01 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-473-CITaJi3dPyy8R-iH1zzouw-1; Thu, 25 May 2023 11:16:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 59B99101B057; Thu, 25 May 2023 15:16:25 +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 46B0C40C6CCF; Thu, 25 May 2023 15:16:25 +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 14D5319465A4; 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 D09D119465B6 for ; Thu, 25 May 2023 15:13:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C2656401026; Thu, 25 May 2023 15:13:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48D4741F2CC for ; Thu, 25 May 2023 15:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685027820; 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=K9DETZEAlSf6ChDSHRfpZAtLhGfTWsWFv49ZlmPatB8=; b=TR3HaEZmyn0/hUOI/4pvmRVHgbh22DpRw8w44vRSZjavPnvHAmYpz8GIVce5GL3vULUfb9 H2S6TLTs7upK4DvffOGOnoDdhlOByc9supxVaF/q9RoD/v82bEFAcxEf2rkXvUXm0acCID RJ1cnV9/F7T6JBPf4hIvQ5npB6cxEbU= X-MC-Unique: CITaJi3dPyy8R-iH1zzouw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/18] testQemuMonitorJSONAttachChardev: Move all setup code under virTestRun Date: Thu, 25 May 2023 17:13:31 +0200 Message-Id: <87b940f85ef50a7e3711efa536ae867cc72abed6.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.2 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: 1685027822765100001 Content-Type: text/plain; charset="utf-8" Any failure which happens outside is hard to debug as errors will be reset and not raised. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 60 ++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 1db1f2b949..3dabd5c00d 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -596,19 +596,35 @@ testQemuMonitorJSONGetTPMModels(const void *opaque) struct qemuMonitorJSONTestAttachChardevData { - qemuMonitorTest *test; virDomainChrSourceDef *chr; const char *expectPty; bool fail; + + virDomainXMLOption *xmlopt; + GHashTable *schema; + const char *expectargs; + const char *reply; }; static int testQemuMonitorJSONAttachChardev(const void *opaque) { const struct qemuMonitorJSONTestAttachChardevData *data =3D opaque; + g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewSchema(data->xml= opt, data->schema); int rc; - if ((rc =3D qemuMonitorAttachCharDev(qemuMonitorTestGetMonitor(data->t= est), + if (!test) + return -1; + + if (data->expectargs) { + g_autofree char *jsonreply =3D g_strdup_printf("{\"return\": {%s}}= ", NULLSTR_EMPTY(data->reply)); + + if (qemuMonitorTestAddItemExpect(test, "chardev-add", + data->expectargs, true, jsonreply= ) < 0) + return -1; + } + + if ((rc =3D qemuMonitorAttachCharDev(qemuMonitorTestGetMonitor(test), "alias", data->chr)) < 0) goto cleanup; @@ -643,37 +659,19 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOptio= n *xmlopt, bool fail) { - struct qemuMonitorJSONTestAttachChardevData data =3D {0}; - g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewSchema(xmlopt, s= chema); - g_autofree char *jsonreply =3D NULL; - g_autofree char *fulllabel =3D NULL; - - if (!test) - return -1; - - if (!reply) - reply =3D ""; - - jsonreply =3D g_strdup_printf("{\"return\": {%s}}", reply); - - fulllabel =3D g_strdup_printf("qemuMonitorJSONTestAttachChardev(%s)", = label); - - if (expectargs && - qemuMonitorTestAddItemExpect(test, "chardev-add", - expectargs, true, jsonreply) < 0) - return -1; - - data.chr =3D chr; - data.fail =3D fail; - data.expectPty =3D expectPty; - data.test =3D test; - - if (virTestRun(fulllabel, &testQemuMonitorJSONAttachChardev, &data) < = 0) - return -1; - - return 0; + struct qemuMonitorJSONTestAttachChardevData data =3D { .chr =3D chr, + .fail =3D fail, + .expectPty =3D ex= pectPty, + .expectargs =3D e= xpectargs, + .reply =3D reply, + .xmlopt =3D xmlop= t, + .schema =3D schem= a }; + g_autofree char *fulllabel =3D g_strdup_printf("qemuMonitorJSONTestAtt= achChardev(%s)", label); + + return virTestRun(fulllabel, &testQemuMonitorJSONAttachChardev, &data); } + static int qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xmlopt, GHashTable *schema) --=20 2.40.1