[PATCH 2/2] tests: Add VTY tests for setting virtual-networks

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/OpenBSC@lists.osmocom.org/.

Ivan Kluchnikov kluchnikovi at gmail.com
Tue Apr 12 10:48:58 UTC 2016


---
 openbsc/tests/vty_test_runner.py | 52 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index ecf5204..ec90167 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -133,6 +133,9 @@ class TestVTYGenericBSC(TestVTYBase):
         self.assertTrue(self.vty.verify("network",['']))
         self.assertEquals(self.vty.node(), 'config-net')
         self.checkForEndAndExit()
+        self.assertTrue(self.vty.verify("virtual-network 0",['']))
+        self.assertEquals(self.vty.node(), 'config-net-virt')
+        self.checkForEndAndExit()
         self.assertTrue(self.vty.verify("bts 0",['']))
         self.assertEquals(self.vty.node(), 'config-net-bts')
         self.checkForEndAndExit()
@@ -154,6 +157,12 @@ class TestVTYGenericBSC(TestVTYBase):
         self.assertEquals(self.vty.node(), 'config-net-bts')
         self.assertTrue(self.vty.verify("exit",['']))
         self.assertEquals(self.vty.node(), 'config-net')
+        self.assertTrue(self.vty.verify("virtual-network 1",['']))
+        self.assertEquals(self.vty.node(), 'config-net-virt')
+        self.checkForEndAndExit()
+        self.vty.command("write terminal")
+        self.assertTrue(self.vty.verify("exit",['']))
+        self.assertEquals(self.vty.node(), 'config-net')
         self.assertTrue(self.vty.verify("exit",['']))
         self.assertEquals(self.vty.node(), 'config')
         self.assertTrue(self.vty.verify("exit",['']))
@@ -307,6 +316,48 @@ class TestVTYNITB(TestVTYGenericBSC):
             if classNum != 10:
                 self.assertEquals(res.find("rach access-control-class " + str(classNum) + " barred"), -1)
 
+    def testVirtualNetworks(self):
+        self.vty.enable()
+        self.vty.command("configure terminal")
+        self.vty.command("network")
+        self.vty.command("virtual-network 0")
+
+        # Test invalid input
+        self.vty.verify("network country code 0", ['% Unknown command.'])
+        self.vty.verify("network country code 1000", ['% Unknown command.'])
+        self.vty.verify("network country code 1234", ['% Unknown command.'])
+        self.vty.verify("mobile network code 0", ['% Unknown command.'])
+        self.vty.verify("mobile network code 1000", ['% Unknown command.'])
+        self.vty.verify("mobile network code 1234", ['% Unknown command.'])
+        self.vty.verify("mobile network code 1234", ['% Unknown command.'])
+        self.vty.verify("short name Test Net", ['% Unknown command.'])
+        self.vty.verify("long name Test Network", ['% Unknown command.'])
+
+        # Set virtual-networks
+        self.vty.verify("network country code 2", [''])
+        self.vty.verify("mobile network code 2", [''])
+        self.vty.verify("short name TestNet2", [''])
+        self.vty.verify("long name TestNetwork2", [''])
+        self.vty.verify("exit",[''])
+        self.vty.command("virtual-network 1")
+        self.vty.verify("network country code 3", [''])
+        self.vty.verify("mobile network code 3", [''])
+        self.vty.verify("short name TestNet3", [''])
+        self.vty.verify("long name TestNetwork3", [''])
+
+         # Verify settings
+        res = self.vty.command("write terminal")
+        self.assert_(res.find('virtual-network 0') > 0)
+        self.assert_(res.find('network country code 2') > 0)
+        self.assert_(res.find('mobile network code 2') > 0)
+        self.assert_(res.find('short name TestNet2') > 0)
+        self.assert_(res.find('long name TestNetwork2') > 0)
+        self.assert_(res.find('virtual-network 1') > 0)
+        self.assert_(res.find('network country code 3') > 0)
+        self.assert_(res.find('mobile network code 3') > 0)
+        self.assert_(res.find('short name TestNet3') > 0)
+        self.assert_(res.find('long name TestNetwork3') > 0)
+
     def testSubscriberCreateDeleteTwice(self):
         """
         OS#1657 indicates that there might be an issue creating the
@@ -342,7 +393,6 @@ class TestVTYNITB(TestVTYGenericBSC):
         res = self.vty.command('show subscriber imsi '+imsi)
         self.assert_(res != '% No subscriber found for imsi '+imsi)
 
-
     def testSubscriberCreateDelete(self):
         self.vty.enable()
 
-- 
1.9.1




More information about the OpenBSC mailing list