blob: 9fe4c3e75e7e3ddb714cdefe3e44db7120de0047 [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
18import os
19import time
20import unittest
Jacob Erlbeck6cb2ccc2013-08-14 11:10:34 +020021import socket
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +020022
23import osmopy.obscvty as obscvty
24import osmopy.osmoutil as osmoutil
25
26confpath = '.'
27
28class TestVTYBase(unittest.TestCase):
29
30 def vty_command(self):
31 raise Exception("Needs to be implemented by a subclass")
32
33 def vty_app(self):
34 raise Exception("Needs to be implemented by a subclass")
35
36 def setUp(self):
37 osmo_vty_cmd = self.vty_command()[:]
38 config_index = osmo_vty_cmd.index('-c')
39 if config_index:
40 cfi = config_index + 1
41 osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi])
42
43 try:
44 print "Launch: %s from %s" % (' '.join(osmo_vty_cmd), os.getcwd())
45 self.proc = osmoutil.popen_devnull(osmo_vty_cmd)
46 except OSError:
47 print >> sys.stderr, "Current directory: %s" % os.getcwd()
48 print >> sys.stderr, "Consider setting -b"
49 time.sleep(1)
50
51 appstring = self.vty_app()[2]
52 appport = self.vty_app()[0]
53 self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport)
54
55 def tearDown(self):
56 self.vty = None
57 osmoutil.end_proc(self.proc)
58
Holger Hans Peter Freyther8d998a72014-07-04 20:23:56 +020059class TestVTYMGCP(TestVTYBase):
60 def vty_command(self):
61 return ["./src/osmo-bsc_mgcp/osmo-bsc_mgcp", "-c",
62 "doc/examples/osmo-bsc_mgcp/mgcp.cfg"]
63
64 def vty_app(self):
65 return (4243, "./src/osmo-bsc_mgcp/osmo-bsc_mgcp", "OpenBSC MGCP", "mgcp")
66
67 def testForcePtime(self):
68 self.vty.enable()
69 res = self.vty.command("show running-config")
70 self.assert_(res.find(' rtp force-ptime 20\r') > 0)
71 self.assertEquals(res.find(' no rtp force-ptime\r'), -1)
72
73 self.vty.command("configure terminal")
74 self.vty.command("mgcp")
75 self.vty.command("no rtp force-ptime")
76 res = self.vty.command("show running-config")
77 self.assertEquals(res.find(' rtp force-ptime 20\r'), -1)
78 self.assertEquals(res.find(' no rtp force-ptime\r'), -1)
79
Holger Hans Peter Freyther619b0142014-11-19 16:04:45 +010080 def testOmitAudio(self):
81 self.vty.enable()
82 res = self.vty.command("show running-config")
83 self.assert_(res.find(' sdp audio-payload send-name\r') > 0)
84 self.assertEquals(res.find(' no sdp audio-payload send-name\r'), -1)
85
86 self.vty.command("configure terminal")
87 self.vty.command("mgcp")
88 self.vty.command("no sdp audio-payload send-name")
89 res = self.vty.command("show running-config")
90 self.assertEquals(res.find(' rtp sdp audio-payload send-name\r'), -1)
91 self.assert_(res.find(' no sdp audio-payload send-name\r') > 0)
92
93 # TODO: test it for the trunk!
94
Holger Hans Peter Freytherc390ae82015-08-20 15:15:50 +020095 def testBindAddr(self):
96 self.vty.enable()
97
98 self.vty.command("configure terminal")
99 self.vty.command("mgcp")
100
101 # enable.. disable bts-bind-ip
102 self.vty.command("rtp bts-bind-ip 254.253.252.250")
103 res = self.vty.command("show running-config")
104 self.assert_(res.find('rtp bts-bind-ip 254.253.252.250') > 0)
105 self.vty.command("no rtp bts-bind-ip")
106 res = self.vty.command("show running-config")
107 self.assertEquals(res.find(' rtp bts-bind-ip'), -1)
108
109 # enable.. disable net-bind-ip
110 self.vty.command("rtp net-bind-ip 254.253.252.250")
111 res = self.vty.command("show running-config")
112 self.assert_(res.find('rtp net-bind-ip 254.253.252.250') > 0)
113 self.vty.command("no rtp net-bind-ip")
114 res = self.vty.command("show running-config")
115 self.assertEquals(res.find(' rtp net-bind-ip'), -1)
116
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200117
118class TestVTYGenericBSC(TestVTYBase):
119
120 def checkForEndAndExit(self):
121 res = self.vty.command("list")
122 #print ('looking for "exit"\n')
123 self.assert_(res.find(' exit\r') > 0)
124 #print 'found "exit"\nlooking for "end"\n'
125 self.assert_(res.find(' end\r') > 0)
126 #print 'found "end"\n'
127
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200128 def _testConfigNetworkTree(self):
129 self.vty.enable()
130 self.assertTrue(self.vty.verify("configure terminal",['']))
131 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100132 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200133 self.assertTrue(self.vty.verify("network",['']))
134 self.assertEquals(self.vty.node(), 'config-net')
135 self.checkForEndAndExit()
136 self.assertTrue(self.vty.verify("bts 0",['']))
137 self.assertEquals(self.vty.node(), 'config-net-bts')
138 self.checkForEndAndExit()
139 self.assertTrue(self.vty.verify("trx 0",['']))
140 self.assertEquals(self.vty.node(), 'config-net-bts-trx')
141 self.checkForEndAndExit()
Jacob Erlbeck733bec82013-09-11 10:46:56 +0200142 self.vty.command("write terminal")
143 self.assertTrue(self.vty.verify("exit",['']))
144 self.assertEquals(self.vty.node(), 'config-net-bts')
145 self.assertTrue(self.vty.verify("exit",['']))
146 self.assertTrue(self.vty.verify("bts 1",['']))
147 self.assertEquals(self.vty.node(), 'config-net-bts')
148 self.checkForEndAndExit()
149 self.assertTrue(self.vty.verify("trx 1",['']))
150 self.assertEquals(self.vty.node(), 'config-net-bts-trx')
151 self.checkForEndAndExit()
152 self.vty.command("write terminal")
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200153 self.assertTrue(self.vty.verify("exit",['']))
154 self.assertEquals(self.vty.node(), 'config-net-bts')
155 self.assertTrue(self.vty.verify("exit",['']))
156 self.assertEquals(self.vty.node(), 'config-net')
157 self.assertTrue(self.vty.verify("exit",['']))
158 self.assertEquals(self.vty.node(), 'config')
159 self.assertTrue(self.vty.verify("exit",['']))
160 self.assertTrue(self.vty.node() is None)
161
162class TestVTYNITB(TestVTYGenericBSC):
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +0200163
164 def vty_command(self):
165 return ["./src/osmo-nitb/osmo-nitb", "-c",
166 "doc/examples/osmo-nitb/nanobts/openbsc.cfg"]
167
168 def vty_app(self):
169 return (4242, "./src/osmo-nitb/osmo-nitb", "OpenBSC", "nitb")
170
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200171 def testConfigNetworkTree(self):
Jacob Erlbeck75877272013-10-23 11:24:14 +0200172 self._testConfigNetworkTree()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200173
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200174 def checkForSmpp(self):
175 """SMPP is not always enabled, check if it is"""
176 res = self.vty.command("list")
177 return "smpp" in res
178
Holger Hans Peter Freyther42cf2e02015-07-06 16:41:30 +0200179 def testSmppFirst(self):
Holger Hans Peter Freyther42cf2e02015-07-06 16:41:30 +0200180 # enable the configuration
181 self.vty.enable()
182 self.vty.command("configure terminal")
Holger Hans Peter Freythera2c41c42015-07-13 11:23:53 +0200183
184 if not self.checkForSmpp():
185 return
186
Holger Hans Peter Freyther42cf2e02015-07-06 16:41:30 +0200187 self.vty.command("smpp")
188
189 # check the default
190 res = self.vty.command("write terminal")
191 self.assert_(res.find(' no smpp-first') > 0)
192
193 self.vty.verify("smpp-first", [''])
194 res = self.vty.command("write terminal")
195 self.assert_(res.find(' smpp-first') > 0)
196 self.assertEquals(res.find('no smpp-first'), -1)
197
198 self.vty.verify("no smpp-first", [''])
199 res = self.vty.command("write terminal")
200 self.assert_(res.find('no smpp-first') > 0)
201
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200202 def testVtyTree(self):
203 self.vty.enable()
204 self.assertTrue(self.vty.verify("configure terminal", ['']))
205 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100206 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200207 self.assertTrue(self.vty.verify('mncc-int', ['']))
208 self.assertEquals(self.vty.node(), 'config-mncc-int')
209 self.checkForEndAndExit()
210 self.assertTrue(self.vty.verify('exit', ['']))
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200211
212 if self.checkForSmpp():
213 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck75877272013-10-23 11:24:14 +0200214 self.assertTrue(self.vty.verify('smpp', ['']))
215 self.assertEquals(self.vty.node(), 'config-smpp')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100216 self.checkForEndAndExit()
Jacob Erlbeck75877272013-10-23 11:24:14 +0200217 self.assertTrue(self.vty.verify("exit", ['']))
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200218
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200219 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200220 self.assertTrue(self.vty.verify("exit", ['']))
221 self.assertTrue(self.vty.node() is None)
222
223 # Check searching for outer node's commands
224 self.vty.command("configure terminal")
225 self.vty.command('mncc-int')
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200226
227 if self.checkForSmpp():
228 self.vty.command('smpp')
229 self.assertEquals(self.vty.node(), 'config-smpp')
230 self.vty.command('mncc-int')
231
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200232 self.assertEquals(self.vty.node(), 'config-mncc-int')
233
Maxddee01f2016-05-24 14:23:27 +0200234 def testVtyAuthorization(self):
235 self.vty.enable()
236 self.vty.command("configure terminal")
237 self.vty.command("network")
238 self.assertTrue(self.vty.verify("auth policy closed", ['']))
239 self.assertTrue(self.vty.verify("auth policy regexp", ['']))
240 self.assertTrue(self.vty.verify("authorized-regexp ^001", ['']))
241 self.assertTrue(self.vty.verify("authorized-regexp 02$", ['']))
242 self.assertTrue(self.vty.verify("authorized-regexp *123.*", ['']))
243 self.vty.command("end")
244 self.vty.command("configure terminal")
245 self.vty.command("nitb")
246 self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
Maxe6052c42016-06-30 10:25:49 +0200247 self.assertTrue(self.vty.verify("subscriber-create-on-demand no-extension", ['']))
Maxddee01f2016-05-24 14:23:27 +0200248 self.vty.command("end")
249
Max0c1bc262016-04-20 12:06:06 +0200250 def testSi2Q(self):
251 self.vty.enable()
252 self.vty.command("configure terminal")
253 self.vty.command("network")
254 self.vty.command("bts 0")
255 before = self.vty.command("show running-config")
256 self.vty.command("si2quater neighbor-list add earfcn 1911 threshold 11 2")
257 self.vty.command("si2quater neighbor-list add earfcn 1924 threshold 11 3")
258 self.vty.command("si2quater neighbor-list add earfcn 2111 threshold 11")
259 self.vty.command("si2quater neighbor-list del earfcn 1911")
260 self.vty.command("si2quater neighbor-list del earfcn 1924")
261 self.vty.command("si2quater neighbor-list del earfcn 2111")
262 self.assertEquals(before, self.vty.command("show running-config"))
Max26679e02016-04-20 15:57:13 +0200263 self.vty.command("si2quater neighbor-list add uarfcn 1976 13 1")
264 self.vty.command("si2quater neighbor-list add uarfcn 1976 38 1")
265 self.vty.command("si2quater neighbor-list add uarfcn 1976 44 1")
266 self.vty.command("si2quater neighbor-list add uarfcn 1976 120 1")
267 self.vty.command("si2quater neighbor-list add uarfcn 1976 140 1")
268 self.vty.command("si2quater neighbor-list add uarfcn 1976 163 1")
269 self.vty.command("si2quater neighbor-list add uarfcn 1976 166 1")
270 self.vty.command("si2quater neighbor-list add uarfcn 1976 217 1")
271 self.vty.command("si2quater neighbor-list add uarfcn 1976 224 1")
272 self.vty.command("si2quater neighbor-list add uarfcn 1976 225 1")
273 self.vty.command("si2quater neighbor-list add uarfcn 1976 226 1")
274 self.vty.command("si2quater neighbor-list del uarfcn 1976 13")
275 self.vty.command("si2quater neighbor-list del uarfcn 1976 38")
276 self.vty.command("si2quater neighbor-list del uarfcn 1976 44")
277 self.vty.command("si2quater neighbor-list del uarfcn 1976 120")
278 self.vty.command("si2quater neighbor-list del uarfcn 1976 140")
279 self.vty.command("si2quater neighbor-list del uarfcn 1976 163")
280 self.vty.command("si2quater neighbor-list del uarfcn 1976 166")
281 self.vty.command("si2quater neighbor-list del uarfcn 1976 217")
282 self.vty.command("si2quater neighbor-list del uarfcn 1976 224")
283 self.vty.command("si2quater neighbor-list del uarfcn 1976 225")
284 self.vty.command("si2quater neighbor-list del uarfcn 1976 226")
285 self.assertEquals(before, self.vty.command("show running-config"))
Max0c1bc262016-04-20 12:06:06 +0200286
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +0200287 def testEnableDisablePeriodicLU(self):
288 self.vty.enable()
289 self.vty.command("configure terminal")
290 self.vty.command("network")
291 self.vty.command("bts 0")
292
293 # Test invalid input
294 self.vty.verify("periodic location update 0", ['% Unknown command.'])
295 self.vty.verify("periodic location update 5", ['% Unknown command.'])
296 self.vty.verify("periodic location update 1531", ['% Unknown command.'])
297
298 # Enable periodic lu..
299 self.vty.verify("periodic location update 60", [''])
300 res = self.vty.command("write terminal")
Holger Hans Peter Freytherc0438e32013-07-27 22:23:25 +0200301 self.assert_(res.find('periodic location update 60') > 0)
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +0200302 self.assertEquals(res.find('no periodic location update'), -1)
303
304 # Now disable it..
305 self.vty.verify("no periodic location update", [''])
306 res = self.vty.command("write terminal")
307 self.assertEquals(res.find('periodic location update 60'), -1)
Holger Hans Peter Freytherc0438e32013-07-27 22:23:25 +0200308 self.assert_(res.find('no periodic location update') > 0)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200309
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100310 def testEnableDisableSiHacks(self):
311 self.vty.enable()
312 self.vty.command("configure terminal")
313 self.vty.command("network")
314 self.vty.command("bts 0")
315
316 # Enable periodic lu..
317 self.vty.verify("force-combined-si", [''])
318 res = self.vty.command("write terminal")
319 self.assert_(res.find(' force-combined-si') > 0)
320 self.assertEquals(res.find('no force-combined-si'), -1)
321
322 # Now disable it..
323 self.vty.verify("no force-combined-si", [''])
324 res = self.vty.command("write terminal")
325 self.assertEquals(res.find(' force-combined-si'), -1)
326 self.assert_(res.find('no force-combined-si') > 0)
327
Ivan Kluchnikov67920592013-09-16 13:13:04 +0400328 def testRachAccessControlClass(self):
329 self.vty.enable()
330 self.vty.command("configure terminal")
331 self.vty.command("network")
332 self.vty.command("bts 0")
333
334 # Test invalid input
335 self.vty.verify("rach access-control-class", ['% Command incomplete.'])
336 self.vty.verify("rach access-control-class 1", ['% Command incomplete.'])
337 self.vty.verify("rach access-control-class -1", ['% Unknown command.'])
338 self.vty.verify("rach access-control-class 10", ['% Unknown command.'])
339 self.vty.verify("rach access-control-class 16", ['% Unknown command.'])
340
341 # Barred rach access control classes
342 for classNum in range(16):
343 if classNum != 10:
344 self.vty.verify("rach access-control-class " + str(classNum) + " barred", [''])
345
346 # Verify settings
347 res = self.vty.command("write terminal")
348 for classNum in range(16):
349 if classNum != 10:
350 self.assert_(res.find("rach access-control-class " + str(classNum) + " barred") > 0)
351
352 # Allowed rach access control classes
353 for classNum in range(16):
354 if classNum != 10:
355 self.vty.verify("rach access-control-class " + str(classNum) + " allowed", [''])
356
357 # Verify settings
358 res = self.vty.command("write terminal")
359 for classNum in range(16):
360 if classNum != 10:
361 self.assertEquals(res.find("rach access-control-class " + str(classNum) + " barred"), -1)
362
Holger Hans Peter Freytherde392252016-04-01 19:44:00 +0200363 def testSubscriberCreateDeleteTwice(self):
364 """
365 OS#1657 indicates that there might be an issue creating the
366 same subscriber twice. This test will use the VTY command to
367 create a subscriber and then issue a second create command
368 with the same IMSI. The test passes if the VTY continues to
369 respond to VTY commands.
370 """
371 self.vty.enable()
372
373 imsi = "204300854013739"
374
375 # Initially we don't have this subscriber
376 self.vty.verify('show subscriber imsi '+imsi, ['% No subscriber found for imsi '+imsi])
377
378 # Lets create one
379 res = self.vty.command('subscriber create imsi '+imsi)
380 self.assert_(res.find(" IMSI: "+imsi) > 0)
381 # And now create one again.
382 res2 = self.vty.command('subscriber create imsi '+imsi)
383 self.assert_(res2.find(" IMSI: "+imsi) > 0)
384 self.assertEqual(res, res2)
385
386 # Verify it has been created
387 res = self.vty.command('show subscriber imsi '+imsi)
388 self.assert_(res.find(" IMSI: "+imsi) > 0)
389
390 # Delete it
Max488902d2016-06-22 14:02:39 +0200391 res = self.vty.command('subscriber imsi ' + imsi + ' delete')
392 self.assert_("" == res)
Holger Hans Peter Freytherde392252016-04-01 19:44:00 +0200393
394 # Now it should not be there anymore
395 res = self.vty.command('show subscriber imsi '+imsi)
Max488902d2016-06-22 14:02:39 +0200396 self.assert_(('% No subscriber found for imsi ' + imsi) == res)
Holger Hans Peter Freytherde392252016-04-01 19:44:00 +0200397
398
Ruben Pollaned04a0d2014-09-24 20:50:13 -0500399 def testSubscriberCreateDelete(self):
Alexander Chemerisbd6d40f2013-10-04 23:54:17 +0200400 self.vty.enable()
401
402 imsi = "204300854013739"
Maxe6052c42016-06-30 10:25:49 +0200403 imsi2 = "222301824913762"
404 imsi3 = "333500854113763"
405 imsi4 = "444583744053764"
Alexander Chemerisbd6d40f2013-10-04 23:54:17 +0200406
407 # Initially we don't have this subscriber
408 self.vty.verify('show subscriber imsi '+imsi, ['% No subscriber found for imsi '+imsi])
409
410 # Lets create one
411 res = self.vty.command('subscriber create imsi '+imsi)
412 self.assert_(res.find(" IMSI: "+imsi) > 0)
Maxe6052c42016-06-30 10:25:49 +0200413 self.assert_(res.find("Extension") > 0)
Alexander Chemerisbd6d40f2013-10-04 23:54:17 +0200414
415 # Now we have it
416 res = self.vty.command('show subscriber imsi '+imsi)
417 self.assert_(res.find(" IMSI: "+imsi) > 0)
418
Maxe6052c42016-06-30 10:25:49 +0200419 # With narrow random interval
420 self.vty.command("configure terminal")
421 self.vty.command("nitb")
422 self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
423 # wrong interval
424 res = self.vty.command("subscriber-create-on-demand random 221 122")
425 # error string will contain arguments
426 self.assert_(res.find("122") > 0)
427 self.assert_(res.find("221") > 0)
428 # correct interval - silent ok
429 self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 222", ['']))
430 self.vty.command("end")
431
432 res = self.vty.command('subscriber create imsi ' + imsi2)
433 self.assert_(res.find(" IMSI: " + imsi2) > 0)
434 self.assert_(res.find("221") > 0 or res.find("222") > 0)
435 self.assert_(res.find(" Extension: ") > 0)
436
437 # Without extension
438 self.vty.command("configure terminal")
439 self.vty.command("nitb")
440 self.assertTrue(self.vty.verify("subscriber-create-on-demand no-extension", ['']))
441 self.vty.command("end")
442 res = self.vty.command('subscriber create imsi ' + imsi3)
443 self.assert_(res.find(" IMSI: " + imsi3) > 0)
444 self.assertEquals(res.find("Extension"), -1)
445
446 # With extension again
447 self.vty.command("configure terminal")
448 self.vty.command("nitb")
449 self.assertTrue(self.vty.verify("no subscriber-create-on-demand", ['']))
450 self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
451 self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 666", ['']))
452 self.vty.command("end")
453
454 res = self.vty.command('subscriber create imsi ' + imsi4)
455 self.assert_(res.find(" IMSI: " + imsi4) > 0)
456 self.assert_(res.find(" Extension: ") > 0)
457
Ruben Pollaned04a0d2014-09-24 20:50:13 -0500458 # Delete it
Max488902d2016-06-22 14:02:39 +0200459 res = self.vty.command('subscriber imsi ' + imsi + ' delete')
460 self.assert_("" == res)
Maxe6052c42016-06-30 10:25:49 +0200461 res = self.vty.command('subscriber imsi ' + imsi2 + ' delete')
462 self.assert_("" == res)
463 res = self.vty.command('subscriber imsi ' + imsi3 + ' delete')
464 self.assert_("" == res)
465 res = self.vty.command('subscriber imsi ' + imsi4 + ' delete')
466 self.assert_("" == res)
Ruben Pollaned04a0d2014-09-24 20:50:13 -0500467
468 # Now it should not be there anymore
469 res = self.vty.command('show subscriber imsi '+imsi)
Max488902d2016-06-22 14:02:39 +0200470 self.assert_(('% No subscriber found for imsi ' + imsi) == res)
Ruben Pollaned04a0d2014-09-24 20:50:13 -0500471
Jacob Erlbeck322b1492015-04-07 17:49:49 +0200472 def testSubscriberSettings(self):
473 self.vty.enable()
474
475 imsi = "204300854013739"
Max0fcd2e22016-06-07 15:32:16 +0200476 imsi2 = "204301824913769"
Jacob Erlbeck322b1492015-04-07 17:49:49 +0200477 wrong_imsi = "204300999999999"
478
479 # Lets create one
480 res = self.vty.command('subscriber create imsi '+imsi)
481 self.assert_(res.find(" IMSI: "+imsi) > 0)
Max0fcd2e22016-06-07 15:32:16 +0200482 self.assert_(res.find("Extension") > 0)
Jacob Erlbeck322b1492015-04-07 17:49:49 +0200483
484 self.vty.verify('subscriber imsi '+wrong_imsi+' name wrong', ['% No subscriber found for imsi '+wrong_imsi])
485 res = self.vty.command('subscriber imsi '+imsi+' name '+('X' * 160))
486 self.assert_(res.find("NAME is too long") > 0)
487
488 self.vty.verify('subscriber imsi '+imsi+' name '+('G' * 159), [''])
489
490 self.vty.verify('subscriber imsi '+wrong_imsi+' extension 840', ['% No subscriber found for imsi '+wrong_imsi])
491 res = self.vty.command('subscriber imsi '+imsi+' extension '+('9' * 15))
492 self.assert_(res.find("EXTENSION is too long") > 0)
493
494 self.vty.verify('subscriber imsi '+imsi+' extension '+('1' * 14), [''])
495
Max0fcd2e22016-06-07 15:32:16 +0200496 # With narrow random interval
497 self.vty.command("configure terminal")
498 self.vty.command("nitb")
499 self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
500 # wrong interval
501 res = self.vty.command("subscriber-create-on-demand random 221 122")
502 self.assert_(res.find("122") > 0)
503 self.assert_(res.find("221") > 0)
504 # correct interval
505 self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 222", ['']))
506 self.vty.command("end")
507
Max488902d2016-06-22 14:02:39 +0200508 # create subscriber with extension in a configured interval
Max0fcd2e22016-06-07 15:32:16 +0200509 res = self.vty.command('subscriber create imsi ' + imsi2)
510 self.assert_(res.find(" IMSI: " + imsi2) > 0)
511 self.assert_(res.find("221") > 0 or res.find("222") > 0)
512 self.assert_(res.find(" Extension: ") > 0)
513
Jacob Erlbeck322b1492015-04-07 17:49:49 +0200514 # Delete it
Max488902d2016-06-22 14:02:39 +0200515 res = self.vty.command('subscriber imsi ' + imsi + ' delete')
Jacob Erlbeck322b1492015-04-07 17:49:49 +0200516 self.assert_(res != "")
Max488902d2016-06-22 14:02:39 +0200517 # imsi2 is inactive so deletion should succeed
518 res = self.vty.command('subscriber imsi ' + imsi2 + ' delete')
519 self.assert_("" == res)
Jacob Erlbeck322b1492015-04-07 17:49:49 +0200520
Holger Hans Peter Freytherec37bb22013-02-05 09:39:09 +0100521 def testShowPagingGroup(self):
522 res = self.vty.command("show paging-group 255 1234567")
523 self.assertEqual(res, "% can't find BTS 255")
524 res = self.vty.command("show paging-group 0 1234567")
525 self.assertEquals(res, "%Paging group for IMSI 1234567 on BTS #0 is 7")
526
Ciabyec6e4f82014-03-06 17:20:55 +0100527 def testShowNetwork(self):
528 res = self.vty.command("show network")
529 self.assert_(res.startswith('BSC is on Country Code') >= 0)
530
Holger Hans Peter Freyther86573262015-01-31 09:47:37 +0100531 def testMeasurementFeed(self):
532 self.vty.enable()
533 self.vty.command("configure terminal")
534 self.vty.command("mncc-int")
535
536 res = self.vty.command("write terminal")
537 self.assertEquals(res.find('meas-feed scenario'), -1)
538
539 self.vty.command("meas-feed scenario bla")
540 res = self.vty.command("write terminal")
541 self.assert_(res.find('meas-feed scenario bla') > 0)
542
543 self.vty.command("meas-feed scenario abcdefghijklmnopqrstuvwxyz01234567890")
544 res = self.vty.command("write terminal")
545 self.assertEquals(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz01234567890'), -1)
546 self.assertEquals(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz012345'), -1)
547 self.assert_(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz01234') > 0)
548
549
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200550class TestVTYBSC(TestVTYGenericBSC):
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200551
552 def vty_command(self):
553 return ["./src/osmo-bsc/osmo-bsc", "-c",
554 "doc/examples/osmo-bsc/osmo-bsc.cfg"]
555
556 def vty_app(self):
557 return (4242, "./src/osmo-bsc/osmo-bsc", "OsmoBSC", "bsc")
558
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200559 def testConfigNetworkTree(self):
Jacob Erlbeck75877272013-10-23 11:24:14 +0200560 self._testConfigNetworkTree()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200561
562 def testVtyTree(self):
563 self.vty.enable()
564 self.assertTrue(self.vty.verify("configure terminal", ['']))
565 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100566 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200567 self.assertTrue(self.vty.verify("msc 0", ['']))
568 self.assertEquals(self.vty.node(), 'config-msc')
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200569 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200570 self.assertTrue(self.vty.verify("exit", ['']))
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200571 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200572 self.assertTrue(self.vty.verify("bsc", ['']))
573 self.assertEquals(self.vty.node(), 'config-bsc')
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200574 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200575 self.assertTrue(self.vty.verify("exit", ['']))
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200576 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200577 self.assertTrue(self.vty.verify("exit", ['']))
578 self.assertTrue(self.vty.node() is None)
579
580 # Check searching for outer node's commands
581 self.vty.command("configure terminal")
582 self.vty.command('msc 0')
583 self.vty.command("bsc")
584 self.assertEquals(self.vty.node(), 'config-bsc')
585 self.vty.command("msc 0")
586 self.assertEquals(self.vty.node(), 'config-msc')
587
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200588 def testUssdNotificationsMsc(self):
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200589 self.vty.enable()
590 self.vty.command("configure terminal")
591 self.vty.command("msc")
592
593 # Test invalid input
594 self.vty.verify("bsc-msc-lost-text", ['% Command incomplete.'])
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200595 self.vty.verify("bsc-welcome-text", ['% Command incomplete.'])
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200596 self.vty.verify("bsc-grace-text", ['% Command incomplete.'])
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200597
598 # Enable USSD notifications
599 self.vty.verify("bsc-msc-lost-text MSC disconnected", [''])
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200600 self.vty.verify("bsc-welcome-text Hello MS", [''])
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200601 self.vty.verify("bsc-grace-text In grace period", [''])
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200602
603 # Verify settings
604 res = self.vty.command("write terminal")
605 self.assert_(res.find('bsc-msc-lost-text MSC disconnected') > 0)
606 self.assertEquals(res.find('no bsc-msc-lost-text'), -1)
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200607 self.assert_(res.find('bsc-welcome-text Hello MS') > 0)
608 self.assertEquals(res.find('no bsc-welcome-text'), -1)
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200609 self.assert_(res.find('bsc-grace-text In grace period') > 0)
610 self.assertEquals(res.find('no bsc-grace-text'), -1)
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200611
612 # Now disable it..
613 self.vty.verify("no bsc-msc-lost-text", [''])
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200614 self.vty.verify("no bsc-welcome-text", [''])
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200615 self.vty.verify("no bsc-grace-text", [''])
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200616
617 # Verify settings
618 res = self.vty.command("write terminal")
619 self.assertEquals(res.find('bsc-msc-lost-text MSC disconnected'), -1)
620 self.assert_(res.find('no bsc-msc-lost-text') > 0)
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200621 self.assertEquals(res.find('bsc-welcome-text Hello MS'), -1)
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200622 self.assert_(res.find('no bsc-welcome-text') > 0)
623 self.assertEquals(res.find('bsc-grace-text In grace period'), -1)
624 self.assert_(res.find('no bsc-grace-text') > 0)
625
626 def testUssdNotificationsBsc(self):
627 self.vty.enable()
628 self.vty.command("configure terminal")
629 self.vty.command("bsc")
630
631 # Test invalid input
632 self.vty.verify("missing-msc-text", ['% Command incomplete.'])
633
634 # Enable USSD notifications
635 self.vty.verify("missing-msc-text No MSC found", [''])
636
637 # Verify settings
638 res = self.vty.command("write terminal")
639 self.assert_(res.find('missing-msc-text No MSC found') > 0)
640 self.assertEquals(res.find('no missing-msc-text'), -1)
641
642 # Now disable it..
643 self.vty.verify("no missing-msc-text", [''])
644
645 # Verify settings
646 res = self.vty.command("write terminal")
647 self.assertEquals(res.find('missing-msc-text No MSC found'), -1)
648 self.assert_(res.find('no missing-msc-text') > 0)
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200649
Jacob Erlbeck946d1412013-09-17 13:59:29 +0200650 def testNetworkTimezone(self):
651 self.vty.enable()
652 self.vty.verify("configure terminal", [''])
653 self.vty.verify("network", [''])
654 self.vty.verify("bts 0", [''])
655
656 # Test invalid input
657 self.vty.verify("timezone", ['% Command incomplete.'])
658 self.vty.verify("timezone 20 0", ['% Unknown command.'])
659 self.vty.verify("timezone 0 11", ['% Unknown command.'])
660 self.vty.verify("timezone 0 0 99", ['% Unknown command.'])
661
662 # Set time zone without DST
663 self.vty.verify("timezone 2 30", [''])
664
665 # Verify settings
666 res = self.vty.command("write terminal")
667 self.assert_(res.find('timezone 2 30') > 0)
668 self.assertEquals(res.find('timezone 2 30 '), -1)
669
670 # Set time zone with DST
671 self.vty.verify("timezone 2 30 1", [''])
672
673 # Verify settings
674 res = self.vty.command("write terminal")
675 self.assert_(res.find('timezone 2 30 1') > 0)
676
677 # Now disable it..
678 self.vty.verify("no timezone", [''])
679
680 # Verify settings
681 res = self.vty.command("write terminal")
682 self.assertEquals(res.find(' timezone'), -1)
683
Ciabyec6e4f82014-03-06 17:20:55 +0100684 def testShowNetwork(self):
685 res = self.vty.command("show network")
686 self.assert_(res.startswith('BSC is on Country Code') >= 0)
687
Holger Hans Peter Freytherdb64f2e2014-10-29 10:06:15 +0100688 def testPingPongConfiguration(self):
689 self.vty.enable()
690 self.vty.verify("configure terminal", [''])
691 self.vty.verify("network", [''])
692 self.vty.verify("msc 0", [''])
693
694 self.vty.verify("timeout-ping 12", [''])
695 self.vty.verify("timeout-pong 14", [''])
696 res = self.vty.command("show running-config")
697 self.assert_(res.find(" timeout-ping 12") > 0)
698 self.assert_(res.find(" timeout-pong 14") > 0)
699 self.assert_(res.find(" no timeout-ping advanced") > 0)
700
701 self.vty.verify("timeout-ping advanced", [''])
702 res = self.vty.command("show running-config")
703 self.assert_(res.find(" timeout-ping 12") > 0)
704 self.assert_(res.find(" timeout-pong 14") > 0)
705 self.assert_(res.find(" timeout-ping advanced") > 0)
706
707 self.vty.verify("no timeout-ping advanced", [''])
708 res = self.vty.command("show running-config")
709 self.assert_(res.find(" timeout-ping 12") > 0)
710 self.assert_(res.find(" timeout-pong 14") > 0)
711 self.assert_(res.find(" no timeout-ping advanced") > 0)
712
713 self.vty.verify("no timeout-ping", [''])
714 res = self.vty.command("show running-config")
715 self.assertEquals(res.find(" timeout-ping 12"), -1)
716 self.assertEquals(res.find(" timeout-pong 14"), -1)
717 self.assertEquals(res.find(" no timeout-ping advanced"), -1)
718 self.assert_(res.find(" no timeout-ping") > 0)
719
720 self.vty.verify("timeout-ping advanced", ['%ping handling is disabled. Enable it first.'])
721
722 # And back to enabling it
723 self.vty.verify("timeout-ping 12", [''])
724 self.vty.verify("timeout-pong 14", [''])
725 res = self.vty.command("show running-config")
726 self.assert_(res.find(" timeout-ping 12") > 0)
727 self.assert_(res.find(" timeout-pong 14") > 0)
728 self.assert_(res.find(" timeout-ping advanced") > 0)
729
Holger Hans Peter Freyther32dd2f32015-04-01 18:15:48 +0200730 def testMscDataCoreLACCI(self):
731 self.vty.enable()
732 res = self.vty.command("show running-config")
733 self.assertEquals(res.find("core-location-area-code"), -1)
734 self.assertEquals(res.find("core-cell-identity"), -1)
735
736 self.vty.command("configure terminal")
737 self.vty.command("msc 0")
738 self.vty.command("core-location-area-code 666")
739 self.vty.command("core-cell-identity 333")
740
741 res = self.vty.command("show running-config")
742 self.assert_(res.find("core-location-area-code 666") > 0)
743 self.assert_(res.find("core-cell-identity 333") > 0)
744
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200745class TestVTYNAT(TestVTYGenericBSC):
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200746
747 def vty_command(self):
Max49364482016-04-13 11:36:39 +0200748 return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-l", "127.0.0.1", "-c",
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200749 "doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg"]
750
751 def vty_app(self):
752 return (4244, "src/osmo-bsc_nat/osmo-bsc_nat", "OsmoBSCNAT", "nat")
753
Max49364482016-04-13 11:36:39 +0200754 def testBSCreload(self):
Holger Hans Peter Freyther44ed4972016-04-14 10:05:13 -0400755 # Use different port for the mock msc to avoid clashing with
756 # the osmo-bsc_nat itself
Holger Hans Peter Freytherf1a61bb2016-04-14 08:50:25 -0400757 ip = "127.0.0.1"
Holger Hans Peter Freythere98c9c72016-04-14 10:58:58 -0400758 port = 5522
Max49364482016-04-13 11:36:39 +0200759 self.vty.enable()
760 bscs1 = self.vty.command("show bscs-config")
761 nat_bsc_reload(self)
762 bscs2 = self.vty.command("show bscs-config")
763 # check that multiple calls to bscs-config-file give the same result
764 self.assertEquals(bscs1, bscs2)
765
766 # add new bsc
767 self.vty.command("configure terminal")
768 self.vty.command("nat")
769 self.vty.command("bsc 5")
770 self.vty.command("token key")
771 self.vty.command("location_area_code 666")
772 self.vty.command("end")
773
774 # update bsc token
775 self.vty.command("configure terminal")
776 self.vty.command("nat")
777 self.vty.command("bsc 1")
778 self.vty.command("token xyu")
779 self.vty.command("end")
780
Holger Hans Peter Freyther44ed4972016-04-14 10:05:13 -0400781 nat_msc_ip(self, ip, port)
782 msc = nat_msc_test(self, ip, port)
Max49364482016-04-13 11:36:39 +0200783 b0 = nat_bsc_sock_test(0, "lol")
784 b1 = nat_bsc_sock_test(1, "xyu")
785 b2 = nat_bsc_sock_test(5, "key")
786
787 self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured"))
788 self.assertTrue(3 == nat_bsc_num_con(self))
789 self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
790
791 nat_bsc_reload(self)
792 bscs2 = self.vty.command("show bscs-config")
793 # check that the reset to initial config succeeded
794 self.assertEquals(bscs1, bscs2)
795
796 self.assertEquals("2 BSCs configured", self.vty.command("show nat num-bscs-configured"))
797 self.assertTrue(1 == nat_bsc_num_con(self))
798 rem = self.vty.command("show bsc connections").split(' ')
799 # remaining connection is for BSC0
800 self.assertEquals('0', rem[2])
801 # remaining connection is authorized
802 self.assertEquals('1', rem[4])
803 self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
804
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200805 def testVtyTree(self):
806 self.vty.enable()
807 self.assertTrue(self.vty.verify('configure terminal', ['']))
808 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100809 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200810 self.assertTrue(self.vty.verify('mgcp', ['']))
811 self.assertEquals(self.vty.node(), 'config-mgcp')
812 self.checkForEndAndExit()
813 self.assertTrue(self.vty.verify('exit', ['']))
814 self.assertEquals(self.vty.node(), 'config')
815 self.assertTrue(self.vty.verify('nat', ['']))
816 self.assertEquals(self.vty.node(), 'config-nat')
817 self.checkForEndAndExit()
818 self.assertTrue(self.vty.verify('bsc 0', ['']))
819 self.assertEquals(self.vty.node(), 'config-nat-bsc')
820 self.checkForEndAndExit()
821 self.assertTrue(self.vty.verify('exit', ['']))
822 self.assertEquals(self.vty.node(), 'config-nat')
823 self.assertTrue(self.vty.verify('exit', ['']))
824 self.assertEquals(self.vty.node(), 'config')
825 self.assertTrue(self.vty.verify('exit', ['']))
826 self.assertTrue(self.vty.node() is None)
827
828 # Check searching for outer node's commands
829 self.vty.command('configure terminal')
830 self.vty.command('mgcp')
831 self.vty.command('nat')
832 self.assertEquals(self.vty.node(), 'config-nat')
Jacob Erlbeck4c9dff52013-09-02 13:17:17 +0200833 self.vty.command('mgcp')
834 self.assertEquals(self.vty.node(), 'config-mgcp')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200835 self.vty.command('nat')
836 self.assertEquals(self.vty.node(), 'config-nat')
837 self.vty.command('bsc 0')
Jacob Erlbeck4c9dff52013-09-02 13:17:17 +0200838 self.vty.command('mgcp')
839 self.assertEquals(self.vty.node(), 'config-mgcp')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200840
Holger Hans Peter Freytherb718ad32013-06-25 09:08:02 +0200841 def testRewriteNoRewrite(self):
842 self.vty.enable()
843 res = self.vty.command("configure terminal")
844 res = self.vty.command("nat")
845 res = self.vty.command("number-rewrite rewrite.cfg")
846 res = self.vty.command("no number-rewrite")
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200847
Holger Hans Peter Freyther7f100c92015-04-23 20:25:17 -0400848 def testEnsureNoEnsureModeSet(self):
849 self.vty.enable()
850 res = self.vty.command("configure terminal")
851 res = self.vty.command("nat")
852
853 # Ensure the default
854 res = self.vty.command("show running-config")
855 self.assert_(res.find('\n sdp-ensure-amr-mode-set') > 0)
856
857 self.vty.command("sdp-ensure-amr-mode-set")
858 res = self.vty.command("show running-config")
859 self.assert_(res.find('\n sdp-ensure-amr-mode-set') > 0)
860
861 self.vty.command("no sdp-ensure-amr-mode-set")
862 res = self.vty.command("show running-config")
863 self.assert_(res.find('\n no sdp-ensure-amr-mode-set') > 0)
864
Holger Hans Peter Freyther67e423c2013-06-25 15:38:31 +0200865 def testRewritePostNoRewrite(self):
866 self.vty.enable()
867 self.vty.command("configure terminal")
868 self.vty.command("nat")
869 self.vty.verify("number-rewrite-post rewrite.cfg", [''])
870 self.vty.verify("no number-rewrite-post", [''])
871
872
Holger Hans Peter Freytherddf191e2013-06-25 11:44:01 +0200873 def testPrefixTreeLoading(self):
874 cfg = os.path.join(confpath, "tests/bsc-nat-trie/prefixes.csv")
875
876 self.vty.enable()
877 self.vty.command("configure terminal")
878 self.vty.command("nat")
879 res = self.vty.command("prefix-tree %s" % cfg)
880 self.assertEqual(res, "% prefix-tree loaded 17 rules.")
881 self.vty.command("end")
882
883 res = self.vty.command("show prefix-tree")
884 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')
885
886 self.vty.command("configure terminal")
887 self.vty.command("nat")
888 self.vty.command("no prefix-tree")
889 self.vty.command("end")
890
891 res = self.vty.command("show prefix-tree")
892 self.assertEqual(res, "% there is now prefix tree loaded.")
893
Jacob Erlbeck6cb2ccc2013-08-14 11:10:34 +0200894 def testUssdSideChannelProvider(self):
895 self.vty.command("end")
896 self.vty.enable()
897 self.vty.command("configure terminal")
898 self.vty.command("nat")
899 self.vty.command("ussd-token key")
900 self.vty.command("end")
901
902 res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is not connected and not authorized.'])
903 self.assertTrue(res)
904
905 ussdSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
906 ussdSocket.connect(('127.0.0.1', 5001))
907 ussdSocket.settimeout(2.0)
908 print "Connected to %s:%d" % ussdSocket.getpeername()
909
910 print "Expecting ID_GET request"
911 data = ussdSocket.recv(4)
912 self.assertEqual(data, "\x00\x01\xfe\x04")
913
914 print "Going to send ID_RESP response"
Max70cf7292016-04-13 11:36:38 +0200915 res = ipa_send_resp(ussdSocket, "\x6b\x65\x79")
Jacob Erlbeck6cb2ccc2013-08-14 11:10:34 +0200916 self.assertEqual(res, 10)
917
918 # initiating PING/PONG cycle to know, that the ID_RESP message has been processed
919
920 print "Going to send PING request"
Max70cf7292016-04-13 11:36:38 +0200921 res = ipa_send_ping(ussdSocket)
Jacob Erlbeck6cb2ccc2013-08-14 11:10:34 +0200922 self.assertEqual(res, 4)
923
924 print "Expecting PONG response"
925 data = ussdSocket.recv(4)
926 self.assertEqual(data, "\x00\x01\xfe\x01")
927
928 res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is connected and authorized.'])
929 self.assertTrue(res)
930
931 print "Going to shut down connection"
932 ussdSocket.shutdown(socket.SHUT_WR)
933
934 print "Expecting EOF"
935 data = ussdSocket.recv(4)
936 self.assertEqual(data, "")
937
938 ussdSocket.close()
939
940 res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is not connected and not authorized.'])
941 self.assertTrue(res)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200942
Holger Hans Peter Freyther64190182014-01-20 10:14:05 +0100943 def testAccessList(self):
944 """
945 Verify that the imsi-deny can have a reject cause or no reject cause
946 """
947 self.vty.enable()
948 self.vty.command("configure terminal")
949 self.vty.command("nat")
950
951 # Old default
952 self.vty.command("access-list test-default imsi-deny ^123[0-9]*$")
953 res = self.vty.command("show running-config").split("\r\n")
954 asserted = False
955 for line in res:
Holger Hans Peter Freyther4ecc6872014-03-04 15:38:00 +0100956 if line.startswith(" access-list test-default"):
Holger Hans Peter Freyther64190182014-01-20 10:14:05 +0100957 self.assertEqual(line, " access-list test-default imsi-deny ^123[0-9]*$ 11 11")
958 asserted = True
959 self.assert_(asserted)
960
961 # Check the optional CM Service Reject Cause
962 self.vty.command("access-list test-cm-deny imsi-deny ^123[0-9]*$ 42").split("\r\n")
963 res = self.vty.command("show running-config").split("\r\n")
964 asserted = False
965 for line in res:
966 if line.startswith(" access-list test-cm"):
967 self.assertEqual(line, " access-list test-cm-deny imsi-deny ^123[0-9]*$ 42 11")
968 asserted = True
969 self.assert_(asserted)
970
971 # Check the optional LU Reject Cause
972 self.vty.command("access-list test-lu-deny imsi-deny ^123[0-9]*$ 23 42").split("\r\n")
973 res = self.vty.command("show running-config").split("\r\n")
974 asserted = False
975 for line in res:
976 if line.startswith(" access-list test-lu"):
977 self.assertEqual(line, " access-list test-lu-deny imsi-deny ^123[0-9]*$ 23 42")
978 asserted = True
979 self.assert_(asserted)
980
Jacob Erlbeck6d233712013-10-23 11:24:15 +0200981class TestVTYGbproxy(TestVTYGenericBSC):
982
983 def vty_command(self):
984 return ["./src/gprs/osmo-gbproxy", "-c",
985 "doc/examples/osmo-gbproxy/osmo-gbproxy.cfg"]
986
987 def vty_app(self):
988 return (4246, "./src/gprs/osmo-gbproxy", "OsmoGbProxy", "bsc")
989
990 def testVtyTree(self):
991 self.vty.enable()
992 self.assertTrue(self.vty.verify('configure terminal', ['']))
993 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck6e919db2013-10-29 09:30:31 +0100994 self.checkForEndAndExit()
Jacob Erlbeck6d233712013-10-23 11:24:15 +0200995 self.assertTrue(self.vty.verify('ns', ['']))
996 self.assertEquals(self.vty.node(), 'config-ns')
997 self.checkForEndAndExit()
998 self.assertTrue(self.vty.verify('exit', ['']))
999 self.assertEquals(self.vty.node(), 'config')
1000 self.assertTrue(self.vty.verify('gbproxy', ['']))
1001 self.assertEquals(self.vty.node(), 'config-gbproxy')
1002 self.checkForEndAndExit()
1003 self.assertTrue(self.vty.verify('exit', ['']))
1004 self.assertEquals(self.vty.node(), 'config')
1005
1006 def testVtyShow(self):
1007 res = self.vty.command("show ns")
1008 self.assert_(res.find('Encapsulation NS-UDP-IP') >= 0)
1009
1010 res = self.vty.command("show gbproxy stats")
1011 self.assert_(res.find('GBProxy Global Statistics') >= 0)
1012
Jacob Erlbeck4211d792013-10-24 12:48:23 +02001013 def testVtyDeletePeer(self):
1014 self.vty.enable()
1015 self.assertTrue(self.vty.verify('delete-gbproxy-peer 9999 bvci 7777', ['BVC not found']))
1016 res = self.vty.command("delete-gbproxy-peer 9999 all dry-run")
1017 self.assert_(res.find('Not Deleted 0 BVC') >= 0)
1018 self.assert_(res.find('Not Deleted 0 NS-VC') >= 0)
1019 res = self.vty.command("delete-gbproxy-peer 9999 only-bvc dry-run")
1020 self.assert_(res.find('Not Deleted 0 BVC') >= 0)
1021 self.assert_(res.find('Not Deleted 0 NS-VC') < 0)
1022 res = self.vty.command("delete-gbproxy-peer 9999 only-nsvc dry-run")
1023 self.assert_(res.find('Not Deleted 0 BVC') < 0)
1024 self.assert_(res.find('Not Deleted 0 NS-VC') >= 0)
1025 res = self.vty.command("delete-gbproxy-peer 9999 all")
1026 self.assert_(res.find('Deleted 0 BVC') >= 0)
1027 self.assert_(res.find('Deleted 0 NS-VC') >= 0)
1028
Jacob Erlbeck144b8b12014-11-04 11:15:01 +01001029class TestVTYSGSN(TestVTYGenericBSC):
1030
1031 def vty_command(self):
1032 return ["./src/gprs/osmo-sgsn", "-c",
1033 "doc/examples/osmo-sgsn/osmo-sgsn.cfg"]
1034
1035 def vty_app(self):
1036 return (4245, "./src/gprs/osmo-sgsn", "OsmoSGSN", "sgsn")
1037
1038 def testVtyTree(self):
1039 self.vty.enable()
1040 self.assertTrue(self.vty.verify('configure terminal', ['']))
1041 self.assertEquals(self.vty.node(), 'config')
1042 self.checkForEndAndExit()
1043 self.assertTrue(self.vty.verify('ns', ['']))
1044 self.assertEquals(self.vty.node(), 'config-ns')
1045 self.checkForEndAndExit()
1046 self.assertTrue(self.vty.verify('exit', ['']))
1047 self.assertEquals(self.vty.node(), 'config')
1048 self.assertTrue(self.vty.verify('sgsn', ['']))
1049 self.assertEquals(self.vty.node(), 'config-sgsn')
1050 self.checkForEndAndExit()
1051 self.assertTrue(self.vty.verify('exit', ['']))
1052 self.assertEquals(self.vty.node(), 'config')
1053
1054 def testVtyShow(self):
1055 res = self.vty.command("show ns")
1056 self.assert_(res.find('Encapsulation NS-UDP-IP') >= 0)
1057 self.assertTrue(self.vty.verify('show bssgp', ['']))
1058 self.assertTrue(self.vty.verify('show bssgp stats', ['']))
1059 # TODO: uncomment when the command does not segfault anymore
1060 # self.assertTrue(self.vty.verify('show bssgp nsei 123', ['']))
1061 # self.assertTrue(self.vty.verify('show bssgp nsei 123 stats', ['']))
1062
1063 self.assertTrue(self.vty.verify('show sgsn', ['']))
1064 self.assertTrue(self.vty.verify('show mm-context all', ['']))
1065 self.assertTrue(self.vty.verify('show mm-context imsi 000001234567', ['No MM context for IMSI 000001234567']))
1066 self.assertTrue(self.vty.verify('show pdp-context all', ['']))
1067
1068 res = self.vty.command("show sndcp")
1069 self.assert_(res.find('State of SNDCP Entities') >= 0)
1070
1071 res = self.vty.command("show llc")
1072 self.assert_(res.find('State of LLC Entities') >= 0)
1073
Jacob Erlbeck106f5472014-11-04 10:08:37 +01001074 def testVtyAuth(self):
1075 self.vty.enable()
1076 self.assertTrue(self.vty.verify('configure terminal', ['']))
1077 self.assertEquals(self.vty.node(), 'config')
1078 self.assertTrue(self.vty.verify('sgsn', ['']))
1079 self.assertEquals(self.vty.node(), 'config-sgsn')
1080 self.assertTrue(self.vty.verify('auth-policy accept-all', ['']))
1081 res = self.vty.command("show running-config")
1082 self.assert_(res.find('auth-policy accept-all') > 0)
1083 self.assertTrue(self.vty.verify('auth-policy acl-only', ['']))
1084 res = self.vty.command("show running-config")
1085 self.assert_(res.find('auth-policy acl-only') > 0)
1086 self.assertTrue(self.vty.verify('auth-policy closed', ['']))
1087 res = self.vty.command("show running-config")
1088 self.assert_(res.find('auth-policy closed') > 0)
Max176b62a2016-07-04 11:09:07 +02001089 self.assertTrue(self.vty.verify('gsup remote-ip 127.0.0.4', ['']))
1090 self.assertTrue(self.vty.verify('gsup remote-port 2222', ['']))
Jacob Erlbeckbe2c8d92014-11-12 10:18:09 +01001091 self.assertTrue(self.vty.verify('auth-policy remote', ['']))
1092 res = self.vty.command("show running-config")
1093 self.assert_(res.find('auth-policy remote') > 0)
Jacob Erlbeck106f5472014-11-04 10:08:37 +01001094
Jacob Erlbeck207f4a52014-11-11 14:01:48 +01001095 def testVtySubscriber(self):
1096 self.vty.enable()
1097 res = self.vty.command('show subscriber cache')
1098 self.assert_(res.find('1234567890') < 0)
Jacob Erlbeckd9193432015-01-19 14:11:46 +01001099 self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 create', ['']))
1100 res = self.vty.command('show subscriber cache')
1101 self.assert_(res.find('1234567890') >= 0)
1102 self.assert_(res.find('Authorized: 0') >= 0)
1103 self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 update-location-result ok', ['']))
Jacob Erlbeck207f4a52014-11-11 14:01:48 +01001104 res = self.vty.command('show subscriber cache')
1105 self.assert_(res.find('1234567890') >= 0)
1106 self.assert_(res.find('Authorized: 1') >= 0)
Jacob Erlbeck8000e0e2015-01-27 14:56:40 +01001107 self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 cancel update-procedure', ['']))
Jacob Erlbeck207f4a52014-11-11 14:01:48 +01001108 res = self.vty.command('show subscriber cache')
Jacob Erlbecke988ae42015-01-27 12:41:19 +01001109 self.assert_(res.find('1234567890') >= 0)
1110 self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 destroy', ['']))
1111 res = self.vty.command('show subscriber cache')
Jacob Erlbeck207f4a52014-11-11 14:01:48 +01001112 self.assert_(res.find('1234567890') < 0)
1113
Jacob Erlbeckcb1db8b2015-02-03 13:47:53 +01001114 def testVtyGgsn(self):
1115 self.vty.enable()
1116 self.assertTrue(self.vty.verify('configure terminal', ['']))
1117 self.assertEquals(self.vty.node(), 'config')
1118 self.assertTrue(self.vty.verify('sgsn', ['']))
1119 self.assertEquals(self.vty.node(), 'config-sgsn')
1120 self.assertTrue(self.vty.verify('ggsn 0 remote-ip 127.99.99.99', ['']))
1121 self.assertTrue(self.vty.verify('ggsn 0 gtp-version 1', ['']))
1122 self.assertTrue(self.vty.verify('apn * ggsn 0', ['']))
1123 self.assertTrue(self.vty.verify('apn apn1.test ggsn 0', ['']))
1124 self.assertTrue(self.vty.verify('apn apn1.test ggsn 1', ['% a GGSN with id 1 has not been defined']))
1125 self.assertTrue(self.vty.verify('apn apn1.test imsi-prefix 123456 ggsn 0', ['']))
1126 self.assertTrue(self.vty.verify('apn apn2.test imsi-prefix 123456 ggsn 0', ['']))
1127 res = self.vty.command("show running-config")
1128 self.assert_(res.find('ggsn 0 remote-ip 127.99.99.99') >= 0)
1129 self.assert_(res.find('ggsn 0 gtp-version 1') >= 0)
1130 self.assert_(res.find('apn * ggsn 0') >= 0)
1131 self.assert_(res.find('apn apn1.test ggsn 0') >= 0)
1132 self.assert_(res.find('apn apn1.test imsi-prefix 123456 ggsn 0') >= 0)
1133 self.assert_(res.find('apn apn2.test imsi-prefix 123456 ggsn 0') >= 0)
1134
Holger Hans Peter Freyther9c20a5f2015-02-06 16:23:29 +01001135 def testVtyEasyAPN(self):
1136 self.vty.enable()
1137 self.assertTrue(self.vty.verify('configure terminal', ['']))
1138 self.assertEquals(self.vty.node(), 'config')
1139 self.assertTrue(self.vty.verify('sgsn', ['']))
1140 self.assertEquals(self.vty.node(), 'config-sgsn')
1141
1142 res = self.vty.command("show running-config")
1143 self.assertEquals(res.find("apn internet"), -1)
1144
1145 self.assertTrue(self.vty.verify("access-point-name internet.apn", ['']))
1146 res = self.vty.command("show running-config")
1147 self.assert_(res.find("apn internet.apn ggsn 0") >= 0)
1148
1149 self.assertTrue(self.vty.verify("no access-point-name internet.apn", ['']))
1150 res = self.vty.command("show running-config")
1151 self.assertEquals(res.find("apn internet"), -1)
1152
Holger Hans Peter Freytherc15c61c2015-05-06 17:46:08 +02001153 def testVtyCDR(self):
1154 self.vty.enable()
1155 self.assertTrue(self.vty.verify('configure terminal', ['']))
1156 self.assertEquals(self.vty.node(), 'config')
1157 self.assertTrue(self.vty.verify('sgsn', ['']))
1158 self.assertEquals(self.vty.node(), 'config-sgsn')
1159
1160 res = self.vty.command("show running-config")
1161 self.assert_(res.find("no cdr filename") > 0)
1162
1163 self.vty.command("cdr filename bla.cdr")
1164 res = self.vty.command("show running-config")
1165 self.assertEquals(res.find("no cdr filename"), -1)
1166 self.assert_(res.find(" cdr filename bla.cdr") > 0)
1167
1168 self.vty.command("no cdr filename")
1169 res = self.vty.command("show running-config")
1170 self.assert_(res.find("no cdr filename") > 0)
1171 self.assertEquals(res.find(" cdr filename bla.cdr"), -1)
1172
1173 res = self.vty.command("show running-config")
1174 self.assert_(res.find(" cdr interval 600") > 0)
1175
1176 self.vty.command("cdr interval 900")
1177 res = self.vty.command("show running-config")
1178 self.assert_(res.find(" cdr interval 900") > 0)
1179 self.assertEquals(res.find(" cdr interval 600"), -1)
1180
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +02001181def add_nat_test(suite, workdir):
1182 if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc_nat/osmo-bsc_nat")):
1183 print("Skipping the NAT test")
1184 return
1185 test = unittest.TestLoader().loadTestsFromTestCase(TestVTYNAT)
1186 suite.addTest(test)
1187
Max70cf7292016-04-13 11:36:38 +02001188def ipa_send_pong(x, verbose = False):
1189 if (verbose):
1190 print "\tBSC -> NAT: PONG!"
1191 return x.send("\x00\x01\xfe\x01")
1192
1193def ipa_send_ping(x, verbose = False):
1194 if (verbose):
1195 print "\tBSC -> NAT: PING?"
1196 return x.send("\x00\x01\xfe\x00")
1197
1198def ipa_send_ack(x, verbose = False):
1199 if (verbose):
1200 print "\tBSC -> NAT: IPA ID ACK"
1201 return x.send("\x00\x01\xfe\x06")
1202
1203def ipa_send_reset(x, verbose = False):
1204 if (verbose):
1205 print "\tBSC -> NAT: RESET"
1206 return x.send("\x00\x12\xfd\x09\x00\x03\x05\x07\x02\x42\xfe\x02\x42\xfe\x06\x00\x04\x30\x04\x01\x20")
1207
1208def ipa_send_resp(x, tk, verbose = False):
1209 if (verbose):
1210 print "\tBSC -> NAT: IPA ID RESP"
1211 return x.send("\x00\x07\xfe\x05\x00\x04\x01" + tk)
1212
Max49364482016-04-13 11:36:39 +02001213def nat_bsc_reload(x):
1214 x.vty.command("configure terminal")
1215 x.vty.command("nat")
1216 x.vty.command("bscs-config-file bscs.config")
1217 x.vty.command("end")
1218
Holger Hans Peter Freyther44ed4972016-04-14 10:05:13 -04001219def nat_msc_ip(x, ip, port):
Max49364482016-04-13 11:36:39 +02001220 x.vty.command("configure terminal")
1221 x.vty.command("nat")
1222 x.vty.command("msc ip " + ip)
Holger Hans Peter Freyther84ae27e2016-04-14 10:40:06 -04001223 x.vty.command("msc port " + str(port))
Max49364482016-04-13 11:36:39 +02001224 x.vty.command("end")
1225
1226def data2str(d):
Holger Hans Peter Freyther8bb62042016-04-14 21:40:04 -04001227 return d.encode('hex').lower()
Max49364482016-04-13 11:36:39 +02001228
Holger Hans Peter Freyther44ed4972016-04-14 10:05:13 -04001229def nat_msc_test(x, ip, port, verbose = False):
Max49364482016-04-13 11:36:39 +02001230 msc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1231 msc.settimeout(32)
Holger Hans Peter Freyther44ed4972016-04-14 10:05:13 -04001232 msc.bind((ip, port))
Max49364482016-04-13 11:36:39 +02001233 msc.listen(5)
1234 if (verbose):
1235 print "MSC is ready at " + ip
1236 while "MSC is connected: 0" == x.vty.command("show msc connection"):
1237 conn, addr = msc.accept()
1238 if (verbose):
1239 print "MSC got connection from ", addr
1240 return conn
1241
1242def ipa_handle_small(x, verbose = False):
1243 s = data2str(x.recv(4))
1244 if "0001fe00" == s:
1245 if (verbose):
1246 print "\tBSC <- NAT: PING?"
1247 ipa_send_pong(x, verbose)
1248 elif "0001fe06" == s:
1249 if (verbose):
1250 print "\tBSC <- NAT: IPA ID ACK"
1251 ipa_send_ack(x, verbose)
1252 elif "0001fe00" == s:
1253 if (verbose):
1254 print "\tBSC <- NAT: PONG!"
1255 else:
1256 if (verbose):
1257 print "\tBSC <- NAT: ", s
1258
1259def ipa_handle_resp(x, tk, verbose = False):
1260 s = data2str(x.recv(38))
1261 if "0023fe040108010701020103010401050101010011" in s:
1262 ipa_send_resp(x, tk, verbose)
1263 else:
1264 if (verbose):
1265 print "\tBSC <- NAT: ", s
1266
1267def nat_bsc_num_con(x):
1268 return len(x.vty.command("show bsc connections").split('\n'))
1269
1270def nat_bsc_sock_test(nr, tk, verbose = False):
1271 bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Holger Hans Peter Freyther2abf2b02016-04-14 21:13:51 -04001272 bsc.bind(('127.0.0.1', 0))
Max49364482016-04-13 11:36:39 +02001273 bsc.connect(('127.0.0.1', 5000))
1274 if (verbose):
1275 print "BSC%d " %nr
1276 print "\tconnected to %s:%d" % bsc.getpeername()
1277 ipa_handle_small(bsc, verbose)
1278 ipa_handle_resp(bsc, tk, verbose)
1279 bsc.recv(27) # MGCP msg
1280 ipa_handle_small(bsc, verbose)
1281 return bsc
1282
Jacob Erlbeck1b894022013-08-28 10:16:54 +02001283def add_bsc_test(suite, workdir):
1284 if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc/osmo-bsc")):
1285 print("Skipping the BSC test")
1286 return
1287 test = unittest.TestLoader().loadTestsFromTestCase(TestVTYBSC)
1288 suite.addTest(test)
1289
Jacob Erlbeck6d233712013-10-23 11:24:15 +02001290def add_gbproxy_test(suite, workdir):
1291 if not os.path.isfile(os.path.join(workdir, "src/gprs/osmo-gbproxy")):
1292 print("Skipping the Gb-Proxy test")
1293 return
1294 test = unittest.TestLoader().loadTestsFromTestCase(TestVTYGbproxy)
1295 suite.addTest(test)
1296
Jacob Erlbeck144b8b12014-11-04 11:15:01 +01001297def add_sgsn_test(suite, workdir):
1298 if not os.path.isfile(os.path.join(workdir, "src/gprs/osmo-sgsn")):
1299 print("Skipping the SGSN test")
1300 return
1301 test = unittest.TestLoader().loadTestsFromTestCase(TestVTYSGSN)
1302 suite.addTest(test)
1303
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +02001304if __name__ == '__main__':
1305 import argparse
1306 import sys
1307
1308 workdir = '.'
1309
1310 parser = argparse.ArgumentParser()
1311 parser.add_argument("-v", "--verbose", dest="verbose",
1312 action="store_true", help="verbose mode")
1313 parser.add_argument("-p", "--pythonconfpath", dest="p",
1314 help="searchpath for config")
1315 parser.add_argument("-w", "--workdir", dest="w",
1316 help="Working directory")
1317 args = parser.parse_args()
1318
1319 verbose_level = 1
1320 if args.verbose:
1321 verbose_level = 2
1322
1323 if args.w:
1324 workdir = args.w
1325
1326 if args.p:
1327 confpath = args.p
1328
1329 print "confpath %s, workdir %s" % (confpath, workdir)
1330 os.chdir(workdir)
1331 print "Running tests for specific VTY commands"
1332 suite = unittest.TestSuite()
Holger Hans Peter Freyther8d998a72014-07-04 20:23:56 +02001333 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYMGCP))
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +02001334 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYNITB))
Jacob Erlbeck1b894022013-08-28 10:16:54 +02001335 add_bsc_test(suite, workdir)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +02001336 add_nat_test(suite, workdir)
Jacob Erlbeck6d233712013-10-23 11:24:15 +02001337 add_gbproxy_test(suite, workdir)
Jacob Erlbeck144b8b12014-11-04 11:15:01 +01001338 add_sgsn_test(suite, workdir)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +02001339 res = unittest.TextTestRunner(verbosity=verbose_level).run(suite)
1340 sys.exit(len(res.errors) + len(res.failures))
Neels Hofmeyr23d37c92016-09-26 03:18:32 +02001341
1342# vim: set shiftwidth=4 expandtab nocin ai