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

pespin gerrit-no-reply at lists.osmocom.org
Tue Mar 16 17:09:08 UTC 2021


pespin has submitted this change. ( 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, 26 insertions(+), 3 deletions(-)

Approvals:
  pespin: Looks good to me, approved; Verified



diff --git a/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh b/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh
index d8ff049..2bdb9de 100644
--- a/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh
+++ b/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh
@@ -1,11 +1,34 @@
 #!/bin/bash
-# This script reads the network type of an Android phone via ADB
+# 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
+#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"
+  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
+
+echo "Waiting for Android UE to become available .."
+
+# 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
+
 while true; do
-  if [ "${serial}" == "0" ]; then
+  if [ "$serial" == "0" ]; then
     # run_type == ssh
     ssh -p "${remote_port}" root@"${remote_ip}" getprop "gsm.network.type"
   else
@@ -13,4 +36,4 @@
     adb -s "${serial}" shell getprop "gsm.network.type"
   fi
   sleep 1
-done
+done
\ No newline at end of file

-- 
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: 5
Gerrit-Owner: srs_andre <andre at softwareradiosystems.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210316/da34fc3d/attachment.htm>


More information about the gerrit-log mailing list