blob: 4929fbb3fe17a82110813817c5348b3fa65c544c [file] [log] [blame]
Roger E. Massefb01d4b1996-12-17 17:41:09 +00001#! /usr/bin/env python
2"""Test program for the fcntl C module.
3 Roger E. Masse
4"""
5import struct
6import fcntl
7import FCNTL
8import os
Roger E. Massefab8ab81996-12-20 22:36:52 +00009from test_support import verbose
Roger E. Massefb01d4b1996-12-17 17:41:09 +000010
11filename = '/tmp/delete-me'
12
13# the example from the library docs
14f = open(filename,'w')
15rv = fcntl.fcntl(f.fileno(), FCNTL.O_NDELAY, 1)
16if verbose:
17 print 'Status from fnctl with O_NDELAY: ', rv
18
19lockdata = struct.pack('hhllhh', FCNTL.F_WRLCK, 0, 0, 0, 0, 0)
20if verbose:
21 print 'struct.pack: ', lockdata
22
23rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW, lockdata)
24if verbose:
25 print 'String from fcntl with F_SETLKW: ', rv
26
27f.close()
28os.unlink(filename)