test_fcntl.py revision 16dffdca1a6a98a9b44f6d0560e8a85c1018c4fb
1#! /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 9from test_support import verbose 10 11filename = '/tmp/delete-me' 12 13# the example from the library docs 14f = open(filename,'w') 15rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETFL, FCNTL.FNDELAY) 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) 29