python (3.11.7)

(root)/
lib/
python3.11/
test/
__pycache__/
test_file_eintr.cpython-311.pyc

e*8ddlZddlZddlZddlZddlZddlZddlZddlmZej	sej
dddlZddlZej
ejdkdGddZGdd	eejZGd
deejZGdd
eZGddeejZGddeejZGddeZGddeejZGddeejZedkrejdSdS)N)supportztest module requires subprocessposixztests requires a posix system.cHeZdZdZdZdZ		d
dZdZdZd	Z	d
Z
dZdS)TestFileIOSignalInterruptcd|_dSN)_processselfs H/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/test/test_file_eintr.pysetUpzTestFileIOSignalInterrupt.setUps



c|jrF|j/	|jdS#t$rYdSwxYwdSdSr)r	pollkillOSErrorr
s rtearDownz"TestFileIOSignalInterrupt.tearDown sp=	T]//119

""$$$$$



		99s=
A
Acd|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
?	rrTc	|j?tjd	|jn#t
$rYnwxYw|r&|j\}}||z
}||z
}|d|d|d|ddS)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='JsOOO

''))))



	!%)]%>%>%@%@"J
j Fj F			33

:	;	;	;	;	;sA		
AAc|}t|dks
Jdtjtjddd|zdzdz|zdzdzgtjtjtj	|_|jj	td
}|d
kr|
d||jj|d
}g}|stj
|jjgddd\}}}|jtj|dz
}|dkr.|j|d||jj}|dkr|
d||jd\}	}
|jjr(|
d|jjz|	|
ddSdS)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_readingKsk!<<>>=!!C''')N'''#(tJ%%(,,7	7
((
+//"
"!ojo!(((
M(--c/.B.BCC	''''(?/8
(
:
:
:
!!-000	J -)=(>BMMKE1aM%%fm444ALc!!
""$$$		HIII
	Jm*3355&  ''(?/:
(
<
<
<222??=#	7''"T]%==F
(
7
7
7
7
7	7	7rzgot = infile.{read_method_name}() ;expected = {expected!r} ;assert got == expected, ("{read_method_name} returned wrong data.\n""got data %r\nexpected %r" % (got, expected))ch|d|jdddS)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_readlinesN.%)%@%G%G)3!3&H&5&5		6	6	6	6	6rcl|d|jdddgdS)2readlines() must handle signals and not lose data.hello
world!	readlinesshello
sworld!
rGrJNrKr
s rtest_readlinesz(TestFileIOSignalInterrupt.test_readlinessS.%)%@%G%G)4",k!:&H&<&<		=	=	=	=	=rc|d|jdd|d|jdddS)z0readall() must handle signals and not lose data.rQreadall
hello
world!
rGrJr3NrKr
s rtest_readallz&TestFileIOSignalInterrupt.test_readalls.%)%@%G%G)2!3&H&5&5		6	6	6	
.%)%@%G%G)/!3&H&5&5		6	6	6	6	6rN)rrT)__name__
__module____qualname__r
rrr%rCrLrNrSrWr(rrrrs>A+/;;;;6D7D7D7R
E666===66666rrceZdZdZdS)CTestFileIOSignalInterrupt_ioNrXrYrZrr(rrr\r\GGGrr\ceZdZdZdS)PyTestFileIOSignalInterrupt_pyioNr^r(rrraraGGGrraceZdZdZdZdS)TestBufferedIOSignalInterruptcd|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?	rch|d|jdddS)z<BufferedReader.read() must handle signals and not lose data.rQr3rVrGrJNrKr
s rrWz*TestBufferedIOSignalInterrupt.test_readallsN.%)%@%G%G)/!3&H&5&5		6	6	6	6	6rN)rXrYrZrrWr(rrreres266666rreceZdZdZdS)CTestBufferedIOSignalInterruptr]Nr^r(rrririr_rriceZdZdZdS)PyTestBufferedIOSignalInterruptrbNr^r(rrrkrkrcrrkc&eZdZdZdZdZdZdS)TestTextIOSignalInterruptcd|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>	rch|d|jdddS)rErFr9zhello, world!
rGrJNrKr
s rrNz'TestTextIOSignalInterrupt.test_readlinesN.%)%@%G%G)3!2&H&4&4		5	5	5	5	5rcl|d|jdddgdS)rPs
hello
world!rRzhello
zworld!
rGrJNrKr
s rrSz(TestTextIOSignalInterrupt.test_readlinessS0%)%@%G%G)4"+Z!8&H&:&:		;	;	;	;	;rch|d|jdddS)z-read() must handle signals and not lose data.rQr3z
hello
world!
rGrJNrKr
s rrWz&TestTextIOSignalInterrupt.test_readallsN.%)%@%G%G)/!2&H&4&4		5	5	5	5	5rN)rXrYrZrrNrSrWr(rrrmrmsP555;;;55555rrmceZdZdZdS)CTestTextIOSignalInterruptr]Nr^r(rrrsrsr_rrsceZdZdZdS)PyTestTextIOSignalInterruptrbNr^r(rrrururcrru__main__)osr5r7r.r0runittesttestrhas_subprocess_supportSkipTestr]rb
skipUnlessnamerTestCaser\rarerirkrmrsrurXmainr(rr<module>rs
			











%?
(
=
>
>>


RW')IJJ[6[6[6[6[6[6[6KJ[6|!:H<M";X=N
6
6
6
6
6$=
6
6
6%BHDU&CXEV55555 9555@!:H<M";X=NzHMOOOOOr