From nobody Wed May 14 23:47:28 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525344975350688.1851716471357; Thu, 3 May 2018 03:56:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E16975724; Thu, 3 May 2018 10:56:14 +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 DDB2B600C8; Thu, 3 May 2018 10:56:13 +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 884494CAA8; Thu, 3 May 2018 10:56:13 +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 w43AsTF1018669 for ; Thu, 3 May 2018 06:54:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 05A932023459; Thu, 3 May 2018 10:54:29 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9DF1F2023456 for ; Thu, 3 May 2018 10:54:28 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:16 +0200 Message-Id: <20180503105423.24837-3-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 2/9] tests: Mock virFileCanonicalizePath() 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: , MIME-Version: 1.0 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 03 May 2018 10:56:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We're going to need this later on. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/virpcimock.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 176c64d654..3d3a4b4a19 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -43,6 +43,7 @@ static char *(*real_canonicalize_file_name)(const char *p= ath); static int (*real_open)(const char *path, int flags, ...); static int (*real_close)(int fd); static DIR * (*real_opendir)(const char *name); +static char *(*real_virFileCanonicalizePath)(const char *path); =20 /* Don't make static, since it causes problems with clang * when passed as an arg to virAsprintf() @@ -814,6 +815,7 @@ init_syms(void) VIR_MOCK_REAL_INIT(open); VIR_MOCK_REAL_INIT(close); VIR_MOCK_REAL_INIT(opendir); + VIR_MOCK_REAL_INIT(virFileCanonicalizePath); } =20 static void @@ -1046,6 +1048,28 @@ close(int fd) return -1; return real_close(fd); } + +char * +virFileCanonicalizePath(const char *path) +{ + char *ret; + + init_syms(); + + if (STRPREFIX(path, SYSFS_PCI_PREFIX)) { + char *newpath; + + if (getrealpath(&newpath, path) < 0) + return NULL; + + ret =3D real_virFileCanonicalizePath(newpath); + VIR_FREE(newpath); + } else { + ret =3D real_virFileCanonicalizePath(path); + } + + return ret; +} #else /* Nothing to override on non-__linux__ platforms */ #endif --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list