Fix test cases

This commit is contained in:
Sebastian Messmer 2018-02-01 02:33:33 -08:00
parent 8da4f4d362
commit 11c6f7fa98
4 changed files with 25 additions and 25 deletions

View File

@ -23,83 +23,83 @@ namespace boost {
class ProgramOptionsTest: public ProgramOptionsTestBase {};
TEST_F(ProgramOptionsTest, BaseDir) {
ProgramOptions testobj("/home/user/mydir", "", none, false, none, none, none, none, {"./myExecutable"});
ProgramOptions testobj("/home/user/mydir", "", none, false, false, none, none, none, none, {"./myExecutable"});
EXPECT_EQ("/home/user/mydir", testobj.baseDir());
}
TEST_F(ProgramOptionsTest, MountDir) {
ProgramOptions testobj("", "/home/user/mydir", none, false, none, none, none, none, {"./myExecutable"});
ProgramOptions testobj("", "/home/user/mydir", none, false, false, none, none, none, none, {"./myExecutable"});
EXPECT_EQ("/home/user/mydir", testobj.mountDir());
}
TEST_F(ProgramOptionsTest, ConfigfileNone) {
ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"});
ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"});
EXPECT_EQ(none, testobj.configFile());
}
TEST_F(ProgramOptionsTest, ConfigfileSome) {
ProgramOptions testobj("", "", bf::path("/home/user/configfile"), true, none, none, none, none, {"./myExecutable"});
ProgramOptions testobj("", "", bf::path("/home/user/configfile"), true, false, none, none, none, none, {"./myExecutable"});
EXPECT_EQ("/home/user/configfile", testobj.configFile().get());
}
TEST_F(ProgramOptionsTest, ForegroundFalse) {
ProgramOptions testobj("", "", none, false, none, none, none, none, {"./myExecutable"});
ProgramOptions testobj("", "", none, false, false, none, none, none, none, {"./myExecutable"});
EXPECT_FALSE(testobj.foreground());
}
TEST_F(ProgramOptionsTest, ForegroundTrue) {
ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"});
ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"});
EXPECT_TRUE(testobj.foreground());
}
TEST_F(ProgramOptionsTest, LogfileNone) {
ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"});
ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"});
EXPECT_EQ(none, testobj.logFile());
}
TEST_F(ProgramOptionsTest, LogfileSome) {
ProgramOptions testobj("", "", none, true, none, bf::path("logfile"), none, none, {"./myExecutable"});
ProgramOptions testobj("", "", none, true, false, none, bf::path("logfile"), none, none, {"./myExecutable"});
EXPECT_EQ("logfile", testobj.logFile().get());
}
TEST_F(ProgramOptionsTest, UnmountAfterIdleMinutesNone) {
ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"});
ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"});
EXPECT_EQ(none, testobj.unmountAfterIdleMinutes());
}
TEST_F(ProgramOptionsTest, UnmountAfterIdleMinutesSome) {
ProgramOptions testobj("", "", none, true, 10, none, none, none, {"./myExecutable"});
ProgramOptions testobj("", "", none, true, false, 10, none, none, none, {"./myExecutable"});
EXPECT_EQ(10, testobj.unmountAfterIdleMinutes().get());
}
TEST_F(ProgramOptionsTest, CipherNone) {
ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"});
ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"});
EXPECT_EQ(none, testobj.cipher());
}
TEST_F(ProgramOptionsTest, CipherSome) {
ProgramOptions testobj("", "", none, true, none, none, string("aes-256-gcm"), none, {"./myExecutable"});
ProgramOptions testobj("", "", none, true, false, none, none, string("aes-256-gcm"), none, {"./myExecutable"});
EXPECT_EQ("aes-256-gcm", testobj.cipher().get());
}
TEST_F(ProgramOptionsTest, BlocksizeBytesNone) {
ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"});
ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"});
EXPECT_EQ(none, testobj.blocksizeBytes());
}
TEST_F(ProgramOptionsTest, BlocksizeSome) {
ProgramOptions testobj("", "", none, true, none, none, none, 10*1024, {"./myExecutable"});
ProgramOptions testobj("", "", none, true, false, none, none, none, 10*1024, {"./myExecutable"});
EXPECT_EQ(10*1024u, testobj.blocksizeBytes().get());
}
TEST_F(ProgramOptionsTest, EmptyFuseOptions) {
ProgramOptions testobj("/rootDir", "/home/user/mydir", none, false, none, none, none, none, {});
ProgramOptions testobj("/rootDir", "/home/user/mydir", none, false, false, none, none, none, none, {});
//Fuse should have the mount dir as first parameter
EXPECT_VECTOR_EQ({}, testobj.fuseOptions());
}
TEST_F(ProgramOptionsTest, SomeFuseOptions) {
ProgramOptions testobj("/rootDir", "/home/user/mydir", none, false, none, none, none, none, {"-f", "--longoption"});
ProgramOptions testobj("/rootDir", "/home/user/mydir", none, false, false, none, none, none, none, {"-f", "--longoption"});
//Fuse should have the mount dir as first parameter
EXPECT_VECTOR_EQ({"-f", "--longoption"}, testobj.fuseOptions());
}

View File

@ -53,41 +53,41 @@ public:
CryConfigFile Create(const string &password = "mypassword", const optional<string> &cipher = none, bool noninteractive = false) {
EXPECT_FALSE(file.exists());
return loader(password, noninteractive, cipher).loadOrCreate(file.path()).value();
return loader(password, noninteractive, cipher).loadOrCreate(file.path(), false).value();
}
optional<CryConfigFile> Load(const string &password = "mypassword", const optional<string> &cipher = none, bool noninteractive = false) {
EXPECT_TRUE(file.exists());
return loader(password, noninteractive, cipher).loadOrCreate(file.path());
return loader(password, noninteractive, cipher).loadOrCreate(file.path(), false);
}
void CreateWithRootBlob(const string &rootBlob, const string &password = "mypassword") {
auto cfg = loader(password, false).loadOrCreate(file.path()).value();
auto cfg = loader(password, false).loadOrCreate(file.path(), false).value();
cfg.config()->SetRootBlob(rootBlob);
cfg.save();
}
void CreateWithCipher(const string &cipher, const string &password = "mypassword") {
auto cfg = loader(password, false).loadOrCreate(file.path()).value();
auto cfg = loader(password, false).loadOrCreate(file.path(), false).value();
cfg.config()->SetCipher(cipher);
cfg.save();
}
void CreateWithEncryptionKey(const string &encKey, const string &password = "mypassword") {
auto cfg = loader(password, false).loadOrCreate(file.path()).value();
auto cfg = loader(password, false).loadOrCreate(file.path(), false).value();
cfg.config()->SetEncryptionKey(encKey);
cfg.save();
}
void CreateWithVersion(const string &version, const string &password = "mypassword") {
auto cfg = loader(password, false).loadOrCreate(file.path()).value();
auto cfg = loader(password, false).loadOrCreate(file.path(), false).value();
cfg.config()->SetVersion(version);
cfg.config()->SetCreatedWithVersion(version);
cfg.save();
}
void CreateWithFilesystemID(const CryConfig::FilesystemID &filesystemId, const string &password = "mypassword") {
auto cfg = loader(password, false).loadOrCreate(file.path()).value();
auto cfg = loader(password, false).loadOrCreate(file.path(), false).value();
cfg.config()->SetFilesystemId(filesystemId);
cfg.save();
}

View File

@ -40,7 +40,7 @@ public:
CryConfigFile loadOrCreateConfig() {
auto askPassword = [] {return "mypassword";};
return CryConfigLoader(make_shared<NoninteractiveConsole>(mockConsole()), Random::PseudoRandom(), SCrypt::TestSettings, askPassword, askPassword, none, none).loadOrCreate(config.path()).value();
return CryConfigLoader(make_shared<NoninteractiveConsole>(mockConsole()), Random::PseudoRandom(), SCrypt::TestSettings, askPassword, askPassword, none, none).loadOrCreate(config.path(), false).value();
}
unique_ref<OnDiskBlockStore> blockStore() {

View File

@ -30,7 +30,7 @@ public:
auto blockStore = cpputils::make_unique_ref<FakeBlockStore>();
auto askPassword = [] {return "mypassword";};
auto config = CryConfigLoader(make_shared<NoninteractiveConsole>(mockConsole()), Random::PseudoRandom(), SCrypt::TestSettings, askPassword, askPassword, none, none)
.loadOrCreate(configFile.path()).value();
.loadOrCreate(configFile.path(), false).value();
return make_unique_ref<CryDevice>(std::move(config), std::move(blockStore));
}