Change in osmo-gsm-tester[master]: osmo-gsm-tester_androidue_conn_chk.sh: improve error handling

srs_andre gerrit-no-reply at lists.osmocom.org
Fri Mar 12 12:12:59 UTC 2021


srs_andre has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/23343 )


Change subject: osmo-gsm-tester_androidue_conn_chk.sh: improve error handling
......................................................................

osmo-gsm-tester_androidue_conn_chk.sh: improve error handling

fix check of $serial and check passed arguments.
exit when adb isn't installed on host

Change-Id: I6190a840dbc86838457da96d188afc17f83ab15f
---
M utils/bin/osmo-gsm-tester_androidue_conn_chk.sh
1 file changed, 36 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/43/23343/1

diff --git a/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh b/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh
index d8ff049..c51d8f0 100644
--- a/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh
+++ b/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh
@@ -1,11 +1,42 @@
 #!/bin/bash
-# This script reads the network type of an Android phone via ADB
-# usage: osmo-gsm-tester_androidue_conn_chk.sh $serial $remote_ip $remote_port
+# This script reads the network type of an Android phone via ADB/SSH
+# If the first argument (serial) is 0, SSH is used to remotely connect to the phone
+# usage: osmo-gsm-tester_androidue_conn_chk.sh $serial $remote_ip $remote_port $timeout
+#set -x
+
+# check if all parameters have been passed
+if ([ ! $3 ])
+then
+  echo "Please call script with osmo-gsm-tester_androidue_conn_chk.sh $serial $remote_ip $remote_port ($timeout)"
+  echo "E.g. ./osmo-gsm-tester_androidue_conn_chk.sh df2df 10.12.1.106 130 10"
+  exit
+fi
+
 serial=$1
 remote_ip=$2
 remote_port=$3
-while true; do
-  if [ "${serial}" == "0" ]; then
+
+# Use default if no second parameter is given
+timeout=360
+if ([ $4 ]); then
+  timeout=$4
+fi
+
+echo "Waiting for Android UE to become available for max. ${timeout}s .."
+
+# Check adb is available, if needed
+if [ "$serial" != "0" ]; then
+  if ! [ -x "$(command -v adb)" ]; then
+    echo 'Error: adb is not installed.' >&2
+    exit 1
+  fi
+  echo "Using SSH to access device"
+fi
+
+wait_time=0
+while [ $wait_time -ne $timeout ]
+do
+  if [ "$serial" == "0" ]; then
     # run_type == ssh
     ssh -p "${remote_port}" root@"${remote_ip}" getprop "gsm.network.type"
   else
@@ -13,4 +44,5 @@
     adb -s "${serial}" shell getprop "gsm.network.type"
   fi
   sleep 1
+  let wait_time++
 done

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/23343
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I6190a840dbc86838457da96d188afc17f83ab15f
Gerrit-Change-Number: 23343
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre <andre at softwareradiosystems.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210312/c522c3c7/attachment.htm>


More information about the gerrit-log mailing list