Commit e5753a96 authored by Alberto Miranda's avatar Alberto Miranda ♨️ Committed by Marc Vef
Browse files

Ensure client lib is only used from --bin-dir

Remove pkg-resources==0.0.0 from requirements.txt.in
Move test_directories.py into own subdirectory
Remove trailing semicolons in Python code
parent 599e455a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,5 +21,5 @@ gkfs_add_python_test(
    NAME test_directories
    PYTHON_VERSION 3.7
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    COMMAND tests/test_directories.py
    COMMAND tests/directories/test_directories.py
)
+8 −6
Original line number Diff line number Diff line
@@ -31,17 +31,19 @@ def test_mkdir(gkfs_daemon, gkfs_client):
    """Create a new directory in the FS's root"""

    topdir = gkfs_daemon.mountdir / "top"
    longer = Path(topdir.parent, topdir.name + "_plus");
    dir_a  = topdir / "dir_a";
    dir_b  = topdir / "dir_b";
    file_a = topdir / "file_a";
    subdir_a  = dir_a / "subdir_a";
    longer = Path(topdir.parent, topdir.name + "_plus")
    dir_a  = topdir / "dir_a"
    dir_b  = topdir / "dir_b"
    file_a = topdir / "file_a"
    subdir_a  = dir_a / "subdir_a"

    # create topdir
    ret = gkfs_client.mkdir(
            topdir,
            stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)

    pprint(ret)

    assert ret.retval == 0
    assert ret.errno == 115 #FIXME: Should be 0!

@@ -161,7 +163,7 @@ def test_mkdir(gkfs_daemon, gkfs_client):
    # create 2nd level subdir and check it's not included in readdir()
    ret = gkfs_client.mkdir(
            subdir_a, 
            stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO);
            stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)

    assert ret.retval == 0
    assert ret.errno == 115 #FIXME: Should be 0!
+33 −8
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
#  SPDX-License-Identifier: MIT                                                #
################################################################################

import os, sh, sys, re
import os, sh, sys, re, pytest
import random, socket, netifaces
from pathlib import Path
from itertools import islice
@@ -105,8 +105,13 @@ class Daemon:

        self._cmd = sh.Command(gkfs_daemon_cmd, self._workspace.bindirs)
        self._env = os.environ.copy()

        libdirs = ':'.join(
                filter(None, [os.environ.get('LD_LIBRARY_PATH', '')] +
                             [str(p) for p in self._workspace.libdirs]))

        self._patched_env = {
            'LD_LIBRARY_PATH'      : ':'.join([os.environ.get('LD_LIBRARY_PATH', '')] + [str(p) for p in self._workspace.libdirs]),
            'LD_LIBRARY_PATH'      : libdirs,
            'GKFS_HOSTS_FILE'      : self.cwd / gkfs_hosts_file,
            'GKFS_DAEMON_LOG_PATH' : self.logdir / gkfs_daemon_log_file,
            'GKFS_LOG_LEVEL'       : gkfs_daemon_log_level,
@@ -237,9 +242,29 @@ class Client:
        self._cmd = sh.Command(gkfs_client_cmd, self._workspace.bindirs)
        self._env = os.environ.copy()

        libdirs = ':'.join(
                filter(None, [os.environ.get('LD_LIBRARY_PATH', '')] +
                             [str(p) for p in self._workspace.libdirs]))

        # ensure the client interception library is available:
        # to avoid running code with potentially installed libraries,
        # it must be found in one (and only one) of the workspace's bindirs
        preloads = []
        for d in self._workspace.bindirs:
            search_path = Path(d) / gkfs_client_lib_file
            if search_path.exists():
                preloads.append(search_path)

        if len(preloads) != 1:
            logger.error(f'Multiple client libraries found in the test\'s binary directories:')
            for p in preloads:
                logger.error(f'  {p}')
            logger.error(f'Make sure that only one copy of the client library is available.')
            pytest.exit("Aborted due to initialization error")

        self._patched_env = {
            'LD_LIBRARY_PATH'      : ':'.join([os.environ.get('LD_LIBRARY_PATH', '')] + [str(p) for p in self._workspace.libdirs]),
            'LD_PRELOAD'           : Path(gkfs_client_lib_file),
            'LD_LIBRARY_PATH'      : libdirs,
            'LD_PRELOAD'           : preloads[0],
            'LIBGKFS_HOSTS_FILE'   : self.cwd / gkfs_hosts_file,
            'LIBGKFS_LOG'          : gkfs_client_log_level,
            'LIBGKFS_LOG_OUTPUT'   : self._workspace.logdir / gkfs_client_log_file
+0 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ packaging==20.1
parso==0.6.1
pexpect==4.8.0
pickleshare==0.7.5
pkg-resources==0.0.0
pluggy==0.13.1
prompt-toolkit==3.0.3
ptyprocess==0.6.0