Added success tests
This commit is contained in:
parent
4d6970837e
commit
9aee4b1657
@ -137,6 +137,7 @@ namespace cryfs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Cli::_initLogfile(const ProgramOptions &options) {
|
void Cli::_initLogfile(const ProgramOptions &options) {
|
||||||
|
spdlog::drop("cryfs");
|
||||||
//TODO Test that --logfile parameter works. Should be: file if specified, otherwise stderr if foreground, else syslog.
|
//TODO Test that --logfile parameter works. Should be: file if specified, otherwise stderr if foreground, else syslog.
|
||||||
if (options.logFile() != none) {
|
if (options.logFile() != none) {
|
||||||
cpputils::logging::setLogger(
|
cpputils::logging::setLogger(
|
||||||
|
@ -59,6 +59,9 @@ public:
|
|||||||
if (GetParam().runningInForeground) {
|
if (GetParam().runningInForeground) {
|
||||||
result.push_back("-f");
|
result.push_back("-f");
|
||||||
}
|
}
|
||||||
|
// Test case should be non-interactive, so don't ask for cipher.
|
||||||
|
result.push_back("--cipher");
|
||||||
|
result.push_back("aes-256-gcm");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -74,7 +77,6 @@ INSTANTIATE_TEST_CASE_P(RunningInForeground_ExternalConfigfile_LogIsNotStderr, C
|
|||||||
|
|
||||||
//Counter-Test. Test that it doesn't fail if we call it without an error condition.
|
//Counter-Test. Test that it doesn't fail if we call it without an error condition.
|
||||||
TEST_P(CliTest_WrongEnvironment, NoErrorCondition) {
|
TEST_P(CliTest_WrongEnvironment, NoErrorCondition) {
|
||||||
if (GetParam().runningInForeground) {return;} // Don't run this test in foreground, because it would block
|
|
||||||
Test_Run_Success();
|
Test_Run_Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +126,6 @@ TEST_P(CliTest_WrongEnvironment, BaseDir_IsNotDirectory) {
|
|||||||
TEST_P(CliTest_WrongEnvironment, BaseDir_AllPermissions) {
|
TEST_P(CliTest_WrongEnvironment, BaseDir_AllPermissions) {
|
||||||
//Counter-Test. Test it doesn't fail if permissions are there.
|
//Counter-Test. Test it doesn't fail if permissions are there.
|
||||||
SetAllPermissions(basedir);
|
SetAllPermissions(basedir);
|
||||||
if (GetParam().runningInForeground) {return;} // Don't run this test in foreground, because it would block
|
|
||||||
Test_Run_Success();
|
Test_Run_Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +162,6 @@ TEST_P(CliTest_WrongEnvironment, MountDir_IsNotDirectory) {
|
|||||||
|
|
||||||
TEST_P(CliTest_WrongEnvironment, MountDir_AllPermissions) {
|
TEST_P(CliTest_WrongEnvironment, MountDir_AllPermissions) {
|
||||||
//Counter-Test. Test it doesn't fail if permissions are there.
|
//Counter-Test. Test it doesn't fail if permissions are there.
|
||||||
if (GetParam().runningInForeground) {return;} // Don't run this test in foreground, because it would block
|
|
||||||
SetAllPermissions(mountdir);
|
SetAllPermissions(mountdir);
|
||||||
Test_Run_Success();
|
Test_Run_Success();
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#define MESSMER_CRYFS_TEST_CLI_TESTUTILS_CLITEST_H
|
#define MESSMER_CRYFS_TEST_CLI_TESTUTILS_CLITEST_H
|
||||||
|
|
||||||
#include <google/gtest/gtest.h>
|
#include <google/gtest/gtest.h>
|
||||||
|
#include <google/gmock/gmock.h>
|
||||||
#include <messmer/cpp-utils/tempfile/TempDir.h>
|
#include <messmer/cpp-utils/tempfile/TempDir.h>
|
||||||
#include <messmer/cpp-utils/tempfile/TempFile.h>
|
#include <messmer/cpp-utils/tempfile/TempFile.h>
|
||||||
#include "../../../src/Cli.h"
|
#include "../../../src/Cli.h"
|
||||||
@ -42,18 +43,19 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EXPECT_RUN_SUCCESS(std::vector<const char*> args, const boost::filesystem::path &mountDir) {
|
void EXPECT_RUN_SUCCESS(std::vector<const char*> args, const boost::filesystem::path &mountDir) {
|
||||||
//TODO
|
std::thread unmountThread([&mountDir] {
|
||||||
/*EXPECT_EXIT(
|
int returncode = -1;
|
||||||
run(args),
|
while (returncode != 0) {
|
||||||
::testing::ExitedWithCode(0),
|
returncode = system((std::string("fusermount -u ") + mountDir.c_str()).c_str());
|
||||||
"Mounting filesystem"
|
std::this_thread::sleep_for(std::chrono::milliseconds(50)); // TODO Is this the test case duration? Does a shorter interval make the test case faster?
|
||||||
);
|
}
|
||||||
|
});
|
||||||
//Cleanup: Unmount filesystem
|
//testing::internal::CaptureStdout();
|
||||||
auto returncode = system((std::string("fusermount -u ")+mountDir.c_str()).c_str());
|
//TODO Don't force foreground, but find a way to run it also in background.
|
||||||
if (0 != returncode) {
|
args.push_back("-f");
|
||||||
cpputils::logging::LOG(cpputils::logging::ERROR) << "Could not unmount cryfs";
|
run(args);
|
||||||
}*/
|
unmountThread.join();
|
||||||
|
//EXPECT_THAT(testing::internal::GetCapturedStdout(), testing::MatchesRegex(".*Mounting filesystem.*"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user