Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement functional tests on real BTRFS filesystems #1

Open
bodik opened this issue Mar 27, 2023 · 1 comment
Open

Implement functional tests on real BTRFS filesystems #1

bodik opened this issue Mar 27, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@bodik
Copy link

bodik commented Mar 27, 2023

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")
@andreittr
Copy link
Owner

Thank you for your kind words and support! I hope the tool was as useful to you as it is to me.

You bring up an important point: btrsync needs proper functional tests on real filesystems in addition to unit tests (whether using pytest or just the std lib, TBD). This has been in the back of my mind for a while, and this is as good a time as any to implement them.

I'm taking the liberty and hijacking this issue to track the implementation of functional tests.

@andreittr andreittr changed the title test btrfs filesystem fixture for pytest Implement functional tests on real BTRFS filesystems Mar 28, 2023
@andreittr andreittr added the enhancement New feature or request label Mar 28, 2023
@andreittr andreittr self-assigned this Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants