Tomas Bzatek 10280e
From def82f87dcc0b21e4890e12d82e6007f98551dcb Mon Sep 17 00:00:00 2001
Tomas Bzatek 10280e
From: Tomas Bzatek <tbzatek@redhat.com>
Tomas Bzatek 10280e
Date: Tue, 30 May 2023 18:23:08 +0200
Tomas Bzatek 10280e
Subject: [PATCH] tests: Forcefully set scsi_debug cd drive as read-only
Tomas Bzatek 10280e
Tomas Bzatek 10280e
There's something fishy in newer kernels and read-only detection
Tomas Bzatek 10280e
doesn't seem to work properly. As suggested in
Tomas Bzatek 10280e
https://github.com/util-linux/util-linux/issues/18#issuecomment-8453739
Tomas Bzatek 10280e
setting device ro by `blockdev --setro` seems to fix the issue.
Tomas Bzatek 10280e
---
Tomas Bzatek 10280e
 src/tests/integration-test | 2 ++
Tomas Bzatek 10280e
 1 file changed, 2 insertions(+)
Tomas Bzatek 10280e
Tomas Bzatek 10280e
diff --git a/src/tests/integration-test b/src/tests/integration-test
Tomas Bzatek 10280e
index 5f68217e0..10cdff85e 100755
Tomas Bzatek 10280e
--- a/src/tests/integration-test
Tomas Bzatek 10280e
+++ b/src/tests/integration-test
Tomas Bzatek 10280e
@@ -1096,6 +1096,7 @@ class FS(UDisksTestCase):
Tomas Bzatek 10280e
             time.sleep(5)
Tomas Bzatek 10280e
             self.sync()
Tomas Bzatek 10280e
             cd_fs = self.udisks_filesystem(cd=True)
Tomas Bzatek 10280e
+            subprocess.call(['blockdev', '--setro', self.cd_device])
Tomas Bzatek 10280e
 
Tomas Bzatek 10280e
             # forcing mount CD drive as 'rw' should fail
Tomas Bzatek 10280e
             try:
Tomas Bzatek 10280e
@@ -1748,6 +1749,7 @@ class Polkit(UDisksTestCase, test_polkitd.PolkitTestCase):
Tomas Bzatek 10280e
         try:
Tomas Bzatek 10280e
             fs = self.udisks_filesystem(cd=True)
Tomas Bzatek 10280e
             self.assertNotEqual(fs, None)
Tomas Bzatek 10280e
+            subprocess.call(['blockdev', '--setro', self.cd_device])
Tomas Bzatek 10280e
             mount_path = fs.call_mount_sync(no_options, None)
Tomas Bzatek 10280e
             self.assertIn('/media/', mount_path)
Tomas Bzatek 10280e