Move wait_sdb() to tct/conf/conf.sh 85/95285/5
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Mon, 10 Oct 2016 07:13:37 +0000 (09:13 +0200)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Mon, 9 Jan 2017 18:53:09 +0000 (19:53 +0100)
Change-Id: I49afd4a22c6959f25f7e009ea36fbad589c9aa3e
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
tct/conf/conf.sh
tct/odroid_prepare_flash_conf.sh

index 9f38ecb..1c74390 100755 (executable)
@@ -86,3 +86,34 @@ copy_sdb() {
     test -n "${DEST}" || DEST="${DEFAULT_DEST}"
     sdb -s "${ID}" push "${FILE}" "${DEST}" || die "SDB copy failed!"
 }
+
+wait_sdb() {
+    SDMUX="$1"
+    test -n "${SDMUX}" || die "Missing argument: sdmux"
+    test -n "${INIT_SLEEP}" || die "Missing env: init_sleep"
+
+    CONNECT_CNT=0
+    sdb start-server >&2
+    SLEEP=${INIT_SLEEP}
+
+    sleep "${SLEEP}"
+
+    while [ -z "$(sdb devices | awk -v SDMUX="${SDMUX}" '$1 == SDMUX {print $1}')" ]
+    do
+        printf "." >&2
+        if [ ${SLEEP} -ge ${MAX_SLEEP} ]
+        then
+            die "Timeout: sdb device not found!"
+        fi
+        if [ ${SLEEP} -ge ${RESTART_SLEEP} ]
+        then
+            echo "Restarting ${SDMUX}" >&2
+            restart_device "${SDMUX}"
+        fi
+        sleep "${SLEEP}"
+        SLEEP=$((SLEEP+INC_SLEEP))
+        CONNECT_CNT=$((CONNECT_CNT+1))
+    done
+
+    echo "${CONNECT_CNT}"
+}
index ca36674..cefd345 100755 (executable)
@@ -73,28 +73,7 @@ restart_device "${SDMUX}"
 
 echo "### conf ###"
 
-CONNECT_CNT=0
-sdb start-server
-SLEEP=${INIT_SLEEP}
-
-sleep "${SLEEP}"
-
-while [ -z "$(sdb devices | awk -v SDMUX="${SDMUX}" '$1 == SDMUX {print $1}')" ]
-do
-    printf "."
-    if [ ${SLEEP} -ge ${MAX_SLEEP} ]
-    then
-        die "Timeout: sdb device not found!" >&2
-    fi
-    if [ ${SLEEP} -ge ${RESTART_SLEEP} ]
-    then
-        echo "Restarting ODROID" >&2
-        restart_device "${SDMUX}"
-    fi
-    sleep "${SLEEP}"
-    SLEEP=$((SLEEP+INC_SLEEP))
-    CONNECT_CNT=$((CONNECT_CNT+1))
-done
+CONNECT_CNT="$(wait_sdb "${SDMUX}")" || die "wait_sdb: failed!"
 
 printf "\n"
 sleep 4