git: 25038e8de6b4 - main - zfsd: fix unit tests after 89f4f91dbfdcabe65bc7476bc5f13dfb837870fe

From: Alan Somers <asomers_at_FreeBSD.org>
Date: Sat, 13 Apr 2024 00:36:42 UTC
The branch main has been updated by asomers:

URL: https://cgit.FreeBSD.org/src/commit/?id=25038e8de6b4e5f2ffca821565b50a633eea499a

commit 25038e8de6b4e5f2ffca821565b50a633eea499a
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2024-04-10 20:55:03 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2024-04-13 00:34:23 +0000

    zfsd: fix unit tests after 89f4f91dbfdcabe65bc7476bc5f13dfb837870fe
    
    Reported by:    markj
    MFC after:      1 week
    MFC with:       89f4f91dbfdcabe65bc7476bc5f13dfb837870fe
    Sponsored by:   Axcient
    Reviewed by:    Alek Pinchuk <pinchuk.alek@gmail.com>
    Differential Revision: https://reviews.freebsd.org/D44744
---
 cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc | 3 +++
 cddl/usr.sbin/zfsd/vdev.h                 | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc b/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc
index d76abb54c9ed..f1e925b0b4ef 100644
--- a/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc
+++ b/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc
@@ -134,6 +134,7 @@ public:
 	MOCK_CONST_METHOD0(PoolGUID, Guid());
 	MOCK_CONST_METHOD0(State, vdev_state());
 	MOCK_CONST_METHOD0(PhysicalPath, string());
+	MOCK_CONST_METHOD2(Name, string(zpool_handle_t * zhp, bool verbose));
 };
 
 MockVdev::MockVdev(nvlist_t *vdevConfig)
@@ -431,6 +432,8 @@ protected:
 		m_vdev = new MockVdev(m_vdevConfig);
 		ON_CALL(*m_vdev, GUID())
 		    .WillByDefault(::testing::Return(Guid(123)));
+		ON_CALL(*m_vdev, Name(::testing::_, ::testing::_))
+		    .WillByDefault(::testing::Return(string("/dev/da999")));
 		ON_CALL(*m_vdev, PoolGUID())
 		    .WillByDefault(::testing::Return(Guid(456)));
 		ON_CALL(*m_vdev, State())
diff --git a/cddl/usr.sbin/zfsd/vdev.h b/cddl/usr.sbin/zfsd/vdev.h
index ace5d5a009fa..42278a3d7229 100644
--- a/cddl/usr.sbin/zfsd/vdev.h
+++ b/cddl/usr.sbin/zfsd/vdev.h
@@ -130,7 +130,7 @@ public:
 	nvlist_t		*Config()	const;
 	Vdev			 Parent();
 	Vdev			 RootVdev();
-	std::string		 Name(zpool_handle_t *, bool verbose)	const;
+	virtual std::string	 Name(zpool_handle_t *, bool verbose)	const;
 	bool			 IsSpare();
 	bool			 IsAvailableSpare()	const;
 	bool			 IsActiveSpare()	const;