[PATCH v2 3/3] common/rc: Check call order of _require_dm_target and _require_scratch*

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



When SCRATCH_DEV is not set and the test case does not call
_require_scratch* before _require_dm_target, _require_block_device
called from _require_dm_target fails to evaluate SCRATCH_DEV and
results in the test case failure. This failure reason is not described
in the error message and it takes some time to catch.

To catch the failure reason easier, check SCRATCH_DEV in
_require_dm_target. If SCRATCH_DEV is not set, fail the test case
and print message which requests to fix call order of _require_scratch*
and _require_dm_target. This improvement follows what _scratch_shutdown
does for _require_scratch_shutdown.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx>
---
 common/rc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/rc b/common/rc
index dda5da06..cbec8aaa 100644
--- a/common/rc
+++ b/common/rc
@@ -1971,6 +1971,9 @@ _require_dm_target()
 
 	# require SCRATCH_DEV to be a valid block device with sane BLKFLSBUF
 	# behaviour
+	if [ -z "$SCRATCH_DEV" ]; then
+		_fail "_require_dm_target: call _require_scratch* first in test"
+	fi
 	_require_block_device $SCRATCH_DEV
 	_require_sane_bdev_flush $SCRATCH_DEV
 	_require_command "$DMSETUP_PROG" dmsetup
-- 
2.31.1




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux