blob: c563018131671a083abbd9e79ad37a89a0e472d5 [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')
Guido van Rossum16dffdc1997-05-09 02:06:05 +000015rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETFL, FCNTL.FNDELAY)
Roger E. Massefb01d4b1996-12-17 17:41:09 +000016if 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:
Guido van Rossum16dffdc1997-05-09 02:06:05 +000021 print 'struct.pack: ', `lockdata`
Roger E. Massefb01d4b1996-12-17 17:41:09 +000022
23rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW, lockdata)
24if verbose:
Guido van Rossum16dffdc1997-05-09 02:06:05 +000025 print 'String from fcntl with F_SETLKW: ', `rv`
Roger E. Massefb01d4b1996-12-17 17:41:09 +000026
27f.close()
28os.unlink(filename)