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. Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx> --- tests/nbd/002 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/nbd/002 b/tests/nbd/002 index 968c9fa..8e4e062 100755 --- a/tests/nbd/002 +++ b/tests/nbd/002 @@ -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 -- 2.44.0