From nobody Mon Feb 9 16:02:35 2026 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=yadro.com ARC-Seal: i=1; a=rsa-sha256; t=1606169449; cv=none; d=zohomail.com; s=zohoarc; b=htIzYuWmipGCrsxB9ElkdOewdyDNc5Ktw2EKIvk4kr7wQUvBTdXsB0ZGLOrip3KItCqOhItybZthXxggFuhfpgq90shB/u1NlkcYgusoLy167jCP37Rki975ImE00EkTrXE+emiudlC3sOeSpWmxgsrEH/ytRPt9lM4fambYwhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606169449; h=Content-Type:Content-Transfer-Encoding:Cc: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=2V6yhyyYA4bJkAERCxB2CRR8BcesrCQsoVgIraisBKs=; b=Q1QQtisqkB4sa/8kmGJZZaNYIm1j/kYA0ZXnzbc2kX3lBdNM++QYp4tNcLtFmbGc5/CTCQ072L3hGMHY+3eLhL4oLwjZyUOSzmyryFL2xfkGxSBBByPmUpumg6uqv1uOns2bzT7KR5uLxuOaNbcOkQ/E/ESPT2rK4GUfej8f8O8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1606169449123798.9885501787336; Mon, 23 Nov 2020 14:10:49 -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-101-8mA0JQd_PYS_M57topHEOg-1; Mon, 23 Nov 2020 17:10:44 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94143805BE5; Mon, 23 Nov 2020 22:10:36 +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 6EEB560C04; Mon, 23 Nov 2020 22:10:36 +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 05B531809CB7; Mon, 23 Nov 2020 22:10:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ANMAW5G031385 for ; Mon, 23 Nov 2020 17:10:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1359C2026D16; Mon, 23 Nov 2020 22:10:32 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0DEFE2026D13 for ; Mon, 23 Nov 2020 22:10:29 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B369A811E85 for ; Mon, 23 Nov 2020 22:10:29 +0000 (UTC) Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-UxtlJa2XN4eQO4KlZmI9rA-1; Mon, 23 Nov 2020 17:10:27 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 6557F412EB for ; Mon, 23 Nov 2020 22:10:25 +0000 (UTC) Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H6zwjO7MtGos for ; Tue, 24 Nov 2020 01:10:24 +0300 (MSK) Received: from T-EXCH-03.corp.yadro.com (t-exch-03.corp.yadro.com [172.17.100.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id E2C8A412EC for ; Tue, 24 Nov 2020 01:10:21 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-03.corp.yadro.com (172.17.100.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 24 Nov 2020 01:10:21 +0300 X-MC-Unique: 8mA0JQd_PYS_M57topHEOg-1 X-MC-Unique: UxtlJa2XN4eQO4KlZmI9rA-1 X-Virus-Scanned: amavisd-new at yadro.com From: Roman Bolshakov To: Subject: [PATCH v2 2/6] tests: Fix mock chaining on macOS Date: Tue, 24 Nov 2020 01:10:14 +0300 Message-ID: <20201123221018.47896-3-r.bolshakov@yadro.com> In-Reply-To: <20201123221018.47896-1-r.bolshakov@yadro.com> References: <20201123221018.47896-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-03.corp.yadro.com (172.17.100.103) X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 0ANMAW5G031385 X-loop: libvir-list@redhat.com Cc: Roman Bolshakov 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.12 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 Content-Type: text/plain; charset="utf-8" Some tests in qemuxml2argvtest need opendir() from virpcimock, others need opendir() from virfilewrapper. But as of now, only opendir() from virpcimock has an effect. real_opendir in virpcimock has a pointer to opendir$INODE64 in libsystem_kernel.dylib instead of pointing to opendir$INODE64 in qemuxml2argvtest (from virfilewrapper). And because the second one is never used, tests that rely on prefixes added by virFileWrapperAddPrefix fail. That can be fixed if dlsym(3) is asked explicitly to search symbols in main executable with RTLD_MAIN_ONLY before going to other dylibs. Existing RTLD_NEXT handle results into libsystem_kernel.dylib being searched before main executable. Signed-off-by: Roman Bolshakov Reviewed-by: Michal Privoznik --- tests/virmock.h | 13 +++++++++++++ tests/virpcimock.c | 1 + 2 files changed, 14 insertions(+) diff --git a/tests/virmock.h b/tests/virmock.h index dea5feb80f..5250e733a1 100644 --- a/tests/virmock.h +++ b/tests/virmock.h @@ -284,9 +284,21 @@ static void (*real_##name)(void); \ void wrap_##name(void) =20 +#if defined(VIR_MOCK_LOOKUP_MAIN) && defined(__APPLE__) +# define VIR_MOCK_REAL_INIT_MAIN(name, alias) \ + do { \ + if (real_##name =3D=3D NULL) { \ + real_##name =3D dlsym(RTLD_MAIN_ONLY, alias); \ + } \ + } while (0) +#else +# define VIR_MOCK_REAL_INIT_MAIN(name, alias) \ + do {} while (0) +#endif =20 #define VIR_MOCK_REAL_INIT(name) \ do { \ + VIR_MOCK_REAL_INIT_MAIN(name, #name); \ if (real_##name =3D=3D NULL && \ !(real_##name =3D dlsym(RTLD_NEXT, \ #name))) { \ @@ -297,6 +309,7 @@ =20 #define VIR_MOCK_REAL_INIT_ALIASED(name, alias) \ do { \ + VIR_MOCK_REAL_INIT_MAIN(name, alias); \ if (real_##name =3D=3D NULL && \ !(real_##name =3D dlsym(RTLD_NEXT, \ alias))) { \ diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 686f894e99..4aa96cae08 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -19,6 +19,7 @@ #include =20 #if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) +# define VIR_MOCK_LOOKUP_MAIN # include "virmock.h" # include # include --=20 2.29.2