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