From nobody Mon Nov 25 11:47:01 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; 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=1604870732; cv=none; d=zohomail.com; s=zohoarc; b=cbXp/HuQMbv6YCYXfMim3B153NsdPf6ToQyAYnlUjtPlATbvtyR+xwSSDpeiXwzHdbe52s+igRHHIxsNfCszynnRGb0YxqI1ZAk+1ip6CbSHuz2vXmQBz9gL2eR73qe3o5Gue7e2Ma6clF9WqTE1jS9mjs6CvpTHCu89mPnMusM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604870732; 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=JkJlzl60ZUDSb/HFCB4zzN6JyB2v2E/7IaK9UYZrO4c=; b=UUQlRq0UPJcw3m0SaHCAmtqiPOPhcfgwXLHlApggBbMbhs6sxQ89yhBpL2OGbBkWSLypbs0WE2gWmZ8E7uAtMCmPOyW6z3zhrDhQ6ov7R+OYK1CourdHwQmHOs6LweX5q2igtHOlKUS+jgeTLYzytfUribe6KOxQnsX2ctrmfy0= 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 1604870732892455.5050153443756; Sun, 8 Nov 2020 13:25:32 -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-147-ZJkkPk-FP22v-Z9aVUzItQ-1; Sun, 08 Nov 2020 16:25:29 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 126C3186840C; Sun, 8 Nov 2020 21:25:24 +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 E70D075121; Sun, 8 Nov 2020 21:25:23 +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 B81B4922F7; Sun, 8 Nov 2020 21:25:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A8LOjXr018086 for ; Sun, 8 Nov 2020 16:24:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id CF24844010; Sun, 8 Nov 2020 21:24:45 +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 C81954401F for ; Sun, 8 Nov 2020 21:24:43 +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 4FB8E811E78 for ; Sun, 8 Nov 2020 21:24:43 +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-163-DvOnDpB8NgGdEZNBXs0qeA-1; Sun, 08 Nov 2020 16:24:40 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 6B93A41301 for ; Sun, 8 Nov 2020 21:24:38 +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 oHbunBiYMQSk for ; Mon, 9 Nov 2020 00:24:37 +0300 (MSK) Received: from T-EXCH-04.corp.yadro.com (t-exch-04.corp.yadro.com [172.17.100.104]) (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 608F8412D9 for ; Mon, 9 Nov 2020 00:24:37 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-04.corp.yadro.com (172.17.100.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Mon, 9 Nov 2020 00:24:36 +0300 X-MC-Unique: ZJkkPk-FP22v-Z9aVUzItQ-1 X-MC-Unique: DvOnDpB8NgGdEZNBXs0qeA-1 X-Virus-Scanned: amavisd-new at yadro.com From: Roman Bolshakov To: Subject: [PATCH 2/4] tests: Fix mock chaining on macOS Date: Mon, 9 Nov 2020 00:24:29 +0300 Message-ID: <20201108212431.81896-3-r.bolshakov@yadro.com> In-Reply-To: <20201108212431.81896-1-r.bolshakov@yadro.com> References: <20201108212431.81896-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-04.corp.yadro.com (172.17.100.104) 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.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 0A8LOjXr018086 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.15 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 --- tests/virmock.h | 37 +++++++++++++++++++++++++++++++++++-- tests/virpcimock.c | 1 + 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/tests/virmock.h b/tests/virmock.h index dea5feb80f..db051f3636 100644 --- a/tests/virmock.h +++ b/tests/virmock.h @@ -284,8 +284,19 @@ static void (*real_##name)(void); \ void wrap_##name(void) =20 +#ifdef __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) \ +#define VIR_MOCK_REAL_INIT_NEXT(name) \ do { \ if (real_##name =3D=3D NULL && \ !(real_##name =3D dlsym(RTLD_NEXT, \ @@ -295,7 +306,7 @@ } \ } while (0) =20 -#define VIR_MOCK_REAL_INIT_ALIASED(name, alias) \ +#define VIR_MOCK_REAL_INIT_ALIASED_NEXT(name, alias) \ do { \ if (real_##name =3D=3D NULL && \ !(real_##name =3D dlsym(RTLD_NEXT, \ @@ -304,3 +315,25 @@ abort(); \ } \ } while (0) + +#ifdef VIR_MOCK_LOOKUP_MAIN +# define VIR_MOCK_REAL_INIT(name) \ + do { \ + VIR_MOCK_REAL_INIT_MAIN(name, #name); \ + VIR_MOCK_REAL_INIT_NEXT(name); \ + } while (0) +# define VIR_MOCK_REAL_INIT_ALIASED(name, alias) \ + do { \ + VIR_MOCK_REAL_INIT_MAIN(name, alias); \ + VIR_MOCK_REAL_INIT_ALIASED_NEXT(name, alias); \ + } while (0) +#else +# define VIR_MOCK_REAL_INIT(name) \ + do { \ + VIR_MOCK_REAL_INIT_NEXT(name); \ + } while (0) +# define VIR_MOCK_REAL_INIT_ALIASED(name, alias) \ + do { \ + VIR_MOCK_REAL_INIT_ALIASED_NEXT(name, alias); \ + } while (0) +#endif 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