Fix test cases
This commit is contained in:
parent
cefba055a0
commit
9ebd3d754c
@ -89,7 +89,7 @@ TEST_P(CliTest_WrongEnvironment, NoErrorCondition) {
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, MountDirIsBaseDir) {
|
||||
mountdir = basedir;
|
||||
Test_Run_Error("Error: base directory can't be inside the mount directory", ErrorCode::BaseDirInsideMountDir);
|
||||
Test_Run_Error("Error 18: base directory can't be inside the mount directory", ErrorCode::BaseDirInsideMountDir);
|
||||
}
|
||||
|
||||
bf::path make_relative(const bf::path &path) {
|
||||
@ -104,26 +104,26 @@ bf::path make_relative(const bf::path &path) {
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, MountDirIsBaseDir_MountDirRelative) {
|
||||
mountdir = make_relative(basedir);
|
||||
Test_Run_Error("Error: base directory can't be inside the mount directory", ErrorCode::BaseDirInsideMountDir);
|
||||
Test_Run_Error("Error 18: base directory can't be inside the mount directory", ErrorCode::BaseDirInsideMountDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, MountDirIsBaseDir_BaseDirRelative) {
|
||||
mountdir = basedir;
|
||||
basedir = make_relative(basedir);
|
||||
Test_Run_Error("Error: base directory can't be inside the mount directory", ErrorCode::BaseDirInsideMountDir);
|
||||
Test_Run_Error("Error 18: base directory can't be inside the mount directory", ErrorCode::BaseDirInsideMountDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, MountDirIsBaseDir_BothRelative) {
|
||||
basedir = make_relative(basedir);
|
||||
mountdir = basedir;
|
||||
Test_Run_Error("Error: base directory can't be inside the mount directory", ErrorCode::BaseDirInsideMountDir);
|
||||
Test_Run_Error("Error 18: base directory can't be inside the mount directory", ErrorCode::BaseDirInsideMountDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, BaseDir_DoesntExist) {
|
||||
_basedir.remove();
|
||||
// ON_CALL and not EXPECT_CALL, because this is a death test (i.e. it is forked) and gmock EXPECT_CALL in fork children don't report to parents.
|
||||
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", _)).WillByDefault(Return(false));
|
||||
Test_Run_Error("Error: base directory not found", ErrorCode::InaccessibleBaseDir);
|
||||
Test_Run_Error("Error 16: base directory not found", ErrorCode::InaccessibleBaseDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, BaseDir_DoesntExist_Noninteractive) {
|
||||
@ -132,7 +132,7 @@ TEST_P(CliTest_WrongEnvironment, BaseDir_DoesntExist_Noninteractive) {
|
||||
// So we set a default answer that shouldn't crash and check it's not called by checking that it crashes.
|
||||
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", _)).WillByDefault(Return(true));
|
||||
cpputils::setenv("CRYFS_FRONTEND", "noninteractive");
|
||||
Test_Run_Error("Error: base directory not found", ErrorCode::InaccessibleBaseDir);
|
||||
Test_Run_Error("Error 16: base directory not found", ErrorCode::InaccessibleBaseDir);
|
||||
cpputils::unsetenv("CRYFS_FRONTEND");
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ TEST_P(CliTest_WrongEnvironment, BaseDir_DoesntExist_Create) {
|
||||
TEST_P(CliTest_WrongEnvironment, BaseDir_IsNotDirectory) {
|
||||
TempFile basedirfile;
|
||||
basedir = basedirfile.path();
|
||||
Test_Run_Error("Error: base directory is not a directory", ErrorCode::InaccessibleBaseDir);
|
||||
Test_Run_Error("Error 16: base directory is not a directory", ErrorCode::InaccessibleBaseDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, BaseDir_AllPermissions) {
|
||||
@ -161,22 +161,22 @@ TEST_P(CliTest_WrongEnvironment, BaseDir_AllPermissions) {
|
||||
#if !defined(_MSC_VER)
|
||||
TEST_P(CliTest_WrongEnvironment, BaseDir_NoReadPermission) {
|
||||
SetNoReadPermission(basedir);
|
||||
Test_Run_Error("Error: Could not read from base directory", ErrorCode::InaccessibleBaseDir);
|
||||
Test_Run_Error("Error 16: Could not read from base directory", ErrorCode::InaccessibleBaseDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, BaseDir_NoExePermission) {
|
||||
SetNoExePermission(basedir);
|
||||
Test_Run_Error("Error: Could not write to base directory", ErrorCode::InaccessibleBaseDir);
|
||||
Test_Run_Error("Error 16: Could not write to base directory", ErrorCode::InaccessibleBaseDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, BaseDir_NoWritePermission) {
|
||||
SetNoWritePermission(basedir);
|
||||
Test_Run_Error("Error: Could not write to base directory", ErrorCode::InaccessibleBaseDir);
|
||||
Test_Run_Error("Error 16: Could not write to base directory", ErrorCode::InaccessibleBaseDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, BaseDir_NoPermission) {
|
||||
SetNoPermission(basedir);
|
||||
Test_Run_Error("Error: Could not write to base directory", ErrorCode::InaccessibleBaseDir);
|
||||
Test_Run_Error("Error 16: Could not write to base directory", ErrorCode::InaccessibleBaseDir);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -208,7 +208,7 @@ TEST_P(CliTest_WrongEnvironment, MountDir_DoesntExist_Create) {
|
||||
TEST_P(CliTest_WrongEnvironment, MountDir_IsNotDirectory) {
|
||||
TempFile mountdirfile;
|
||||
mountdir = mountdirfile.path();
|
||||
Test_Run_Error("Error: mount directory is not a directory", ErrorCode::InaccessibleMountDir);
|
||||
Test_Run_Error("Error 17: mount directory is not a directory", ErrorCode::InaccessibleMountDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, MountDir_AllPermissions) {
|
||||
@ -222,21 +222,21 @@ TEST_P(CliTest_WrongEnvironment, MountDir_AllPermissions) {
|
||||
#if !defined(_MSC_VER)
|
||||
TEST_P(CliTest_WrongEnvironment, MountDir_NoReadPermission) {
|
||||
SetNoReadPermission(mountdir);
|
||||
Test_Run_Error("Error: Could not read from mount directory", ErrorCode::InaccessibleMountDir);
|
||||
Test_Run_Error("Error 17: Could not read from mount directory", ErrorCode::InaccessibleMountDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, MountDir_NoExePermission) {
|
||||
SetNoExePermission(mountdir);
|
||||
Test_Run_Error("Error: Could not write to mount directory", ErrorCode::InaccessibleMountDir);
|
||||
Test_Run_Error("Error 17: Could not write to mount directory", ErrorCode::InaccessibleMountDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, MountDir_NoWritePermission) {
|
||||
SetNoWritePermission(mountdir);
|
||||
Test_Run_Error("Error: Could not write to mount directory", ErrorCode::InaccessibleMountDir);
|
||||
Test_Run_Error("Error 17: Could not write to mount directory", ErrorCode::InaccessibleMountDir);
|
||||
}
|
||||
|
||||
TEST_P(CliTest_WrongEnvironment, MountDir_NoPermission) {
|
||||
SetNoPermission(mountdir);
|
||||
Test_Run_Error("Error: Could not write to mount directory", ErrorCode::InaccessibleMountDir);
|
||||
Test_Run_Error("Error 17: Could not write to mount directory", ErrorCode::InaccessibleMountDir);
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user