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

37 lines
1.3 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"
#include "../../../testutils/OpenFileHandle.h"
2014-11-27 03:48:38 +01:00
class FuseReadTest: public FuseTest {
public:
const char *FILENAME = "/myfile";
struct ReadError {
2018-10-14 22:26:30 +02:00
int error{};
2018-09-15 23:32:58 +02:00
fspp::num_bytes_t read_bytes;
};
2018-09-15 23:32:58 +02:00
void ReadFile(const char *filename, void *buf, fspp::num_bytes_t count, fspp::num_bytes_t offset);
ReadError ReadFileReturnError(const char *filename, void *buf, fspp::num_bytes_t count, fspp::num_bytes_t offset);
2014-11-27 03:48:38 +01:00
2018-09-15 23:32:58 +02:00
::testing::Action<fspp::num_bytes_t(int, void*, fspp::num_bytes_t, fspp::num_bytes_t)> ReturnSuccessfulRead =
::testing::Invoke([](int, void *, fspp::num_bytes_t count, fspp::num_bytes_t) {
2014-11-27 03:48:38 +01:00
return count;
});
2018-09-15 23:32:58 +02:00
::testing::Action<fspp::num_bytes_t(int, void*, fspp::num_bytes_t, fspp::num_bytes_t)> ReturnSuccessfulReadRegardingSize(fspp::num_bytes_t filesize) {
return ::testing::Invoke([filesize](int, void *, fspp::num_bytes_t count, fspp::num_bytes_t offset) {
fspp::num_bytes_t ableToReadCount = std::min(count, filesize - offset);
2014-11-27 03:48:38 +01:00
return ableToReadCount;
});
}
private:
cpputils::unique_ref<OpenFileHandle> OpenFile(const TempTestFS *fs, const char *filename);
2014-11-27 03:48:38 +01:00
};
#endif