2014-11-27 03:48:38 +01:00
|
|
|
#include "testutils/FuseReadTest.h"
|
|
|
|
|
2014-11-28 14:46:45 +01:00
|
|
|
#include "fspp/fuse/FuseErrnoException.h"
|
2014-11-27 03:48:38 +01:00
|
|
|
|
|
|
|
using ::testing::_;
|
|
|
|
using ::testing::StrEq;
|
|
|
|
using ::testing::Eq;
|
|
|
|
using ::testing::Return;
|
|
|
|
using ::testing::Invoke;
|
|
|
|
using ::testing::Action;
|
|
|
|
|
|
|
|
using std::min;
|
|
|
|
|
2014-11-28 14:46:45 +01:00
|
|
|
using namespace fspp::fuse;
|
2014-11-27 03:48:38 +01:00
|
|
|
|
|
|
|
class FuseReadOverflowTest: public FuseReadTest {
|
|
|
|
public:
|
|
|
|
const size_t FILESIZE = 1000;
|
|
|
|
const size_t READSIZE = 2000;
|
|
|
|
const size_t OFFSET = 500;
|
|
|
|
|
|
|
|
void SetUp() override {
|
|
|
|
ReturnIsFileOnLstatWithSize(FILENAME, FILESIZE);
|
|
|
|
OnOpenReturnFileDescriptor(FILENAME, 0);
|
|
|
|
EXPECT_CALL(fsimpl, read(0, _, _, _)).WillRepeatedly(ReturnSuccessfulReadRegardingSize(FILESIZE));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(FuseReadOverflowTest, ReadMoreThanFileSizeFromBeginning) {
|
|
|
|
char buf[READSIZE];
|
2014-12-06 15:33:01 +01:00
|
|
|
auto retval = ReadFileReturnError(FILENAME, buf, READSIZE, 0);
|
|
|
|
EXPECT_EQ(FILESIZE, retval.read_bytes);
|
2014-11-27 03:48:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseReadOverflowTest, ReadMoreThanFileSizeFromMiddle) {
|
|
|
|
char buf[READSIZE];
|
2014-12-06 15:33:01 +01:00
|
|
|
auto retval = ReadFileReturnError(FILENAME, buf, READSIZE, OFFSET);
|
|
|
|
EXPECT_EQ(FILESIZE-OFFSET, retval.read_bytes);
|
2014-11-27 03:48:38 +01:00
|
|
|
}
|