blob: 46dbce7c4e44f473271afe9025c99e8d9ed5cd2c [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
Jacob Erlbeck96903c42013-09-02 13:17:14 +020059
60class TestVTYGenericBSC(TestVTYBase):
61
62 def checkForEndAndExit(self):
63 res = self.vty.command("list")
64 #print ('looking for "exit"\n')
65 self.assert_(res.find(' exit\r') > 0)
66 #print 'found "exit"\nlooking for "end"\n'
67 self.assert_(res.find(' end\r') > 0)
68 #print 'found "end"\n'
69
70 def ignoredCheckForEndAndExit(self):
71 sys.stderr.write('Going to ignore the next assertion(s) due to known bugs\n')
72 try:
73 self.checkForEndAndExit()
74 except BaseException as e:
75 sys.stderr.write('Expected and ignored failure: %s\n' % (str(e)))
76
Jacob Erlbeck96903c42013-09-02 13:17:14 +020077 def _testConfigNetworkTree(self):
78 self.vty.enable()
79 self.assertTrue(self.vty.verify("configure terminal",['']))
80 self.assertEquals(self.vty.node(), 'config')
81 self.ignoredCheckForEndAndExit()
82 self.assertTrue(self.vty.verify("network",['']))
83 self.assertEquals(self.vty.node(), 'config-net')
84 self.checkForEndAndExit()
85 self.assertTrue(self.vty.verify("bts 0",['']))
86 self.assertEquals(self.vty.node(), 'config-net-bts')
87 self.checkForEndAndExit()
88 self.assertTrue(self.vty.verify("trx 0",['']))
89 self.assertEquals(self.vty.node(), 'config-net-bts-trx')
90 self.checkForEndAndExit()
Jacob Erlbeck733bec82013-09-11 10:46:56 +020091 self.vty.command("write terminal")
92 self.assertTrue(self.vty.verify("exit",['']))
93 self.assertEquals(self.vty.node(), 'config-net-bts')
94 self.assertTrue(self.vty.verify("exit",['']))
95 self.assertTrue(self.vty.verify("bts 1",['']))
96 self.assertEquals(self.vty.node(), 'config-net-bts')
97 self.checkForEndAndExit()
98 self.assertTrue(self.vty.verify("trx 1",['']))
99 self.assertEquals(self.vty.node(), 'config-net-bts-trx')
100 self.checkForEndAndExit()
101 self.vty.command("write terminal")
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200102 self.assertTrue(self.vty.verify("exit",['']))
103 self.assertEquals(self.vty.node(), 'config-net-bts')
104 self.assertTrue(self.vty.verify("exit",['']))
105 self.assertEquals(self.vty.node(), 'config-net')
106 self.assertTrue(self.vty.verify("exit",['']))
107 self.assertEquals(self.vty.node(), 'config')
108 self.assertTrue(self.vty.verify("exit",['']))
109 self.assertTrue(self.vty.node() is None)
110
111class TestVTYNITB(TestVTYGenericBSC):
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +0200112
113 def vty_command(self):
114 return ["./src/osmo-nitb/osmo-nitb", "-c",
115 "doc/examples/osmo-nitb/nanobts/openbsc.cfg"]
116
117 def vty_app(self):
118 return (4242, "./src/osmo-nitb/osmo-nitb", "OpenBSC", "nitb")
119
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200120 def testConfigNetworkTree(self):
121 self._testConfigNetworkTree()
122
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200123 def checkForSmpp(self):
124 """SMPP is not always enabled, check if it is"""
125 res = self.vty.command("list")
126 return "smpp" in res
127
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200128 def testVtyTree(self):
129 self.vty.enable()
130 self.assertTrue(self.vty.verify("configure terminal", ['']))
131 self.assertEquals(self.vty.node(), 'config')
132 self.ignoredCheckForEndAndExit()
133 self.assertTrue(self.vty.verify('mncc-int', ['']))
134 self.assertEquals(self.vty.node(), 'config-mncc-int')
135 self.checkForEndAndExit()
136 self.assertTrue(self.vty.verify('exit', ['']))
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200137
138 if self.checkForSmpp():
139 self.assertEquals(self.vty.node(), 'config')
140 self.assertTrue(self.vty.verify('smpp', ['']))
141 self.assertEquals(self.vty.node(), 'config-smpp')
142 self.ignoredCheckForEndAndExit()
143 self.assertTrue(self.vty.verify("exit", ['']))
144
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200145 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200146 self.assertTrue(self.vty.verify("exit", ['']))
147 self.assertTrue(self.vty.node() is None)
148
149 # Check searching for outer node's commands
150 self.vty.command("configure terminal")
151 self.vty.command('mncc-int')
Holger Hans Peter Freyther0df1ab92013-09-02 20:58:38 +0200152
153 if self.checkForSmpp():
154 self.vty.command('smpp')
155 self.assertEquals(self.vty.node(), 'config-smpp')
156 self.vty.command('mncc-int')
157
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200158 self.assertEquals(self.vty.node(), 'config-mncc-int')
159
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +0200160 def testEnableDisablePeriodicLU(self):
161 self.vty.enable()
162 self.vty.command("configure terminal")
163 self.vty.command("network")
164 self.vty.command("bts 0")
165
166 # Test invalid input
167 self.vty.verify("periodic location update 0", ['% Unknown command.'])
168 self.vty.verify("periodic location update 5", ['% Unknown command.'])
169 self.vty.verify("periodic location update 1531", ['% Unknown command.'])
170
171 # Enable periodic lu..
172 self.vty.verify("periodic location update 60", [''])
173 res = self.vty.command("write terminal")
Holger Hans Peter Freytherc0438e32013-07-27 22:23:25 +0200174 self.assert_(res.find('periodic location update 60') > 0)
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +0200175 self.assertEquals(res.find('no periodic location update'), -1)
176
177 # Now disable it..
178 self.vty.verify("no periodic location update", [''])
179 res = self.vty.command("write terminal")
180 self.assertEquals(res.find('periodic location update 60'), -1)
Holger Hans Peter Freytherc0438e32013-07-27 22:23:25 +0200181 self.assert_(res.find('no periodic location update') > 0)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200182
Ivan Kluchnikov67920592013-09-16 13:13:04 +0400183 def testRachAccessControlClass(self):
184 self.vty.enable()
185 self.vty.command("configure terminal")
186 self.vty.command("network")
187 self.vty.command("bts 0")
188
189 # Test invalid input
190 self.vty.verify("rach access-control-class", ['% Command incomplete.'])
191 self.vty.verify("rach access-control-class 1", ['% Command incomplete.'])
192 self.vty.verify("rach access-control-class -1", ['% Unknown command.'])
193 self.vty.verify("rach access-control-class 10", ['% Unknown command.'])
194 self.vty.verify("rach access-control-class 16", ['% Unknown command.'])
195
196 # Barred rach access control classes
197 for classNum in range(16):
198 if classNum != 10:
199 self.vty.verify("rach access-control-class " + str(classNum) + " barred", [''])
200
201 # Verify settings
202 res = self.vty.command("write terminal")
203 for classNum in range(16):
204 if classNum != 10:
205 self.assert_(res.find("rach access-control-class " + str(classNum) + " barred") > 0)
206
207 # Allowed rach access control classes
208 for classNum in range(16):
209 if classNum != 10:
210 self.vty.verify("rach access-control-class " + str(classNum) + " allowed", [''])
211
212 # Verify settings
213 res = self.vty.command("write terminal")
214 for classNum in range(16):
215 if classNum != 10:
216 self.assertEquals(res.find("rach access-control-class " + str(classNum) + " barred"), -1)
217
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200218class TestVTYBSC(TestVTYGenericBSC):
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200219
220 def vty_command(self):
221 return ["./src/osmo-bsc/osmo-bsc", "-c",
222 "doc/examples/osmo-bsc/osmo-bsc.cfg"]
223
224 def vty_app(self):
225 return (4242, "./src/osmo-bsc/osmo-bsc", "OsmoBSC", "bsc")
226
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200227 def testConfigNetworkTree(self):
228 self._testConfigNetworkTree()
229
230 def testVtyTree(self):
231 self.vty.enable()
232 self.assertTrue(self.vty.verify("configure terminal", ['']))
233 self.assertEquals(self.vty.node(), 'config')
234 self.ignoredCheckForEndAndExit()
235 self.assertTrue(self.vty.verify("msc 0", ['']))
236 self.assertEquals(self.vty.node(), 'config-msc')
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200237 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200238 self.assertTrue(self.vty.verify("exit", ['']))
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200239 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200240 self.assertTrue(self.vty.verify("bsc", ['']))
241 self.assertEquals(self.vty.node(), 'config-bsc')
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200242 self.checkForEndAndExit()
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200243 self.assertTrue(self.vty.verify("exit", ['']))
Jacob Erlbeck0ae92a92013-09-02 13:17:16 +0200244 self.assertEquals(self.vty.node(), 'config')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200245 self.assertTrue(self.vty.verify("exit", ['']))
246 self.assertTrue(self.vty.node() is None)
247
248 # Check searching for outer node's commands
249 self.vty.command("configure terminal")
250 self.vty.command('msc 0')
251 self.vty.command("bsc")
252 self.assertEquals(self.vty.node(), 'config-bsc')
253 self.vty.command("msc 0")
254 self.assertEquals(self.vty.node(), 'config-msc')
255
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200256 def testUssdNotificationsMsc(self):
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200257 self.vty.enable()
258 self.vty.command("configure terminal")
259 self.vty.command("msc")
260
261 # Test invalid input
262 self.vty.verify("bsc-msc-lost-text", ['% Command incomplete.'])
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200263 self.vty.verify("bsc-welcome-text", ['% Command incomplete.'])
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200264 self.vty.verify("bsc-grace-text", ['% Command incomplete.'])
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200265
266 # Enable USSD notifications
267 self.vty.verify("bsc-msc-lost-text MSC disconnected", [''])
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200268 self.vty.verify("bsc-welcome-text Hello MS", [''])
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200269 self.vty.verify("bsc-grace-text In grace period", [''])
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200270
271 # Verify settings
272 res = self.vty.command("write terminal")
273 self.assert_(res.find('bsc-msc-lost-text MSC disconnected') > 0)
274 self.assertEquals(res.find('no bsc-msc-lost-text'), -1)
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200275 self.assert_(res.find('bsc-welcome-text Hello MS') > 0)
276 self.assertEquals(res.find('no bsc-welcome-text'), -1)
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200277 self.assert_(res.find('bsc-grace-text In grace period') > 0)
278 self.assertEquals(res.find('no bsc-grace-text'), -1)
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200279
280 # Now disable it..
281 self.vty.verify("no bsc-msc-lost-text", [''])
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200282 self.vty.verify("no bsc-welcome-text", [''])
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200283 self.vty.verify("no bsc-grace-text", [''])
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200284
285 # Verify settings
286 res = self.vty.command("write terminal")
287 self.assertEquals(res.find('bsc-msc-lost-text MSC disconnected'), -1)
288 self.assert_(res.find('no bsc-msc-lost-text') > 0)
Jacob Erlbeck97e139f2013-08-28 10:16:55 +0200289 self.assertEquals(res.find('bsc-welcome-text Hello MS'), -1)
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200290 self.assert_(res.find('no bsc-welcome-text') > 0)
291 self.assertEquals(res.find('bsc-grace-text In grace period'), -1)
292 self.assert_(res.find('no bsc-grace-text') > 0)
293
294 def testUssdNotificationsBsc(self):
295 self.vty.enable()
296 self.vty.command("configure terminal")
297 self.vty.command("bsc")
298
299 # Test invalid input
300 self.vty.verify("missing-msc-text", ['% Command incomplete.'])
301
302 # Enable USSD notifications
303 self.vty.verify("missing-msc-text No MSC found", [''])
304
305 # Verify settings
306 res = self.vty.command("write terminal")
307 self.assert_(res.find('missing-msc-text No MSC found') > 0)
308 self.assertEquals(res.find('no missing-msc-text'), -1)
309
310 # Now disable it..
311 self.vty.verify("no missing-msc-text", [''])
312
313 # Verify settings
314 res = self.vty.command("write terminal")
315 self.assertEquals(res.find('missing-msc-text No MSC found'), -1)
316 self.assert_(res.find('no missing-msc-text') > 0)
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200317
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200318class TestVTYNAT(TestVTYGenericBSC):
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200319
320 def vty_command(self):
321 return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-c",
322 "doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg"]
323
324 def vty_app(self):
325 return (4244, "src/osmo-bsc_nat/osmo-bsc_nat", "OsmoBSCNAT", "nat")
326
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200327 def testVtyTree(self):
328 self.vty.enable()
329 self.assertTrue(self.vty.verify('configure terminal', ['']))
330 self.assertEquals(self.vty.node(), 'config')
331 self.ignoredCheckForEndAndExit()
332 self.assertTrue(self.vty.verify('mgcp', ['']))
333 self.assertEquals(self.vty.node(), 'config-mgcp')
334 self.checkForEndAndExit()
335 self.assertTrue(self.vty.verify('exit', ['']))
336 self.assertEquals(self.vty.node(), 'config')
337 self.assertTrue(self.vty.verify('nat', ['']))
338 self.assertEquals(self.vty.node(), 'config-nat')
339 self.checkForEndAndExit()
340 self.assertTrue(self.vty.verify('bsc 0', ['']))
341 self.assertEquals(self.vty.node(), 'config-nat-bsc')
342 self.checkForEndAndExit()
343 self.assertTrue(self.vty.verify('exit', ['']))
344 self.assertEquals(self.vty.node(), 'config-nat')
345 self.assertTrue(self.vty.verify('exit', ['']))
346 self.assertEquals(self.vty.node(), 'config')
347 self.assertTrue(self.vty.verify('exit', ['']))
348 self.assertTrue(self.vty.node() is None)
349
350 # Check searching for outer node's commands
351 self.vty.command('configure terminal')
352 self.vty.command('mgcp')
353 self.vty.command('nat')
354 self.assertEquals(self.vty.node(), 'config-nat')
Jacob Erlbeck4c9dff52013-09-02 13:17:17 +0200355 self.vty.command('mgcp')
356 self.assertEquals(self.vty.node(), 'config-mgcp')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200357 self.vty.command('nat')
358 self.assertEquals(self.vty.node(), 'config-nat')
359 self.vty.command('bsc 0')
Jacob Erlbeck4c9dff52013-09-02 13:17:17 +0200360 self.vty.command('mgcp')
361 self.assertEquals(self.vty.node(), 'config-mgcp')
Jacob Erlbeck96903c42013-09-02 13:17:14 +0200362
Holger Hans Peter Freytherb718ad32013-06-25 09:08:02 +0200363 def testRewriteNoRewrite(self):
364 self.vty.enable()
365 res = self.vty.command("configure terminal")
366 res = self.vty.command("nat")
367 res = self.vty.command("number-rewrite rewrite.cfg")
368 res = self.vty.command("no number-rewrite")
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200369
Holger Hans Peter Freyther67e423c2013-06-25 15:38:31 +0200370 def testRewritePostNoRewrite(self):
371 self.vty.enable()
372 self.vty.command("configure terminal")
373 self.vty.command("nat")
374 self.vty.verify("number-rewrite-post rewrite.cfg", [''])
375 self.vty.verify("no number-rewrite-post", [''])
376
377
Holger Hans Peter Freytherddf191e2013-06-25 11:44:01 +0200378 def testPrefixTreeLoading(self):
379 cfg = os.path.join(confpath, "tests/bsc-nat-trie/prefixes.csv")
380
381 self.vty.enable()
382 self.vty.command("configure terminal")
383 self.vty.command("nat")
384 res = self.vty.command("prefix-tree %s" % cfg)
385 self.assertEqual(res, "% prefix-tree loaded 17 rules.")
386 self.vty.command("end")
387
388 res = self.vty.command("show prefix-tree")
389 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')
390
391 self.vty.command("configure terminal")
392 self.vty.command("nat")
393 self.vty.command("no prefix-tree")
394 self.vty.command("end")
395
396 res = self.vty.command("show prefix-tree")
397 self.assertEqual(res, "% there is now prefix tree loaded.")
398
Jacob Erlbeck6cb2ccc2013-08-14 11:10:34 +0200399 def testUssdSideChannelProvider(self):
400 self.vty.command("end")
401 self.vty.enable()
402 self.vty.command("configure terminal")
403 self.vty.command("nat")
404 self.vty.command("ussd-token key")
405 self.vty.command("end")
406
407 res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is not connected and not authorized.'])
408 self.assertTrue(res)
409
410 ussdSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
411 ussdSocket.connect(('127.0.0.1', 5001))
412 ussdSocket.settimeout(2.0)
413 print "Connected to %s:%d" % ussdSocket.getpeername()
414
415 print "Expecting ID_GET request"
416 data = ussdSocket.recv(4)
417 self.assertEqual(data, "\x00\x01\xfe\x04")
418
419 print "Going to send ID_RESP response"
420 res = ussdSocket.send("\x00\x07\xfe\x05\x00\x04\x01\x6b\x65\x79")
421 self.assertEqual(res, 10)
422
423 # initiating PING/PONG cycle to know, that the ID_RESP message has been processed
424
425 print "Going to send PING request"
426 res = ussdSocket.send("\x00\x01\xfe\x00")
427 self.assertEqual(res, 4)
428
429 print "Expecting PONG response"
430 data = ussdSocket.recv(4)
431 self.assertEqual(data, "\x00\x01\xfe\x01")
432
433 res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is connected and authorized.'])
434 self.assertTrue(res)
435
436 print "Going to shut down connection"
437 ussdSocket.shutdown(socket.SHUT_WR)
438
439 print "Expecting EOF"
440 data = ussdSocket.recv(4)
441 self.assertEqual(data, "")
442
443 ussdSocket.close()
444
445 res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is not connected and not authorized.'])
446 self.assertTrue(res)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200447
448def add_nat_test(suite, workdir):
449 if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc_nat/osmo-bsc_nat")):
450 print("Skipping the NAT test")
451 return
452 test = unittest.TestLoader().loadTestsFromTestCase(TestVTYNAT)
453 suite.addTest(test)
454
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200455def add_bsc_test(suite, workdir):
456 if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc/osmo-bsc")):
457 print("Skipping the BSC test")
458 return
459 test = unittest.TestLoader().loadTestsFromTestCase(TestVTYBSC)
460 suite.addTest(test)
461
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200462if __name__ == '__main__':
463 import argparse
464 import sys
465
466 workdir = '.'
467
468 parser = argparse.ArgumentParser()
469 parser.add_argument("-v", "--verbose", dest="verbose",
470 action="store_true", help="verbose mode")
471 parser.add_argument("-p", "--pythonconfpath", dest="p",
472 help="searchpath for config")
473 parser.add_argument("-w", "--workdir", dest="w",
474 help="Working directory")
475 args = parser.parse_args()
476
477 verbose_level = 1
478 if args.verbose:
479 verbose_level = 2
480
481 if args.w:
482 workdir = args.w
483
484 if args.p:
485 confpath = args.p
486
487 print "confpath %s, workdir %s" % (confpath, workdir)
488 os.chdir(workdir)
489 print "Running tests for specific VTY commands"
490 suite = unittest.TestSuite()
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +0200491 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYNITB))
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200492 add_bsc_test(suite, workdir)
Holger Hans Peter Freythereb0acb62013-06-24 15:47:34 +0200493 add_nat_test(suite, workdir)
494 res = unittest.TextTestRunner(verbosity=verbose_level).run(suite)
495 sys.exit(len(res.errors) + len(res.failures))