Skip to content

Commit

Permalink
loop: Add regression test for unsupported backing file fallocate
Browse files Browse the repository at this point in the history
Add the test case to confirm fix by the kernel commit 5f75e081ab5c ("
loop: Disable fallocate() zero and discard if not supported").

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
[Shin'ichiro: improved descriptions, used $loop_dev and long options]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
  • Loading branch information
metan-ucw authored and kawasaki committed Jun 20, 2024
1 parent cae266b commit 2271bef
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/loop/011
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (C) 2024 Cyril Hrubis
#
# Regression test for the commit 5f75e081ab5c ("loop: Disable fallocate() zero
# and discard if not supported").

. tests/loop/rc
DESCRIPTION="Make sure unsupported backing file fallocate does not fill dmesg with errors"

requires() {
_have_program mkfs.ext2
}

test() {
local loop_dev;
echo "Running ${TEST_NAME}"

mkdir "$TMPDIR/tmpfs"
mount --types tmpfs testfs "$TMPDIR/tmpfs"
dd if=/dev/zero of="$TMPDIR/tmpfs/disk.img" bs=1M count=100 &> /dev/null

if ! loop_dev="$(losetup --find --show "$TMPDIR/tmpfs/disk.img")"; then
return 1
fi

mkfs.ext2 "$loop_dev" &> /dev/null

errors=$(_dmesg_since_test_start |grep -c "operation not supported error, dev .*WRITE_ZEROES")

losetup --detach "$loop_dev"
umount "$TMPDIR/tmpfs"

echo "Found $errors error(s) in dmesg"

echo "Test complete"
}
3 changes: 3 additions & 0 deletions tests/loop/011.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Running loop/011
Found 1 error(s) in dmesg
Test complete

0 comments on commit 2271bef

Please sign in to comment.