From nobody Mon May 6 06:14:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562347371; cv=none; d=zoho.com; s=zohoarc; b=Gi4jSpcYqmDuCeBG4n+20adDAckFF2lKdULWvZMgNgnFog35uBXiBWSNxlaZs9qntU0cprEoTbOy6fph1yk6BCKo/mCLVROX/eok55Qt8E+xpy3KT9117QsgnmPlC13tCxYcZ5aQV9N+r49FrbPue15mJb7qVFvISHghXEAzcbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562347371; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=AzNV4lQH5bxLd+o7VremhEXm6PlNbI851JOSNqXh0Fk=; b=mxDIhS9V4LG9h3UP9JbHYZAHuejb24vW/Ii//x596LYoyx8AqA+YgXu2kJOegfcIPKVLs9gkJ9MvPebIxm8XnE/OnYnNtfcyfIRBTbiuOPJ8a7UfUYnxykqnkmXmDolZM/XtGkveGhyhMPWqfgYEp62eSsN1mca9XpAiTbCSk8I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562347371025780.2898026333306; Fri, 5 Jul 2019 10:22:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B53053082134; Fri, 5 Jul 2019 17:22:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D527060BEE; Fri, 5 Jul 2019 17:22:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0FF811818485; Fri, 5 Jul 2019 17:22:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x65HLwaY010242 for ; Fri, 5 Jul 2019 13:21:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id A25B51001B2B; Fri, 5 Jul 2019 17:21:58 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-48.ams2.redhat.com [10.36.112.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id CACA81001B18; Fri, 5 Jul 2019 17:21:55 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 5 Jul 2019 18:21:52 +0100 Message-Id: <20190705172152.32248-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tests: fix mocking of virFileGetXAttrQuiet on FreeBSD X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 05 Jul 2019 17:22:48 +0000 (UTC) The qemusecuritytest is failing on FreeBSD 11/12, reporting that files are not correctly restored. Debugging code printfs show that the virFileGetXAttrQuiet mock is returning 0, but the virFileGetXAttr function is seeing -1 as the return value. Essentially there appears to be some kind of optimization between the real virFileGetXAttrQuiet and the real virFileGetXAttr, which breaks when we mock virFileGetXAttrQuiet. Rather than trying to figure out how to avoid this, it is simpler to just mock virFileGetXAttr too since it is very short code. Signed-off-by: Daniel P. Berrang=C3=A9 --- Pushed as a CI build fix tests/qemusecuritymock.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c index 2a9095e1bf..a15eef29c9 100644 --- a/tests/qemusecuritymock.c +++ b/tests/qemusecuritymock.c @@ -156,6 +156,34 @@ virFileGetXAttrQuiet(const char *path, } =20 =20 +/* + * This may look redundant but is needed to work around an + * compiler quirk. The call from the real virFileGetXAttr + * to the real virFileGetXAttrQuiet has a quirk where the + * return value from virFileGetXAttrQuiet gets scrambled + * if we mock virFileGetXAttrQuiet, returning -1 instead + * of 0 despite succeeding. This happens on FreeBSD 11/12 + * hosts with CLang, and is suspected to be some kind of + * compiler optimization. By mocking this function too we + * can workaround it. + */ +int +virFileGetXAttr(const char *path, + const char *name, + char **value) +{ + int ret; + + if ((ret =3D virFileGetXAttrQuiet(path, name, value)) < 0) { + virReportSystemError(errno, + "Unable to get XATTR %s on %s", + name, path); + } + + return ret; +} + + int virFileSetXAttr(const char *path, const char *name, const char *value) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list