refactor tests
All checks were successful
BlockStorage/repertory_osx_builds/pipeline/head This commit looks good
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2023-11-18 15:34:43 -06:00
parent 7a24cc54f8
commit 4348e89f99
5 changed files with 222 additions and 215 deletions

View File

@ -360,9 +360,17 @@ public:
}
#ifdef REPERTORY_TESTING
void set_host_config(host_config hc) { hc_ = std::move(hc); }
void set_host_config(host_config hc) {
config_changed_ = true;
hc_ = std::move(hc);
save();
}
void set_s3_config(s3_config s3) { s3_config_ = std::move(s3); }
void set_s3_config(s3_config s3) {
config_changed_ = true;
s3_config_ = std::move(s3);
save();
}
#endif
void set_is_remote_mount(bool is_remote_mount);

View File

@ -36,12 +36,9 @@ app_config::app_config(const provider_type &prov,
api_port_(default_rpc_port(prov)),
api_user_("repertory"),
config_changed_(false),
data_directory_(
data_directory.empty() ? default_data_directory(prov)
: ((prov == provider_type::remote) || (prov == provider_type::s3))
? utils::path::absolute(data_directory)
: utils::path::absolute(utils::path::combine(
data_directory, {get_provider_name(prov)}))),
data_directory_(data_directory.empty()
? default_data_directory(prov)
: utils::path::absolute(data_directory)),
download_timeout_secs_(30),
enable_chunk_downloader_timeout_(true),
enable_comm_duration_events_(false),
@ -639,9 +636,9 @@ auto app_config::load() -> bool {
}
void app_config::save() {
const auto configFilePath = get_config_file_path();
const auto file_path = get_config_file_path();
recur_mutex_lock lock(read_write_mutex_);
if (config_changed_ || not utils::file::is_file(configFilePath)) {
if (config_changed_ || not utils::file::is_file(file_path)) {
if (not utils::file::is_directory(data_directory_)) {
if (not utils::file::create_full_directory_path(data_directory_)) {
utils::error::raise_error(
@ -654,7 +651,7 @@ void app_config::save() {
json data = get_json();
auto success = false;
for (auto i = 0; not success && (i < 5); i++) {
if (not(success = utils::file::write_json_file(configFilePath, data))) {
if (not(success = utils::file::write_json_file(file_path, data))) {
std::this_thread::sleep_for(1s);
}
}

View File

@ -121,10 +121,11 @@ auto main(int argc, char **argv) -> int {
std::cerr << "Name of S3 instance not provided" << std::endl;
res = exit_code::invalid_syntax;
} else {
data_directory = utils::path::combine(
data_directory.empty() ? app_config::default_data_directory(prov)
: data_directory,
{unique_id});
data_directory = utils::path::absolute(
data_directory.empty()
? utils::path::combine(app_config::default_data_directory(prov),
{unique_id})
: data_directory);
}
}
}

View File

@ -135,6 +135,9 @@ auto parse_drive_options(int argc, char **argv,
} else if ((std::string(argv[i]) == options::remote_mount_option[0]) ||
(std::string(argv[i]) == options::remote_mount_option[1])) {
i++;
} else if ((std::string(argv[i]) == options::data_directory_option[0]) ||
(std::string(argv[i]) == options::data_directory_option[1])) {
i++;
}
#ifdef REPERTORY_ENABLE_S3
else if ((std::string(argv[i]) == options::name_option[0]) ||

View File

@ -38,29 +38,33 @@
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
#endif
static constexpr const auto SLEEP_SECONDS = 1.5s;
namespace repertory {
static void execute_mount(app_config &cfg, lock_data &ld, i_provider &provider,
static void execute_mount(const std::string &data_directory,
const std::vector<std::string> &drive_args,
std::thread &th) {
EXPECT_EQ(0, fuse_drive(cfg, ld, provider).mount(drive_args));
th.join();
std::thread &mount_thread) {
auto cmd = "./repertory -dd \"" + data_directory + "\"" + " " +
utils::string::join(drive_args, ' ');
std::cout << cmd << std::endl;
EXPECT_EQ(0, system(cmd.c_str()));
mount_thread.join();
}
static void execute_unmount(i_provider &provider,
const std::string &mount_location) {
filesystem_item fsi{};
EXPECT_EQ(api_error::success, provider.get_filesystem_item("/", true, fsi));
EXPECT_STREQ("/", fsi.api_path.c_str());
EXPECT_TRUE(fsi.api_parent.empty());
EXPECT_TRUE(fsi.directory);
EXPECT_EQ(std::uint64_t(0u), fsi.size);
EXPECT_TRUE(fsi.source_path.empty());
api_meta_map meta{};
EXPECT_EQ(api_error::success, provider.get_item_meta("/", meta));
for (const auto &kv : meta) {
std::cout << kv.first << '=' << kv.second << std::endl;
}
static void execute_unmount(const std::string &mount_location) {
// filesystem_item fsi{};
// EXPECT_EQ(api_error::success, provider.get_filesystem_item("/", true,
// fsi)); EXPECT_STREQ("/", fsi.api_path.c_str());
// EXPECT_TRUE(fsi.api_parent.empty());
// EXPECT_TRUE(fsi.directory);
// EXPECT_EQ(std::uint64_t(0u), fsi.size);
// EXPECT_TRUE(fsi.source_path.empty());
//
// api_meta_map meta{};
// EXPECT_EQ(api_error::success, provider.get_item_meta("/", meta));
// for (const auto &kv : meta) {
// std::cout << kv.first << '=' << kv.second << std::endl;
// }
auto unmounted = false;
for (int i = 0; not unmounted && (i < 50); i++) {
@ -75,6 +79,7 @@ static void execute_unmount(i_provider &provider,
static auto create_file_and_test(const std::string &mount_location,
std::string name) -> std::string {
std::cout << __FUNCTION__ << std::endl;
auto file_path =
utils::path::absolute(utils::path::combine(mount_location, {name}));
@ -89,12 +94,13 @@ static auto create_file_and_test(const std::string &mount_location,
EXPECT_EQ(0u, file_size);
EXPECT_EQ(0, close(fd));
std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(SLEEP_SECONDS);
return file_path;
}
static void rmdir_and_test(const std::string &directory_path) {
std::cout << __FUNCTION__ << std::endl;
int ret = 0;
for (auto i = 0; ((ret = rmdir(directory_path.c_str())) != 0) && (i < 20);
i++) {
@ -102,13 +108,14 @@ static void rmdir_and_test(const std::string &directory_path) {
}
EXPECT_EQ(0, ret);
std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(SLEEP_SECONDS);
EXPECT_FALSE(utils::file::is_directory(directory_path));
EXPECT_FALSE(utils::file::is_file(directory_path));
}
static void unlink_file_and_test(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
int ret = 0;
for (auto i = 0; ((ret = unlink(file_path.c_str())) != 0) && (i < 20); i++) {
std::this_thread::sleep_for(100ms);
@ -116,66 +123,63 @@ static void unlink_file_and_test(const std::string &file_path) {
EXPECT_EQ(0, ret);
std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(SLEEP_SECONDS);
EXPECT_FALSE(utils::file::is_directory(file_path));
EXPECT_FALSE(utils::file::is_file(file_path));
}
static void test_chmod(const std::string &api_path,
const std::string &file_path, i_provider &provider) {
const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR));
std::string mode;
EXPECT_EQ(api_error::success,
provider.get_item_meta(api_path.c_str(), META_MODE, mode));
std::this_thread::sleep_for(SLEEP_SECONDS);
struct stat64 path_stat {};
stat64(file_path.c_str(), &path_stat);
EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR),
ACCESSPERMS & utils::string::to_uint32(mode));
ACCESSPERMS & path_stat.st_mode);
}
static void test_chown(const std::string &api_path,
const std::string &file_path, i_provider &provider) {
const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
EXPECT_EQ(0, chown(file_path.c_str(), -1, 0));
std::string gid;
EXPECT_EQ(api_error::success,
provider.get_item_meta(api_path, META_GID, gid));
EXPECT_STREQ("0", gid.c_str());
std::this_thread::sleep_for(SLEEP_SECONDS);
struct stat64 path_stat {};
stat64(file_path.c_str(), &path_stat);
EXPECT_EQ(0, path_stat.st_gid);
EXPECT_EQ(0, chown(file_path.c_str(), 0, -1));
std::string uid;
EXPECT_EQ(api_error::success,
provider.get_item_meta(api_path, META_UID, uid));
EXPECT_STREQ("0", uid.c_str());
std::this_thread::sleep_for(SLEEP_SECONDS);
stat64(file_path.c_str(), &path_stat);
EXPECT_EQ(0, path_stat.st_gid);
}
static void test_mkdir(const std::string &api_path,
const std::string &directory_path,
i_provider &provider) {
const std::string &directory_path) {
std::cout << __FUNCTION__ << std::endl;
EXPECT_EQ(0, mkdir(directory_path.c_str(),
S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP));
EXPECT_TRUE(utils::file::is_directory(directory_path));
EXPECT_FALSE(utils::file::is_file(directory_path));
std::string uid;
EXPECT_EQ(api_error::success,
provider.get_item_meta(api_path, META_UID, uid));
EXPECT_EQ(getuid(), utils::string::to_uint32(uid));
struct stat64 path_stat {};
stat64(directory_path.c_str(), &path_stat);
std::string gid;
EXPECT_EQ(api_error::success,
provider.get_item_meta(api_path, META_GID, gid));
EXPECT_EQ(getgid(), utils::string::to_uint32(gid));
EXPECT_EQ(getuid(), path_stat.st_uid);
EXPECT_EQ(getgid(), path_stat.st_gid);
std::string mode;
EXPECT_EQ(api_error::success,
provider.get_item_meta(api_path, META_MODE, mode));
EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP |
S_IXGRP),
ACCESSPERMS & (utils::string::to_uint32(mode)));
ACCESSPERMS & path_stat.st_mode);
}
static void test_write_and_read(const std::string &api_path,
const std::string &file_path,
i_provider &provider) {
const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
auto fd =
open(file_path.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP);
EXPECT_LE(1, fd);
@ -195,29 +199,30 @@ static void test_write_and_read(const std::string &api_path,
EXPECT_EQ(0, close(fd));
std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(SLEEP_SECONDS);
std::uint64_t file_size{};
EXPECT_TRUE(utils::file::get_file_size(file_path, file_size));
EXPECT_EQ(data.size(), file_size);
filesystem_item fsi{};
EXPECT_EQ(api_error::success,
provider.get_filesystem_item(api_path, false, fsi));
EXPECT_TRUE(utils::file::get_file_size(fsi.source_path, file_size));
EXPECT_EQ(data.size(), file_size);
// filesystem_item fsi{};
// EXPECT_EQ(api_error::success,
// provider.get_filesystem_item(api_path, false, fsi));
// EXPECT_TRUE(utils::file::get_file_size(fsi.source_path, file_size));
// EXPECT_EQ(data.size(), file_size);
}
static void test_rename_file(const std::string &from_file_path,
const std::string &to_file_path,
i_provider &provider) {
bool is_rename_supported) {
std::cout << __FUNCTION__ << std::endl;
auto fd = open(from_file_path.c_str(), O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP);
EXPECT_LE(1, fd);
close(fd);
std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(SLEEP_SECONDS);
if (provider.is_rename_supported()) {
if (is_rename_supported) {
EXPECT_EQ(0, rename(from_file_path.c_str(), to_file_path.c_str()));
EXPECT_FALSE(utils::file::is_file(from_file_path));
EXPECT_TRUE(utils::file::is_file(to_file_path));
@ -230,13 +235,14 @@ static void test_rename_file(const std::string &from_file_path,
static void test_rename_directory(const std::string &from_dir_path,
const std::string &to_dir_path,
i_provider &provider) {
bool is_rename_supported) {
std::cout << __FUNCTION__ << std::endl;
EXPECT_EQ(0, mkdir(from_dir_path.c_str(),
S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP));
std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(SLEEP_SECONDS);
EXPECT_TRUE(utils::file::is_directory(from_dir_path));
if (provider.is_rename_supported()) {
if (is_rename_supported) {
EXPECT_EQ(0, rename(from_dir_path.c_str(), to_dir_path.c_str()));
EXPECT_FALSE(utils::file::is_directory(from_dir_path));
EXPECT_TRUE(utils::file::is_directory(to_dir_path));
@ -248,6 +254,7 @@ static void test_rename_directory(const std::string &from_dir_path,
}
static void test_truncate(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
EXPECT_EQ(0, truncate(file_path.c_str(), 10u));
std::uint64_t file_size{};
@ -257,6 +264,7 @@ static void test_truncate(const std::string &file_path) {
}
static void test_ftruncate(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
auto fd = open(file_path.c_str(), O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP);
EXPECT_LE(1, fd);
@ -272,7 +280,8 @@ static void test_ftruncate(const std::string &file_path) {
#ifndef __APPLE__
static void test_fallocate(const std::string &api_path,
const std::string &file_path, i_provider &provider) {
const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
auto fd =
open(file_path.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP);
EXPECT_LE(1, fd);
@ -284,19 +293,23 @@ static void test_fallocate(const std::string &api_path,
EXPECT_EQ(0, close(fd));
filesystem_item fsi{};
EXPECT_EQ(api_error::success,
provider.get_filesystem_item(api_path, false, fsi));
file_size = 0u;
EXPECT_TRUE(utils::file::get_file_size(fsi.source_path, file_size));
EXPECT_TRUE(utils::file::get_file_size(file_path, file_size));
EXPECT_EQ(16u, file_size);
// filesystem_item fsi{};
// EXPECT_EQ(api_error::success,
// provider.get_filesystem_item(api_path, false, fsi));
// file_size = 0u;
// EXPECT_TRUE(utils::file::get_file_size(fsi.source_path, file_size));
// EXPECT_EQ(16u, file_size);
}
#endif
static void test_file_getattr(const std::string & /* api_path */,
const std::string &file_path,
i_provider & /* provider */) {
const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
auto fd =
open(file_path.c_str(), O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP);
EXPECT_LE(1, fd);
@ -312,8 +325,8 @@ static void test_file_getattr(const std::string & /* api_path */,
}
static void test_directory_getattr(const std::string & /* api_path */,
const std::string &directory_path,
i_provider & /* provider */) {
const std::string &directory_path) {
std::cout << __FUNCTION__ << std::endl;
EXPECT_EQ(0, mkdir(directory_path.c_str(),
S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP));
@ -328,8 +341,8 @@ static void test_directory_getattr(const std::string & /* api_path */,
static void
test_write_operations_fail_if_read_only(const std::string &api_path,
const std::string &file_path,
i_provider &provider) {
const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
auto fd =
open(file_path.c_str(), O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP);
EXPECT_LE(1, fd);
@ -345,21 +358,22 @@ test_write_operations_fail_if_read_only(const std::string &api_path,
EXPECT_EQ(0, close(fd));
std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(SLEEP_SECONDS);
std::uint64_t file_size{};
EXPECT_TRUE(utils::file::get_file_size(file_path, file_size));
EXPECT_EQ(std::size_t(0u), file_size);
filesystem_item fsi{};
EXPECT_EQ(api_error::success,
provider.get_filesystem_item(api_path, false, fsi));
EXPECT_TRUE(utils::file::get_file_size(fsi.source_path, file_size));
EXPECT_EQ(std::size_t(0u), file_size);
// filesystem_item fsi{};
// EXPECT_EQ(api_error::success,
// provider.get_filesystem_item(api_path, false, fsi));
// EXPECT_TRUE(utils::file::get_file_size(fsi.source_path, file_size));
// EXPECT_EQ(std::size_t(0u), file_size);
}
#if !__APPLE__ && HAS_SETXATTR
static void test_xattr_invalid_parameters(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
std::string attr = "moose";
EXPECT_EQ(-1, setxattr(nullptr, "user.test_attr", attr.data(), attr.size(),
XATTR_CREATE));
@ -375,6 +389,7 @@ static void test_xattr_invalid_parameters(const std::string &file_path) {
}
static void test_xattr_create_and_get(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
std::string attr = "moose";
EXPECT_EQ(0, setxattr(file_path.c_str(), "user.test_attr", attr.data(),
attr.size(), XATTR_CREATE));
@ -388,6 +403,7 @@ static void test_xattr_create_and_get(const std::string &file_path) {
}
static void test_xattr_listxattr(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
std::string attr = "moose";
EXPECT_EQ(0, setxattr(file_path.c_str(), "user.test_attr", attr.data(),
attr.size(), XATTR_CREATE));
@ -416,6 +432,7 @@ static void test_xattr_listxattr(const std::string &file_path) {
}
static void test_xattr_replace(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
std::string attr = "moose";
EXPECT_EQ(0, setxattr(file_path.c_str(), "user.test_attr", attr.data(),
attr.size(), XATTR_CREATE));
@ -433,6 +450,7 @@ static void test_xattr_replace(const std::string &file_path) {
}
static void test_xattr_default_create(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
std::string attr = "moose";
EXPECT_EQ(0, setxattr(file_path.c_str(), "user.test_attr", attr.data(),
attr.size(), 0));
@ -446,6 +464,7 @@ static void test_xattr_default_create(const std::string &file_path) {
}
static void test_xattr_default_replace(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
std::string attr = "moose";
EXPECT_EQ(0, setxattr(file_path.c_str(), "user.test_attr", attr.data(),
attr.size(), 0));
@ -463,6 +482,7 @@ static void test_xattr_default_replace(const std::string &file_path) {
}
static void test_xattr_create_fails_if_exists(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
std::string attr = "moose";
EXPECT_EQ(0, setxattr(file_path.c_str(), "user.test_attr", attr.data(),
attr.size(), 0));
@ -473,6 +493,7 @@ static void test_xattr_create_fails_if_exists(const std::string &file_path) {
static void
test_xattr_create_fails_if_not_exists(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
std::string attr = "moose";
EXPECT_EQ(-1, setxattr(file_path.c_str(), "user.test_attr", attr.data(),
attr.size(), XATTR_REPLACE));
@ -480,6 +501,7 @@ test_xattr_create_fails_if_not_exists(const std::string &file_path) {
}
static void test_xattr_removexattr(const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl;
std::string attr = "moose";
EXPECT_EQ(0, setxattr(file_path.c_str(), "user.test_attr", attr.data(),
attr.size(), XATTR_CREATE));
@ -511,13 +533,14 @@ TEST(fuse_drive, all_tests) {
std::unique_ptr<app_config> config_ptr{};
std::unique_ptr<curl_comm> comm_ptr{};
std::unique_ptr<i_provider> provider_ptr{};
std::unique_ptr<lock_data> lock_data_ptr{};
const auto cfg_directory = utils::path::absolute(
utils::path::combine(test_directory, {"cfg", std::to_string(idx)}));
EXPECT_TRUE(utils::file::delete_directory_recursively(cfg_directory));
EXPECT_TRUE(utils::file::create_full_directory_path(cfg_directory));
std::vector<std::string> drive_args{};
switch (idx) {
case 0U: {
#ifdef REPERTORY_ENABLE_S3
@ -533,8 +556,7 @@ TEST(fuse_drive, all_tests) {
comm_ptr = std::make_unique<curl_comm>(config_ptr->get_s3_config());
provider_ptr = std::make_unique<s3_provider>(*config_ptr, *comm_ptr);
lock_data_ptr = std::make_unique<lock_data>(
provider_type::s3, "unittests_" + std::to_string(idx));
drive_args = std::vector<std::string>({"-s3", "-na", "storj"});
#else
continue;
#endif
@ -553,8 +575,6 @@ TEST(fuse_drive, all_tests) {
comm_ptr = std::make_unique<curl_comm>(config_ptr->get_host_config());
provider_ptr = std::make_unique<sia_provider>(*config_ptr, *comm_ptr);
lock_data_ptr = std::make_unique<lock_data>(
provider_type::sia, "unittests_" + std::to_string(idx));
} break;
default:
@ -563,45 +583,33 @@ TEST(fuse_drive, all_tests) {
continue;
}
event_capture ec({
"drive_mounted",
"drive_unmounted",
"drive_unmount_pending",
"drive_mount_result",
});
std::thread th([&] {
const auto mounted = ec.wait_for_event("drive_mounted");
EXPECT_TRUE(mounted);
if (mounted) {
EXPECT_EQ(0,
system(("mount|grep \"" + mount_location + "\"").c_str()));
std::this_thread::sleep_for(5s);
EXPECT_EQ(0, system(("mount|grep \"" + mount_location + "\"").c_str()));
auto file_path = create_file_and_test(mount_location, "chmod_test");
test_chmod(utils::path::create_api_path("chmod_test"), file_path,
*provider_ptr);
test_chmod(utils::path::create_api_path("chmod_test"), file_path);
unlink_file_and_test(file_path);
file_path = create_file_and_test(mount_location, "chown_test");
test_chown(utils::path::create_api_path("chown_test"), file_path,
*provider_ptr);
test_chown(utils::path::create_api_path("chown_test"), file_path);
unlink_file_and_test(file_path);
file_path = utils::path::combine(mount_location, {"mkdir_test"});
test_mkdir(utils::path::create_api_path("mkdir_test"), file_path,
*provider_ptr);
test_mkdir(utils::path::create_api_path("mkdir_test"), file_path);
rmdir_and_test(file_path);
file_path = create_file_and_test(mount_location, "write_read_test");
test_write_and_read(utils::path::create_api_path("write_read_test"),
file_path, *provider_ptr);
file_path);
unlink_file_and_test(file_path);
file_path =
create_file_and_test(mount_location, "from_rename_file_test");
auto to_file_path = utils::path::absolute(
utils::path::combine(mount_location, {"to_rename_file_test"}));
test_rename_file(file_path, to_file_path, *provider_ptr);
test_rename_file(file_path, to_file_path,
provider_ptr->is_rename_supported());
EXPECT_TRUE(utils::file::retry_delete_file(file_path));
EXPECT_TRUE(utils::file::retry_delete_file(to_file_path));
@ -609,44 +617,39 @@ TEST(fuse_drive, all_tests) {
utils::path::combine(mount_location, {"from_rename_dir_test"}));
to_file_path = utils::path::absolute(
utils::path::combine(mount_location, {"to_rename_dir_test"}));
test_rename_directory(file_path, to_file_path, *provider_ptr);
test_rename_directory(file_path, to_file_path,
provider_ptr->is_rename_supported());
EXPECT_TRUE(utils::file::retry_delete_directory(file_path.c_str()));
EXPECT_TRUE(
utils::file::retry_delete_directory(to_file_path.c_str()));
EXPECT_TRUE(utils::file::retry_delete_directory(to_file_path.c_str()));
file_path =
create_file_and_test(mount_location, "truncate_file_test");
file_path = create_file_and_test(mount_location, "truncate_file_test");
test_truncate(file_path);
unlink_file_and_test(file_path);
file_path =
create_file_and_test(mount_location, "ftruncate_file_test");
file_path = create_file_and_test(mount_location, "ftruncate_file_test");
test_ftruncate(file_path);
unlink_file_and_test(file_path);
#ifndef __APPLE__
file_path =
create_file_and_test(mount_location, "fallocate_file_test");
file_path = create_file_and_test(mount_location, "fallocate_file_test");
test_fallocate(utils::path::create_api_path("fallocate_file_test"),
file_path, *provider_ptr);
file_path);
unlink_file_and_test(file_path);
#endif
file_path =
create_file_and_test(mount_location, "write_fails_ro_test");
file_path = create_file_and_test(mount_location, "write_fails_ro_test");
test_write_operations_fail_if_read_only(
utils::path::create_api_path("write_fails_ro_test"), file_path,
*provider_ptr);
utils::path::create_api_path("write_fails_ro_test"), file_path);
unlink_file_and_test(file_path);
file_path = create_file_and_test(mount_location, "getattr.txt");
test_file_getattr(utils::path::create_api_path("getattr.txt"),
file_path, *provider_ptr);
file_path);
unlink_file_and_test(file_path);
file_path = utils::path::combine(mount_location, {"getattr_dir"});
test_directory_getattr(utils::path::create_api_path("getattr_dir"),
file_path, *provider_ptr);
file_path);
rmdir_and_test(file_path);
#if !__APPLE__ && HAS_SETXATTR
@ -665,8 +668,7 @@ TEST(fuse_drive, all_tests) {
test_xattr_listxattr(file_path);
unlink_file_and_test(file_path);
file_path =
create_file_and_test(mount_location, "xattr_replace_test");
file_path = create_file_and_test(mount_location, "xattr_replace_test");
test_xattr_replace(file_path);
unlink_file_and_test(file_path);
@ -675,8 +677,8 @@ TEST(fuse_drive, all_tests) {
test_xattr_default_create(file_path);
unlink_file_and_test(file_path);
file_path = create_file_and_test(mount_location,
"xattr_default_replace_test");
file_path =
create_file_and_test(mount_location, "xattr_default_replace_test");
test_xattr_default_replace(file_path);
unlink_file_and_test(file_path);
@ -685,8 +687,8 @@ TEST(fuse_drive, all_tests) {
test_xattr_create_fails_if_exists(file_path);
unlink_file_and_test(file_path);
file_path = create_file_and_test(
mount_location, "xattr_create_fails_not_exists_test");
file_path = create_file_and_test(mount_location,
"xattr_create_fails_not_exists_test");
test_xattr_create_fails_if_not_exists(file_path);
unlink_file_and_test(file_path);
@ -695,16 +697,12 @@ TEST(fuse_drive, all_tests) {
test_xattr_removexattr(file_path);
unlink_file_and_test(file_path);
#endif
}
execute_unmount(*provider_ptr, mount_location);
execute_unmount(mount_location);
});
auto drive_args =
std::vector<std::string>({"unittests", "-f", mount_location});
execute_mount(*config_ptr, *lock_data_ptr, *provider_ptr, drive_args, th);
ec.wait_for_empty();
drive_args.push_back(mount_location);
execute_mount(config_ptr->get_data_directory(), drive_args, th);
}
EXPECT_TRUE(utils::file::delete_directory_recursively(mount_location));