fix macos unit tests
This commit is contained in:
@@ -133,7 +133,6 @@ protected:
|
|||||||
"-s3",
|
"-s3",
|
||||||
"-na",
|
"-na",
|
||||||
"s3",
|
"s3",
|
||||||
mount_location,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +178,6 @@ protected:
|
|||||||
config->get_data_directory(),
|
config->get_data_directory(),
|
||||||
"-na",
|
"-na",
|
||||||
"sia",
|
"sia",
|
||||||
mount_location,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,11 +216,10 @@ protected:
|
|||||||
config2->get_data_directory(),
|
config2->get_data_directory(),
|
||||||
"-rm",
|
"-rm",
|
||||||
fmt::format("localhost:{}", port),
|
fmt::format("localhost:{}", port),
|
||||||
mount_location,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
execute_mount(drive_args2, mount_location);
|
execute_mount(drive_args2, mount_location2);
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (provider_t::type) {
|
switch (provider_t::type) {
|
||||||
@@ -264,10 +261,10 @@ protected:
|
|||||||
|
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestCase() {
|
||||||
if (provider_t::type == provider_type::remote) {
|
if (provider_t::type == provider_type::remote) {
|
||||||
execute_unmount(mount_location);
|
execute_unmount(drive_args);
|
||||||
execute_unmount(mount_location2);
|
execute_unmount(drive_args2);
|
||||||
} else {
|
} else {
|
||||||
execute_unmount(mount_location);
|
execute_unmount(drive_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.reset();
|
meta.reset();
|
||||||
@@ -353,19 +350,26 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void execute_mount(auto args, auto location) {
|
static void execute_mount(auto args, auto location) {
|
||||||
|
args.emplace_back(location);
|
||||||
auto mount_cmd = "./repertory " + utils::string::join(args, ' ');
|
auto mount_cmd = "./repertory " + utils::string::join(args, ' ');
|
||||||
std::cout << "mount command: " << mount_cmd << std::endl;
|
std::cout << "mount command: " << mount_cmd << std::endl;
|
||||||
|
|
||||||
ASSERT_EQ(0, system(mount_cmd.c_str()));
|
ASSERT_EQ(0, system(mount_cmd.c_str()));
|
||||||
std::this_thread::sleep_for(5s);
|
std::this_thread::sleep_for(5s);
|
||||||
ASSERT_TRUE(utils::file::directory{location}.exists());
|
ASSERT_TRUE(utils::file::directory{location}.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void execute_unmount(auto location) {
|
static void execute_unmount(auto args) {
|
||||||
auto unmounted{false};
|
auto unmounted{false};
|
||||||
|
|
||||||
|
args.emplace_back("-unmount");
|
||||||
|
auto unmount_cmd = "./repertory " + utils::string::join(args, ' ');
|
||||||
|
std::cout << "unmount command: " << unmount_cmd << std::endl;
|
||||||
|
|
||||||
for (int i = 0; not unmounted && (i < 50); i++) {
|
for (int i = 0; not unmounted && (i < 50); i++) {
|
||||||
auto res = fuse_base::unmount(location);
|
auto res = system(unmount_cmd.c_str());
|
||||||
unmounted = res == 0;
|
unmounted = res == 0;
|
||||||
ASSERT_EQ(0, res);
|
EXPECT_EQ(0, res);
|
||||||
if (not unmounted) {
|
if (not unmounted) {
|
||||||
std::this_thread::sleep_for(5s);
|
std::this_thread::sleep_for(5s);
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,7 @@ TYPED_TEST(fuse_test, chmod_can_chmod_if_owner) {
|
|||||||
EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR));
|
EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR));
|
||||||
std::this_thread::sleep_for(SLEEP_SECONDS);
|
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||||
|
|
||||||
struct stat64 unix_st {};
|
struct stat64 unix_st{};
|
||||||
stat64(file_path.c_str(), &unix_st);
|
stat64(file_path.c_str(), &unix_st);
|
||||||
EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR),
|
EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR),
|
||||||
ACCESSPERMS & unix_st.st_mode);
|
ACCESSPERMS & unix_st.st_mode);
|
||||||
@@ -65,8 +65,17 @@ TYPED_TEST(fuse_test, chmod_can_not_chmod_setgid_if_not_root) {
|
|||||||
std::string file_name{"chmod_test"};
|
std::string file_name{"chmod_test"};
|
||||||
auto file_path = this->create_file_and_test(file_name);
|
auto file_path = this->create_file_and_test(file_name);
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISGID));
|
||||||
|
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||||
|
|
||||||
|
struct stat64 unix_st{};
|
||||||
|
stat64(file_path.c_str(), &unix_st);
|
||||||
|
EXPECT_EQ(0, S_ISGID & unix_st.st_mode);
|
||||||
|
#else // !defined(__APPLE__)
|
||||||
EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISGID));
|
EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISGID));
|
||||||
EXPECT_EQ(EPERM, errno);
|
EXPECT_EQ(EPERM, errno);
|
||||||
|
#endif // defined(__APPLE__)
|
||||||
|
|
||||||
this->unlink_file_and_test(file_path);
|
this->unlink_file_and_test(file_path);
|
||||||
}
|
}
|
||||||
@@ -75,8 +84,17 @@ TYPED_TEST(fuse_test, chmod_can_not_chmod_setuid_if_not_root) {
|
|||||||
std::string file_name{"chmod_test"};
|
std::string file_name{"chmod_test"};
|
||||||
auto file_path = this->create_file_and_test(file_name);
|
auto file_path = this->create_file_and_test(file_name);
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISUID));
|
||||||
|
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||||
|
|
||||||
|
struct stat64 unix_st{};
|
||||||
|
stat64(file_path.c_str(), &unix_st);
|
||||||
|
EXPECT_EQ(0, S_ISUID & unix_st.st_mode);
|
||||||
|
#else // !defined(__APPLE__)
|
||||||
EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISUID));
|
EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISUID));
|
||||||
EXPECT_EQ(EPERM, errno);
|
EXPECT_EQ(EPERM, errno);
|
||||||
|
#endif // defined(__APPLE__)
|
||||||
|
|
||||||
this->unlink_file_and_test(file_path);
|
this->unlink_file_and_test(file_path);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user