aboutsummaryrefslogtreecommitdiff
path: root/sbin/mdconfig/tests
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-08-31 19:50:09 +0000
committerMark Johnston <markj@FreeBSD.org>2021-08-31 19:50:09 +0000
commited59446b47095fc20c1f77e832286f5b953cd289 (patch)
tree6cb937f75f748f0b13dac9af0c75e9a67aabf453 /sbin/mdconfig/tests
parent47619b604402c9672a0f9bf62666f3bcba1dfb7e (diff)
downloadsrc-ed59446b47095fc20c1f77e832286f5b953cd289.tar.gz
src-ed59446b47095fc20c1f77e832286f5b953cd289.zip
mdconfig: Add a regression test for mediasize rounding
MFC after: 1 week Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sbin/mdconfig/tests')
-rwxr-xr-xsbin/mdconfig/tests/mdconfig_test.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/sbin/mdconfig/tests/mdconfig_test.sh b/sbin/mdconfig/tests/mdconfig_test.sh
index 92ba0342447c..c3a5f85e341b 100755
--- a/sbin/mdconfig/tests/mdconfig_test.sh
+++ b/sbin/mdconfig/tests/mdconfig_test.sh
@@ -267,6 +267,36 @@ attach_with_specific_unit_number_cleanup()
cleanup_common
}
+atf_test_case attach_size_rounddown cleanup
+attach_size_rounddown()
+{
+ atf_set "descr" "Verify that md provider sizes are a multiple of the sector size"
+}
+attach_size_rounddown_body()
+{
+ local md
+ local ss=8192
+ local ms=$(($ss + 4096))
+ local ms2=$((2 * $ss + 4096))
+
+ # Use a sector size that's a likely multiple of PAGE_SIZE, as md(4)
+ # expects that for swap MDs.
+ atf_check -s exit:0 -o save:mdconfig.out -e empty \
+ -x "mdconfig -a -t swap -S $ss -s ${ms}b"
+ md=$(cat mdconfig.out)
+ # 12288 bytes should be rounded down to one sector.
+ check_diskinfo "$md" 8192 1 $ss
+
+ # Resize and verify that the new size was also rounded down.
+ atf_check -s exit:0 -o empty -e empty \
+ -x "mdconfig -r -u ${md#md} -s ${ms2}b"
+ check_diskinfo "$md" 16384 2 $ss
+}
+attach_size_rounddown()
+{
+ cleanup_common
+}
+
atf_init_test_cases()
{
atf_add_test_case attach_vnode_non_explicit_type
@@ -277,4 +307,5 @@ atf_init_test_cases()
atf_add_test_case attach_malloc
atf_add_test_case attach_swap
atf_add_test_case attach_with_specific_unit_number
+ atf_add_test_case attach_size_rounddown
}