From nobody Mon Feb 9 18:19:47 2026 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=1647964985; cv=none; d=zohomail.com; s=zohoarc; b=RvDb7n7RAcRz/bjiS2rMigJp0OZJO6kRbdPQprajBZPBbbgbhwojGm/MEGdO/Ds0rCbF1A3tm5UAs4ooPEEMxSmOCm7hhXNiG0RrElaP5b1qOAVuntkYzSFeyv9JBmpJRKSmcS8KSvZuKJoHIdX9JernY1gXKmYiZT1B6kVjWKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647964985; 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=FCJFovmdkLsoE5Vh9+AdDvNI+m4I+PFdtfZQZdkSd/k=; b=Hm7ucEQtVLs7tcettrIyScGg654A+hBNHjjjHiYRXw1qiF2An62EE4dyCB42LRE987lsEe+B8Ze2axBPz3/xLebVuQ+7aDEwWDcKzKegYZ+EMaDIxBHaacrpLWQ3hw/l6IMJL6D8Exy9i09d5pzHLkBmtI6xvWcpsceXCh0DlrA= 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 1647964985907848.0191419424348; Tue, 22 Mar 2022 09:03:05 -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-453-Qb3ByHPQNj674DMpBwlc5Q-1; Tue, 22 Mar 2022 12:02:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 47D4A805900; Tue, 22 Mar 2022 16:02: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 1BC6540CF918; Tue, 22 Mar 2022 16:02: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 400941940364; Tue, 22 Mar 2022 16:02:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A6D70193F6ED for ; Tue, 22 Mar 2022 16:02:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 869CCC27EA0; Tue, 22 Mar 2022 16:02:15 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DE3FC23DC3 for ; Tue, 22 Mar 2022 16:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647964984; 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=FCJFovmdkLsoE5Vh9+AdDvNI+m4I+PFdtfZQZdkSd/k=; b=QcATDcnpwGljbz+qHgMa65iN/NfYGo7xBAm1KRrpMy2OTHbi7aY+lL98V00WdpF+epqgzv EQ13LXKIwGIpRSrudDn6X6YwEi//OF3rfz3KN+G6sWu75wwf8p+DeMhnUB4IDq1DDso4/t wo7m2aM3mK08XRCDaiNvpihDAVBs2C0= X-MC-Unique: Qb3ByHPQNj674DMpBwlc5Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 7/7] commandtest: Use virTestCompareToFile() in checkoutput() Date: Tue, 22 Mar 2022 17:02:06 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1647964987843100001 Content-Type: text/plain; charset="utf-8" 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 573a4f250d..60daf6e48f 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -60,29 +60,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) @@ -1281,6 +1270,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.34.1