winfsp unit tests and fixes

This commit is contained in:
Scott E. Graves 2024-10-29 14:29:10 -05:00
parent ec2b8e1854
commit d6aace8c51

View File

@ -49,6 +49,7 @@ public:
static std::unique_ptr<app_config> config;
static std::filesystem::path current_directory;
static std::unique_ptr<winfsp_drive> drive;
static std::vector<std::string> drive_args;
static std::string mount_location;
static std::unique_ptr<i_provider> provider;
static std::string test_directory;
@ -70,8 +71,6 @@ protected:
config = std::make_unique<app_config>(provider_t::type, cfg_directory);
std::vector<std::string> drive_args{};
switch (provider_t::type) {
case provider_type::s3: {
{
@ -99,11 +98,17 @@ protected:
utils::path::combine(test::get_test_config_dir(), {"sia"}),
};
config->set_enable_drive_events(true);
config->set_event_level(event_level::debug);
config->set_event_level(event_level::trace);
config->set_host_config(src_cfg.get_host_config());
config->set_sia_config(src_cfg.get_sia_config());
}
comm = std::make_unique<curl_comm>(config->get_host_config());
drive_args = std::vector<std::string>({
"-na",
"sia",
});
} break;
// case 0U: {
// config =
@ -130,6 +135,7 @@ protected:
provider = std::make_unique<provider_t>(*config, *comm);
drive_args.push_back(mount_location);
execute_mount();
}
static void TearDownTestCase() {
@ -192,7 +198,7 @@ public:
EXPECT_FALSE(utils::file::file(file_path).exists());
}
static void execute_mount(auto &&drive_args) {
static void execute_mount() {
auto mount_cmd = ".\\repertory.exe -dd \"" + config->get_data_directory() +
"\"" + " " + utils::string::join(drive_args, ' ');
std::cout << "mount command: " << mount_cmd << std::endl;
@ -205,10 +211,11 @@ public:
auto unmounted{false};
auto unmount_cmd = ".\\repertory.exe -dd \"" +
config->get_data_directory() + "\" -unmount";
config->get_data_directory() + "\"" + " " +
utils::string::join(drive_args, ' ') + " -unmount";
for (int i = 0; not unmounted && (i < 50); i++) {
std::cout << "unmount command: " << unmount_cmd << std::endl;
ASSERT_EQ(0, system(unmount_cmd.c_str()));
system(unmount_cmd.c_str());
unmounted = not utils::file::directory{mount_location}.exists();
if (not unmounted) {
std::this_thread::sleep_for(5s);
@ -222,6 +229,9 @@ public:
template <typename provider_t>
std::string winfsp_test<provider_t>::cfg_directory;
template <typename provider_t>
std::unique_ptr<curl_comm> winfsp_test<provider_t>::comm;
template <typename provider_t>
std::unique_ptr<app_config> winfsp_test<provider_t>::config;
@ -229,7 +239,10 @@ template <typename provider_t>
std::filesystem::path winfsp_test<provider_t>::current_directory;
template <typename provider_t>
std::unique_ptr<curl_comm> winfsp_test<provider_t>::comm;
std::unique_ptr<winfsp_drive> winfsp_test<provider_t>::drive;
template <typename provider_t>
std::vector<std::string> winfsp_test<provider_t>::drive_args;
template <typename provider_t>
std::string winfsp_test<provider_t>::mount_location;
@ -240,9 +253,6 @@ std::unique_ptr<i_provider> winfsp_test<provider_t>::provider;
template <typename provider_t>
std::string winfsp_test<provider_t>::test_directory;
template <typename provider_t>
std::unique_ptr<winfsp_drive> winfsp_test<provider_t>::drive;
using winfsp_provider_types = ::testing::Types<s3_provider>;
// using winfsp_provider_types = ::testing::Types<s3_provider, sia_provider>;
} // namespace repertory