@@ -658,6 +658,61 @@ async def test_subprocess():
658
658
659
659
loop .run_until_complete (test_subprocess ())
660
660
661
+ def test_write_huge_stdin_8192 (self ):
662
+ self ._test_write_huge_stdin (8192 )
663
+
664
+ def test_write_huge_stdin_8193 (self ):
665
+ self ._test_write_huge_stdin (8193 )
666
+ # this one only fails on darwin...
667
+ if sys .platform == 'darwin' :
668
+ unittest .expectedFailure (test_write_huge_stdin_8193 )
669
+
670
+ def test_write_huge_stdin_219263 (self ):
671
+ self ._test_write_huge_stdin (219263 )
672
+ # this one only fails on darwin, but not on linux
673
+ if sys .platform == 'darwin' :
674
+ unittest .expectedFailure (test_write_huge_stdin_219263 )
675
+
676
+ # this one fails on darwin and linux...
677
+ @unittest .expectedFailure
678
+ def test_write_huge_stdin_219264 (self ):
679
+ self ._test_write_huge_stdin (219264 )
680
+
681
+ def _test_write_huge_stdin (self , buf_size ):
682
+ code = '''
683
+ import sys
684
+ n = 0
685
+ while True:
686
+ line = sys.stdin.readline()
687
+ if not line:
688
+ print("unexpected EOF")
689
+ break
690
+ if n > 8186:
691
+ print(n, repr(line), file=sys.stderr)
692
+ if line == "END\\ n":
693
+ break
694
+ n+=1
695
+ print(n)'''
696
+ num_lines = buf_size - len (b"END\n " )
697
+ args = [sys .executable , b'-W' , b'ignore' , b'-c' , code ]
698
+ async def test ():
699
+ proc = await asyncio .create_subprocess_exec (* args ,
700
+ stdout = asyncio .subprocess .PIPE ,
701
+ stdin = asyncio .subprocess .PIPE )
702
+ data = b"\n " * num_lines + b"END\n "
703
+ self .assertEqual (len (data ), buf_size )
704
+ proc .stdin .write (data )
705
+ await proc .stdin .drain ()
706
+ try :
707
+ await asyncio .wait_for (proc .wait (), timeout = 1.0 )
708
+ except asyncio .TimeoutError :
709
+ proc .kill ()
710
+ proc .stdin .close ()
711
+ await proc .wait ()
712
+ raise
713
+ out = await proc .stdout .read ()
714
+ self .assertEqual (int (out ), num_lines )
715
+ self .loop .run_until_complete (test ())
661
716
662
717
class Test_UV_Process (_TestProcess , tb .UVTestCase ):
663
718
0 commit comments