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_fs_fcntl.py

Revision 5963, 1.1 KB (checked in by nitin, 5 years ago)

unit test for FD_CLOEXEC.

Line 
1import lind_test_server
2from emultimer import sleep
3from lind_net_constants import *
4from lind_fs_constants import *
5
6lind_test_server._blank_fs_init()
7
8SyscallError = lind_test_server.SyscallError
9
10#create a file and socket descriptor...
11sockfd = lind_test_server.socket_syscall(AF_INET, SOCK_STREAM, 0)
12filefd = lind_test_server.open_syscall("/tmp", O_CREAT | O_EXCL, S_IRWXA)
13
14#Set FD_CLOEXEC flag...
15assert lind_test_server.fcntl_syscall(sockfd, F_SETFD, FD_CLOEXEC) == 0,\
16  "F_SETFD failed..."
17
18#Checking if the FD_CLOEXEC is set or not...
19assert lind_test_server.fcntl_syscall(sockfd, F_GETFD) == 1, "F_GETFD failed."
20
21#Reset FD_CLOEXEC flag...
22#assert lind_test_server.fcntl_syscall(sockfd, F_SETFD, 0) == 0, "F_SETFD failed."
23
24#Set some extra flags on file descriptor...
25assert lind_test_server.fcntl_syscall(filefd, F_SETFL, O_RDONLY|O_NONBLOCK) == 0,\
26  "F_SETFL failed."
27
28#check if the flags are updated or not...
29assert lind_test_server.fcntl_syscall(filefd, F_GETFL) == 2048, "F_GETFL failed."
30
31lind_test_server.close_syscall(sockfd)
32lind_test_server.close_syscall(filefd)
Note: See TracBrowser for help on using the browser.