]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
nbd/002: repeat partition existence check for ioctl interface
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 17 Apr 2024 10:42:09 +0000 (19:42 +0900)
committerShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Thu, 25 Apr 2024 11:16:17 +0000 (20:16 +0900)
When nbd-client is set up with the ioctl interface, it takes some time
for the nbd driver and the block layer to complete the partition read.
The test script calls stat command for the /dev/nbd0p1 device to check
the partition exists as expected. However, this stat command is often
called before the partition read completion, then causes the test case
failure.

To avoid the test case failure, repeat the partition check a few times
with one second wait.

Tested-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
tests/nbd/002

index 968c9facd8230313cc2f3060c2e447a0ba9f3a51..8e4e062eba66e12a5c8e2faab1d4c5591a512d24 100755 (executable)
@@ -21,6 +21,8 @@ requires() {
 }
 
 test() {
+       local pass i
+
        echo "Running ${TEST_NAME}"
        _start_nbd_server
        {
@@ -64,7 +66,15 @@ test() {
 
        udevadm settle
 
-       if ! stat /dev/nbd0p1 >> "$FULL" 2>&1; then
+       pass=false
+       for ((i = 0; i < 3; i++)); do
+               if stat /dev/nbd0p1 >> "$FULL" 2>&1; then
+                       pass=true
+                       break
+               fi
+               sleep 1
+       done
+       if [[ $pass != true ]]; then
                echo "Didn't have partition on ioctl path"
                nbd-client -nonetlink -d /dev/nbd0 >> "$FULL" 2>&1
                _stop_nbd_server