~soren/nova/iptables-security-groups

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/test/process_tester.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Test program for processes."""
 
2
 
 
3
import sys, os
 
4
 
 
5
test_file_match = "process_test.log.*"
 
6
test_file = "process_test.log.%d" % os.getpid()
 
7
 
 
8
def main():
 
9
    f = open(test_file, 'wb')
 
10
    
 
11
    # stage 1
 
12
    bytes = sys.stdin.read(4)
 
13
    f.write("one: %r\n" % bytes)
 
14
    # stage 2
 
15
    sys.stdout.write(bytes)
 
16
    sys.stdout.flush()
 
17
    os.close(sys.stdout.fileno())
 
18
    
 
19
    # and a one, and a two, and a...
 
20
    bytes = sys.stdin.read(4)
 
21
    f.write("two: %r\n" % bytes)
 
22
    
 
23
    # stage 3
 
24
    sys.stderr.write(bytes)
 
25
    sys.stderr.flush()
 
26
    os.close(sys.stderr.fileno())
 
27
    
 
28
    # stage 4
 
29
    bytes = sys.stdin.read(4)
 
30
    f.write("three: %r\n" % bytes)
 
31
 
 
32
    # exit with status code 23
 
33
    sys.exit(23)
 
34
 
 
35
 
 
36
if __name__ == '__main__':
 
37
    main()