From nobody Sun Feb 8 08:36:49 2026 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=1669801712; cv=none; d=zohomail.com; s=zohoarc; b=jF5o9nUGkIj91lP2/oDR+OrTuQqhzCVIKaChbjF8exGi4VcILNDIpd5EUPAA/pIMD0OHr6i1x95SgKS+tmT1oIMKV21+o4gmfSHixEmV2EV5GoU/jqr+91okjrDN4c6S3Qp00KLNQDhLeR5G/W05IygLrB0T+/LZns7tUAwXISU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801712; 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=yNXSrwuULZodtSjaJuqJ6rHa6EvZU7VqM7y8OpqeQcw=; b=lNN2HesZ8SlX/AVNm13iO763IzIjWfyrxj8jg36Ve/S2VHjMhJBVOl31y+ivymGXP0uFaQh+fHzX7GlExPH0zGRum9daNHG5dN1HKTYOSqe2J67j9/s6hXwb5tqHroaoUbUZ4qxE3NO01FsfWMO/LC82qf1R+vbhRF+DqbU+mzQ= 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 1669801712416139.17281621149925; Wed, 30 Nov 2022 01:48:32 -0800 (PST) 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-314-ui1wV_jrMRKdDPOWDaKr1g-1; Wed, 30 Nov 2022 04:48:22 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F34933C0DDB8; Wed, 30 Nov 2022 09:48:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD4584B3FCE; Wed, 30 Nov 2022 09:48:19 +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 D1D8819465A0; Wed, 30 Nov 2022 09:48:19 +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 CEFA219465A0 for ; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C23264B3FCE; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 679DA4B3FC8 for ; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801711; 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=yNXSrwuULZodtSjaJuqJ6rHa6EvZU7VqM7y8OpqeQcw=; b=buHowGmDuWY6GXSfmNG77nmfZzRv31oQNVn8r+FC41TOC+qrMuoD1/S5PZxxa8mulWDiQS csX/FHrZ6RezUeg4aIFkklNqoSzM7aO6HgBHoS3+OgZCuCzyDOBKm9dpyAurlPziv+tT95 57NBCp+msAG4FBcM+0+HXh4jV61OIUY= X-MC-Unique: ui1wV_jrMRKdDPOWDaKr1g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 6/9] commandtest: Use virTestCompareToFile() in checkoutput() Date: Wed, 30 Nov 2022 10:48:08 +0100 Message-Id: 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.9 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: 1669801712807100007 Content-Type: text/plain; charset="utf-8"; x-default="true" In the commandtest there is checkoutput() function which checks the latest log of commandhelper (containing things like cmd line arguments, env vars, FDs, CWD, etc.) and compares that against expected output. Well, the way this function implements that is effectively by open coding virTestCompareToFile() except for the nice feature that the virTestCompareToFile() has: VIR_TEST_OUTPUT_REGENERATE. Signed-off-by: Michal Privoznik --- tests/commandtest.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index 6d45ff196f..ffc4b24ef4 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -58,29 +58,18 @@ static int checkoutput(const char *testname) { int ret =3D -1; g_autofree char *expectname =3D NULL; - g_autofree char *expectlog =3D NULL; g_autofree char *actualname =3D NULL; g_autofree char *actuallog =3D NULL; =20 expectname =3D g_strdup_printf("%s/commanddata/%s.log", abs_srcdir, te= stname); actualname =3D g_strdup_printf("%s/commandhelper.log", abs_builddir); =20 - if (virFileReadAll(expectname, 1024*64, &expectlog) < 0) { - fprintf(stderr, "cannot read %s\n", expectname); - goto cleanup; - } - if (virFileReadAll(actualname, 1024*64, &actuallog) < 0) { fprintf(stderr, "cannot read %s\n", actualname); goto cleanup; } =20 - if (STRNEQ(expectlog, actuallog)) { - virTestDifference(stderr, expectlog, actuallog); - goto cleanup; - } - - ret =3D 0; + ret =3D virTestCompareToFile(actuallog, expectname); =20 cleanup: if (actualname) @@ -1292,6 +1281,7 @@ mymain(void) * since we're about to reset 'environ' */ ignore_value(virTestGetDebug()); ignore_value(virTestGetVerbose()); + ignore_value(virTestGetRegenerate()); =20 /* Make sure to not leak fd's */ virinitret =3D virInitialize(); --=20 2.37.4