fix macos unit tests
Some checks failed
BlockStorage/repertory_mac/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head There was a failure building this commit

This commit is contained in:
2025-08-02 20:43:31 -05:00
parent 2df11b693c
commit d8f3f87760
2 changed files with 33 additions and 11 deletions

View File

@@ -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);
}

View File

@@ -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));
std::this_thread::sleep_for(SLEEP_SECONDS);
struct stat64 unix_st {};
struct stat64 unix_st{};
stat64(file_path.c_str(), &unix_st);
EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR),
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"};
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);
}