Lines Matching defs:fcntl
1 """Test program for the fcntl C module.
14 # Skip test if no fcntl module.
15 fcntl = import_module('fcntl')
36 fcntl.F_WRLCK, 0)
38 lockdata = struct.pack('qqihhi', 0, 0, 0, fcntl.F_WRLCK, 0, 0)
40 lockdata = struct.pack('hhlllii', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
42 lockdata = struct.pack('hh'+start_len+'hh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
59 fcntl.lockf(f, cmd)
67 fcntl.lockf(f, cmd)
68 fcntl.lockf(f, fcntl.LOCK_UN)
84 rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
86 print('Status from fcntl with O_NONBLOCK: ', rv)
87 rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETLKW, lockdata)
89 print('String from fcntl with F_SETLKW: ', repr(rv))
95 rv = fcntl.fcntl(self.f, fcntl.F_SETFL, os.O_NONBLOCK)
97 print('Status from fcntl with O_NONBLOCK: ', rv)
98 rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata)
100 print('String from fcntl with F_SETLKW: ', repr(rv))
105 fcntl.fcntl(-1, fcntl.F_SETFL, os.O_NONBLOCK)
107 fcntl.fcntl(BadFile(-1), fcntl.F_SETFL, os.O_NONBLOCK)
109 fcntl.fcntl('spam', fcntl.F_SETFL, os.O_NONBLOCK)
111 fcntl.fcntl(BadFile('spam'), fcntl.F_SETFL, os.O_NONBLOCK)
118 fcntl.fcntl(INT_MAX + 1, fcntl.F_SETFL, os.O_NONBLOCK)
120 fcntl.fcntl(BadFile(INT_MAX + 1), fcntl.F_SETFL, os.O_NONBLOCK)
122 fcntl.fcntl(INT_MIN - 1, fcntl.F_SETFL, os.O_NONBLOCK)
124 fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK)
130 # Issue #1309352: fcntl shouldn't fail when the third arg fits in a
133 cmd = fcntl.F_NOTIFY
135 flags = fcntl.DN_MULTISHOT
140 fcntl.fcntl(fd, cmd, flags)
148 fcntl.flock(fileno, fcntl.LOCK_SH)
149 fcntl.flock(fileno, fcntl.LOCK_UN)
150 fcntl.flock(self.f, fcntl.LOCK_SH | fcntl.LOCK_NB)
151 fcntl.flock(self.f, fcntl.LOCK_UN)
152 fcntl.flock(fileno, fcntl.LOCK_EX)
153 fcntl.flock(fileno, fcntl.LOCK_UN)
155 self.assertRaises(ValueError, fcntl.flock, -1, fcntl.LOCK_SH)
156 self.assertRaises(TypeError, fcntl.flock, 'spam', fcntl.LOCK_SH)
161 cmd = fcntl.LOCK_EX | fcntl.LOCK_NB
162 fcntl.lockf(self.f, cmd)
166 fcntl.lockf(self.f, fcntl.LOCK_UN)
172 cmd = fcntl.LOCK_SH | fcntl.LOCK_NB
173 fcntl.lockf(self.f, cmd)
177 fcntl.lockf(self.f, fcntl.LOCK_UN)
183 self.assertRaises(OverflowError, fcntl.flock, _testcapi.INT_MAX+1,
184 fcntl.LOCK_SH)
190 res = fcntl.fcntl(self.f.fileno(), fcntl.F_GETPATH, bytes(len(expected)))
194 hasattr(fcntl, "F_SETPIPE_SZ") and hasattr(fcntl, "F_GETPIPE_SZ"),
200 pipesize_default = fcntl.fcntl(test_pipe_w, fcntl.F_GETPIPE_SZ)
205 fcntl.fcntl(test_pipe_w, fcntl.F_SETPIPE_SZ, pipesize)
206 self.assertEqual(fcntl.fcntl(test_pipe_w, fcntl.F_GETPIPE_SZ),