python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_file_eintr.cpython-312.pyc

͑e*PddlZddlZddlZddlZddlZddlZddlZddlmZejsejdddlZddlZejejdk(dGddZGdd	eej ZGd
deej ZGdd
eZGddeej ZGddeej ZGddeZGddeej ZGddeej Zedk(rej4yy)N)supportztest module requires subprocessposixztests requires a posix system.cFeZdZdZdZdZ		ddZdZdZdZ	dZ
d	Zy
)TestFileIOSignalInterruptcd|_yN)_processselfs H/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_file_eintr.pysetUpzTestFileIOSignalInterrupt.setUps	
c|jr7|jj	|jjyyy#t$rYywxYwr)r	pollkillOSErrorr
s rtearDownz"TestFileIOSignalInterrupt.tearDown sK==T]]//19


""$:=

sA	AAc d|jzS)zReturns the infile = ... line of code for the reader process.

        subclasseses should override this to test different IO objects.
        z=import %s as io ;infile = io.FileIO(sys.stdin.fileno(), "rb")modnamer
s r_generate_infile_setup_codez5TestFileIOSignalInterrupt._generate_infile_setup_code's
?	rc	v|jj0tjd	|jj	|r'|jj
\}}||z
}||z
}|jd|d|jd|jdy#t
$rYlwxYw)a;A common way to cleanup and fail with useful debug output.

        Kills the process if it is still running, collects remaining output
        and fails the test with an error message including the output.

        Args:
            why: Text to go after "Error from IO process" in the message.
            stdout, stderr: standard output and error from the process so
                far to include in the error message.
            communicate: bool, when True we call communicate() on the process
                after killing it to gather additional output.
        Ng?zError from IO process z
:
STDOUT:
zSTDERR:

)	r	rtimesleep	terminatercommunicatefaildecode)rwhystdoutstderrr
stdout_end
stderr_ends       rfail_with_process_infoz0TestFileIOSignalInterrupt.fail_with_process_info0s=='JJsO


'')%)]]%>%>%@"J
j Fj F		

:	;


sB,,	B87B8ch|j}t|dksJdtjtj
ddd|zdzdz|zdzdzgtjtjtj	|_|jjjtd
}|d
k7r|jd||jjj|d
}g}|stj|jjgddd\}}}|jjtj |dz
}|dkDr+|jj#|j%d|s|jjj'}|dk7r|jd||jj)d\}	}
|jj*r-|jd|jj*z|	|
dyy)anGeneric buffered read method test harness to validate EINTR behavior.

        Also validates that Python signal handlers are run during the read.

        Args:
            data_to_write: String to write to the child process for reading
                before sending it a signal, confirming the signal was handled,
                writing a final newline and closing the infile pipe.
            read_and_verify_code: Single "line" of code to read from a file
                object named 'infile' and validate the result.  This will be
                executed as part of a python subprocess fed data_to_write.
        iz#data_to_write must fit in pipe buf.z-uz-czXimport signal, sys ;signal.signal(signal.SIGINT, lambda s, f: sys.stderr.write("$\n")) ;z ;z"sys.stderr.write("Worm Sign!\n") ;zinfile.close())stdinr!r"sWorm Sign!
zwhile awaiting a sign)r"rg?z,reader process failed to handle our signals.s$
zwhile awaiting signal
)inputzexited rc=%dF)rN)rlen
subprocessPopensys
executablePIPEr	r"readr%r'writeselectsend_signalsignalSIGINTrrreadliner
returncode)r
data_to_writeread_and_verify_codeinfile_setup_code	worm_signsignals_sentrlist_signal_liner!r"s           r
_test_readingz'TestFileIOSignalInterrupt._test_readingKs!<<>=!C'N)NN#((tJ%%(,,7	7
((
+//"
"!oojoo!(
MM((--c/.BC	'''(?/8
(
:

!!-0 --)=)=(>BMKE1aMM%%fmm4ALc!

""$		HI
mm**335& ''(?/:
(
<222?==##''"T]]%=%==F
(
7$rzgot = infile.{read_method_name}() ;expected = {expected!r} ;assert got == expected, ("{read_method_name} returned wrong data.\n""got data %r\nexpected %r" % (got, expected))c`|jd|jjddy)1readline() must handle signals and not lose data.
hello, world!r9shello, world!
read_method_nameexpectedr;r<NrC_READING_CODE_TEMPLATEformatr
s r
test_readlinez'TestFileIOSignalInterrupt.test_readlines8.%)%@%@%G%G)3!3&H&5		6rcd|jd|jjdddgy)2readlines() must handle signals and not lose data.hello
world!	readlinesshello
sworld!
rGrJNrKr
s rtest_readlinesz(TestFileIOSignalInterrupt.test_readliness=.%)%@%@%G%G)4",k!:&H&<		=rc|jd|jjdd|jd|jjddy)z0readall() must handle signals and not lose data.rQreadall
hello
world!
rGrJr3NrKr
s rtest_readallz&TestFileIOSignalInterrupt.test_readallsp.%)%@%@%G%G)2!3&H&5		6	
.%)%@%@%G%G)/!3&H&5		6rN)rrT)__name__
__module____qualname__r
rrr%rCrLrNrSrWr(rrrrs@>A+/;6D7R
E6=6rrceZdZdZy)CTestFileIOSignalInterrupt_ioNrXrYrZrr(rrr\r\Grr\ceZdZdZy)PyTestFileIOSignalInterrupt_pyioNr^r(rrraraGrraceZdZdZdZy)TestBufferedIOSignalInterruptc d|jzS)z?Returns the infile = ... line of code to make a BufferedReader.ziimport %s as io ;infile = io.open(sys.stdin.fileno(), "rb") ;assert isinstance(infile, io.BufferedReader)rr
s rrz9TestBufferedIOSignalInterrupt._generate_infile_setup_codes?	rc`|jd|jjddy)z<BufferedReader.read() must handle signals and not lose data.rQr3rVrGrJNrKr
s rrWz*TestBufferedIOSignalInterrupt.test_readalls8.%)%@%@%G%G)/!3&H&5		6rN)rXrYrZrrWr(rrreres6rreceZdZdZy)CTestBufferedIOSignalInterruptr]Nr^r(rrririr_rriceZdZdZy)PyTestBufferedIOSignalInterruptrbNr^r(rrrkrkrcrrkc$eZdZdZdZdZdZy)TestTextIOSignalInterruptc d|jzS)z>Returns the infile = ... line of code to make a TextIOWrapper.zimport %s as io ;infile = io.open(sys.stdin.fileno(), encoding="utf-8", newline=None) ;assert isinstance(infile, io.TextIOWrapper)rr
s rrz5TestTextIOSignalInterrupt._generate_infile_setup_codes>	rc`|jd|jjddy)rErFr9zhello, world!
rGrJNrKr
s rrNz'TestTextIOSignalInterrupt.test_readlines8.%)%@%@%G%G)3!2&H&4		5rcd|jd|jjdddgy)rPs
hello
world!rRzhello
zworld!
rGrJNrKr
s rrSz(TestTextIOSignalInterrupt.test_readliness=0%)%@%@%G%G)4"+Z!8&H&:		;rc`|jd|jjddy)z-read() must handle signals and not lose data.rQr3z
hello
world!
rGrJNrKr
s rrWz&TestTextIOSignalInterrupt.test_readalls8.%)%@%@%G%G)/!2&H&4		5rN)rXrYrZrrNrSrWr(rrrmrms5;5rrmceZdZdZy)CTestTextIOSignalInterruptr]Nr^r(rrrsrsr_rrsceZdZdZy)PyTestTextIOSignalInterruptrbNr^r(rrrururcrru__main__)osr5r7r.r0runittesttestrhas_subprocess_supportSkipTestr]rb
skipUnlessnamerTestCaser\rarerirkrmrsrurXmainr(rr<module>rs,



%%
(

=
>>RWW')IJ[6[6K[6|!:H<M<M";X=N=N
6$=
6%BHDUDU&CXEVEV5 95@!:H<M<M";X=N=NzHMMOr