-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
loop: Add regression test for unsupported backing file fallocate
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
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |