Resolve "increase testing coverage"

This MR increases testing coverage significantly by including additional tests and implementing basic syscall testing.

It also fixes the following issues:

  • Include <array> to compile with GCC 12.1
  • Solved SIGSEV in fchdir (When debug is enabled)

Closes #216 (closed)

Edited by Alberto Miranda

Merge request reports

Loading
+1 −0
Changes for include/client/open_file_map.hpp: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include <mutex>
#include <memory>
#include <atomic>
#include <array>

namespace gkfs::filemap {

+2 −0
Changes for include/common/rpc/rpc_util.hpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -44,8 +44,10 @@ bool_to_merc_bool(bool state);
std::string
get_my_hostname(bool short_hostname = false);

#ifdef GKFS_ENABLE_UNUSED_FUNCTIONS
std::string
get_host_by_name(const std::string& hostname);
#endif

} // namespace gkfs::rpc

+4 −2
Changes for src/client/gkfs_functions.cpp: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -411,6 +411,7 @@ gkfs_statfs(struct statfs* buf) {
    return 0;
}

#ifdef GKFS_ENABLE_UNUSED_FUNCTIONS
/**
 * gkfs wrapper for statvfs() system calls
 * errno may be set
@@ -444,6 +445,7 @@ gkfs_statvfs(struct statvfs* buf) {
            ST_NOATIME | ST_NODIRATIME | ST_NOSUID | ST_NODEV | ST_SYNCHRONOUS;
    return 0;
}
#endif

/**
 * gkfs wrapper for lseek() system calls with available file descriptor
@@ -1094,7 +1096,7 @@ gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp,


#ifdef HAS_SYMLINKS

#ifdef GKFS_ENABLE_UNUSED_FUNCTIONS
/**
 * gkfs wrapper for make symlink() system calls
 * errno may be set
@@ -1177,7 +1179,7 @@ gkfs_readlink(const std::string& path, char* buf, int bufsize) {
    std::strcpy(buf + CTX->mountdir().size(), md->target_path().c_str());
    return path_size;
}

#endif
#endif

} // namespace gkfs::syscall
+2 −2
Changes for src/client/hooks.cpp: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -712,8 +712,8 @@ hook_fchdir(unsigned int fd) {
        auto open_dir = CTX->file_map()->get_dir(fd);
        if(open_dir == nullptr) {
            // Cast did not succeeded: open_file is a regular file
            LOG(ERROR, "{}() file descriptor refers to a normal file: '{}'",
                __func__, open_dir->path());
            LOG(ERROR, "{}() file descriptor refers to a normal file",
                __func__);
            return -EBADF;
        }

+2 −1
Changes for src/common/rpc/rpc_util.cpp: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ get_my_hostname(bool short_hostname) {
        return ""s;
}


#ifdef GKFS_ENABLE_UNUSED_FUNCTIONS
string
get_host_by_name(const string& hostname) {
    int err = 0;
@@ -102,5 +102,6 @@ get_host_by_name(const string& hostname) {
    freeaddrinfo(addr);
    return addr_str;
}
#endif

} // namespace gkfs::rpc
 No newline at end of file
Loading
Loading