Loading .gitlab-ci.yml +0 −12 Original line number Diff line number Diff line Loading @@ -145,18 +145,6 @@ test truncate: paths: - "${LOG_PATH}" test path resolution: stage: test script: - mkdir -p "${LOG_PATH}" - ${INSTALL_PATH}/bin/gkfs_daemon --mount /tmp/mountdir --root /tmp/root & - sleep 4 - LD_PRELOAD=${INSTALL_PATH}/lib/libgkfs_intercept.so ${TESTS_BUILD_PATH}/gkfs_test_path_resolution artifacts: when: on_failure paths: - "${LOG_PATH}" test lseek: stage: test script: Loading test/CMakeLists.txt +0 −2 Original line number Diff line number Diff line Loading @@ -26,8 +26,6 @@ add_executable(gkfs_test_truncate truncate.cpp) add_executable(gkfs_test_lseek lseek.cpp) add_executable(gkfs_test_symlink symlink_test.cpp) add_executable(gkfs_test_path_resolution path_resolution.cpp) find_package(MPI) if(${MPI_FOUND}) set(SOURCE_FILES_MPI main_MPI.cpp) Loading test/path_resolution.cppdeleted 100644 → 0 +0 −161 Original line number Diff line number Diff line #include <iostream> #include <fcntl.h> #include <unistd.h> #include <system_error> #include <cassert> #include <cstring> #include <sys/stat.h> static const std::string extdir = "/tmp/ext.tmp"; static const std::string ext_linkdir = "/tmp/link.tmp"; static const std::string nodir = "/tmp/notexistent"; static const std::string mountdir = "/tmp/mountdir"; static const std::string intdir = mountdir + "/int"; void setup() { int ret; // Clean external dir ret = rmdir(extdir.c_str()); if (ret != 0) { if (errno != ENOENT) { std::cerr << "ERROR: cannot remove external dir: " << strerror(errno) << std::endl; std::exit(EXIT_FAILURE); } } ret = mkdir(extdir.c_str(), 0770); if (ret != 0) { std::cerr << "ERROR: cannot create external dir: " << strerror(errno) << std::endl; std::exit(EXIT_FAILURE); } // Clean internal dir ret = rmdir(intdir.c_str()); if (ret != 0) { if (errno != ENOENT) { std::cerr << "ERROR: cannot remove internal dir: " << strerror(errno) << std::endl; std::exit(EXIT_FAILURE); } } ret = mkdir(intdir.c_str(), 0770); if (ret != 0) { std::cerr << "ERROR: cannot create internal dir: " << strerror(errno) << std::endl; std::exit(EXIT_FAILURE); } } void teardown() { // Clean external link if (unlink(ext_linkdir.c_str())) { if (errno != ENOENT) { std::cerr << "ERROR: cannot remove external dir: " << strerror(errno) << std::endl; } } // Clean external dir if (rmdir(extdir.c_str())) { if (errno != ENOENT) { std::cerr << "ERROR: cannot remove external dir: " << strerror(errno) << std::endl; } } // Clean internal dir if (rmdir(intdir.c_str())) { if (errno != ENOENT) { std::cerr << "ERROR: cannot remove internal dir: " << strerror(errno) << std::endl; } } } void test_chdir(const std::string& dst, const std::string& expected) { char path[125]; int ret = chdir(dst.c_str()); if (ret != 0) { throw std::system_error(errno, std::system_category(), "ERROR: Failed to chdir into: " + dst); } char * cwd = getcwd(path, sizeof(path)); if (cwd == NULL) { throw std::system_error(errno, std::system_category(), "ERROR: Failed to get current cwd"); } if (std::string(path) != expected) { throw std::system_error(errno, std::system_category(), "ERROR: Expected path do not match"); } } int main(int argc, char* argv[]) { if(std::atexit(teardown)) { std::cerr << "Teardown function registration failed" << std::endl; return EXIT_FAILURE; } setup(); char buffIn[] = "oops."; char *buffOut = new char[strlen(buffIn) + 1 + 20 ]; char path[125]; struct stat st; int fd; int ret; // change to unexistent dir assert(stat(nodir.c_str(), &st) != 0); ret = chdir(nodir.c_str()); if (ret == 0) { std::cerr << "ERROR: Succeeded on chdir to a non-existing dir" << std::endl; return EXIT_FAILURE; } if (errno != ENOENT) { std::cerr << "ERROR: wrong error number while opening non-existing file: " << errno << std::endl; return EXIT_FAILURE; } // change to external dir ret = chdir(extdir.c_str()); if (ret != 0) { std::cerr << "ERROR: Failed to chdir into external dir: " << strerror(errno) << std::endl; return EXIT_FAILURE; } // test path resolution: from outside to inside test_chdir("../mountdir/int", intdir); // test path resolution: from inside to outside test_chdir("../../ext.tmp", extdir); // test complex path resolution test_chdir(mountdir + "/int/..//./int//../../../tmp/mountdir/../mountdir/./int/.//", intdir); // Create external link ret = symlink(extdir.c_str(), ext_linkdir.c_str()); if (ret != 0) { std::cerr << "ERROR: Failed to make symbolic link: " << strerror(errno) << std::endl; return EXIT_FAILURE; } test_chdir("../../link.tmp", extdir); test_chdir("../link.tmp/../link.tmp/../mountdir/int", intdir); } tests/integration/CMakeLists.txt +17 −5 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ gkfs_add_python_test( NAME test_directories PYTHON_VERSION 3.6 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/integration SOURCE directories/test_directories.py SOURCE directories/ ) if (GLIBC_HAS_STATX) Loading Loading @@ -75,6 +75,7 @@ if(GKFS_INSTALL_TESTS) PATTERN "gkfs.io" EXCLUDE ) if(SYMLINK_SUPPORT) install(DIRECTORY directories DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gkfs/tests/integration FILES_MATCHING Loading @@ -82,6 +83,17 @@ if(GKFS_INSTALL_TESTS) PATTERN "__pycache__" EXCLUDE PATTERN ".pytest_cache" EXCLUDE ) else() install(DIRECTORY directories DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gkfs/tests/integration FILES_MATCHING REGEX ".*\\.py" PATTERN "__pycache__" EXCLUDE PATTERN ".pytest_cache" EXCLUDE PATTERN "test_symlink.py" EXCLUDE ) endif() install(DIRECTORY status DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gkfs/tests/integration Loading tests/integration/directories/test_pathresolution.py 0 → 100644 +97 −0 Original line number Diff line number Diff line ################################################################################ # Copyright 2018-2020, Barcelona Supercomputing Center (BSC), Spain # # Copyright 2015-2020, Johannes Gutenberg Universitaet Mainz, Germany # # # # This software was partially supported by the # # EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). # # # # This software was partially supported by the # # ADA-FS project under the SPPEXA project funded by the DFG. # # # # SPDX-License-Identifier: MIT # ################################################################################ import harness from pathlib import Path import errno import stat import os import ctypes import sh import sys import pytest from harness.logger import logger nonexisting = "nonexisting" #@pytest.mark.xfail(reason="invalid errno returned on success") def test_pathresolution(gkfs_daemon, gkfs_client): """Testing different path resolution capabilities""" mountdir = gkfs_daemon.mountdir extdir = "/tmp/ext.tmp" ext_linkdir = "/tmp/link.tmp" nodir = "/tmp/notexistent" intdir = mountdir / "int" # Just clean if it exists, due to a failed test ret = gkfs_client.rmdir(extdir) try: os.unlink(ext_linkdir) # it is external except Exception as e: pass ret = gkfs_client.mkdir( extdir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) assert ret.retval == 0 ret = gkfs_client.mkdir( intdir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) assert ret.retval == 0 # test stat on existing dir ret = gkfs_client.stat(nodir) assert ret.retval == -1 assert ret.errno == errno.ENOENT ret = gkfs_client.chdir(nodir) assert ret.retval == -1 assert ret.errno == errno.ENOENT # Chdir to external dir ret = gkfs_client.chdir(extdir) assert ret.retval == 0 ret = gkfs_client.getcwd_validate(str(intdir)+"../../../../../../../../../../../../../../../../../../.."+str(intdir)) assert ret.path == str(intdir) assert ret.retval == 0 # test path resolution: from inside to outside ret = gkfs_client.getcwd_validate("../../../../../../../../../../../.." + str(extdir)) assert ret.path == str(extdir) assert ret.retval == 0 # test complex path resolution ret = gkfs_client.getcwd_validate("../../../../../../../../../../../.." + str(extdir) + "/../../../../../../../../../../../.." + str(intdir)) assert ret.path == str(intdir) assert ret.retval == 0 # Teardown ret = gkfs_client.rmdir(extdir) assert ret.retval == 0 # Clean internal dir ret = gkfs_client.rmdir(intdir) assert ret.retval == 0 return Loading
.gitlab-ci.yml +0 −12 Original line number Diff line number Diff line Loading @@ -145,18 +145,6 @@ test truncate: paths: - "${LOG_PATH}" test path resolution: stage: test script: - mkdir -p "${LOG_PATH}" - ${INSTALL_PATH}/bin/gkfs_daemon --mount /tmp/mountdir --root /tmp/root & - sleep 4 - LD_PRELOAD=${INSTALL_PATH}/lib/libgkfs_intercept.so ${TESTS_BUILD_PATH}/gkfs_test_path_resolution artifacts: when: on_failure paths: - "${LOG_PATH}" test lseek: stage: test script: Loading
test/CMakeLists.txt +0 −2 Original line number Diff line number Diff line Loading @@ -26,8 +26,6 @@ add_executable(gkfs_test_truncate truncate.cpp) add_executable(gkfs_test_lseek lseek.cpp) add_executable(gkfs_test_symlink symlink_test.cpp) add_executable(gkfs_test_path_resolution path_resolution.cpp) find_package(MPI) if(${MPI_FOUND}) set(SOURCE_FILES_MPI main_MPI.cpp) Loading
test/path_resolution.cppdeleted 100644 → 0 +0 −161 Original line number Diff line number Diff line #include <iostream> #include <fcntl.h> #include <unistd.h> #include <system_error> #include <cassert> #include <cstring> #include <sys/stat.h> static const std::string extdir = "/tmp/ext.tmp"; static const std::string ext_linkdir = "/tmp/link.tmp"; static const std::string nodir = "/tmp/notexistent"; static const std::string mountdir = "/tmp/mountdir"; static const std::string intdir = mountdir + "/int"; void setup() { int ret; // Clean external dir ret = rmdir(extdir.c_str()); if (ret != 0) { if (errno != ENOENT) { std::cerr << "ERROR: cannot remove external dir: " << strerror(errno) << std::endl; std::exit(EXIT_FAILURE); } } ret = mkdir(extdir.c_str(), 0770); if (ret != 0) { std::cerr << "ERROR: cannot create external dir: " << strerror(errno) << std::endl; std::exit(EXIT_FAILURE); } // Clean internal dir ret = rmdir(intdir.c_str()); if (ret != 0) { if (errno != ENOENT) { std::cerr << "ERROR: cannot remove internal dir: " << strerror(errno) << std::endl; std::exit(EXIT_FAILURE); } } ret = mkdir(intdir.c_str(), 0770); if (ret != 0) { std::cerr << "ERROR: cannot create internal dir: " << strerror(errno) << std::endl; std::exit(EXIT_FAILURE); } } void teardown() { // Clean external link if (unlink(ext_linkdir.c_str())) { if (errno != ENOENT) { std::cerr << "ERROR: cannot remove external dir: " << strerror(errno) << std::endl; } } // Clean external dir if (rmdir(extdir.c_str())) { if (errno != ENOENT) { std::cerr << "ERROR: cannot remove external dir: " << strerror(errno) << std::endl; } } // Clean internal dir if (rmdir(intdir.c_str())) { if (errno != ENOENT) { std::cerr << "ERROR: cannot remove internal dir: " << strerror(errno) << std::endl; } } } void test_chdir(const std::string& dst, const std::string& expected) { char path[125]; int ret = chdir(dst.c_str()); if (ret != 0) { throw std::system_error(errno, std::system_category(), "ERROR: Failed to chdir into: " + dst); } char * cwd = getcwd(path, sizeof(path)); if (cwd == NULL) { throw std::system_error(errno, std::system_category(), "ERROR: Failed to get current cwd"); } if (std::string(path) != expected) { throw std::system_error(errno, std::system_category(), "ERROR: Expected path do not match"); } } int main(int argc, char* argv[]) { if(std::atexit(teardown)) { std::cerr << "Teardown function registration failed" << std::endl; return EXIT_FAILURE; } setup(); char buffIn[] = "oops."; char *buffOut = new char[strlen(buffIn) + 1 + 20 ]; char path[125]; struct stat st; int fd; int ret; // change to unexistent dir assert(stat(nodir.c_str(), &st) != 0); ret = chdir(nodir.c_str()); if (ret == 0) { std::cerr << "ERROR: Succeeded on chdir to a non-existing dir" << std::endl; return EXIT_FAILURE; } if (errno != ENOENT) { std::cerr << "ERROR: wrong error number while opening non-existing file: " << errno << std::endl; return EXIT_FAILURE; } // change to external dir ret = chdir(extdir.c_str()); if (ret != 0) { std::cerr << "ERROR: Failed to chdir into external dir: " << strerror(errno) << std::endl; return EXIT_FAILURE; } // test path resolution: from outside to inside test_chdir("../mountdir/int", intdir); // test path resolution: from inside to outside test_chdir("../../ext.tmp", extdir); // test complex path resolution test_chdir(mountdir + "/int/..//./int//../../../tmp/mountdir/../mountdir/./int/.//", intdir); // Create external link ret = symlink(extdir.c_str(), ext_linkdir.c_str()); if (ret != 0) { std::cerr << "ERROR: Failed to make symbolic link: " << strerror(errno) << std::endl; return EXIT_FAILURE; } test_chdir("../../link.tmp", extdir); test_chdir("../link.tmp/../link.tmp/../mountdir/int", intdir); }
tests/integration/CMakeLists.txt +17 −5 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ gkfs_add_python_test( NAME test_directories PYTHON_VERSION 3.6 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/integration SOURCE directories/test_directories.py SOURCE directories/ ) if (GLIBC_HAS_STATX) Loading Loading @@ -75,6 +75,7 @@ if(GKFS_INSTALL_TESTS) PATTERN "gkfs.io" EXCLUDE ) if(SYMLINK_SUPPORT) install(DIRECTORY directories DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gkfs/tests/integration FILES_MATCHING Loading @@ -82,6 +83,17 @@ if(GKFS_INSTALL_TESTS) PATTERN "__pycache__" EXCLUDE PATTERN ".pytest_cache" EXCLUDE ) else() install(DIRECTORY directories DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gkfs/tests/integration FILES_MATCHING REGEX ".*\\.py" PATTERN "__pycache__" EXCLUDE PATTERN ".pytest_cache" EXCLUDE PATTERN "test_symlink.py" EXCLUDE ) endif() install(DIRECTORY status DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gkfs/tests/integration Loading
tests/integration/directories/test_pathresolution.py 0 → 100644 +97 −0 Original line number Diff line number Diff line ################################################################################ # Copyright 2018-2020, Barcelona Supercomputing Center (BSC), Spain # # Copyright 2015-2020, Johannes Gutenberg Universitaet Mainz, Germany # # # # This software was partially supported by the # # EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). # # # # This software was partially supported by the # # ADA-FS project under the SPPEXA project funded by the DFG. # # # # SPDX-License-Identifier: MIT # ################################################################################ import harness from pathlib import Path import errno import stat import os import ctypes import sh import sys import pytest from harness.logger import logger nonexisting = "nonexisting" #@pytest.mark.xfail(reason="invalid errno returned on success") def test_pathresolution(gkfs_daemon, gkfs_client): """Testing different path resolution capabilities""" mountdir = gkfs_daemon.mountdir extdir = "/tmp/ext.tmp" ext_linkdir = "/tmp/link.tmp" nodir = "/tmp/notexistent" intdir = mountdir / "int" # Just clean if it exists, due to a failed test ret = gkfs_client.rmdir(extdir) try: os.unlink(ext_linkdir) # it is external except Exception as e: pass ret = gkfs_client.mkdir( extdir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) assert ret.retval == 0 ret = gkfs_client.mkdir( intdir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) assert ret.retval == 0 # test stat on existing dir ret = gkfs_client.stat(nodir) assert ret.retval == -1 assert ret.errno == errno.ENOENT ret = gkfs_client.chdir(nodir) assert ret.retval == -1 assert ret.errno == errno.ENOENT # Chdir to external dir ret = gkfs_client.chdir(extdir) assert ret.retval == 0 ret = gkfs_client.getcwd_validate(str(intdir)+"../../../../../../../../../../../../../../../../../../.."+str(intdir)) assert ret.path == str(intdir) assert ret.retval == 0 # test path resolution: from inside to outside ret = gkfs_client.getcwd_validate("../../../../../../../../../../../.." + str(extdir)) assert ret.path == str(extdir) assert ret.retval == 0 # test complex path resolution ret = gkfs_client.getcwd_validate("../../../../../../../../../../../.." + str(extdir) + "/../../../../../../../../../../../.." + str(intdir)) assert ret.path == str(intdir) assert ret.retval == 0 # Teardown ret = gkfs_client.rmdir(extdir) assert ret.retval == 0 # Clean internal dir ret = gkfs_client.rmdir(intdir) assert ret.retval == 0 return