File: CryfsUnmountTest.cpp

package info (click to toggle)
cryfs 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 28,412 kB
  • sloc: cpp: 150,187; asm: 10,493; python: 1,455; javascript: 65; sh: 50; makefile: 17; xml: 7
file content (25 lines) | stat: -rw-r--r-- 956 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "testutils/CliTest.h"
#include <cryfs-cli/Cli.h>
#include <cryfs-unmount/Cli.h>

using CliTest_Unmount = CliTest;
namespace bf = boost::filesystem;

namespace {
void unmount(const bf::path& mountdir) {
    std::vector<const char*> _args = {"cryfs-unmount", mountdir.string().c_str()};
    cryfs_unmount::Cli().main(2, _args.data());
}

TEST_F(CliTest_Unmount, givenMountedFilesystem_whenUnmounting_thenSucceeds) {
    // we're passing in boost::none as mountdir so EXPECT_RUN_SUCCESS doesn't unmount itself.
    // if the unmount we're calling here in the onMounted callback wouldn't work, EXPECT_RUN_SUCCESS
    // would never return and this would be a deadlock.
    EXPECT_RUN_SUCCESS({basedir.string().c_str(), mountdir.string().c_str(), "-f"}, boost::none, [this] () {
        unmount(mountdir);
    });
}

// TODO Test calling with invalid args, valid '--version' or '--help' args, with a non-mounted mountdir and a nonexisting mountdir.

}