libcryfs/test/fuse/read/testutils/FuseReadTest.h

36 lines
1.0 KiB
C
Raw Normal View History

2014-11-27 03:48:38 +01:00
#pragma once
2015-10-15 13:04:57 +02:00
#ifndef MESSMER_FSPP_TEST_FUSE_READ_TESTUTILS_FUSEREADTEST_H_
#define MESSMER_FSPP_TEST_FUSE_READ_TESTUTILS_FUSEREADTEST_H_
2014-11-27 03:48:38 +01:00
2015-02-17 00:48:49 +01:00
#include "../../../testutils/FuseTest.h"
2014-11-27 03:48:38 +01:00
class FuseReadTest: public FuseTest {
public:
const char *FILENAME = "/myfile";
struct ReadError {
int error;
size_t read_bytes;
};
2014-11-27 03:48:38 +01:00
void ReadFile(const char *filename, void *buf, size_t count, off_t offset);
ReadError ReadFileReturnError(const char *filename, void *buf, size_t count, off_t offset);
2014-11-27 03:48:38 +01:00
2015-12-11 00:46:24 +01:00
::testing::Action<size_t(int, void*, size_t, off_t)> ReturnSuccessfulRead =
2014-11-27 03:48:38 +01:00
::testing::Invoke([](int, void *, size_t count, off_t) {
return count;
});
2015-12-11 00:46:24 +01:00
::testing::Action<size_t(int, void*, size_t, off_t)> ReturnSuccessfulReadRegardingSize(size_t filesize) {
2014-11-27 03:48:38 +01:00
return ::testing::Invoke([filesize](int, void *, size_t count, off_t offset) {
2015-11-25 16:36:57 +01:00
size_t ableToReadCount = std::min(count, (size_t)(filesize - offset));
2014-11-27 03:48:38 +01:00
return ableToReadCount;
});
}
private:
int OpenFile(const TempTestFS *fs, const char *filename);
};
#endif