Fix test cases
This commit is contained in:
parent
9516d4facc
commit
0ec081750e
@ -96,6 +96,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, createSymlink_TimestampsOfCreatedSymlink) {
|
|||||||
|
|
||||||
TYPED_TEST_P(FsppDirTest_Timestamps, children_empty) {
|
TYPED_TEST_P(FsppDirTest_Timestamps, children_empty) {
|
||||||
auto dir = this->CreateDir("/mydir");
|
auto dir = this->CreateDir("/mydir");
|
||||||
|
this->setModificationTimestampLaterThanAccessTimestamp("/mydir"); // to make sure that even in relatime behavior, the read access below changes the access timestamp
|
||||||
auto operation = [&dir] () {
|
auto operation = [&dir] () {
|
||||||
dir->children();
|
dir->children();
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,7 @@ TYPED_TEST_CASE_P(FsppSymlinkTest_Timestamps);
|
|||||||
|
|
||||||
TYPED_TEST_P(FsppSymlinkTest_Timestamps, target) {
|
TYPED_TEST_P(FsppSymlinkTest_Timestamps, target) {
|
||||||
auto symlink = this->CreateSymlink("/mysymlink");
|
auto symlink = this->CreateSymlink("/mysymlink");
|
||||||
|
this->setModificationTimestampLaterThanAccessTimestamp("/mysymlink"); // to make sure that even in relatime behavior, the read access below changes the access timestamp
|
||||||
auto operation = [&symlink] () {
|
auto operation = [&symlink] () {
|
||||||
symlink->target();
|
symlink->target();
|
||||||
};
|
};
|
||||||
|
@ -86,6 +86,17 @@ public:
|
|||||||
void EXPECT_IS_SYMLINK(const cpputils::unique_ref<fspp::Node> &node) {
|
void EXPECT_IS_SYMLINK(const cpputils::unique_ref<fspp::Node> &node) {
|
||||||
EXPECT_NE(nullptr, dynamic_cast<const fspp::Symlink*>(node.get()));
|
EXPECT_NE(nullptr, dynamic_cast<const fspp::Symlink*>(node.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setModificationTimestampLaterThanAccessTimestamp(const boost::filesystem::path& path) {
|
||||||
|
auto node = device->Load(path).value();
|
||||||
|
struct stat st;
|
||||||
|
node->stat(&st);
|
||||||
|
st.st_mtim.tv_nsec = st.st_mtim.tv_nsec + 1;
|
||||||
|
node->utimens(
|
||||||
|
st.st_atim,
|
||||||
|
st.st_mtim
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "blockstore/implementations/encrypted/EncryptedBlockStore2.h"
|
#include "blockstore/implementations/encrypted/EncryptedBlockStore2.h"
|
||||||
#include "blockstore/implementations/inmemory/InMemoryBlockStore2.h"
|
#include "blockstore/implementations/inmemory/InMemoryBlockStore2.h"
|
||||||
#include "blockstore/utils/BlockStoreUtils.h"
|
#include "blockstore/utils/BlockStoreUtils.h"
|
||||||
|
#include "../../testutils/gtest_printers.h"
|
||||||
#include <cpp-utils/data/DataFixture.h>
|
#include <cpp-utils/data/DataFixture.h>
|
||||||
|
|
||||||
using ::testing::Test;
|
using ::testing::Test;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "blockstore/utils/BlockStoreUtils.h"
|
#include "blockstore/utils/BlockStoreUtils.h"
|
||||||
#include <cpp-utils/data/DataFixture.h>
|
#include <cpp-utils/data/DataFixture.h>
|
||||||
#include <cpp-utils/tempfile/TempFile.h>
|
#include <cpp-utils/tempfile/TempFile.h>
|
||||||
|
#include "../../testutils/gtest_printers.h"
|
||||||
|
|
||||||
using ::testing::Test;
|
using ::testing::Test;
|
||||||
|
|
||||||
|
21
test/blockstore/testutils/gtest_printers.h
Normal file
21
test/blockstore/testutils/gtest_printers.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef MESSMER_BLOCKSTORE_TEST_TESTUTILS_GTESTPRINTERS_H_
|
||||||
|
#define MESSMER_BLOCKSTORE_TEST_TESTUTILS_GTESTPRINTERS_H_
|
||||||
|
|
||||||
|
namespace cpputils {
|
||||||
|
|
||||||
|
inline void PrintTo(const Data& /*data*/, ::std::ostream* os) {
|
||||||
|
*os << "cpputils::Data";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void PrintTo(const boost::optional<Data>& data, ::std::ostream* os) {
|
||||||
|
if (data == boost::none) {
|
||||||
|
*os << "none";
|
||||||
|
} else {
|
||||||
|
PrintTo(*data, os);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -78,7 +78,10 @@ TEST_F(CryCipherTest, FindsCorrectCipher) {
|
|||||||
"twofish-256-gcm", "twofish-256-cfb", "twofish-256-gcm", "twofish-256-cfb",
|
"twofish-256-gcm", "twofish-256-cfb", "twofish-256-gcm", "twofish-256-cfb",
|
||||||
"serpent-256-gcm", "serpent-256-cfb", "serpent-256-gcm", "serpent-256-cfb",
|
"serpent-256-gcm", "serpent-256-cfb", "serpent-256-gcm", "serpent-256-cfb",
|
||||||
"cast-256-gcm", "cast-256-cfb",
|
"cast-256-gcm", "cast-256-cfb",
|
||||||
"mars-448-gcm", "mars-448-cfb", "mars-256-gcm", "mars-256-cfb", "mars-256-gcm", "mars-256-cfb"
|
#if CRYPTOPP_VERSION != 564
|
||||||
|
"mars-448-gcm", "mars-448-cfb",
|
||||||
|
#endif
|
||||||
|
"mars-256-gcm", "mars-256-cfb", "mars-256-gcm", "mars-256-cfb"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,25 @@
|
|||||||
#include "FuseCreateAndOpenTest.h"
|
#include "FuseCreateAndOpenTest.h"
|
||||||
|
|
||||||
using ::testing::_;
|
using ::testing::_;
|
||||||
|
using cpputils::unique_ref;
|
||||||
|
using cpputils::make_unique_ref;
|
||||||
|
|
||||||
void FuseCreateAndOpenTest::CreateAndOpenFile(const char *filename, int flags) {
|
void FuseCreateAndOpenTest::CreateAndOpenFile(const std::string &filename, int flags) {
|
||||||
auto fs = TestFS();
|
auto fs = TestFS();
|
||||||
|
|
||||||
auto realpath = fs->mountDir() / filename;
|
auto fd = CreateAndOpenFileAllowErrors(fs.get(), filename, flags);
|
||||||
OpenFileHandle fd(realpath.c_str(), flags | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
EXPECT_GE(fd->fd(), 0) << "Opening file failed";
|
||||||
|
|
||||||
EXPECT_GE(fd.fd(), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int FuseCreateAndOpenTest::CreateAndOpenFileReturnError(const char *filename, int flags) {
|
int FuseCreateAndOpenTest::CreateAndOpenFileReturnError(const std::string &filename, int flags) {
|
||||||
OpenFileHandle fd(filename, flags);
|
auto fs = TestFS();
|
||||||
return fd.errorcode();
|
|
||||||
|
auto fd = CreateAndOpenFileAllowErrors(fs.get(), filename, flags);
|
||||||
|
return fd->errorcode();
|
||||||
|
}
|
||||||
|
|
||||||
|
unique_ref<OpenFileHandle> FuseCreateAndOpenTest::CreateAndOpenFileAllowErrors(const TempTestFS *fs, const std::string &filename, int flags) {
|
||||||
|
auto real_path = fs->mountDir() / filename;
|
||||||
|
auto fd = make_unique_ref<OpenFileHandle>(real_path.c_str(), flags | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||||
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,10 @@ class FuseCreateAndOpenTest: public FuseTest {
|
|||||||
public:
|
public:
|
||||||
const char *FILENAME = "/myfile";
|
const char *FILENAME = "/myfile";
|
||||||
|
|
||||||
void CreateAndOpenFile(const char *FILENAME, int flags);
|
void CreateAndOpenFile(const std::string& FILENAME, int flags);
|
||||||
int CreateAndOpenFileReturnError(const char *FILENAME, int flags);
|
int CreateAndOpenFileReturnError(const std::string& FILENAME, int flags);
|
||||||
|
private:
|
||||||
|
cpputils::unique_ref<OpenFileHandle> CreateAndOpenFileAllowErrors(const TempTestFS *fs, const std::string &filename, int flags);
|
||||||
};
|
};
|
||||||
|
|
||||||
MATCHER_P(OpenFlagsEq, expectedFlags, "") {
|
MATCHER_P(OpenFlagsEq, expectedFlags, "") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user