From 618501f8e671c449db842688282fb9a148c8eeb7 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 28 Jun 2020 17:22:21 -0700 Subject: [PATCH] storage: tests: Ignore cases needing loop devices when not available - In containers, loopback devices may not be available. Skip tests in this case by looking at the output of losetup setup utility. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/storage/tests/test_storage.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plinth/modules/storage/tests/test_storage.py b/plinth/modules/storage/tests/test_storage.py index 4b0716cdf..3a3f84b49 100644 --- a/plinth/modules/storage/tests/test_storage.py +++ b/plinth/modules/storage/tests/test_storage.py @@ -48,7 +48,13 @@ class Disk(): command = 'losetup --show --find {file}'.format( file=self.disk_file.name) process = subprocess.run(command.split(), stdout=subprocess.PIPE, - check=True) + stderr=subprocess.PIPE) + if process.returncode: + if b'cannot find an unused loop device' in process.stderr: + pytest.skip('Loopback devices not available') + else: + raise Exception(process.stderr) + device = process.stdout.decode().strip() subprocess.run(['partprobe', device], check=True)