#pragma once #ifndef MESSMER_CRYFS_TEST_CLI_TESTUTILS_CLITEST_H #define MESSMER_CRYFS_TEST_CLI_TESTUTILS_CLITEST_H #include #include #include #include "../../../src/Cli.h" class CliTest : public ::testing::Test { public: CliTest(): basedir(std::make_shared()), mountdir(std::make_shared()), logfile(), configfile(false) {} std::shared_ptr basedir; std::shared_ptr mountdir; cpputils::TempFile logfile; cpputils::TempFile configfile; void run(std::vector args) { std::vector _args; _args.reserve(args.size()+1); _args.push_back(const_cast("cryfs")); for (const char *arg : args) { _args.push_back(const_cast(arg)); } cryfs::Cli().main(_args.size(), _args.data()); } void EXPECT_EXIT_WITH_HELP_MESSAGE(std::vector args) { EXPECT_RUN_ERROR(args, "Usage"); } void EXPECT_RUN_ERROR(std::vector args, const char *message) { EXPECT_EXIT( run(args), ::testing::ExitedWithCode(1), message ); } void EXPECT_RUN_SUCCESS(std::vector args) { //TODO /*EXPECT_EXIT( run(args), ::testing::ExitedWithCode(0), "Filesystem is running" );*/ //TODO Then stop running cryfs process again } }; #endif