blob: e19b12b14bd6e49c753b6cbd1e191a3202e4c0a6 [file] [log] [blame]
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +02001#!/usr/bin/env python
2
3# (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
4# (C) 2013 by Holger Hans Peter Freyther
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
Max3e676892016-11-16 14:55:21 +010018import os, sys
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +020019import time
20import unittest
Jacob Erlbeck6cb2ccc2013-08-14 11:10:34 +020021import socket
Neels Hofmeyrbcfee2a2017-02-03 16:09:17 +010022import subprocess
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +020023
24import osmopy.obscvty as obscvty
25import osmopy.osmoutil as osmoutil
26
Neels Hofmeyr476c4bb2017-02-24 17:55:11 +010027# add $top_srcdir/contrib to find ipa.py
28sys.path.append(os.path.join(sys.path[0], '..', 'contrib'))
29
Max3e676892016-11-16 14:55:21 +010030from ipa import IPA
31
Neels Hofmeyr476c4bb2017-02-24 17:55:11 +010032# to be able to find $top_srcdir/doc/...
33confpath = os.path.join(sys.path[0], '..')
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +020034
35class TestVTYBase(unittest.TestCase):
36
37 def vty_command(self):
38 raise Exception("Needs to be implemented by a subclass")
39
40 def vty_app(self):
41 raise Exception("Needs to be implemented by a subclass")
42
43 def setUp(self):
44 osmo_vty_cmd = self.vty_command()[:]
45 config_index = osmo_vty_cmd.index('-c')
46 if config_index:
47 cfi = config_index + 1
48 osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi])
49
50 try:
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +020051 self.proc = osmoutil.popen_devnull(osmo_vty_cmd)
52 except OSError:
53 print >> sys.stderr, "Current directory: %s" % os.getcwd()
54 print >> sys.stderr, "Consider setting -b"
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +020055
56 appstring = self.vty_app()[2]
57 appport = self.vty_app()[0]
58 self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport)
59
60 def tearDown(self):
Neels Hofmeyr40a91b32017-02-24 17:54:22 +010061 if self.vty:
62 self.vty._close_socket()
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +020063 self.vty = None
64 osmoutil.end_proc(self.proc)
65
Holger Hans Peter Freyther8d998a72014-07-04 20:23:56 +020066class TestVTYMGCP(TestVTYBase):
67 def vty_command(self):
68 return ["./src/osmo-bsc_mgcp/osmo-bsc_mgcp", "-c",
69 "doc/examples/osmo-bsc_mgcp/mgcp.cfg"]
70
71 def vty_app(self):
72 return (4243, "./src/osmo-bsc_mgcp/osmo-bsc_mgcp", "OpenBSC MGCP", "mgcp")
73
74 def testForcePtime(self):
Neels Hofmeyr0867b722016-09-28 23:28:06 +020075 self.vty.enable()
76 res = self.vty.command("show running-config")
77 self.assert_(res.find(' rtp force-ptime 20\r') > 0)
78 self.assertEquals(res.find(' no rtp force-ptime\r'), -1)
Holger Hans Peter Freyther8d998a72014-07-04 20:23:56 +020079
Neels Hofmeyr0867b722016-09-28 23:28:06 +020080 self.vty.command("configure terminal")
81 self.vty.command("mgcp")
82 self.vty.command("no rtp force-ptime")
83 res = self.vty.command("show running-config")
84 self.assertEquals(res.find(' rtp force-ptime 20\r'), -1)
85 self.assertEquals(res.find(' no rtp force-ptime\r'), -1)
Holger Hans Peter Freyther8d998a72014-07-04 20:23:56 +020086
Holger Hans Peter Freyther619b0142014-11-19 16:04:45 +010087 def testOmitAudio(self):
88 self.vty.enable()
Neels Hofmeyr0867b722016-09-28 23:28:06 +020089 res = self.vty.command("show running-config")
90 self.assert_(res.find(' sdp audio-payload send-name\r') > 0)
91 self.assertEquals(res.find(' no sdp audio-payload send-name\r'), -1)
Holger Hans Peter Freyther619b0142014-11-19 16:04:45 +010092
Neels Hofmeyr0867b722016-09-28 23:28:06 +020093 self.vty.command("configure terminal")
94 self.vty.command("mgcp")
95 self.vty.command("no sdp audio-payload send-name")
96 res = self.vty.command("show running-config")
97 self.assertEquals(res.find(' rtp sdp audio-payload send-name\r'), -1)
98 self.assert_(res.find(' no sdp audio-payload send-name\r') > 0)
Holger Hans Peter Freyther619b0142014-11-19 16:04:45 +010099
100 # TODO: test it for the trunk!
101
Holger Hans Peter Freytherc390ae82015-08-20 15:15:50 +0200102 def testBindAddr(self):
103 self.vty.enable()
104
Neels Hofmeyr0867b722016-09-28 23:28:06 +0200105 self.vty.command("configure terminal")
106 self.vty.command("mgcp")
Holger Hans Peter Freytherc390ae82015-08-20 15:15:50 +0200107
108 # enable.. disable bts-bind-ip
109 self.vty.command("rtp bts-bind-ip 254.253.252.250")
110 res = self.vty.command("show running-config")
111 self.assert_(res.find('rtp bts-bind-ip 254.253.252.250') > 0)
112 self.vty.command("no rtp bts-bind-ip")
113 res = self.vty.command("show running-config")
114 self.assertEquals(res.find(' rtp bts-bind-ip'), -1)
115
116 # enable.. disable net-bind-ip
117 self.vty.command("rtp net-bind-ip 254.253.252.250")
118 res = self.vty.command("show running-config")
119 self.assert_(res.find('rtp net-bind-ip 254.253.252.250') > 0)
120 self.vty.command("no rtp net-bind-ip")
121 res = self.vty.command("show running-config")
122 self.assertEquals(res.find(' rtp net-bind-ip'), -1)
123
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200124
125class TestVTYGenericBSC(TestVTYBase):
126
127 def checkForEndAndExit(self):
128 res = self.vty.command("list")
129 #print ('looking for "exit"\n')
130 self.assert_(res.find(' exit\r') > 0)
131 #print 'found "exit"\nlooking for "end"\n'
132 self.assert_(res.find(' end\r') > 0)
133 #print 'found "end"\n'
134
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200135 def _testConfigNetworkTree(self):
136 self.vty.enable()
137 self.assertTrue(self.vty.verify("configure terminal",['']))
138 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100139 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200140 self.assertTrue(self.vty.verify("network",['']))
141 self.assertEquals(self.vty.node(), 'config-net')
142 self.checkForEndAndExit()
143 self.assertTrue(self.vty.verify("bts 0",['']))
144 self.assertEquals(self.vty.node(), 'config-net-bts')
145 self.checkForEndAndExit()
146 self.assertTrue(self.vty.verify("trx 0",['']))
147 self.assertEquals(self.vty.node(), 'config-net-bts-trx')
148 self.checkForEndAndExit()
Jacob Erlbeck733bec82013-09-11 10:46:56 +0200149 self.vty.command("write terminal")
150 self.assertTrue(self.vty.verify("exit",['']))
151 self.assertEquals(self.vty.node(), 'config-net-bts')
152 self.assertTrue(self.vty.verify("exit",['']))
153 self.assertTrue(self.vty.verify("bts 1",['']))
154 self.assertEquals(self.vty.node(), 'config-net-bts')
155 self.checkForEndAndExit()
156 self.assertTrue(self.vty.verify("trx 1",['']))
157 self.assertEquals(self.vty.node(), 'config-net-bts-trx')
158 self.checkForEndAndExit()
159 self.vty.command("write terminal")
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200160 self.assertTrue(self.vty.verify("exit",['']))
161 self.assertEquals(self.vty.node(), 'config-net-bts')
162 self.assertTrue(self.vty.verify("exit",['']))
163 self.assertEquals(self.vty.node(), 'config-net')
164 self.assertTrue(self.vty.verify("exit",['']))
165 self.assertEquals(self.vty.node(), 'config')
166 self.assertTrue(self.vty.verify("exit",['']))
167 self.assertTrue(self.vty.node() is None)
168
169class TestVTYNITB(TestVTYGenericBSC):
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +0200170
171 def vty_command(self):
172 return ["./src/osmo-nitb/osmo-nitb", "-c",
173 "doc/examples/osmo-nitb/nanobts/openbsc.cfg"]
174
175 def vty_app(self):
176 return (4242, "./src/osmo-nitb/osmo-nitb", "OpenBSC", "nitb")
177
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200178 def testConfigNetworkTree(self):
Jacob Erlbeck75877272013-10-23 11:24:14 +0200179 self._testConfigNetworkTree()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200180
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200181 def checkForSmpp(self):
182 """SMPP is not always enabled, check if it is"""
183 res = self.vty.command("list")
184 return "smpp" in res
185
Holger Hans Peter Freyther42cf2e02015-07-06 16:41:30 +0200186 def testSmppFirst(self):
Holger Hans Peter Freyther42cf2e02015-07-06 16:41:30 +0200187 # enable the configuration
188 self.vty.enable()
189 self.vty.command("configure terminal")
Holger Hans Peter Freythera2c41c42015-07-13 11:23:53 +0200190
191 if not self.checkForSmpp():
192 return
193
Holger Hans Peter Freyther42cf2e02015-07-06 16:41:30 +0200194 self.vty.command("smpp")
195
196 # check the default
197 res = self.vty.command("write terminal")
198 self.assert_(res.find(' no smpp-first') > 0)
199
200 self.vty.verify("smpp-first", [''])
201 res = self.vty.command("write terminal")
202 self.assert_(res.find(' smpp-first') > 0)
203 self.assertEquals(res.find('no smpp-first'), -1)
204
205 self.vty.verify("no smpp-first", [''])
206 res = self.vty.command("write terminal")
207 self.assert_(res.find('no smpp-first') > 0)
208
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200209 def testVtyTree(self):
210 self.vty.enable()
211 self.assertTrue(self.vty.verify("configure terminal", ['']))
212 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100213 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200214 self.assertTrue(self.vty.verify('mncc-int', ['']))
215 self.assertEquals(self.vty.node(), 'config-mncc-int')
216 self.checkForEndAndExit()
217 self.assertTrue(self.vty.verify('exit', ['']))
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200218
219 if self.checkForSmpp():
220 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck75877272013-10-23 11:24:14 +0200221 self.assertTrue(self.vty.verify('smpp', ['']))
222 self.assertEquals(self.vty.node(), 'config-smpp')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100223 self.checkForEndAndExit()
Jacob Erlbeck75877272013-10-23 11:24:14 +0200224 self.assertTrue(self.vty.verify("exit", ['']))
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200225
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200226 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200227 self.assertTrue(self.vty.verify("exit", ['']))
228 self.assertTrue(self.vty.node() is None)
229
230 # Check searching for outer node's commands
231 self.vty.command("configure terminal")
232 self.vty.command('mncc-int')
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200233
234 if self.checkForSmpp():
235 self.vty.command('smpp')
236 self.assertEquals(self.vty.node(), 'config-smpp')
237 self.vty.command('mncc-int')
238
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200239 self.assertEquals(self.vty.node(), 'config-mncc-int')
240
Maxddee01f2016-05-24 14:23:27 +0200241 def testVtyAuthorization(self):
242 self.vty.enable()
243 self.vty.command("configure terminal")
244 self.vty.command("network")
245 self.assertTrue(self.vty.verify("auth policy closed", ['']))
246 self.assertTrue(self.vty.verify("auth policy regexp", ['']))
247 self.assertTrue(self.vty.verify("authorized-regexp ^001", ['']))
248 self.assertTrue(self.vty.verify("authorized-regexp 02$", ['']))
249 self.assertTrue(self.vty.verify("authorized-regexp *123.*", ['']))
250 self.vty.command("end")
251 self.vty.command("configure terminal")
252 self.vty.command("nitb")
Harald Welte2483f1b2016-06-19 18:06:02 +0200253 self.assertTrue(self.vty.verify('subscriber-create-on-demand',
254 ["% 'subscriber-create-on-demand' is no longer supported.", '% This is now up to osmo-hlr.']))
255 self.assertTrue(self.vty.verify("subscriber-create-on-demand no-extension",
256 ["% 'subscriber-create-on-demand' is no longer supported.", '% This is now up to osmo-hlr.']))
Maxddee01f2016-05-24 14:23:27 +0200257 self.vty.command("end")
258
Max0c1bc262016-04-20 12:06:06 +0200259 def testSi2Q(self):
260 self.vty.enable()
261 self.vty.command("configure terminal")
262 self.vty.command("network")
263 self.vty.command("bts 0")
264 before = self.vty.command("show running-config")
265 self.vty.command("si2quater neighbor-list add earfcn 1911 threshold 11 2")
266 self.vty.command("si2quater neighbor-list add earfcn 1924 threshold 11 3")
267 self.vty.command("si2quater neighbor-list add earfcn 2111 threshold 11")
268 self.vty.command("si2quater neighbor-list del earfcn 1911")
269 self.vty.command("si2quater neighbor-list del earfcn 1924")
270 self.vty.command("si2quater neighbor-list del earfcn 2111")
271 self.assertEquals(before, self.vty.command("show running-config"))
Max26679e02016-04-20 15:57:13 +0200272 self.vty.command("si2quater neighbor-list add uarfcn 1976 13 1")
273 self.vty.command("si2quater neighbor-list add uarfcn 1976 38 1")
274 self.vty.command("si2quater neighbor-list add uarfcn 1976 44 1")
275 self.vty.command("si2quater neighbor-list add uarfcn 1976 120 1")
276 self.vty.command("si2quater neighbor-list add uarfcn 1976 140 1")
277 self.vty.command("si2quater neighbor-list add uarfcn 1976 163 1")
278 self.vty.command("si2quater neighbor-list add uarfcn 1976 166 1")
279 self.vty.command("si2quater neighbor-list add uarfcn 1976 217 1")
280 self.vty.command("si2quater neighbor-list add uarfcn 1976 224 1")
281 self.vty.command("si2quater neighbor-list add uarfcn 1976 225 1")
282 self.vty.command("si2quater neighbor-list add uarfcn 1976 226 1")
283 self.vty.command("si2quater neighbor-list del uarfcn 1976 13")
284 self.vty.command("si2quater neighbor-list del uarfcn 1976 38")
285 self.vty.command("si2quater neighbor-list del uarfcn 1976 44")
286 self.vty.command("si2quater neighbor-list del uarfcn 1976 120")
287 self.vty.command("si2quater neighbor-list del uarfcn 1976 140")
288 self.vty.command("si2quater neighbor-list del uarfcn 1976 163")
289 self.vty.command("si2quater neighbor-list del uarfcn 1976 166")
290 self.vty.command("si2quater neighbor-list del uarfcn 1976 217")
291 self.vty.command("si2quater neighbor-list del uarfcn 1976 224")
292 self.vty.command("si2quater neighbor-list del uarfcn 1976 225")
293 self.vty.command("si2quater neighbor-list del uarfcn 1976 226")
294 self.assertEquals(before, self.vty.command("show running-config"))
Max0c1bc262016-04-20 12:06:06 +0200295
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +0200296 def testEnableDisablePeriodicLU(self):
297 self.vty.enable()
298 self.vty.command("configure terminal")
299 self.vty.command("network")
300 self.vty.command("bts 0")
301
302 # Test invalid input
303 self.vty.verify("periodic location update 0", ['% Unknown command.'])
304 self.vty.verify("periodic location update 5", ['% Unknown command.'])
305 self.vty.verify("periodic location update 1531", ['% Unknown command.'])
306
307 # Enable periodic lu..
308 self.vty.verify("periodic location update 60", [''])
309 res = self.vty.command("write terminal")
Holger Hans Peter Freytherc0438e32013-07-27 22:23:25 +0200310 self.assert_(res.find('periodic location update 60') > 0)
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +0200311 self.assertEquals(res.find('no periodic location update'), -1)
312
313 # Now disable it..
314 self.vty.verify("no periodic location update", [''])
315 res = self.vty.command("write terminal")
316 self.assertEquals(res.find('periodic location update 60'), -1)
Holger Hans Peter Freytherc0438e32013-07-27 22:23:25 +0200317 self.assert_(res.find('no periodic location update') > 0)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200318
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100319 def testEnableDisableSiHacks(self):
320 self.vty.enable()
321 self.vty.command("configure terminal")
322 self.vty.command("network")
323 self.vty.command("bts 0")
324
325 # Enable periodic lu..
326 self.vty.verify("force-combined-si", [''])
327 res = self.vty.command("write terminal")
328 self.assert_(res.find(' force-combined-si') > 0)
329 self.assertEquals(res.find('no force-combined-si'), -1)
330
331 # Now disable it..
332 self.vty.verify("no force-combined-si", [''])
333 res = self.vty.command("write terminal")
334 self.assertEquals(res.find(' force-combined-si'), -1)
335 self.assert_(res.find('no force-combined-si') > 0)
336
Ivan Kluchnikov67920592013-09-16 13:13:04 +0400337 def testRachAccessControlClass(self):
338 self.vty.enable()
339 self.vty.command("configure terminal")
340 self.vty.command("network")
341 self.vty.command("bts 0")
342
343 # Test invalid input
344 self.vty.verify("rach access-control-class", ['% Command incomplete.'])
345 self.vty.verify("rach access-control-class 1", ['% Command incomplete.'])
346 self.vty.verify("rach access-control-class -1", ['% Unknown command.'])
347 self.vty.verify("rach access-control-class 10", ['% Unknown command.'])
348 self.vty.verify("rach access-control-class 16", ['% Unknown command.'])
349
350 # Barred rach access control classes
351 for classNum in range(16):
352 if classNum != 10:
353 self.vty.verify("rach access-control-class " + str(classNum) + " barred", [''])
354
355 # Verify settings
356 res = self.vty.command("write terminal")
357 for classNum in range(16):
358 if classNum != 10:
359 self.assert_(res.find("rach access-control-class " + str(classNum) + " barred") > 0)
360
361 # Allowed rach access control classes
362 for classNum in range(16):
363 if classNum != 10:
364 self.vty.verify("rach access-control-class " + str(classNum) + " allowed", [''])
365
366 # Verify settings
367 res = self.vty.command("write terminal")
368 for classNum in range(16):
369 if classNum != 10:
370 self.assertEquals(res.find("rach access-control-class " + str(classNum) + " barred"), -1)
371
Ruben Pollaned04a0d2014-09-24 20:50:13 -0500372 def testSubscriberCreateDelete(self):
Alexander Chemerisbd6d40f2013-10-04 23:54:17 +0200373 self.vty.enable()
374
375 imsi = "204300854013739"
376
377 # Initially we don't have this subscriber
Harald Welte2483f1b2016-06-19 18:06:02 +0200378 self.assertTrue(self.vty.verify('show subscriber imsi '+imsi, ['% No subscriber found for imsi '+imsi]))
Alexander Chemerisbd6d40f2013-10-04 23:54:17 +0200379
Harald Welte2483f1b2016-06-19 18:06:02 +0200380 # deprecated
381 self.assertTrue(self.vty.verify('subscriber create imsi '+imsi, ["% 'subscriber create' now needs to be done at osmo-hlr"]))
Ruben Pollaned04a0d2014-09-24 20:50:13 -0500382
Neels Hofmeyr34ce3d92017-05-12 14:56:25 +0200383 # range
384 self.vty.command("end")
385 self.vty.command("configure terminal")
386 self.vty.command("nitb")
Harald Welte2483f1b2016-06-19 18:06:02 +0200387 self.assertTrue(self.vty.verify('subscriber-create-on-demand', ["% 'subscriber-create-on-demand' is no longer supported.", '% This is now up to osmo-hlr.']))
Neels Hofmeyr34ce3d92017-05-12 14:56:25 +0200388 res = self.vty.command("show running-config")
Harald Welte2483f1b2016-06-19 18:06:02 +0200389 self.assert_(res.find("subscriber-create-on-demand") < 0)
Neels Hofmeyr34ce3d92017-05-12 14:56:25 +0200390 self.vty.command("end")
391
Neels Hofmeyr7590ff32017-05-12 15:37:27 +0200392 res = self.vty.command('show subscriber imsi '+imsi)
393 self.assert_(('% No subscriber found for imsi ' + imsi) == res)
Neels Hofmeyr34ce3d92017-05-12 14:56:25 +0200394
395
Jacob Erlbeck322b1492015-04-07 17:49:49 +0200396 def testSubscriberSettings(self):
397 self.vty.enable()
398
399 imsi = "204300854013739"
Jacob Erlbeck322b1492015-04-07 17:49:49 +0200400
Harald Welte2483f1b2016-06-19 18:06:02 +0200401 self.assertTrue(self.vty.verify('subscriber imsi '+imsi+' name foo', ["% 'subscriber name' is no longer supported.", '% This is now up to osmo-hlr.']))
402 self.assertTrue(self.vty.verify('subscriber imsi '+imsi+' extension 1234', ["% 'subscriber extension' is no longer supported.", '% This is now up to osmo-hlr.']))
403 self.assertTrue(self.vty.verify('subscriber imsi '+imsi+' delete', ["% 'subscriber delete' is no longer supported.", '% This is now up to osmo-hlr.']))
Jacob Erlbeck322b1492015-04-07 17:49:49 +0200404
Max0fcd2e22016-06-07 15:32:16 +0200405 # With narrow random interval
406 self.vty.command("configure terminal")
407 self.vty.command("nitb")
Harald Welte2483f1b2016-06-19 18:06:02 +0200408 self.assertTrue(self.vty.verify('subscriber-create-on-demand', ["% 'subscriber-create-on-demand' is no longer supported.", '% This is now up to osmo-hlr.']))
Jacob Erlbeck322b1492015-04-07 17:49:49 +0200409
Holger Hans Peter Freytherec37bb22013-02-05 09:39:09 +0100410 def testShowPagingGroup(self):
411 res = self.vty.command("show paging-group 255 1234567")
412 self.assertEqual(res, "% can't find BTS 255")
413 res = self.vty.command("show paging-group 0 1234567")
414 self.assertEquals(res, "%Paging group for IMSI 1234567 on BTS #0 is 7")
415
Ciabyec6e4f82014-03-06 17:20:55 +0100416 def testShowNetwork(self):
417 res = self.vty.command("show network")
418 self.assert_(res.startswith('BSC is on Country Code') >= 0)
419
Holger Hans Peter Freyther86573262015-01-31 09:47:37 +0100420 def testMeasurementFeed(self):
421 self.vty.enable()
422 self.vty.command("configure terminal")
423 self.vty.command("mncc-int")
424
425 res = self.vty.command("write terminal")
426 self.assertEquals(res.find('meas-feed scenario'), -1)
427
428 self.vty.command("meas-feed scenario bla")
429 res = self.vty.command("write terminal")
430 self.assert_(res.find('meas-feed scenario bla') > 0)
431
Neels Hofmeyr0867b722016-09-28 23:28:06 +0200432 self.vty.command("meas-feed scenario abcdefghijklmnopqrstuvwxyz01234567890")
Holger Hans Peter Freyther86573262015-01-31 09:47:37 +0100433 res = self.vty.command("write terminal")
434 self.assertEquals(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz01234567890'), -1)
435 self.assertEquals(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz012345'), -1)
436 self.assert_(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz01234') > 0)
437
438
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200439class TestVTYBSC(TestVTYGenericBSC):
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200440
441 def vty_command(self):
442 return ["./src/osmo-bsc/osmo-bsc", "-c",
443 "doc/examples/osmo-bsc/osmo-bsc.cfg"]
444
445 def vty_app(self):
446 return (4242, "./src/osmo-bsc/osmo-bsc", "OsmoBSC", "bsc")
447
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200448 def testConfigNetworkTree(self):
Jacob Erlbeck75877272013-10-23 11:24:14 +0200449 self._testConfigNetworkTree()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200450
451 def testVtyTree(self):
452 self.vty.enable()
453 self.assertTrue(self.vty.verify("configure terminal", ['']))
454 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100455 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200456 self.assertTrue(self.vty.verify("msc 0", ['']))
457 self.assertEquals(self.vty.node(), 'config-msc')
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200458 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200459 self.assertTrue(self.vty.verify("exit", ['']))
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200460 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200461 self.assertTrue(self.vty.verify("bsc", ['']))
462 self.assertEquals(self.vty.node(), 'config-bsc')
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200463 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200464 self.assertTrue(self.vty.verify("exit", ['']))
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200465 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200466 self.assertTrue(self.vty.verify("exit", ['']))
467 self.assertTrue(self.vty.node() is None)
468
469 # Check searching for outer node's commands
470 self.vty.command("configure terminal")
471 self.vty.command('msc 0')
472 self.vty.command("bsc")
473 self.assertEquals(self.vty.node(), 'config-bsc')
474 self.vty.command("msc 0")
475 self.assertEquals(self.vty.node(), 'config-msc')
476
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200477 def testUssdNotificationsMsc(self):
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200478 self.vty.enable()
479 self.vty.command("configure terminal")
480 self.vty.command("msc")
481
482 # Test invalid input
483 self.vty.verify("bsc-msc-lost-text", ['% Command incomplete.'])
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200484 self.vty.verify("bsc-welcome-text", ['% Command incomplete.'])
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200485 self.vty.verify("bsc-grace-text", ['% Command incomplete.'])
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200486
487 # Enable USSD notifications
488 self.vty.verify("bsc-msc-lost-text MSC disconnected", [''])
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200489 self.vty.verify("bsc-welcome-text Hello MS", [''])
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200490 self.vty.verify("bsc-grace-text In grace period", [''])
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200491
492 # Verify settings
493 res = self.vty.command("write terminal")
494 self.assert_(res.find('bsc-msc-lost-text MSC disconnected') > 0)
495 self.assertEquals(res.find('no bsc-msc-lost-text'), -1)
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200496 self.assert_(res.find('bsc-welcome-text Hello MS') > 0)
497 self.assertEquals(res.find('no bsc-welcome-text'), -1)
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200498 self.assert_(res.find('bsc-grace-text In grace period') > 0)
499 self.assertEquals(res.find('no bsc-grace-text'), -1)
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200500
501 # Now disable it..
502 self.vty.verify("no bsc-msc-lost-text", [''])
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200503 self.vty.verify("no bsc-welcome-text", [''])
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200504 self.vty.verify("no bsc-grace-text", [''])
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200505
506 # Verify settings
507 res = self.vty.command("write terminal")
508 self.assertEquals(res.find('bsc-msc-lost-text MSC disconnected'), -1)
509 self.assert_(res.find('no bsc-msc-lost-text') > 0)
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200510 self.assertEquals(res.find('bsc-welcome-text Hello MS'), -1)
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200511 self.assert_(res.find('no bsc-welcome-text') > 0)
512 self.assertEquals(res.find('bsc-grace-text In grace period'), -1)
513 self.assert_(res.find('no bsc-grace-text') > 0)
514
515 def testUssdNotificationsBsc(self):
516 self.vty.enable()
517 self.vty.command("configure terminal")
518 self.vty.command("bsc")
519
520 # Test invalid input
521 self.vty.verify("missing-msc-text", ['% Command incomplete.'])
522
523 # Enable USSD notifications
524 self.vty.verify("missing-msc-text No MSC found", [''])
525
526 # Verify settings
527 res = self.vty.command("write terminal")
528 self.assert_(res.find('missing-msc-text No MSC found') > 0)
529 self.assertEquals(res.find('no missing-msc-text'), -1)
530
531 # Now disable it..
532 self.vty.verify("no missing-msc-text", [''])
533
534 # Verify settings
535 res = self.vty.command("write terminal")
536 self.assertEquals(res.find('missing-msc-text No MSC found'), -1)
537 self.assert_(res.find('no missing-msc-text') > 0)
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200538
Jacob Erlbeck946d1412013-09-17 13:59:29 +0200539 def testNetworkTimezone(self):
540 self.vty.enable()
541 self.vty.verify("configure terminal", [''])
542 self.vty.verify("network", [''])
Jacob Erlbeck946d1412013-09-17 13:59:29 +0200543
544 # Test invalid input
545 self.vty.verify("timezone", ['% Command incomplete.'])
546 self.vty.verify("timezone 20 0", ['% Unknown command.'])
547 self.vty.verify("timezone 0 11", ['% Unknown command.'])
548 self.vty.verify("timezone 0 0 99", ['% Unknown command.'])
549
550 # Set time zone without DST
551 self.vty.verify("timezone 2 30", [''])
552
553 # Verify settings
554 res = self.vty.command("write terminal")
555 self.assert_(res.find('timezone 2 30') > 0)
556 self.assertEquals(res.find('timezone 2 30 '), -1)
557
558 # Set time zone with DST
559 self.vty.verify("timezone 2 30 1", [''])
560
561 # Verify settings
562 res = self.vty.command("write terminal")
563 self.assert_(res.find('timezone 2 30 1') > 0)
564
565 # Now disable it..
566 self.vty.verify("no timezone", [''])
567
568 # Verify settings
569 res = self.vty.command("write terminal")
570 self.assertEquals(res.find(' timezone'), -1)
571
Ciabyec6e4f82014-03-06 17:20:55 +0100572 def testShowNetwork(self):
573 res = self.vty.command("show network")
574 self.assert_(res.startswith('BSC is on Country Code') >= 0)
575
Holger Hans Peter Freytherdb64f2e2014-10-29 10:06:15 +0100576 def testPingPongConfiguration(self):
577 self.vty.enable()
578 self.vty.verify("configure terminal", [''])
579 self.vty.verify("network", [''])
580 self.vty.verify("msc 0", [''])
581
582 self.vty.verify("timeout-ping 12", [''])
583 self.vty.verify("timeout-pong 14", [''])
584 res = self.vty.command("show running-config")
585 self.assert_(res.find(" timeout-ping 12") > 0)
586 self.assert_(res.find(" timeout-pong 14") > 0)
587 self.assert_(res.find(" no timeout-ping advanced") > 0)
588
589 self.vty.verify("timeout-ping advanced", [''])
590 res = self.vty.command("show running-config")
591 self.assert_(res.find(" timeout-ping 12") > 0)
592 self.assert_(res.find(" timeout-pong 14") > 0)
593 self.assert_(res.find(" timeout-ping advanced") > 0)
594
595 self.vty.verify("no timeout-ping advanced", [''])
596 res = self.vty.command("show running-config")
597 self.assert_(res.find(" timeout-ping 12") > 0)
598 self.assert_(res.find(" timeout-pong 14") > 0)
599 self.assert_(res.find(" no timeout-ping advanced") > 0)
600
601 self.vty.verify("no timeout-ping", [''])
602 res = self.vty.command("show running-config")
603 self.assertEquals(res.find(" timeout-ping 12"), -1)
604 self.assertEquals(res.find(" timeout-pong 14"), -1)
605 self.assertEquals(res.find(" no timeout-ping advanced"), -1)
606 self.assert_(res.find(" no timeout-ping") > 0)
607
608 self.vty.verify("timeout-ping advanced", ['%ping handling is disabled. Enable it first.'])
609
610 # And back to enabling it
611 self.vty.verify("timeout-ping 12", [''])
612 self.vty.verify("timeout-pong 14", [''])
613 res = self.vty.command("show running-config")
614 self.assert_(res.find(" timeout-ping 12") > 0)
615 self.assert_(res.find(" timeout-pong 14") > 0)
616 self.assert_(res.find(" timeout-ping advanced") > 0)
617
Holger Hans Peter Freyther32dd2f32015-04-01 18:15:48 +0200618 def testMscDataCoreLACCI(self):
619 self.vty.enable()
620 res = self.vty.command("show running-config")
621 self.assertEquals(res.find("core-location-area-code"), -1)
622 self.assertEquals(res.find("core-cell-identity"), -1)
623
Neels Hofmeyr0867b722016-09-28 23:28:06 +0200624 self.vty.command("configure terminal")
Holger Hans Peter Freyther32dd2f32015-04-01 18:15:48 +0200625 self.vty.command("msc 0")
626 self.vty.command("core-location-area-code 666")
627 self.vty.command("core-cell-identity 333")
628
629 res = self.vty.command("show running-config")
630 self.assert_(res.find("core-location-area-code 666") > 0)
631 self.assert_(res.find("core-cell-identity 333") > 0)
632
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200633class TestVTYNAT(TestVTYGenericBSC):
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200634
635 def vty_command(self):
Max49364482016-04-13 11:36:39 +0200636 return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-l", "127.0.0.1", "-c",
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200637 "doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg"]
638
639 def vty_app(self):
640 return (4244, "src/osmo-bsc_nat/osmo-bsc_nat", "OsmoBSCNAT", "nat")
641
Max49364482016-04-13 11:36:39 +0200642 def testBSCreload(self):
Holger Hans Peter Freyther44ed4972016-04-14 10:05:13 -0400643 # Use different port for the mock msc to avoid clashing with
644 # the osmo-bsc_nat itself
Holger Hans Peter Freytherf1a61bb2016-04-14 08:50:25 -0400645 ip = "127.0.0.1"
Holger Hans Peter Freythere98c9c72016-04-14 10:58:58 -0400646 port = 5522
Max49364482016-04-13 11:36:39 +0200647 self.vty.enable()
648 bscs1 = self.vty.command("show bscs-config")
649 nat_bsc_reload(self)
650 bscs2 = self.vty.command("show bscs-config")
651 # check that multiple calls to bscs-config-file give the same result
652 self.assertEquals(bscs1, bscs2)
653
654 # add new bsc
655 self.vty.command("configure terminal")
656 self.vty.command("nat")
657 self.vty.command("bsc 5")
658 self.vty.command("token key")
659 self.vty.command("location_area_code 666")
660 self.vty.command("end")
661
662 # update bsc token
663 self.vty.command("configure terminal")
664 self.vty.command("nat")
665 self.vty.command("bsc 1")
666 self.vty.command("token xyu")
667 self.vty.command("end")
668
Holger Hans Peter Freyther44ed4972016-04-14 10:05:13 -0400669 nat_msc_ip(self, ip, port)
Neels Hofmeyr0b619322017-02-28 02:37:39 +0100670 msc_socket, msc = nat_msc_test(self, ip, port, verbose=True)
671 try:
672 b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc)
673 b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc)
674 b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc)
Max49364482016-04-13 11:36:39 +0200675
Neels Hofmeyr0b619322017-02-28 02:37:39 +0100676 self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured"))
677 self.assertTrue(3 == nat_bsc_num_con(self))
678 self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
Max49364482016-04-13 11:36:39 +0200679
Neels Hofmeyr0b619322017-02-28 02:37:39 +0100680 nat_bsc_reload(self)
681 bscs2 = self.vty.command("show bscs-config")
682 # check that the reset to initial config succeeded
683 self.assertEquals(bscs1, bscs2)
Max49364482016-04-13 11:36:39 +0200684
Neels Hofmeyr0b619322017-02-28 02:37:39 +0100685 self.assertEquals("2 BSCs configured", self.vty.command("show nat num-bscs-configured"))
686 self.assertTrue(1 == nat_bsc_num_con(self))
687 rem = self.vty.command("show bsc connections").split(' ')
688 # remaining connection is for BSC0
689 self.assertEquals('0', rem[2])
690 # remaining connection is authorized
691 self.assertEquals('1', rem[4])
692 self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
693 finally:
694 msc.close()
695 msc_socket.close()
Max49364482016-04-13 11:36:39 +0200696
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200697 def testVtyTree(self):
698 self.vty.enable()
699 self.assertTrue(self.vty.verify('configure terminal', ['']))
700 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100701 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200702 self.assertTrue(self.vty.verify('mgcp', ['']))
703 self.assertEquals(self.vty.node(), 'config-mgcp')
704 self.checkForEndAndExit()
705 self.assertTrue(self.vty.verify('exit', ['']))
706 self.assertEquals(self.vty.node(), 'config')
707 self.assertTrue(self.vty.verify('nat', ['']))
708 self.assertEquals(self.vty.node(), 'config-nat')
709 self.checkForEndAndExit()
710 self.assertTrue(self.vty.verify('bsc 0', ['']))
711 self.assertEquals(self.vty.node(), 'config-nat-bsc')
712 self.checkForEndAndExit()
713 self.assertTrue(self.vty.verify('exit', ['']))
714 self.assertEquals(self.vty.node(), 'config-nat')
715 self.assertTrue(self.vty.verify('exit', ['']))
716 self.assertEquals(self.vty.node(), 'config')
717 self.assertTrue(self.vty.verify('exit', ['']))
718 self.assertTrue(self.vty.node() is None)
719
720 # Check searching for outer node's commands
721 self.vty.command('configure terminal')
722 self.vty.command('mgcp')
723 self.vty.command('nat')
724 self.assertEquals(self.vty.node(), 'config-nat')
Jacob Erlbeck4c9dff52013-09-02 13:17:17 +0200725 self.vty.command('mgcp')
726 self.assertEquals(self.vty.node(), 'config-mgcp')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200727 self.vty.command('nat')
728 self.assertEquals(self.vty.node(), 'config-nat')
729 self.vty.command('bsc 0')
Jacob Erlbeck4c9dff52013-09-02 13:17:17 +0200730 self.vty.command('mgcp')
731 self.assertEquals(self.vty.node(), 'config-mgcp')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200732
Holger Hans Peter Freytherb718ad32013-06-25 09:08:02 +0200733 def testRewriteNoRewrite(self):
734 self.vty.enable()
735 res = self.vty.command("configure terminal")
736 res = self.vty.command("nat")
737 res = self.vty.command("number-rewrite rewrite.cfg")
738 res = self.vty.command("no number-rewrite")
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200739
Holger Hans Peter Freyther7f100c92015-04-23 20:25:17 -0400740 def testEnsureNoEnsureModeSet(self):
741 self.vty.enable()
742 res = self.vty.command("configure terminal")
743 res = self.vty.command("nat")
744
745 # Ensure the default
746 res = self.vty.command("show running-config")
747 self.assert_(res.find('\n sdp-ensure-amr-mode-set') > 0)
748
749 self.vty.command("sdp-ensure-amr-mode-set")
750 res = self.vty.command("show running-config")
751 self.assert_(res.find('\n sdp-ensure-amr-mode-set') > 0)
752
753 self.vty.command("no sdp-ensure-amr-mode-set")
754 res = self.vty.command("show running-config")
755 self.assert_(res.find('\n no sdp-ensure-amr-mode-set') > 0)
756
Holger Hans Peter Freyther67e423c2013-06-25 15:38:31 +0200757 def testRewritePostNoRewrite(self):
758 self.vty.enable()
759 self.vty.command("configure terminal")
760 self.vty.command("nat")
761 self.vty.verify("number-rewrite-post rewrite.cfg", [''])
762 self.vty.verify("no number-rewrite-post", [''])
763
764
Holger Hans Peter Freytherddf191e2013-06-25 11:44:01 +0200765 def testPrefixTreeLoading(self):
766 cfg = os.path.join(confpath, "tests/bsc-nat-trie/prefixes.csv")
767
768 self.vty.enable()
769 self.vty.command("configure terminal")
770 self.vty.command("nat")
771 res = self.vty.command("prefix-tree %s" % cfg)
772 self.assertEqual(res, "% prefix-tree loaded 17 rules.")
773 self.vty.command("end")
774
775 res = self.vty.command("show prefix-tree")
776 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')
777
778 self.vty.command("configure terminal")
779 self.vty.command("nat")
780 self.vty.command("no prefix-tree")
781 self.vty.command("end")
782
783 res = self.vty.command("show prefix-tree")
784 self.assertEqual(res, "% there is now prefix tree loaded.")
785
Jacob Erlbeck6cb2ccc2013-08-14 11:10:34 +0200786 def testUssdSideChannelProvider(self):
787 self.vty.command("end")
788 self.vty.enable()
789 self.vty.command("configure terminal")
790 self.vty.command("nat")
791 self.vty.command("ussd-token key")
792 self.vty.command("end")
793
794 res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is not connected and not authorized.'])
795 self.assertTrue(res)
796
797 ussdSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
798 ussdSocket.connect(('127.0.0.1', 5001))
799 ussdSocket.settimeout(2.0)
800 print "Connected to %s:%d" % ussdSocket.getpeername()
801
802 print "Expecting ID_GET request"
803 data = ussdSocket.recv(4)
804 self.assertEqual(data, "\x00\x01\xfe\x04")
805
806 print "Going to send ID_RESP response"
Max3e676892016-11-16 14:55:21 +0100807 res = ussdSocket.send(IPA().id_resp(IPA().tag_name('key')))
Jacob Erlbeck6cb2ccc2013-08-14 11:10:34 +0200808 self.assertEqual(res, 10)
809
810 # initiating PING/PONG cycle to know, that the ID_RESP message has been processed
811
812 print "Going to send PING request"
Max3e676892016-11-16 14:55:21 +0100813 res = ussdSocket.send(IPA().ping())
Jacob Erlbeck6cb2ccc2013-08-14 11:10:34 +0200814 self.assertEqual(res, 4)
815
816 print "Expecting PONG response"
817 data = ussdSocket.recv(4)
818 self.assertEqual(data, "\x00\x01\xfe\x01")
819
820 res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is connected and authorized.'])
821 self.assertTrue(res)
822
823 print "Going to shut down connection"
824 ussdSocket.shutdown(socket.SHUT_WR)
825
826 print "Expecting EOF"
827 data = ussdSocket.recv(4)
828 self.assertEqual(data, "")
829
830 ussdSocket.close()
831
832 res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is not connected and not authorized.'])
833 self.assertTrue(res)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200834
Holger Hans Peter Freyther64190182014-01-20 10:14:05 +0100835 def testAccessList(self):
836 """
837 Verify that the imsi-deny can have a reject cause or no reject cause
838 """
839 self.vty.enable()
840 self.vty.command("configure terminal")
841 self.vty.command("nat")
842
843 # Old default
844 self.vty.command("access-list test-default imsi-deny ^123[0-9]*$")
845 res = self.vty.command("show running-config").split("\r\n")
846 asserted = False
847 for line in res:
Holger Hans Peter Freyther4ecc6872014-03-04 15:38:00 +0100848 if line.startswith(" access-list test-default"):
Holger Hans Peter Freyther64190182014-01-20 10:14:05 +0100849 self.assertEqual(line, " access-list test-default imsi-deny ^123[0-9]*$ 11 11")
850 asserted = True
851 self.assert_(asserted)
852
853 # Check the optional CM Service Reject Cause
854 self.vty.command("access-list test-cm-deny imsi-deny ^123[0-9]*$ 42").split("\r\n")
855 res = self.vty.command("show running-config").split("\r\n")
856 asserted = False
857 for line in res:
858 if line.startswith(" access-list test-cm"):
859 self.assertEqual(line, " access-list test-cm-deny imsi-deny ^123[0-9]*$ 42 11")
860 asserted = True
861 self.assert_(asserted)
862
863 # Check the optional LU Reject Cause
864 self.vty.command("access-list test-lu-deny imsi-deny ^123[0-9]*$ 23 42").split("\r\n")
865 res = self.vty.command("show running-config").split("\r\n")
866 asserted = False
867 for line in res:
868 if line.startswith(" access-list test-lu"):
869 self.assertEqual(line, " access-list test-lu-deny imsi-deny ^123[0-9]*$ 23 42")
870 asserted = True
871 self.assert_(asserted)
872
Jacob Erlbeck6d233712013-10-23 11:24:15 +0200873class TestVTYGbproxy(TestVTYGenericBSC):
874
875 def vty_command(self):
876 return ["./src/gprs/osmo-gbproxy", "-c",
877 "doc/examples/osmo-gbproxy/osmo-gbproxy.cfg"]
878
879 def vty_app(self):
880 return (4246, "./src/gprs/osmo-gbproxy", "OsmoGbProxy", "bsc")
881
882 def testVtyTree(self):
883 self.vty.enable()
884 self.assertTrue(self.vty.verify('configure terminal', ['']))
885 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100886 self.checkForEndAndExit()
Jacob Erlbeck6d233712013-10-23 11:24:15 +0200887 self.assertTrue(self.vty.verify('ns', ['']))
888 self.assertEquals(self.vty.node(), 'config-ns')
889 self.checkForEndAndExit()
890 self.assertTrue(self.vty.verify('exit', ['']))
891 self.assertEquals(self.vty.node(), 'config')
892 self.assertTrue(self.vty.verify('gbproxy', ['']))
893 self.assertEquals(self.vty.node(), 'config-gbproxy')
894 self.checkForEndAndExit()
895 self.assertTrue(self.vty.verify('exit', ['']))
896 self.assertEquals(self.vty.node(), 'config')
897
898 def testVtyShow(self):
899 res = self.vty.command("show ns")
900 self.assert_(res.find('Encapsulation NS-UDP-IP') >= 0)
901
902 res = self.vty.command("show gbproxy stats")
903 self.assert_(res.find('GBProxy Global Statistics') >= 0)
904
Jacob Erlbeck4211d792013-10-24 12:48:23 +0200905 def testVtyDeletePeer(self):
906 self.vty.enable()
907 self.assertTrue(self.vty.verify('delete-gbproxy-peer 9999 bvci 7777', ['BVC not found']))
908 res = self.vty.command("delete-gbproxy-peer 9999 all dry-run")
909 self.assert_(res.find('Not Deleted 0 BVC') >= 0)
910 self.assert_(res.find('Not Deleted 0 NS-VC') >= 0)
911 res = self.vty.command("delete-gbproxy-peer 9999 only-bvc dry-run")
912 self.assert_(res.find('Not Deleted 0 BVC') >= 0)
913 self.assert_(res.find('Not Deleted 0 NS-VC') < 0)
914 res = self.vty.command("delete-gbproxy-peer 9999 only-nsvc dry-run")
915 self.assert_(res.find('Not Deleted 0 BVC') < 0)
916 self.assert_(res.find('Not Deleted 0 NS-VC') >= 0)
917 res = self.vty.command("delete-gbproxy-peer 9999 all")
918 self.assert_(res.find('Deleted 0 BVC') >= 0)
919 self.assert_(res.find('Deleted 0 NS-VC') >= 0)
920
Jacob Erlbeck144b8b12014-11-04 11:15:01 +0100921class TestVTYSGSN(TestVTYGenericBSC):
922
923 def vty_command(self):
924 return ["./src/gprs/osmo-sgsn", "-c",
925 "doc/examples/osmo-sgsn/osmo-sgsn.cfg"]
926
927 def vty_app(self):
928 return (4245, "./src/gprs/osmo-sgsn", "OsmoSGSN", "sgsn")
929
930 def testVtyTree(self):
931 self.vty.enable()
932 self.assertTrue(self.vty.verify('configure terminal', ['']))
933 self.assertEquals(self.vty.node(), 'config')
934 self.checkForEndAndExit()
935 self.assertTrue(self.vty.verify('ns', ['']))
936 self.assertEquals(self.vty.node(), 'config-ns')
937 self.checkForEndAndExit()
938 self.assertTrue(self.vty.verify('exit', ['']))
939 self.assertEquals(self.vty.node(), 'config')
940 self.assertTrue(self.vty.verify('sgsn', ['']))
941 self.assertEquals(self.vty.node(), 'config-sgsn')
942 self.checkForEndAndExit()
943 self.assertTrue(self.vty.verify('exit', ['']))
944 self.assertEquals(self.vty.node(), 'config')
945
946 def testVtyShow(self):
947 res = self.vty.command("show ns")
948 self.assert_(res.find('Encapsulation NS-UDP-IP') >= 0)
949 self.assertTrue(self.vty.verify('show bssgp', ['']))
950 self.assertTrue(self.vty.verify('show bssgp stats', ['']))
951 # TODO: uncomment when the command does not segfault anymore
952 # self.assertTrue(self.vty.verify('show bssgp nsei 123', ['']))
953 # self.assertTrue(self.vty.verify('show bssgp nsei 123 stats', ['']))
954
955 self.assertTrue(self.vty.verify('show sgsn', ['']))
956 self.assertTrue(self.vty.verify('show mm-context all', ['']))
957 self.assertTrue(self.vty.verify('show mm-context imsi 000001234567', ['No MM context for IMSI 000001234567']))
958 self.assertTrue(self.vty.verify('show pdp-context all', ['']))
959
960 res = self.vty.command("show sndcp")
961 self.assert_(res.find('State of SNDCP Entities') >= 0)
962
963 res = self.vty.command("show llc")
964 self.assert_(res.find('State of LLC Entities') >= 0)
965
Jacob Erlbeck106f5472014-11-04 10:08:37 +0100966 def testVtyAuth(self):
967 self.vty.enable()
968 self.assertTrue(self.vty.verify('configure terminal', ['']))
969 self.assertEquals(self.vty.node(), 'config')
970 self.assertTrue(self.vty.verify('sgsn', ['']))
971 self.assertEquals(self.vty.node(), 'config-sgsn')
972 self.assertTrue(self.vty.verify('auth-policy accept-all', ['']))
973 res = self.vty.command("show running-config")
974 self.assert_(res.find('auth-policy accept-all') > 0)
975 self.assertTrue(self.vty.verify('auth-policy acl-only', ['']))
976 res = self.vty.command("show running-config")
977 self.assert_(res.find('auth-policy acl-only') > 0)
978 self.assertTrue(self.vty.verify('auth-policy closed', ['']))
979 res = self.vty.command("show running-config")
980 self.assert_(res.find('auth-policy closed') > 0)
Max176b62a2016-07-04 11:09:07 +0200981 self.assertTrue(self.vty.verify('gsup remote-ip 127.0.0.4', ['']))
982 self.assertTrue(self.vty.verify('gsup remote-port 2222', ['']))
Jacob Erlbeckbe2c8d92014-11-12 10:18:09 +0100983 self.assertTrue(self.vty.verify('auth-policy remote', ['']))
984 res = self.vty.command("show running-config")
985 self.assert_(res.find('auth-policy remote') > 0)
Jacob Erlbeck106f5472014-11-04 10:08:37 +0100986
Jacob Erlbeck207f4a52014-11-11 14:01:48 +0100987 def testVtySubscriber(self):
988 self.vty.enable()
989 res = self.vty.command('show subscriber cache')
990 self.assert_(res.find('1234567890') < 0)
Jacob Erlbeckd9193432015-01-19 14:11:46 +0100991 self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 create', ['']))
992 res = self.vty.command('show subscriber cache')
993 self.assert_(res.find('1234567890') >= 0)
994 self.assert_(res.find('Authorized: 0') >= 0)
995 self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 update-location-result ok', ['']))
Jacob Erlbeck207f4a52014-11-11 14:01:48 +0100996 res = self.vty.command('show subscriber cache')
997 self.assert_(res.find('1234567890') >= 0)
998 self.assert_(res.find('Authorized: 1') >= 0)
Jacob Erlbeck8000e0e2015-01-27 14:56:40 +0100999 self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 cancel update-procedure', ['']))
Jacob Erlbeck207f4a52014-11-11 14:01:48 +01001000 res = self.vty.command('show subscriber cache')
Jacob Erlbecke988ae42015-01-27 12:41:19 +01001001 self.assert_(res.find('1234567890') >= 0)
1002 self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 destroy', ['']))
1003 res = self.vty.command('show subscriber cache')
Jacob Erlbeck207f4a52014-11-11 14:01:48 +01001004 self.assert_(res.find('1234567890') < 0)
1005
Jacob Erlbeckcb1db8b2015-02-03 13:47:53 +01001006 def testVtyGgsn(self):
1007 self.vty.enable()
1008 self.assertTrue(self.vty.verify('configure terminal', ['']))
1009 self.assertEquals(self.vty.node(), 'config')
1010 self.assertTrue(self.vty.verify('sgsn', ['']))
1011 self.assertEquals(self.vty.node(), 'config-sgsn')
1012 self.assertTrue(self.vty.verify('ggsn 0 remote-ip 127.99.99.99', ['']))
1013 self.assertTrue(self.vty.verify('ggsn 0 gtp-version 1', ['']))
1014 self.assertTrue(self.vty.verify('apn * ggsn 0', ['']))
1015 self.assertTrue(self.vty.verify('apn apn1.test ggsn 0', ['']))
1016 self.assertTrue(self.vty.verify('apn apn1.test ggsn 1', ['% a GGSN with id 1 has not been defined']))
1017 self.assertTrue(self.vty.verify('apn apn1.test imsi-prefix 123456 ggsn 0', ['']))
1018 self.assertTrue(self.vty.verify('apn apn2.test imsi-prefix 123456 ggsn 0', ['']))
1019 res = self.vty.command("show running-config")
1020 self.assert_(res.find('ggsn 0 remote-ip 127.99.99.99') >= 0)
1021 self.assert_(res.find('ggsn 0 gtp-version 1') >= 0)
1022 self.assert_(res.find('apn * ggsn 0') >= 0)
1023 self.assert_(res.find('apn apn1.test ggsn 0') >= 0)
1024 self.assert_(res.find('apn apn1.test imsi-prefix 123456 ggsn 0') >= 0)
1025 self.assert_(res.find('apn apn2.test imsi-prefix 123456 ggsn 0') >= 0)
1026
Holger Hans Peter Freyther9c20a5f2015-02-06 16:23:29 +01001027 def testVtyEasyAPN(self):
1028 self.vty.enable()
1029 self.assertTrue(self.vty.verify('configure terminal', ['']))
1030 self.assertEquals(self.vty.node(), 'config')
1031 self.assertTrue(self.vty.verify('sgsn', ['']))
1032 self.assertEquals(self.vty.node(), 'config-sgsn')
1033
1034 res = self.vty.command("show running-config")
1035 self.assertEquals(res.find("apn internet"), -1)
1036
1037 self.assertTrue(self.vty.verify("access-point-name internet.apn", ['']))
1038 res = self.vty.command("show running-config")
1039 self.assert_(res.find("apn internet.apn ggsn 0") >= 0)
1040
1041 self.assertTrue(self.vty.verify("no access-point-name internet.apn", ['']))
1042 res = self.vty.command("show running-config")
1043 self.assertEquals(res.find("apn internet"), -1)
1044
Holger Hans Peter Freytherc15c61c2015-05-06 17:46:08 +02001045 def testVtyCDR(self):
1046 self.vty.enable()
1047 self.assertTrue(self.vty.verify('configure terminal', ['']))
1048 self.assertEquals(self.vty.node(), 'config')
1049 self.assertTrue(self.vty.verify('sgsn', ['']))
1050 self.assertEquals(self.vty.node(), 'config-sgsn')
1051
1052 res = self.vty.command("show running-config")
1053 self.assert_(res.find("no cdr filename") > 0)
1054
1055 self.vty.command("cdr filename bla.cdr")
1056 res = self.vty.command("show running-config")
1057 self.assertEquals(res.find("no cdr filename"), -1)
1058 self.assert_(res.find(" cdr filename bla.cdr") > 0)
1059
1060 self.vty.command("no cdr filename")
1061 res = self.vty.command("show running-config")
1062 self.assert_(res.find("no cdr filename") > 0)
1063 self.assertEquals(res.find(" cdr filename bla.cdr"), -1)
1064
1065 res = self.vty.command("show running-config")
1066 self.assert_(res.find(" cdr interval 600") > 0)
1067
1068 self.vty.command("cdr interval 900")
1069 res = self.vty.command("show running-config")
1070 self.assert_(res.find(" cdr interval 900") > 0)
1071 self.assertEquals(res.find(" cdr interval 600"), -1)
1072
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +02001073def add_nat_test(suite, workdir):
1074 if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc_nat/osmo-bsc_nat")):
1075 print("Skipping the NAT test")
1076 return
1077 test = unittest.TestLoader().loadTestsFromTestCase(TestVTYNAT)
1078 suite.addTest(test)
1079
Max49364482016-04-13 11:36:39 +02001080def nat_bsc_reload(x):
1081 x.vty.command("configure terminal")
1082 x.vty.command("nat")
Neels Hofmeyr625e05a2017-07-20 17:57:37 +02001083 x.vty.command("bscs-config-file bscs.cfg")
Max49364482016-04-13 11:36:39 +02001084 x.vty.command("end")
1085
Holger Hans Peter Freyther44ed4972016-04-14 10:05:13 -04001086def nat_msc_ip(x, ip, port):
Max49364482016-04-13 11:36:39 +02001087 x.vty.command("configure terminal")
1088 x.vty.command("nat")
1089 x.vty.command("msc ip " + ip)
Holger Hans Peter Freyther84ae27e2016-04-14 10:40:06 -04001090 x.vty.command("msc port " + str(port))
Max49364482016-04-13 11:36:39 +02001091 x.vty.command("end")
1092
1093def data2str(d):
Holger Hans Peter Freyther8bb62042016-04-14 21:40:04 -04001094 return d.encode('hex').lower()
Max49364482016-04-13 11:36:39 +02001095
Holger Hans Peter Freyther44ed4972016-04-14 10:05:13 -04001096def nat_msc_test(x, ip, port, verbose = False):
Max49364482016-04-13 11:36:39 +02001097 msc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Neels Hofmeyr53403452017-02-28 02:38:43 +01001098 msc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Neels Hofmeyrcaeb62d2016-09-28 23:38:45 +02001099 msc.settimeout(5)
Holger Hans Peter Freyther44ed4972016-04-14 10:05:13 -04001100 msc.bind((ip, port))
Max49364482016-04-13 11:36:39 +02001101 msc.listen(5)
1102 if (verbose):
1103 print "MSC is ready at " + ip
Neels Hofmeyr89d20b62016-09-26 12:59:36 +02001104 conn = None
Neels Hofmeyrcaeb62d2016-09-28 23:38:45 +02001105 while True:
1106 vty_response = x.vty.command("show msc connection")
1107 print "'show msc connection' says: %r" % vty_response
1108 if vty_response == "MSC is connected: 1":
1109 # success
1110 break;
1111 if vty_response != "MSC is connected: 0":
1112 raise Exception("Unexpected response to 'show msc connection'"
1113 " vty command: %r" % vty_response)
1114
1115 timeout_retries = 6
1116 while timeout_retries > 0:
1117 try:
1118 conn, addr = msc.accept()
1119 print "MSC got connection from ", addr
1120 break
1121 except socket.timeout:
1122 print "socket timed out."
1123 timeout_retries -= 1
1124 continue
1125
Neels Hofmeyr89d20b62016-09-26 12:59:36 +02001126 if not conn:
Neels Hofmeyr0867b722016-09-28 23:28:06 +02001127 raise Exception("VTY reports MSC is connected, but I haven't"
1128 " connected yet: %r %r" % (ip, port))
Neels Hofmeyr0b619322017-02-28 02:37:39 +01001129 return msc, conn
Max49364482016-04-13 11:36:39 +02001130
1131def ipa_handle_small(x, verbose = False):
1132 s = data2str(x.recv(4))
Neels Hofmeyrba1468e2017-02-03 04:23:46 +01001133 if len(s) != 4*2:
1134 raise Exception("expected to receive 4 bytes, but got %d (%r)" % (len(s)/2, s))
Max49364482016-04-13 11:36:39 +02001135 if "0001fe00" == s:
1136 if (verbose):
1137 print "\tBSC <- NAT: PING?"
Max3e676892016-11-16 14:55:21 +01001138 x.send(IPA().pong())
Max49364482016-04-13 11:36:39 +02001139 elif "0001fe06" == s:
1140 if (verbose):
1141 print "\tBSC <- NAT: IPA ID ACK"
Max3e676892016-11-16 14:55:21 +01001142 x.send(IPA().id_ack())
Max49364482016-04-13 11:36:39 +02001143 elif "0001fe00" == s:
1144 if (verbose):
1145 print "\tBSC <- NAT: PONG!"
1146 else:
1147 if (verbose):
1148 print "\tBSC <- NAT: ", s
1149
Neels Hofmeyrbcfee2a2017-02-03 16:09:17 +01001150def ipa_handle_resp(x, tk, verbose = False, proc=None):
Max49364482016-04-13 11:36:39 +02001151 s = data2str(x.recv(38))
1152 if "0023fe040108010701020103010401050101010011" in s:
Neels Hofmeyr7d17c3e2017-01-26 23:04:28 +01001153 retries = 3
1154 while True:
1155 print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T"))
1156 try:
1157 x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8'))))
1158 print "\tdone sending IPA identity(%s) at %s" % (tk,
1159 time.strftime("%T"))
1160 break
1161 except:
1162 print "\tfailed sending IPA identity at", time.strftime("%T")
Neels Hofmeyrbcfee2a2017-02-03 16:09:17 +01001163 if proc:
1164 print "\tproc.poll() = %r" % proc.poll()
Neels Hofmeyr7d17c3e2017-01-26 23:04:28 +01001165 if retries < 1:
1166 print "\tgiving up"
1167 raise
Neels Hofmeyre02e1e72017-02-03 05:55:26 +01001168 print "\tretrying (%d attempts left)" % retries
Neels Hofmeyr7d17c3e2017-01-26 23:04:28 +01001169 retries -= 1
Max49364482016-04-13 11:36:39 +02001170 else:
1171 if (verbose):
1172 print "\tBSC <- NAT: ", s
1173
1174def nat_bsc_num_con(x):
1175 return len(x.vty.command("show bsc connections").split('\n'))
1176
Neels Hofmeyrbcfee2a2017-02-03 16:09:17 +01001177def nat_bsc_sock_test(nr, tk, verbose = False, proc=None):
Max49364482016-04-13 11:36:39 +02001178 bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Holger Hans Peter Freyther2abf2b02016-04-14 21:13:51 -04001179 bsc.bind(('127.0.0.1', 0))
Max49364482016-04-13 11:36:39 +02001180 bsc.connect(('127.0.0.1', 5000))
1181 if (verbose):
1182 print "BSC%d " %nr
1183 print "\tconnected to %s:%d" % bsc.getpeername()
Neels Hofmeyrbcfee2a2017-02-03 16:09:17 +01001184 if proc:
1185 print "\tproc.poll() = %r" % proc.poll()
1186 print "\tproc.pid = %r" % proc.pid
Max49364482016-04-13 11:36:39 +02001187 ipa_handle_small(bsc, verbose)
Neels Hofmeyrbcfee2a2017-02-03 16:09:17 +01001188 ipa_handle_resp(bsc, tk, verbose, proc=proc)
1189 if proc:
1190 print "\tproc.poll() = %r" % proc.poll()
Max49364482016-04-13 11:36:39 +02001191 bsc.recv(27) # MGCP msg
Neels Hofmeyrbcfee2a2017-02-03 16:09:17 +01001192 if proc:
1193 print "\tproc.poll() = %r" % proc.poll()
Max49364482016-04-13 11:36:39 +02001194 ipa_handle_small(bsc, verbose)
1195 return bsc
1196
Jacob Erlbeck1b894022013-08-28 10:16:54 +02001197def add_bsc_test(suite, workdir):
1198 if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc/osmo-bsc")):
1199 print("Skipping the BSC test")
1200 return
1201 test = unittest.TestLoader().loadTestsFromTestCase(TestVTYBSC)
1202 suite.addTest(test)
1203
Jacob Erlbeck6d233712013-10-23 11:24:15 +02001204def add_gbproxy_test(suite, workdir):
1205 if not os.path.isfile(os.path.join(workdir, "src/gprs/osmo-gbproxy")):
1206 print("Skipping the Gb-Proxy test")
1207 return
1208 test = unittest.TestLoader().loadTestsFromTestCase(TestVTYGbproxy)
1209 suite.addTest(test)
1210
Jacob Erlbeck144b8b12014-11-04 11:15:01 +01001211def add_sgsn_test(suite, workdir):
1212 if not os.path.isfile(os.path.join(workdir, "src/gprs/osmo-sgsn")):
1213 print("Skipping the SGSN test")
1214 return
1215 test = unittest.TestLoader().loadTestsFromTestCase(TestVTYSGSN)
1216 suite.addTest(test)
1217
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +02001218if __name__ == '__main__':
1219 import argparse
1220 import sys
1221
1222 workdir = '.'
1223
1224 parser = argparse.ArgumentParser()
1225 parser.add_argument("-v", "--verbose", dest="verbose",
1226 action="store_true", help="verbose mode")
1227 parser.add_argument("-p", "--pythonconfpath", dest="p",
1228 help="searchpath for config")
1229 parser.add_argument("-w", "--workdir", dest="w",
1230 help="Working directory")
Neels Hofmeyr3f8a8f72017-02-28 02:43:29 +01001231 parser.add_argument("test_name", nargs="*", help="(parts of) test names to run, case-insensitive")
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +02001232 args = parser.parse_args()
1233
1234 verbose_level = 1
1235 if args.verbose:
1236 verbose_level = 2
1237
1238 if args.w:
1239 workdir = args.w
1240
1241 if args.p:
1242 confpath = args.p
1243
1244 print "confpath %s, workdir %s" % (confpath, workdir)
1245 os.chdir(workdir)
1246 print "Running tests for specific VTY commands"
1247 suite = unittest.TestSuite()
Holger Hans Peter Freyther8d998a72014-07-04 20:23:56 +02001248 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYMGCP))
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +02001249 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYNITB))
Jacob Erlbeck1b894022013-08-28 10:16:54 +02001250 add_bsc_test(suite, workdir)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +02001251 add_nat_test(suite, workdir)
Jacob Erlbeck6d233712013-10-23 11:24:15 +02001252 add_gbproxy_test(suite, workdir)
Jacob Erlbeck144b8b12014-11-04 11:15:01 +01001253 add_sgsn_test(suite, workdir)
Neels Hofmeyr3f8a8f72017-02-28 02:43:29 +01001254
1255 if args.test_name:
1256 osmoutil.pick_tests(suite, *args.test_name)
1257
Neels Hofmeyr0a45c1e2016-09-28 23:48:02 +02001258 res = unittest.TextTestRunner(verbosity=verbose_level, stream=sys.stdout).run(suite)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +02001259 sys.exit(len(res.errors) + len(res.failures))
Neels Hofmeyr23d37c92016-09-26 03:18:32 +02001260
Neels Hofmeyr0867b722016-09-28 23:28:06 +02001261# vim: shiftwidth=4 expandtab nocin ai