Skip to contentSkip to conversation

blktests: add ability for multiple dev sysfs checks

PATCH In review John Pittman 2 participants 4 messages Jan 22 – Jan 25 Block layer

lore
Share & tools
lore
#0 lore raw

v2 cover blktests: add ability for multiple dev sysfs checks

This patchset adds the ability to loop within _require_test_dev_sysfs() and check multiple sysfs values rather than only one. In older kernels, as we've seen in recent testing, its common for sysfs values to be missing, so it's good to check these files prior to testing. We also use the new format in block/042 to resolve recently seen failures.

Changes in v2:
* set attr variable to local in _require_test_dev_sysfs()
* removed empty arg to _require_test_dev_sysfs() in device_requires()
* changed spaces to tabs before _require_test_dev_sysfs

John Pittman (2):
common/rc: support multiple arguments for _require_test_dev_sysfs() block/042: check sysfs values prior to running

 common/rc       | 13 ++++++++-----
 tests/block/042 |  4 +++-
 2 files changed, 11 insertions(+), 6 deletions(-)
Signature · 1 line
2.51.1
#1 lore raw

PATCH v2 1/2 common/rc: support multiple arguments for _require_test_dev_sysfs()

In some cases we may need to check multiple sysfs values for tests. If this happens, create the ability to pass in multiple arguments to _require_test_dev_sysfs() instead of having to call the function multiple times.

---
 common/rc | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
common/rc +8 -5
index b76a856..f09ba8b 100644
@@ -326,11 +326,14 @@ _test_dev_is_rotational() {
 }
 
 _require_test_dev_sysfs() {
-	if [[ ! -e "${TEST_DEV_SYSFS}/$1" ]]; then
-		SKIP_REASONS+=("${TEST_DEV} does not have sysfs attribute $1")
-		return 1
-	fi
-	return 0
+	local attr ret=0
+	for attr in "$@"; do
+		if [[ ! -e "${TEST_DEV_SYSFS}/$attr" ]]; then
+			SKIP_REASONS+=("${TEST_DEV} does not have sysfs attribute $attr")
+			ret=1
+		fi
+	done
+	return $ret
 }
 
 _require_test_dev_is_rotational() {
Signature · 1 line
2.51.1
#2 lore raw

PATCH v2 2/2 block/042: check sysfs values prior to running

In reply to John Pittman

In testing some older kernels recently, block/042 has failed due to dma_alignment and virt_boundary_mask not being present.

Running block/042
+cat: '.../queue/dma_alignment': No such file or directory +cat: '.../queue/virt_boundary_mask': No such file or directory +dio-offsets: test_dma_aligned: failed to write buf: Invalid argument

To ensure we skip if this is the case, check all sysfs values prior to run. Also, change the spaces to tabs before _require_test_dev_sysfs for consistency with the rest of blktests.

---
 tests/block/042 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/block/042 +3 -1
index 28ac4a2..8a31149 100644
@@ -11,7 +11,9 @@ DESCRIPTION="Test unusual direct-io offsets"
 QUICK=1
 
 device_requires() {
-        _require_test_dev_sysfs
+	_require_test_dev_sysfs "queue/max_segments" "queue/dma_alignment" \
+		"queue/virt_boundary_mask" "queue/logical_block_size" \
+		"queue/max_sectors_kb"
 }
 
 test_device() {
Signature · 1 line
2.51.1
#3 lore raw
In reply to John Pittman
Quoted 5 lines · John Pittman

This patchset adds the ability to loop within _require_test_dev_sysfs() and check multiple sysfs values rather than only one. In older kernels, as we've seen in recent testing, its common for sysfs values to be missing, so it's good to check these files prior to testing. We also use the new format in block/042 to resolve recently seen failures.

John, thanks for this v2 series. I applied it.