summaryrefslogtreecommitdiff
path: root/pexpect/tests/test_run_out_of_pty.py
blob: 3eee0631d788d1149051de5b3608f21be263a970 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
import pexpect
import unittest
import commands
import sys

class ExpectTestCase(unittest.TestCase):
        
    def off_test_run_out (self):
        """This assumes that the tested platform has < 10000 pty devices.
	This test currently does not work under Solaris.
	Under Solaris it runs out of file descriptors first and
	ld.so starts to barf:
	    ld.so.1: pt_chmod: fatal: /usr/lib/libc.so.1: Too many open files
        """

        plist=[]
        for count in range (0,10000):
                try:
                        plist.append (pexpect.spawn('ls -l'))
                except pexpect.ExceptionPexpect, e:
                        for c in range (0,count):
                            plist[c].close()
                        return
                except Exception, e:
                        self.fail ('Expected ExceptionPexpect. ' + str(e))
        self.fail ('Could not run out of pty devices. This may be OK.')

if __name__ == '__main__':
    unittest.main()

suite = unittest.makeSuite(ExpectTestCase,'test')

#fout = open('delete_me_1','wb')
#fout.write(the_old_way)
#fout.close
#fout = open('delete_me_2', 'wb')
#fout.write(the_new_way)
#fout.close