Skip to content

Commit 37c4da9

Browse files
committed
Extend stratis-decode-dm tests
They now include all --output options. Signed-off-by: mulhern <amulhern@redhat.com>
1 parent 6ae7d31 commit 37c4da9

1 file changed

Lines changed: 57 additions & 1 deletion

File tree

testlib/infra.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import time
2727
import unittest
2828
from enum import Enum
29+
from pathlib import Path
2930
from tempfile import NamedTemporaryFile
3031

3132
# isort: THIRDPARTY
@@ -428,7 +429,7 @@ class FilesystemSymlinkMonitor(unittest.TestCase):
428429

429430
maxDiff = None
430431

431-
def run_check(self, stop_time):
432+
def run_check(self, stop_time): # pylint: disable=too-many-locals
432433
"""
433434
Check that the filesystem links on the D-Bus and the filesystem links
434435
expected from looking at filesystem devicemapper paths match exactly.
@@ -478,6 +479,61 @@ def run_check(self, stop_time):
478479
f"{decode_dm} invocation failed: "
479480
f"{stderrdata.decode('utf-8')}"
480481
)
482+
try:
483+
(_, dev, stratis, pool_name, filesystem_name) = Path(
484+
symlink
485+
).parts
486+
except ValueError as err:
487+
raise RuntimeError(
488+
f"Symlink {symlink} did not decompose into expected parts"
489+
) from err
490+
491+
self.assertEqual(stratis, "stratis")
492+
self.assertEqual(dev, "dev")
493+
494+
command = [
495+
decode_dm,
496+
os.path.join(DEV_MAPPER, dev),
497+
"--output=filesystem-name",
498+
]
499+
500+
with subprocess.Popen(
501+
command,
502+
stdout=subprocess.PIPE,
503+
stderr=subprocess.PIPE,
504+
) as proc:
505+
(stdoutdata, stderrdata) = proc.communicate()
506+
if proc.returncode == 0:
507+
self.assertEqual(
508+
stdoutdata.decode("utf-8").strip(), filesystem_name
509+
)
510+
else:
511+
raise RuntimeError(
512+
f"{decode_dm} invocation failed: "
513+
f"{stderrdata.decode('utf-8')}"
514+
)
515+
516+
command = [
517+
decode_dm,
518+
os.path.join(DEV_MAPPER, dev),
519+
"--output=pool-name",
520+
]
521+
522+
with subprocess.Popen(
523+
command,
524+
stdout=subprocess.PIPE,
525+
stderr=subprocess.PIPE,
526+
) as proc:
527+
(stdoutdata, stderrdata) = proc.communicate()
528+
if proc.returncode == 0:
529+
self.assertEqual(
530+
stdoutdata.decode("utf-8").strip(), pool_name
531+
)
532+
else:
533+
raise RuntimeError(
534+
f"{decode_dm} invocation failed: "
535+
f"{stderrdata.decode('utf-8')}"
536+
)
481537
except FileNotFoundError as err:
482538
raise RuntimeError(
483539
f"Script '{decode_dm}' missing, test could not be run"

0 commit comments

Comments
 (0)