2014-12-02 22:16:48 +01:00
|
|
|
#include "testutils/FuseReadDirTest.h"
|
|
|
|
|
2018-05-21 08:18:34 +02:00
|
|
|
#include "fspp/fs_interface/FuseErrnoException.h"
|
2014-12-02 22:16:48 +01:00
|
|
|
|
2019-10-13 17:49:57 +02:00
|
|
|
using ::testing::Eq;
|
2014-12-02 22:16:48 +01:00
|
|
|
using ::testing::Throw;
|
|
|
|
using ::testing::WithParamInterface;
|
|
|
|
using ::testing::Values;
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
using namespace fspp::fuse;
|
|
|
|
|
|
|
|
class FuseReadDirErrorTest: public FuseReadDirTest, public WithParamInterface<int> {
|
|
|
|
};
|
2019-10-13 14:16:06 +02:00
|
|
|
INSTANTIATE_TEST_SUITE_P(FuseReadDirErrorTest, FuseReadDirErrorTest, Values(EACCES, EBADF, EMFILE, ENFILE, ENOMEM, ENOTDIR, EFAULT, EINVAL));
|
2014-12-02 22:16:48 +01:00
|
|
|
|
|
|
|
//TODO On ENOENT, libfuse doesn't return the ENOENT error, but returns a success response with an empty directory. Why?
|
|
|
|
|
|
|
|
TEST_F(FuseReadDirErrorTest, NoError) {
|
|
|
|
ReturnIsDirOnLstat(DIRNAME);
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, readDir(Eq(DIRNAME)))
|
2014-12-02 22:16:48 +01:00
|
|
|
.Times(1).WillOnce(ReturnDirEntries({}));
|
|
|
|
|
|
|
|
int error = ReadDirReturnError(DIRNAME);
|
|
|
|
EXPECT_EQ(0, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(FuseReadDirErrorTest, ReturnedErrorCodeIsCorrect) {
|
|
|
|
ReturnIsDirOnLstat(DIRNAME);
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, readDir(Eq(DIRNAME)))
|
2014-12-02 22:16:48 +01:00
|
|
|
.Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
|
|
|
|
|
|
|
|
int error = ReadDirReturnError(DIRNAME);
|
|
|
|
EXPECT_EQ(GetParam(), error);
|
|
|
|
}
|