mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
storage: Skip tests if not enough disk space is available
Closes: #2147. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
aaf0879434
commit
aa2d70de2e
@ -143,7 +143,17 @@ class Disk():
|
||||
self._remove_disk_file()
|
||||
|
||||
|
||||
def disk_space_available():
|
||||
"""Return disk space available in temporary directory."""
|
||||
directory = tempfile.gettempdir()
|
||||
output = subprocess.check_output(['df', '-m', '--output=avail',
|
||||
directory]).decode()
|
||||
return int(output.splitlines()[1])
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('needs_root')
|
||||
@pytest.mark.skipif(disk_space_available() < 1024,
|
||||
reason='Needs 1024MiB of space')
|
||||
def test_simple_case():
|
||||
"""Test a simple with no complications"""
|
||||
disk_info = [
|
||||
@ -167,6 +177,8 @@ def test_simple_case():
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('needs_root')
|
||||
@pytest.mark.skipif(disk_space_available() < 512,
|
||||
reason='Needs 512MiB of space')
|
||||
def test_extended_partition_free_space():
|
||||
"""Test that free space does not show up when outside extended."""
|
||||
disk_info = [
|
||||
@ -179,6 +191,8 @@ def test_extended_partition_free_space():
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('needs_root')
|
||||
@pytest.mark.skipif(disk_space_available() < 512,
|
||||
reason='Needs 512MiB of space')
|
||||
def test_gpt_partition_free_space():
|
||||
"""Test that GPT partitions can be expanded."""
|
||||
# Specifically check for partition number > 4
|
||||
@ -201,6 +215,7 @@ def test_gpt_partition_free_space():
|
||||
|
||||
@pytest.mark.usefixtures('needs_root')
|
||||
@pytest.mark.parametrize('partition_table_type', ['gpt', 'msdos'])
|
||||
@pytest.mark.skipif(disk_space_available() < 32, reason='Needs 32MiB of space')
|
||||
def test_unsupported_file_system(partition_table_type):
|
||||
"""Test that free space after unknown file system does not count."""
|
||||
disk_info = [f'mktable {partition_table_type}', 'mkpart primary 1 8']
|
||||
@ -211,6 +226,8 @@ def test_unsupported_file_system(partition_table_type):
|
||||
|
||||
@pytest.mark.usefixtures('needs_root')
|
||||
@pytest.mark.parametrize('partition_table_type', ['gpt', 'msdos'])
|
||||
@pytest.mark.skipif(disk_space_available() < 512,
|
||||
reason='Needs 512MiB of space')
|
||||
def test_btrfs_expansion(partition_table_type):
|
||||
"""Test that btrfs file system can be expanded."""
|
||||
disk_info = [
|
||||
@ -224,6 +241,8 @@ def test_btrfs_expansion(partition_table_type):
|
||||
|
||||
@pytest.mark.usefixtures('needs_root')
|
||||
@pytest.mark.parametrize('partition_table_type', ['gpt', 'msdos'])
|
||||
@pytest.mark.skipif(disk_space_available() < 128,
|
||||
reason='Needs 128MiB of space')
|
||||
def test_ext4_expansion(partition_table_type):
|
||||
"""Test that ext4 file system can be expanded."""
|
||||
disk_info = [f'mktable {partition_table_type}', 'mkpart primary ext4 1 64']
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user