diff --git a/repertory/repertory_test/include/fixtures/fuse_fixture.hpp b/repertory/repertory_test/include/fixtures/fuse_fixture.hpp index 002cddaf..e6acc0b4 100644 --- a/repertory/repertory_test/include/fixtures/fuse_fixture.hpp +++ b/repertory/repertory_test/include/fixtures/fuse_fixture.hpp @@ -164,7 +164,9 @@ public: auto opt_size = utils::file::file{file_path}.size(); EXPECT_TRUE(opt_size.has_value()); - EXPECT_EQ(0U, opt_size.value()); + if (opt_size.has_value()) { + EXPECT_EQ(0U, opt_size.value()); + } EXPECT_EQ(0, close(fd)); std::this_thread::sleep_for(SLEEP_SECONDS); @@ -174,10 +176,7 @@ public: static auto create_root_file(std::string &file_name) -> std::string { auto file_path = create_file_and_test(file_name); - std::cout << file_path << std::endl; - auto api_path = utils::path::create_api_path(file_name); - std::cout << api_path << std::endl; meta->set_item_meta(api_path, { {META_UID, "0"}, @@ -205,8 +204,9 @@ public: 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())); - unmounted = not utils::file::directory{mount_location}.exists(); + auto res = system(unmount_cmd.c_str()); + unmounted = res == 0; + ASSERT_EQ(0, res); if (not unmounted) { std::this_thread::sleep_for(5s); } diff --git a/repertory/repertory_test/src/fuse_drive_test.cpp b/repertory/repertory_test/src/fuse_drive_test.cpp index 49869eb2..ec0a52c6 100644 --- a/repertory/repertory_test/src/fuse_drive_test.cpp +++ b/repertory/repertory_test/src/fuse_drive_test.cpp @@ -581,6 +581,7 @@ TYPED_TEST(fuse_test, can_chown_group_if_owner_and_a_member_of_the_group) { EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); EXPECT_EQ(0, chown(file_path.c_str(), static_cast(-1), getgid())); + std::cout << errno << std::endl; std::this_thread::sleep_for(SLEEP_SECONDS); struct stat64 unix_st2 {}; diff --git a/support/include/utils/common.hpp b/support/include/utils/common.hpp index 006ea367..1da0974b 100644 --- a/support/include/utils/common.hpp +++ b/support/include/utils/common.hpp @@ -26,9 +26,9 @@ namespace repertory::utils { struct result final { - std::string_view function_name; - bool ok{false}; - std::string reason{}; + std::string function_name; + bool ok{true}; + std::string reason{"success"}; [[nodiscard]] operator bool() const { return ok; } }; diff --git a/support/include/utils/unix.hpp b/support/include/utils/unix.hpp index 5ea7e84e..4c54d828 100644 --- a/support/include/utils/unix.hpp +++ b/support/include/utils/unix.hpp @@ -41,8 +41,7 @@ convert_to_uint64(const thread_t *thread_ptr) -> std::uint64_t; [[nodiscard]] auto get_thread_id() -> std::uint64_t; -[[nodiscard]] auto is_uid_member_of_group(const uid_t &uid, - const gid_t &gid) -> bool; +[[nodiscard]] auto is_uid_member_of_group(uid_t uid, gid_t gid) -> bool; void set_last_error_code(int error_code); diff --git a/support/src/utils/path.cpp b/support/src/utils/path.cpp index 901570ec..7bde8000 100644 --- a/support/src/utils/path.cpp +++ b/support/src/utils/path.cpp @@ -64,7 +64,7 @@ namespace { home = repertory::utils::path::combine("/home", {pw->pw_name}); } }); - if (res) { + if (not res) { throw repertory::utils::error::create_exception(function_name, { "failed to getpwuid", diff --git a/support/src/utils/unix.cpp b/support/src/utils/unix.cpp index d997dc4e..ff5f0509 100644 --- a/support/src/utils/unix.cpp +++ b/support/src/utils/unix.cpp @@ -19,11 +19,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include #if !defined(_WIN32) -#include "utils/collection.hpp" #include "utils/unix.hpp" +#include "utils/collection.hpp" namespace repertory::utils { #if !defined(__APPLE__) @@ -38,7 +37,7 @@ auto get_thread_id() -> std::uint64_t { return convert_to_uint64(pthread_self()); } -auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool { +auto is_uid_member_of_group(uid_t uid, gid_t gid) -> bool { std::vector groups{}; auto res = use_getpwuid(uid, [&groups](struct passwd *pass) { int group_count{}; @@ -53,7 +52,7 @@ auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool { } }); - if (not res.ok) { + if (not res) { throw utils::error::create_exception(res.function_name, {"use_getpwuid failed", res.reason}); } @@ -69,11 +68,15 @@ auto use_getpwuid(uid_t uid, passwd_callback_t callback) -> result { auto *temp_pw = getpwuid(uid); if (temp_pw == nullptr) { - return {function_name, false, "'getpwuid' returned nullptr"}; + return { + std::string{function_name}, + false, + "'getpwuid' returned nullptr", + }; } callback(temp_pw); - return {function_name}; + return {std::string{function_name}}; } } // namespace repertory::utils