From nobody Sun May 5 18:57:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612432476; cv=none; d=zohomail.com; s=zohoarc; b=QeBgEGIUOxtlxBtKNTJFJQRBLp+hFQgxrOKHfij60p//8n9FS+W5fJ7px0h1hBzvdyoLSt2nwZPZgLUMJ+NKfvrmBCt++EYC2r86T+vgtkgkau2UBlIcJF4WkJq9rkMxXdaSioJ3br4ylsWMtiBCJtElOAzJ+1R3WbXCz+hsCXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612432476; 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=fm30gCbKNQEeiAxykaEVgVwiFVrz5PJW+sfunSCoF3I=; b=BSjFB7GJZO8IAkDfHzRm/FUnpiWRSYw73eE6gIby3+Zq1gV5PYvUdhXnxEVuPm1S4uLFHtB77j412LRNQSp5MaAbbj5aIGPxmqFSiC19HiZ3j/nMfEe2nNWk+Ntft1MXziyyoCjAG9LAOrj+Ga2YasUR8LWFgYIQi8JfCPr1KUI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612432476580634.8477258524141; Thu, 4 Feb 2021 01:54:36 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-508-f12LSXwoNFa_La478NogNA-1; Thu, 04 Feb 2021 04:54:33 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72963100CCC4; Thu, 4 Feb 2021 09:54:27 +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 216C577BF5; Thu, 4 Feb 2021 09:54:27 +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 B71AC18095CE; Thu, 4 Feb 2021 09:54:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1149s6ha026498 for ; Thu, 4 Feb 2021 04:54:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 058EB131EF; Thu, 4 Feb 2021 09:54:06 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.192.200]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1FDA8194A4 for ; Thu, 4 Feb 2021 09:54:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612432475; 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=fm30gCbKNQEeiAxykaEVgVwiFVrz5PJW+sfunSCoF3I=; b=RCRqLbkbzYs/HWeY1R4RTQoj7EOb1OXx53HU6Mnsk2EccnykTwCo9FtkJHN7/4wF5ANQ9w IhYRQFVXgTvn2Hsqz5A/vMvs6G8sLpeVb+mqFX+6KgikkU99iOc9FIMNidEV/JGAoq+knZ +nsLr7vbkU0sqUL4RRHoDQVSY51kokI= X-MC-Unique: f12LSXwoNFa_La478NogNA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] tests: Split macOS stat() mocking logic Date: Thu, 4 Feb 2021 10:53:55 +0100 Message-Id: <20210204095356.160505-2-abologna@redhat.com> In-Reply-To: <20210204095356.160505-1-abologna@redhat.com> References: <20210204095356.160505-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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) Content-Type: text/plain; charset="utf-8" On macOS, most of the symbols and declarations that we look at to determine which versions of stat() we need to mock are not present; on the other hand, there are some specific wrinkles that are introduced with Apple Silicon which we will need to take care of. To avoid making the logic even more of an opaque mess than it currently is, move the macOS part to a separate branch. This commit is better viewed with 'git show -w'. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virmockstathelpers.c | 73 ++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/tests/virmockstathelpers.c b/tests/virmockstathelpers.c index 3bd2437ffe..97f628368d 100644 --- a/tests/virmockstathelpers.c +++ b/tests/virmockstathelpers.c @@ -74,42 +74,47 @@ * The same all applies to lstat() */ =20 - -#if !defined(WITH___XSTAT_DECL) -# if defined(WITH_STAT) -# if !defined(WITH___XSTAT) && !defined(WITH_STAT64) || defined(__APPLE__) -# define MOCK_STAT +#if !defined(__APPLE__) +# if !defined(WITH___XSTAT_DECL) +# if defined(WITH_STAT) +# if !defined(WITH___XSTAT) && !defined(WITH_STAT64) +# define MOCK_STAT +# endif # endif -# endif -# if defined(WITH_STAT64) -# define MOCK_STAT64 -# endif -#else /* WITH___XSTAT_DECL */ -# if defined(WITH___XSTAT) && !defined(WITH___XSTAT64) -# define MOCK___XSTAT -# endif -# if defined(WITH___XSTAT64) -# define MOCK___XSTAT64 -# endif -#endif /* WITH___XSTAT_DECL */ - -#if !defined(WITH___LXSTAT_DECL) -# if defined(WITH_LSTAT) -# if !defined(WITH___LXSTAT) && !defined(WITH_LSTAT64) || defined(__APPLE= __) -# define MOCK_LSTAT +# if defined(WITH_STAT64) +# define MOCK_STAT64 # endif -# endif -# if defined(WITH_LSTAT64) -# define MOCK_LSTAT64 -# endif -#else /* WITH___LXSTAT_DECL */ -# if defined(WITH___LXSTAT) && !defined(WITH___LXSTAT64) -# define MOCK___LXSTAT -# endif -# if defined(WITH___LXSTAT64) -# define MOCK___LXSTAT64 -# endif -#endif /* WITH___LXSTAT_DECL */ +# else /* WITH___XSTAT_DECL */ +# if defined(WITH___XSTAT) && !defined(WITH___XSTAT64) +# define MOCK___XSTAT +# endif +# if defined(WITH___XSTAT64) +# define MOCK___XSTAT64 +# endif +# endif /* WITH___XSTAT_DECL */ +# if !defined(WITH___LXSTAT_DECL) +# if defined(WITH_LSTAT) +# if !defined(WITH___LXSTAT) && !defined(WITH_LSTAT64) +# define MOCK_LSTAT +# endif +# endif +# if defined(WITH_LSTAT64) +# define MOCK_LSTAT64 +# endif +# else /* WITH___LXSTAT_DECL */ +# if defined(WITH___LXSTAT) && !defined(WITH___LXSTAT64) +# define MOCK___LXSTAT +# endif +# if defined(WITH___LXSTAT64) +# define MOCK___LXSTAT64 +# endif +# endif /* WITH___LXSTAT_DECL */ +#else /* __APPLE__ */ +# define MOCK_STAT +# define MOCK_STAT64 +# define MOCK_LSTAT +# define MOCK_LSTAT64 +#endif =20 #ifdef MOCK_STAT static int (*real_stat)(const char *path, struct stat *sb); --=20 2.26.2 From nobody Sun May 5 18:57:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612432506; cv=none; d=zohomail.com; s=zohoarc; b=JhGSPzksat5i81E0hkmYEIxfKS6j9IrH39rT6DRn7yfZC7jgmnwE7BZ1NJJqTZeBlHglzIge4OzV8XmWwhLFeMDh+ib3offvpb/JJfVwo5wFV8jNKxI6KqtOolGqdJs1WATlidQR3KL9zMohv1iNlLCgC14PFa0zc9D+RqpUZ4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612432506; 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=6od0H9Tri6kPdrt5yXf5oi4CAD7PA0mvRdvpJMkdmzw=; b=ciqK8Q+2w5529z0RqA6ymn9tvsx+TqBHXKvKgbi1uVrvhcBcf8j1NC9ra3R1gdwLapuhYskKJI0lyL5yyZUQhtQiiy9i9OQrHIAXui5RLsUbbUDEpDj/bTcVtFlEb5mfIQjH1qpqaY63DLDFJav+oS3mVDx0JSeFJo8MPk3uwWk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612432506574616.4460122423924; Thu, 4 Feb 2021 01:55:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-602-jM3v87MsPVC8T3UQF8tVGA-1; Thu, 04 Feb 2021 04:54:40 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0240B801960; Thu, 4 Feb 2021 09:54:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99FFA10016F9; Thu, 4 Feb 2021 09:54:33 +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 60BB958074; Thu, 4 Feb 2021 09:54:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1149s7Wa026508 for ; Thu, 4 Feb 2021 04:54:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 32524131EF; Thu, 4 Feb 2021 09:54:07 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.192.200]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A22618E4F for ; Thu, 4 Feb 2021 09:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612432505; 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=6od0H9Tri6kPdrt5yXf5oi4CAD7PA0mvRdvpJMkdmzw=; b=gbyqkzGpz9d/BXc1BaSy5ACeXwKuUMCbncRxrto3bT2u6BmxqJqMFR5C/zmnoOXu88nDCH VBaQy7YMoproXOf7kl6R0kdmSOECxinjpTgXMbtb4+BIr8i79C5VsUfoCA66ltP+J+5H+O cogWG2s6j98IH2r6gLNg3thrJASQKEc= X-MC-Unique: jM3v87MsPVC8T3UQF8tVGA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] tests: Improve macOS stat() mocking logic Date: Thu, 4 Feb 2021 10:53:56 +0100 Message-Id: <20210204095356.160505-3-abologna@redhat.com> In-Reply-To: <20210204095356.160505-1-abologna@redhat.com> References: <20210204095356.160505-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) Content-Type: text/plain; charset="utf-8" We should not mock stat64() when building on Apple Silicon, because the declaration is not present in the header file. Detect this situation and handle it gracefully. https://gitlab.com/libvirt/libvirt/-/issues/121 Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virmockstathelpers.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/virmockstathelpers.c b/tests/virmockstathelpers.c index 97f628368d..830dfe1085 100644 --- a/tests/virmockstathelpers.c +++ b/tests/virmockstathelpers.c @@ -57,7 +57,9 @@ * * On macOS stat() and lstat() are resolved to _stat$INODE64 and * _lstat$INODE64, respectively. stat(2) man page also declares that - * stat64(), lstat64() and fstat64() are deprecated. + * stat64(), lstat64() and fstat64() are deprecated, and when + * building on Apple Silicon (aarch64) those functions are missing + * from the header altogether and should not be mocked. * * With all this in mind the list of functions we have to mock will depend * on several factors @@ -111,9 +113,13 @@ # endif /* WITH___LXSTAT_DECL */ #else /* __APPLE__ */ # define MOCK_STAT -# define MOCK_STAT64 +# if defined(WITH_STAT64_DECL) +# define MOCK_STAT64 +# endif # define MOCK_LSTAT -# define MOCK_LSTAT64 +# if defined(WITH_LSTAT64_DECL) +# define MOCK_LSTAT64 +# endif #endif =20 #ifdef MOCK_STAT --=20 2.26.2