libcryfs/test/fuse/fstat/FuseFstatParameterTest.cpp

38 lines
1.1 KiB
C++
Raw Normal View History

2014-11-25 14:29:44 +01:00
#include "testutils/FuseFstatTest.h"
2015-02-17 00:48:49 +01:00
#include "../../../fuse/FuseErrnoException.h"
2014-11-25 14:29:44 +01:00
using ::testing::_;
using ::testing::StrEq;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Eq;
using ::testing::Return;
using ::testing::Throw;
using namespace fspp::fuse;
2014-11-25 14:29:44 +01:00
// Cite from FUSE documentation on the fgetattr function:
// "Currently this is only called after the create() method if that is implemented (see above).
// Later it may be called for invocations of fstat() too."
// So we need to issue a create to get our fstat called.
class FuseFstatParameterTest: public FuseFstatTest, public WithParamInterface<int> {
public:
2014-11-25 14:58:00 +01:00
void CallFstat(const char *filename) {
auto fs = TestFS();
CreateFile(fs.get(), filename);
}
2014-11-25 14:29:44 +01:00
};
INSTANTIATE_TEST_CASE_P(FuseFstatParameterTest, FuseFstatParameterTest, Values(0,1,10,1000,1024*1024*1024));
TEST_P(FuseFstatParameterTest, FileDescriptorIsCorrect) {
ReturnDoesntExistOnLstat(FILENAME);
2014-11-25 18:43:50 +01:00
OnCreateAndOpenReturnFileDescriptor(FILENAME, GetParam());
2014-11-25 14:29:44 +01:00
EXPECT_CALL(fsimpl, fstat(Eq(GetParam()), _)).Times(1).WillOnce(ReturnIsFileFstat);
2014-11-25 14:58:00 +01:00
CallFstat(FILENAME);
2014-11-25 14:29:44 +01:00
}