Change in osmo-gsm-tester[master]: ctrl: add get_var() to properly GET and read a GET_REPLY

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

neels gerrit-no-reply at lists.osmocom.org
Thu Dec 3 23:56:25 UTC 2020


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


Change subject: ctrl: add get_var() to properly GET and read a GET_REPLY
......................................................................

ctrl: add get_var() to properly GET and read a GET_REPLY

So far all GET interaction worked more incidentally than correctly.
Properly match a GET_REPLY to a sent GET by the message ID.

Change-Id: I75ec2494412e9b36b665ee6e45bd9f8fcdd27be6
---
M src/osmo_gsm_tester/obj/osmo_ctrl.py
1 file changed, 20 insertions(+), 0 deletions(-)



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

diff --git a/src/osmo_gsm_tester/obj/osmo_ctrl.py b/src/osmo_gsm_tester/obj/osmo_ctrl.py
index c2dd7e3..43191df 100644
--- a/src/osmo_gsm_tester/obj/osmo_ctrl.py
+++ b/src/osmo_gsm_tester/obj/osmo_ctrl.py
@@ -92,6 +92,26 @@
         self._send(getmsg)
         return use_id
 
+    def get_var(self, var):
+        used_id = self.do_get(var)
+        reply_header = 'GET_REPLY %d %s ' % (used_id, var)
+        error_header = 'ERROR %d ' % (used_id)
+        for i in range(10):
+            data = self.receive()
+            while len(data) > 0:
+                msg, data = self.remove_ipa_ctrl_header(data)
+                msg_str = msg.decode('utf-8')
+                if msg_str.startswith(error_header):
+                    raise CtrlInterfaceExn('GET on %s returned %r' % (var, msg_str))
+                if msg_str.startswith(reply_header):
+                    answer_str = msg_str[len(reply_header):]
+                    #self.dbg('%s = %r' % (var, answer_str))
+                    return answer_str
+        raise CtrlInterfaceExn('No answer found: ' + reply_header)
+
+    def get_int_var(self, var):
+        return int(self.get_var(var))
+
     def __enter__(self):
         self.connect()
         return self

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/21520
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: I75ec2494412e9b36b665ee6e45bd9f8fcdd27be6
Gerrit-Change-Number: 21520
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201203/9a24fbaa/attachment.htm>


More information about the gerrit-log mailing list