Skip to content

Commit b3dd06b

Browse files
committed
common/rc: introduce _page_size_equals helper to skip incompatible tests
Introduce a new helper function `_get_page_size` to get system page size, and `_page_size_equals()` to check the whether system page size equal one value. Update `scsi/011` and `zbd/010` to use this helper and gracefully skip the tests if the page size is not 4096 bytes. This prevents test failures on non-4K page architectures. Fixes: #234 Suggested-by: Bart Van Assche <[email protected]> Signed-off-by: Yi Zhang <[email protected]>
1 parent dd55eba commit b3dd06b

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

common/rc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,31 @@ _have_systemctl_unit() {
552552
return 0
553553
}
554554

555+
# Get system page size from kernel conguration
556+
_get_page_size() {
557+
local page_shift
558+
559+
page_shift=$(_get_kernel_option PAGE_SHIFT)
560+
561+
echo $((1<< page_shift))
562+
}
563+
564+
# Check if the system page size matches the required size (in bytes).
565+
# Example: _page_size_equals 4096
566+
_page_size_equals() {
567+
local required_size="$1"
568+
local current_size
569+
570+
current_size=$(_get_page_size)
571+
572+
if [ "$current_size" -ne "$required_size" ]; then
573+
SKIP_REASONS+=("This test requires ${required_size} bytes page size, but system has ${current_size} bytes")
574+
return 1
575+
fi
576+
577+
return 0
578+
}
579+
555580
_systemctl_start() {
556581
local unit="$1"
557582

tests/scsi/011

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ requires() {
1717
_have_kver 6 10
1818
_have_program mkfs.f2fs
1919
_have_scsi_debug_group_number_stats
20+
_page_size_equals 4096
2021
}
2122

2223
run_test() {

tests/zbd/010

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ requires() {
1616
_have_module_param scsi_debug zone_cap_mb
1717
_have_program mkfs.f2fs
1818
_have_module scsi_debug
19+
_page_size_equals 4096
1920
}
2021

2122
test() {

0 commit comments

Comments
 (0)