From f0acb9f68f845ccd3d8fad584cea422b3bf3553e Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Thu, 20 Nov 2014 14:53:09 +0100 Subject: [PATCH] Add more lstat tests --- src/test/fspp/fuse/FuseLstatTest.cpp | 37 +++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/test/fspp/fuse/FuseLstatTest.cpp b/src/test/fspp/fuse/FuseLstatTest.cpp index 46752677..8da30e86 100644 --- a/src/test/fspp/fuse/FuseLstatTest.cpp +++ b/src/test/fspp/fuse/FuseLstatTest.cpp @@ -29,6 +29,8 @@ public: const off_t SIZE1 = 0; const off_t SIZE2 = 4096; const off_t SIZE3 = 1024*1024*1024; + const nlink_t NLINK1 = 1; + const nlink_t NLINK2 = 5; void LstatPath(const string &path) { struct stat dummy; @@ -70,6 +72,14 @@ public: struct stat CallDirLstatWithSize(off_t size) { return CallDirLstatWithImpl(LstatSizeImpl(size)); } + + struct stat CallFileLstatWithNlink(nlink_t nlink) { + return CallFileLstatWithImpl(LstatNlinkImpl(nlink)); + } + + struct stat CallDirLstatWithNlink(nlink_t nlink) { + return CallDirLstatWithImpl(LstatNlinkImpl(nlink)); + } private: static function LstatUidImpl(uid_t uid) { @@ -90,6 +100,12 @@ private: }; } + static function LstatNlinkImpl(nlink_t nlink) { + return [nlink] (struct stat *stat) { + stat->st_nlink = nlink; + }; + } + struct stat CallFileLstatWithImpl(function implementation) { return CallLstatWithModeAndImpl(S_IFREG, implementation); } @@ -227,7 +243,26 @@ TEST_F(FuseLstatTest, ReturnedDirSizeIsCorrect3) { EXPECT_EQ(SIZE3, result.st_size); } -//TODO st_nlink? +TEST_F(FuseLstatTest, ReturnedFileNlinkIsCorrect1) { + struct ::stat result = CallFileLstatWithNlink(NLINK1); + EXPECT_EQ(NLINK1, result.st_nlink); +} + +TEST_F(FuseLstatTest, ReturnedFileNlinkIsCorrect2) { + struct ::stat result = CallFileLstatWithNlink(NLINK2); + EXPECT_EQ(NLINK2, result.st_nlink); +} + +TEST_F(FuseLstatTest, ReturnedDirNlinkIsCorrect1) { + struct ::stat result = CallDirLstatWithNlink(NLINK1); + EXPECT_EQ(NLINK1, result.st_nlink); +} + +TEST_F(FuseLstatTest, ReturnedDirNlinkIsCorrect2) { + struct ::stat result = CallDirLstatWithNlink(NLINK2); + EXPECT_EQ(NLINK2, result.st_nlink); +} + //TODO st_atim //TODO st_mtim //TODO st_ctim