[PATCH] openbsc[master]: vty tests: close msc socket after nat_msc_test

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 Hofmeyr gerrit-no-reply at lists.osmocom.org
Tue Feb 28 02:08:05 UTC 2017


Review at  https://gerrit.osmocom.org/1934

vty tests: close msc socket after nat_msc_test

Change-Id: Ib64cf8690627803e1b4a8497ea63f1e766960478
---
M openbsc/tests/vty_test_runner.py
1 file changed, 24 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/34/1934/1

diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 93d1755..305c956 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -785,28 +785,32 @@
         self.vty.command("end")
 
         nat_msc_ip(self, ip, port)
-        msc = nat_msc_test(self, ip, port, verbose=True)
-        b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc)
-        b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc)
-        b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc)
+        msc_socket, msc = nat_msc_test(self, ip, port, verbose=True)
+        try:
+            b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc)
+            b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc)
+            b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc)
 
-        self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured"))
-        self.assertTrue(3 == nat_bsc_num_con(self))
-        self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
+            self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured"))
+            self.assertTrue(3 == nat_bsc_num_con(self))
+            self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
 
-        nat_bsc_reload(self)
-        bscs2 = self.vty.command("show bscs-config")
-        # check that the reset to initial config succeeded
-        self.assertEquals(bscs1, bscs2)
+            nat_bsc_reload(self)
+            bscs2 = self.vty.command("show bscs-config")
+            # check that the reset to initial config succeeded
+            self.assertEquals(bscs1, bscs2)
 
-        self.assertEquals("2 BSCs configured", self.vty.command("show nat num-bscs-configured"))
-        self.assertTrue(1 == nat_bsc_num_con(self))
-        rem = self.vty.command("show bsc connections").split(' ')
-        # remaining connection is for BSC0
-        self.assertEquals('0', rem[2])
-        # remaining connection is authorized
-        self.assertEquals('1', rem[4])
-        self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
+            self.assertEquals("2 BSCs configured", self.vty.command("show nat num-bscs-configured"))
+            self.assertTrue(1 == nat_bsc_num_con(self))
+            rem = self.vty.command("show bsc connections").split(' ')
+            # remaining connection is for BSC0
+            self.assertEquals('0', rem[2])
+            # remaining connection is authorized
+            self.assertEquals('1', rem[4])
+            self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
+        finally:
+            msc.close()
+            msc_socket.close()
 
     def testVtyTree(self):
         self.vty.enable()
@@ -1240,7 +1244,7 @@
     if not conn:
         raise Exception("VTY reports MSC is connected, but I haven't"
                         " connected yet: %r %r" % (ip, port))
-    return conn
+    return msc, conn
 
 def ipa_handle_small(x, verbose = False):
     s = data2str(x.recv(4))

-- 
To view, visit https://gerrit.osmocom.org/1934
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib64cf8690627803e1b4a8497ea63f1e766960478
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list