diff --git a/plinth/modules/storage/tests/test_storage.py b/plinth/modules/storage/tests/test_storage.py index 30bbf55a0..4877ee81b 100644 --- a/plinth/modules/storage/tests/test_storage.py +++ b/plinth/modules/storage/tests/test_storage.py @@ -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']