Skip to content

Implement functional tests on real BTRFS filesystems #1

@bodik

Description

@bodik

thank you for awesome tool. you might consider using "real" BTRFS filesystem fixtures handy some time

def btrfstest_fs_instance(path):
    """create test btrfs filesystem"""

    testmount = Path(path)

    if testmount.exists():
        subprocess.run(f"umount --force --quiet {testmount}", check=False, shell=True)
        Path(f"{testmount}.raw").unlink(missing_ok=True)
    else:
        testmount.mkdir()

    subprocess.run(
        f"dd if=/dev/zero of={testmount}.raw bs=500M count=1", check=True, shell=True
    )
    subprocess.run(f"mkfs.btrfs {testmount}.raw", check=True, shell=True)
    subprocess.run(f"mount -o loop {testmount}.raw {testmount}", check=True, shell=True)

    yield testmount

    subprocess.run(f"umount {testmount}", check=True, shell=True)
    Path(f"{testmount}.raw").unlink(missing_ok=True)


@pytest.fixture(scope="function") 
def btrfstest_fs(): 
    """yield first test filesystem"""
    
    yield from btrfstest_fs_instance("/tmp/btrfstest")

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions