Please note that the CVS and issue trackers have moved to GitHub. These Trac pages are no longer kept up-to-date.

root/seattle/branches/nacl_repy/seattlelib/tests/ut_lind_net_bind.py

Revision 5140, 0.9 KB (checked in by justinc, 6 years ago)

removed circular imports and created a new Python testing mechanism called
lind_test_server. This removes the need for wrappers, etc.

Line 
1import lind_test_server
2
3
4from lind_net_constants import *
5
6SyscallError = lind_test_server.SyscallError
7
8
9sockfd = lind_test_server.socket_syscall(AF_INET, SOCK_STREAM, 0)
10
11# should work...
12lind_test_server.bind_syscall(sockfd,'127.0.0.1',50102)
13
14try:
15  lind_test_server.bind_syscall(sockfd,'127.0.0.1',50103)
16
17except SyscallError:
18  # should fail (already bound)
19  pass
20else:
21  print "Should be an error (already bound)"
22
23
24# let's try to bind another to the same IP /port...
25sockfd = lind_test_server.socket_syscall(AF_INET, SOCK_STREAM, 0)
26
27try:
28  # should fail...
29  lind_test_server.bind_syscall(sockfd,'127.0.0.1',50102)
30
31except SyscallError:
32  # should fail another socket is already bound here...
33  pass
34else:
35  print "Should be an error (already bound)"
36
37
38sockfd = lind_test_server.socket_syscall(AF_INET, SOCK_DGRAM, 0)
39# however, UDP should work...
40lind_test_server.bind_syscall(sockfd,'127.0.0.1',50102)
Note: See TracBrowser for help on using the browser.