From 055f272517306e6877a126e414aa60191b483eba Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Sun, 5 May 2019 13:11:03 -0400 Subject: Added new example filesystem passthrough_hp puts emphasis and performance and correctness, rather than simplicity. --- test/test_examples.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_syscalls.c | 11 +++++++---- test/travis-build.sh | 9 +++++++-- 3 files changed, 68 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/test_examples.py b/test/test_examples.py index 1b98a7c..3aabd19 100755 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -153,6 +153,60 @@ def test_passthrough(tmpdir, name, debug, capfd, writeback): else: umount(mount_process, mnt_dir) +@pytest.mark.parametrize("cache", (False, True)) +def test_passthrough_hp(tmpdir, cache): + mnt_dir = str(tmpdir.mkdir('mnt')) + src_dir = str(tmpdir.mkdir('src')) + + cmdline = base_cmdline + \ + [ pjoin(basename, 'example', 'passthrough_hp'), + src_dir, mnt_dir ] + + if not cache: + cmdline.append('--nocache') + + mount_process = subprocess.Popen(cmdline) + try: + wait_for_mount(mount_process, mnt_dir) + + tst_statvfs(mnt_dir) + tst_readdir(src_dir, mnt_dir) + tst_readdir_big(src_dir, mnt_dir) + tst_open_read(src_dir, mnt_dir) + tst_open_write(src_dir, mnt_dir) + tst_create(mnt_dir) + tst_passthrough(src_dir, mnt_dir) + tst_append(src_dir, mnt_dir) + tst_seek(src_dir, mnt_dir) + tst_mkdir(mnt_dir) + tst_rmdir(src_dir, mnt_dir) + tst_unlink(src_dir, mnt_dir) + tst_symlink(mnt_dir) + if os.getuid() == 0: + tst_chown(mnt_dir) + + # Underlying fs may not have full nanosecond resolution + tst_utimens(mnt_dir, ns_tol=1000) + + tst_link(mnt_dir) + tst_truncate_path(mnt_dir) + tst_truncate_fd(mnt_dir) + tst_open_unlink(mnt_dir) + + # test_syscalls assumes that changes in source directory + # will be reflected immediately in mountpoint, so we + # can't use it. + if not cache: + syscall_test_cmd = [ os.path.join(basename, 'test', 'test_syscalls'), + mnt_dir, ':' + src_dir ] + subprocess.check_call(syscall_test_cmd) + except: + cleanup(mount_process, mnt_dir) + raise + else: + umount(mount_process, mnt_dir) + + @pytest.mark.skipif(fuse_proto < (7,11), reason='not supported by running kernel') def test_ioctl(tmpdir): diff --git a/test/test_syscalls.c b/test/test_syscalls.c index db4be56..a7e2bc7 100644 --- a/test/test_syscalls.c +++ b/test/test_syscalls.c @@ -67,6 +67,11 @@ static void test_error(const char *func, const char *msg, ...) fprintf(stderr, "\n"); } +static int is_dot_or_dotdot(const char *name) { + return name[0] == '.' && + (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')); +} + static void success(void) { fprintf(stderr, "%s OK\n", testname); @@ -381,10 +386,6 @@ static int check_dir_contents(const char *path, const char **contents) found[i] = 0; cont[i] = contents[i]; } - found[i] = 0; - cont[i++] = "."; - found[i] = 0; - cont[i++] = ".."; cont[i] = NULL; dp = opendir(path); @@ -405,6 +406,8 @@ static int check_dir_contents(const char *path, const char **contents) } break; } + if (is_dot_or_dotdot(de->d_name)) + continue; for (i = 0; cont[i] != NULL; i++) { assert(i < MAX_ENTRIES); if (strcmp(cont[i], de->d_name) == 0) { diff --git a/test/travis-build.sh b/test/travis-build.sh index dc46120..b2f3610 100755 --- a/test/travis-build.sh +++ b/test/travis-build.sh @@ -27,12 +27,15 @@ cd "${TEST_DIR}" # Standard build for CC in gcc gcc-7 clang; do mkdir build-${CC}; cd build-${CC} + if [ "${CC}" == "clang" ]; then + export CXX="clang++" + fi if [ ${CC} == 'gcc-7' ]; then build_opts='-D b_lundef=false' else build_opts='' fi - meson -D werror=true ${build_opts} "${SOURCE_DIR}" + meson -D werror=true ${build_opts} "${SOURCE_DIR}" || (cat meson-logs/meson-log.txt; false) ninja sudo chown root:root util/fusermount3 @@ -44,11 +47,13 @@ done # Sanitized build CC=clang +CXX=clang++ for san in undefined address; do mkdir build-${san}; cd build-${san} # b_lundef=false is required to work around clang # bug, cf. https://groups.google.com/forum/#!topic/mesonbuild/tgEdAXIIdC4 - meson -D b_sanitize=${san} -D b_lundef=false -D werror=true "${SOURCE_DIR}" + meson -D b_sanitize=${san} -D b_lundef=false -D werror=true "${SOURCE_DIR}" \ + || (cat meson-logs/meson-log.txt; false) ninja # Test as root and regular user -- cgit v1.2.1