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) {
|
TEST_P(CliTest_WrongEnvironment, MountDirIsBaseDir) {
|
||||||
mountdir = 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
bf::path make_relative(const bf::path &path) {
|
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) {
|
TEST_P(CliTest_WrongEnvironment, MountDirIsBaseDir_MountDirRelative) {
|
||||||
mountdir = make_relative(basedir);
|
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) {
|
TEST_P(CliTest_WrongEnvironment, MountDirIsBaseDir_BaseDirRelative) {
|
||||||
mountdir = basedir;
|
mountdir = basedir;
|
||||||
basedir = make_relative(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) {
|
TEST_P(CliTest_WrongEnvironment, MountDirIsBaseDir_BothRelative) {
|
||||||
basedir = make_relative(basedir);
|
basedir = make_relative(basedir);
|
||||||
mountdir = 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) {
|
TEST_P(CliTest_WrongEnvironment, BaseDir_DoesntExist) {
|
||||||
_basedir.remove();
|
_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 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));
|
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) {
|
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.
|
// 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));
|
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", _)).WillByDefault(Return(true));
|
||||||
cpputils::setenv("CRYFS_FRONTEND", "noninteractive");
|
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");
|
cpputils::unsetenv("CRYFS_FRONTEND");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ TEST_P(CliTest_WrongEnvironment, BaseDir_DoesntExist_Create) {
|
|||||||
TEST_P(CliTest_WrongEnvironment, BaseDir_IsNotDirectory) {
|
TEST_P(CliTest_WrongEnvironment, BaseDir_IsNotDirectory) {
|
||||||
TempFile basedirfile;
|
TempFile basedirfile;
|
||||||
basedir = basedirfile.path();
|
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) {
|
TEST_P(CliTest_WrongEnvironment, BaseDir_AllPermissions) {
|
||||||
@ -161,22 +161,22 @@ TEST_P(CliTest_WrongEnvironment, BaseDir_AllPermissions) {
|
|||||||
#if !defined(_MSC_VER)
|
#if !defined(_MSC_VER)
|
||||||
TEST_P(CliTest_WrongEnvironment, BaseDir_NoReadPermission) {
|
TEST_P(CliTest_WrongEnvironment, BaseDir_NoReadPermission) {
|
||||||
SetNoReadPermission(basedir);
|
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) {
|
TEST_P(CliTest_WrongEnvironment, BaseDir_NoExePermission) {
|
||||||
SetNoExePermission(basedir);
|
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) {
|
TEST_P(CliTest_WrongEnvironment, BaseDir_NoWritePermission) {
|
||||||
SetNoWritePermission(basedir);
|
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) {
|
TEST_P(CliTest_WrongEnvironment, BaseDir_NoPermission) {
|
||||||
SetNoPermission(basedir);
|
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
|
#endif
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ TEST_P(CliTest_WrongEnvironment, MountDir_DoesntExist_Create) {
|
|||||||
TEST_P(CliTest_WrongEnvironment, MountDir_IsNotDirectory) {
|
TEST_P(CliTest_WrongEnvironment, MountDir_IsNotDirectory) {
|
||||||
TempFile mountdirfile;
|
TempFile mountdirfile;
|
||||||
mountdir = mountdirfile.path();
|
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) {
|
TEST_P(CliTest_WrongEnvironment, MountDir_AllPermissions) {
|
||||||
@ -222,21 +222,21 @@ TEST_P(CliTest_WrongEnvironment, MountDir_AllPermissions) {
|
|||||||
#if !defined(_MSC_VER)
|
#if !defined(_MSC_VER)
|
||||||
TEST_P(CliTest_WrongEnvironment, MountDir_NoReadPermission) {
|
TEST_P(CliTest_WrongEnvironment, MountDir_NoReadPermission) {
|
||||||
SetNoReadPermission(mountdir);
|
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) {
|
TEST_P(CliTest_WrongEnvironment, MountDir_NoExePermission) {
|
||||||
SetNoExePermission(mountdir);
|
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) {
|
TEST_P(CliTest_WrongEnvironment, MountDir_NoWritePermission) {
|
||||||
SetNoWritePermission(mountdir);
|
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) {
|
TEST_P(CliTest_WrongEnvironment, MountDir_NoPermission) {
|
||||||
SetNoPermission(mountdir);
|
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
|
#endif
|
Loading…
Reference in New Issue
Block a user