]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
sg: test for patch "Keep disk read-only when re-reading partition"
authorJeremy Cline <jeremy@jcline.org>
Tue, 6 Mar 2018 19:22:33 +0000 (14:22 -0500)
committerJeremy Cline <jeremy@jcline.org>
Wed, 7 Mar 2018 20:58:02 +0000 (15:58 -0500)
Add a regression test for the patch "scsi: sd: Keep disk read-only when
re-reading partition" which ensures re-reading a disk's partition table
doesn't change its read-only flag.

Signed-off-by: Jeremy Cline <jeremy@jcline.org>
tests/sg/003 [new file with mode: 0755]
tests/sg/003.out [new file with mode: 0644]

diff --git a/tests/sg/003 b/tests/sg/003
new file mode 100755 (executable)
index 0000000..063ddd5
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+#
+# Regression test for patch "scsi: sd: Keep disk read-only when re-reading
+# partition"
+#
+# Copyright (C) 2018 Jeremy Cline <jeremy@jcline.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+DESCRIPTION="ensure re-reading the partition table keeps its read-only flag"
+QUICK=1
+
+test_device() {
+       echo "Running ${TEST_NAME}"
+
+       blockdev --setro "$TEST_DEV"
+       blockdev --getro "$TEST_DEV"
+       blockdev --rereadpt "$TEST_DEV"
+       blockdev --getro "$TEST_DEV"
+       dd if=/dev/zero of="$TEST_DEV" count=1024 |& grep -o "Operation not permitted"
+
+       blockdev --setrw "$TEST_DEV"
+       blockdev --getro "$TEST_DEV"
+       blockdev --rereadpt "$TEST_DEV"
+       blockdev --getro "$TEST_DEV"
+       dd if=/dev/zero of="$TEST_DEV" count=1024 |& grep -o "Operation not permitted"
+
+       echo "Test complete"
+}
diff --git a/tests/sg/003.out b/tests/sg/003.out
new file mode 100644 (file)
index 0000000..3fcaddf
--- /dev/null
@@ -0,0 +1,7 @@
+Running sg/003
+1
+1
+Operation not permitted
+0
+0
+Test complete