]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
block/013: Add test for BLKRRPART ioctl
authorxiao yang <yangx.jy@cn.fujitsu.com>
Tue, 19 Dec 2017 10:30:23 +0000 (18:30 +0800)
committerOmar Sandoval <osandov@fb.com>
Tue, 19 Dec 2017 23:40:55 +0000 (15:40 -0800)
If the entire block device is formatted with a filesystem and
mounted, running "blockdev --rereadpt" should fail and return
EBUSY instead of pass.

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: xiao yang <yangx.jy@cn.fujitsu.com>
[Omar: simplified a bit]
Signed-off-by: Omar Sandoval <osandov@fb.com>
tests/block/013 [new file with mode: 0755]
tests/block/013.out [new file with mode: 0644]

diff --git a/tests/block/013 b/tests/block/013
new file mode 100755 (executable)
index 0000000..dbba9ff
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# If the entire block device is formatted with a filesystem and mounted,
+# running "blockdev --rereadpt" should fail and return EBUSY. On buggy kernel,
+# it passes unexpectedly.
+#
+# Regression test for commit 77032ca66f86 ("Return EBUSY from BLKRRPART for
+# mounted whole-dev fs").
+#
+# Copyright (c) 2017 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
+#
+# 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="try BLKRRPART on a mounted device"
+QUICK=1
+
+requires() {
+       _have_program mkfs.ext3
+}
+
+test_device() {
+       echo "Running ${TEST_NAME}"
+
+       mkfs.ext3 -q -F "$TEST_DEV"
+       mkdir "$TMPDIR/mntpoint"
+       mount "$TEST_DEV" "$TMPDIR/mntpoint"
+
+       local out="$(blockdev --rereadpt "$TEST_DEV" 2>&1)"
+       if ! grep -o "Device or resource busy" <<< "$out"; then
+               echo "$out"
+       fi
+
+       umount "$TMPDIR/mntpoint"
+
+       echo "Test complete"
+}
diff --git a/tests/block/013.out b/tests/block/013.out
new file mode 100644 (file)
index 0000000..1a97562
--- /dev/null
@@ -0,0 +1,3 @@
+Running block/013
+Device or resource busy
+Test complete