From 22f65e474d1216966ead1a1fe8651c63b4e9490a Mon Sep 17 00:00:00 2001 From: cunyinch Date: Fri, 16 Jun 2017 10:36:26 +0800 Subject: [PATCH] test/nvme: detect the online NVMe devices before the setup.sh. This patch remove the fixed delay time before the setup.sh, make sure the test could keep go on as soon as all the NVMe devices get online. Change-Id: I42b49f9b1dc79690aabb3f1a855fecf28a570aba Signed-off-by: cunyinch Reviewed-on: https://review.gerrithub.io/365742 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- test/lib/nvme/hotplug.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/lib/nvme/hotplug.sh b/test/lib/nvme/hotplug.sh index 8d255ebbe..827ed7561 100755 --- a/test/lib/nvme/hotplug.sh +++ b/test/lib/nvme/hotplug.sh @@ -20,6 +20,19 @@ function monitor_cmd() { return $rc } +function get_online_devices_count() { + ssh_vm "lspci | grep "NVM" | wc -l" +} + +function wait_for_devices_ready() { + count=$(get_online_devices_count) + + while [ "$count" -ne "4" ]; do + echo "waitting for all devices online" + count=$(get_online_devices_count) + done +} + function devices_initialization() { timing_enter devices_initialization dd if=/dev/zero of=/root/test0 bs=1M count=1024 @@ -38,7 +51,7 @@ function insert_devices() { monitor_cmd "device_add nvme,drive=drive1,id=nvme1,serial=nvme1" monitor_cmd "device_add nvme,drive=drive2,id=nvme2,serial=nvme2" monitor_cmd "device_add nvme,drive=drive3,id=nvme3,serial=nvme3" - sleep 5 + wait_for_devices_ready ssh_vm "scripts/setup.sh" }