annotate Lib/test/test_fcntl.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 595a5fe140d4
children 39b413ac2cc9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4755
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
1 #! /usr/bin/env python
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
2 """Test program for the fcntl C module.
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
3 Roger E. Masse
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
4 """
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
5 import struct
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
6 import fcntl
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
7 import FCNTL
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
8 import os
4811
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4755
diff changeset
9 from test_support import verbose
4755
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
10
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
11 filename = '/tmp/delete-me'
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
12
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
13 # the example from the library docs
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
14 f = open(filename,'w')
5484
595a5fe140d4 Finally found a wat to set a file nonblocking that works on Irix,
Guido van Rossum <guido@python.org>
parents: 5458
diff changeset
15 rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETFL, os.O_NONBLOCK)
4755
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
16 if verbose:
5484
595a5fe140d4 Finally found a wat to set a file nonblocking that works on Irix,
Guido van Rossum <guido@python.org>
parents: 5458
diff changeset
17 print 'Status from fnctl with O_NONBLOCK: ', rv
4755
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
18
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
19 lockdata = struct.pack('hhllhh', FCNTL.F_WRLCK, 0, 0, 0, 0, 0)
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
20 if verbose:
5458
13052dc2d5f6 Fix the NDELAY test; avoid outputting binary garbage.
Guido van Rossum <guido@python.org>
parents: 4811
diff changeset
21 print 'struct.pack: ', `lockdata`
4755
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
22
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
23 rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW, lockdata)
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
24 if verbose:
5458
13052dc2d5f6 Fix the NDELAY test; avoid outputting binary garbage.
Guido van Rossum <guido@python.org>
parents: 4811
diff changeset
25 print 'String from fcntl with F_SETLKW: ', `rv`
4755
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
26
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
27 f.close()
1de96c572b02 Added a test script for the fcntl C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
28 os.unlink(filename)