When running blktests with kernel debugging enabled it can happen that
_find_nvme_loop_dev() returns before the NVMe block device has appeared
in sysfs. This patch avoids that the NVMe tests fail as follows:

+cat: /sys/block/nvme1n1/uuid: No such file or directory
+cat: /sys/block/nvme1n1/wwid: No such file or directory

Cc: Logan Gunthorpe <[email protected]>
Cc: Chaitanya Kulkarni <[email protected]>
Cc: Johannes Thumshirn <[email protected]>
Signed-off-by: Bart Van Assche <[email protected]>
---
 tests/nvme/rc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tests/nvme/rc b/tests/nvme/rc
index 348b4a3c2cbc..05dfc5915a13 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -169,8 +169,16 @@ _find_nvme_loop_dev() {
                transport="$(cat "/sys/class/nvme/${dev}/transport")"
                if [[ "$transport" == "loop" ]]; then
                        echo "$dev"
+                       for ((i=0;i<10;i++)); do
+                               [ -e /sys/block/$dev/uuid ] &&
+                                       [ -e /sys/block/$dev/wwid ] &&
+                                       return 0
+                               sleep .1
+                       done
+                       return 1
                fi
        done
+       return 1
 }
 
 _filter_discovery() {
-- 
2.22.0.770.g0f2c4a37fd-goog

Reply via email to