File: test_inetdomain.py

package info (click to toggle)
zorp 3.3.6-1.1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,260 kB
  • ctags: 4,707
  • sloc: ansic: 30,937; sh: 10,171; python: 4,051; makefile: 487
file content (30 lines) | stat: -rw-r--r-- 656 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from Zorp.Core import *
from Zorp.SockAddr import inet_ntoa
from traceback import print_exc

config.options.kzorp_enabled = FALSE

true = 1
false = 0

def test(str, res, expect):
	if res != expect:
		print str, 'failed,', res, 'should be: ', expect
	else:
		print str, 'ok,', res
		
def init(name):
	try:
		dom = InetDomain("192.168.0.1/24")
		test("netaddr(): ", inet_ntoa(dom.netaddr()), "192.168.0.0")
		test("broadcast(): ", inet_ntoa(dom.broadcast()), "192.168.0.255")
		test("netmask(): ", inet_ntoa(dom.netmask()), "255.255.255.0")

	except Exception, e:
		print 'exception: fail', e
		print_exc()
		Zorp.quit(1)
		return 0

	Zorp.quit(0)
	return 1