Verified Commit aa69c39b authored by Ramon Nou's avatar Ramon Nou Committed by Marc Vef
Browse files

Modify ext to int rename test

parent 6e1e69bd
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -891,8 +891,12 @@ hook_renameat(int olddfd, const char* oldname, int newdfd, const char* newname,

        case gkfs::preload::RelativizeStatus::internal:
#ifdef HAS_RENAME
            if(oldpath_status == gkfs::preload::RelativizeStatus::internal) {
                return with_errno(gkfs::syscall::gkfs_rename(oldpath_resolved,
                                                             newpath_resolved));
            } else {
                return -ENOTSUP;
            }
#else
            return -ENOTSUP;
#endif
+7 −0
Original line number Diff line number Diff line
@@ -125,11 +125,16 @@ gkfs_add_python_test(
    PYTHON_VERSION 3.6
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/integration
    SOURCE syscalls/
)

if (RENAME_SUPPORT)
gkfs_add_python_test(
    NAME test_rename
    PYTHON_VERSION 3.6
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/integration
    SOURCE rename/
)
endif()

if(GKFS_INSTALL_TESTS)
    install(DIRECTORY harness
@@ -218,6 +223,7 @@ if(GKFS_INSTALL_TESTS)
    )
    endif ()

    if (RENAME_SUPPORT)
    install(DIRECTORY rename
        DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gkfs/tests/integration
        FILES_MATCHING
@@ -226,6 +232,7 @@ if(GKFS_INSTALL_TESTS)
            PATTERN ".pytest_cache" EXCLUDE
    )
    endif()
endif()


+9 −5
Original line number Diff line number Diff line
@@ -366,21 +366,25 @@ syscall_coverage_exec(const syscall_coverage_options& opts) {
        return;
    }

    std::string pid = std::to_string(getpid());
    std::string path1 = "/tmp/"+pid+"test_rename";
    std::string path2 = "/tmp/"+pid+"test_rename2";

    // renameat external
    auto fdtmp = ::open("/tmp/test_rename", O_CREAT | O_WRONLY, 0644);
    ::close(fdtmp);

    rv = ::renameat(AT_FDCWD, "/tmp/test_rename", AT_FDCWD,
    rv = ::renameat(AT_FDCWD, path1.c_str(), AT_FDCWD,
                    opts.pathname.c_str());
    if(errno != ENOTSUP) {
        output("renameat", rv, opts);
        output("renameat_ext_to_int", rv, opts);
        return;
    }

    rv = ::renameat(AT_FDCWD, "/tmp/test_rename", AT_FDCWD,
                    "/tmp/test_rename2");
    rv = ::renameat(AT_FDCWD, path1.c_str(), AT_FDCWD,
                    path2.c_str());
    if(rv < 0) {
        output("renameat", rv, opts);
        output("renameat_ext_to_ext", rv, opts);
        return;
    }
    // sys_open