def main() -> None: with tempfile.TemporaryDirectory() as tmpdir: temp_path = Path(tmpdir) mnt_path = fuse_mount(temp_path, "memfs_mnt") fuse_check_mnt(tmpdir, mnt_path) with subtest("Create files with same name in different dirs"): node_list = [ "foo", "bar", os.path.join("foo", "foo"), os.path.join("bar", "foo"), ] try: os.mkdir(os.path.join(mnt_path, node_list[0])) except Exception as e: print(e) fuse_unmount(mnt_path) sys.exit(1) try: os.mkdir(os.path.join(mnt_path, node_list[1])) except Exception as e: print(e) fuse_unmount(mnt_path) sys.exit(1) try: os.mknod(os.path.join(mnt_path, node_list[2])) except Exception as e: print(e) fuse_unmount(mnt_path) sys.exit(1) try: os.mknod(os.path.join(mnt_path, node_list[3])) except Exception as e: print(e) fuse_unmount(mnt_path) sys.exit(1) if sorted(os.listdir(mnt_path)) != sorted(["foo", "bar"]): fuse_unmount(mnt_path) sys.exit(1) if os.listdir(os.path.join(mnt_path, node_list[0])) != ["foo"]: fuse_unmount(mnt_path) sys.exit(1) if os.listdir(os.path.join(mnt_path, node_list[1])) != ["foo"]: fuse_unmount(mnt_path) sys.exit(1) fuse_unmount(mnt_path) sys.exit(0)
def main() -> None: with tempfile.TemporaryDirectory() as tmpdir: temp_path = Path(tmpdir) mnt_path = fuse_mount(temp_path, "memfs_mnt") with subtest("Check mount"): fuse_check_mnt(tmpdir, mnt_path) fuse_unmount(mnt_path) sys.exit(0)
def main() -> None: with tempfile.TemporaryDirectory() as tmpdir: temp_path = Path(tmpdir) mnt_path = fuse_mount(temp_path, "memfs_mnt") fuse_check_mnt(tmpdir, mnt_path) with subtest("Check if mount point is a directory"): if not os.path.isdir(mnt_path): fuse_unmount(mnt_path) sys.exit(1) fuse_unmount(mnt_path) sys.exit(0)
def main() -> None: with tempfile.TemporaryDirectory() as tmpdir: temp_path = Path(tmpdir) mnt_path = fuse_mount(temp_path, "memfs_mnt") fuse_check_mnt(tmpdir, mnt_path) with subtest("Check empty directory on mount"): path_nodes = os.listdir(mnt_path) if len(path_nodes) != 0: fuse_unmount(mnt_path) sys.exit(1) fuse_unmount(mnt_path) sys.exit(0)
def main() -> None: with tempfile.TemporaryDirectory() as tmpdir: temp_path = Path(tmpdir) mnt_path = fuse_mount(temp_path, "memfs_mnt") fuse_check_mnt(tmpdir, mnt_path) with subtest("Create hierarchical files"): dir_list = [ "foo", os.path.join("foo", "bar"), ] for dir in dir_list: os.mkdir(os.path.join(mnt_path, dir)) file_list = [ "hello", os.path.join("foo", "hello_one"), os.path.join("", *["foo", "bar", "hello_two"]) ] for file in file_list: os.mknod(os.path.join(mnt_path, file)) flat_file_list = ["hello"] check_dir_list = os.listdir(mnt_path) for file in flat_file_list: if file not in check_dir_list: fuse_unmount(mnt_path) sys.exit(1) hier_file_list_level_one = ["hello_one"] check_dir_list = os.listdir(os.path.join("", *[mnt_path, "foo"])) for file in hier_file_list_level_one: if file not in check_dir_list: fuse_unmount(mnt_path) sys.exit(1) hier_file_list_level_two = ["hello_two"] check_dir_list = os.listdir(os.path.join("", *[mnt_path, "foo", "bar"])) for file in hier_file_list_level_two: if file not in check_dir_list: fuse_unmount(mnt_path) sys.exit(1) fuse_unmount(mnt_path) sys.exit(0)
def main() -> None: with tempfile.TemporaryDirectory() as tmpdir: temp_path = Path(tmpdir) mnt_path = fuse_mount(temp_path, "memfs_mnt") fuse_check_mnt(tmpdir, mnt_path) with subtest("Create hierarchical directories with distinct names"): dir_list = [ "foo", "bar", "foobar", "barfoo", os.path.join("foo", "b"), os.path.join("foo", "f"), os.path.join("", *["foo", "b", "foob"]), os.path.join("", *["foo", "b", "ba"]), ] for dir in dir_list: os.mkdir(os.path.join(mnt_path, dir)) flat_dir_list = ["foo", "bar", "foobar", "barfoo"] check_dir_list = os.listdir(mnt_path) for dir in flat_dir_list: if dir not in check_dir_list: fuse_unmount(mnt_path) sys.exit(1) hier_dir_level_one = ["f", "b"] check_dir_list = os.listdir(os.path.join(mnt_path, "foo")) for dir in hier_dir_level_one: if dir not in check_dir_list: fuse_unmount(mnt_path) sys.exit(1) hier_dir_level_two = ["foob", "ba"] check_dir_list = os.listdir( os.path.join(mnt_path, os.path.join("foo", "b"))) for dir in hier_dir_level_two: if dir not in check_dir_list: fuse_unmount(mnt_path) sys.exit(1) fuse_unmount(mnt_path) sys.exit(0)
def main() -> None: with tempfile.TemporaryDirectory() as tmpdir: temp_path = Path(tmpdir) mnt_path = fuse_mount(temp_path, "memfs_mnt") fuse_check_mnt(tmpdir, mnt_path) with subtest("Create flat directories"): dir_list = ["foo", "bar", "foobar", "barfoo"] for dir in dir_list: os.mkdir(os.path.join(mnt_path, dir)) check_dir_list = os.listdir(mnt_path) for dir in dir_list: if dir not in check_dir_list: fuse_unmount(mnt_path) sys.exit(1) fuse_unmount(mnt_path) sys.exit(0)
def main() -> None: with tempfile.TemporaryDirectory() as tmpdir: temp_path = Path(tmpdir) mnt_path = fuse_mount(temp_path, "memfs_mnt") fuse_check_mnt(tmpdir, mnt_path) with subtest( "Check that file and dir cannot have same name in same dir when file is created first" ): file_list = ["foo"] for file in file_list: os.mkdir(os.path.join(mnt_path, file)) try: os.mknod(os.path.join(mnt_path, file_list[0])) fuse_unmount(mnt_path) sys.exit(1) except FileExistsError as e: fuse_unmount(mnt_path) sys.exit(0)
def main() -> None: with tempfile.TemporaryDirectory() as tmpdir: temp_path = Path(tmpdir) mnt_path = fuse_mount(temp_path, "memfs_mnt") fuse_check_mnt(tmpdir, mnt_path) with subtest(""): run([os.path.join("tests", "file_io.sh"), "-o", os.path.join(mnt_path, "foo"), "hello"]) proc = run([os.path.join("tests", "file_io.sh"), "-d", os.path.join(mnt_path, "foo")], stdout=subprocess.PIPE) try: if proc.stdout != "hello\n": fuse_unmount(mnt_path) print("Written and read data don't match") sys.exit(1) except Exception as e: fuse_unmount(mnt_path) sys.exit(1) fuse_unmount(mnt_path) sys.exit(0)