Fix death tests in multithreading context

This commit is contained in:
Sebastian Meßmer 2015-10-16 04:06:00 +02:00
parent 20612fb245
commit bb90bb19ba
3 changed files with 13 additions and 9 deletions

View File

@ -7,6 +7,7 @@ using namespace cryfs::program_options;
using std::pair; using std::pair;
using std::vector; using std::vector;
using std::cerr; using std::cerr;
using std::endl;
using std::string; using std::string;
Parser::Parser(int argc, char *argv[]) :_options(_argsToVector(argc, argv)) {} Parser::Parser(int argc, char *argv[]) :_options(_argsToVector(argc, argv)) {}
@ -81,6 +82,6 @@ void Parser::_addPositionalOptionForBaseDir(po::options_description *desc, po::p
cerr << "Usage: cryfs --config configFile [other options] rootDir mountPoint [-- [FUSE Mount Options]]\n"; cerr << "Usage: cryfs --config configFile [other options] rootDir mountPoint [-- [FUSE Mount Options]]\n";
po::options_description desc; po::options_description desc;
_addAllowedOptions(&desc); _addAllowedOptions(&desc);
cerr << desc << "\n"; cerr << desc << endl;
exit(1); exit(1);
} }

View File

@ -7,7 +7,7 @@
namespace cryfs { namespace cryfs {
namespace program_options { namespace program_options {
class ProgramOptions { class ProgramOptions final {
public: public:
ProgramOptions(const std::string &baseDir, const std::string &mountDir, const std::string &configFile, bool foreground, const std::vector<char *> &fuseOptions); ProgramOptions(const std::string &baseDir, const std::string &mountDir, const std::string &configFile, bool foreground, const std::vector<char *> &fuseOptions);
~ProgramOptions(); ~ProgramOptions();

View File

@ -12,35 +12,38 @@ public:
} }
}; };
TEST_F(ProgramOptionsParserTest, MissingAllOptions) { class ProgramOptionsParserDeathTest: public ProgramOptionsParserTest {};
TEST_F(ProgramOptionsParserDeathTest, MissingAllOptions) {
EXPECT_DEATH( EXPECT_DEATH(
parse({"./myExecutable"}), parse({"./myExecutable"}),
"Usage:" "Usage:"
); );
std::cout << "exited" << std::endl;
} }
TEST_F(ProgramOptionsParserTest, MissingDir) { TEST_F(ProgramOptionsParserDeathTest, MissingDir) {
EXPECT_DEATH( EXPECT_DEATH(
parse({"./myExecutable", "/home/user/baseDir"}), parse({"./myExecutable", "/home/user/baseDir"}),
"Usage:" "Usage:"
); );
} }
TEST_F(ProgramOptionsParserTest, ConfigFileMissing) { TEST_F(ProgramOptionsParserDeathTest, ConfigFileMissing) {
EXPECT_DEATH( EXPECT_DEATH(
parse({"./myExecutable", "/home/user/baseDir", "/home/user/mountDir"}), parse({"./myExecutable", "/home/user/baseDir", "/home/user/mountDir"}),
"Usage:" "Usage:"
); );
} }
TEST_F(ProgramOptionsParserTest, HelpLongOption) { TEST_F(ProgramOptionsParserDeathTest, HelpLongOption) {
EXPECT_DEATH( EXPECT_DEATH(
parse({"./myExecutable", "--help"}), parse({"./myExecutable", "--help"}),
"Usage:" "Usage:"
); );
} }
TEST_F(ProgramOptionsParserTest, HelpShortOption) { TEST_F(ProgramOptionsParserDeathTest, HelpShortOption) {
EXPECT_DEATH( EXPECT_DEATH(
parse({"./myExecutable", "-h"}), parse({"./myExecutable", "-h"}),
"Usage:" "Usage:"