aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/vty_test_runner.py
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-06-25 11:44:01 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-31 16:36:40 +0200
commitddf191eafc079cb26e2956a611d59e5235de1798 (patch)
treef1c012375d24c6f58e14c8606a11fb671d3b1da2 /openbsc/tests/vty_test_runner.py
parent85d3b34ed2c3b627fca50c82abe426b7239b62a3 (diff)
nat: Allow to use the prefix lookup to rewrite numbers
* Increase the rewritten rule to five digits (this is the easiest for the unit test). This will add another 40kb to the runtime size. * Create a unit test that tests adding and removing the prefix rules. * Use the regexp match to replace from one package
Diffstat (limited to 'openbsc/tests/vty_test_runner.py')
-rw-r--r--openbsc/tests/vty_test_runner.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 456573d74..91b4684d4 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -103,6 +103,27 @@ class TestVTYNAT(TestVTYBase):
res = self.vty.command("number-rewrite rewrite.cfg")
res = self.vty.command("no number-rewrite")
+ def testPrefixTreeLoading(self):
+ cfg = os.path.join(confpath, "tests/bsc-nat-trie/prefixes.csv")
+
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+ res = self.vty.command("prefix-tree %s" % cfg)
+ self.assertEqual(res, "% prefix-tree loaded 17 rules.")
+ self.vty.command("end")
+
+ res = self.vty.command("show prefix-tree")
+ self.assertEqual(res, '1,1\r\n12,2\r\n123,3\r\n1234,4\r\n12345,5\r\n123456,6\r\n1234567,7\r\n12345678,8\r\n123456789,9\r\n1234567890,10\r\n13,11\r\n14,12\r\n15,13\r\n16,14\r\n82,16\r\n823455,15\r\n+49123,17')
+
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+ self.vty.command("no prefix-tree")
+ self.vty.command("end")
+
+ res = self.vty.command("show prefix-tree")
+ self.assertEqual(res, "% there is now prefix tree loaded.")
+
def add_nat_test(suite, workdir):
if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc_nat/osmo-bsc_nat")):