HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/samba/tests/blackbox/__pycache__/check_output.cpython-310.pyc
o

�/a
�@sDdZddlZddlmZGdd�d�Zddd	�ZGd
d�de�ZdS)
z7
Blackbox tests for blackboxtest check output methods.
�N)�BlackboxTestCasec@s@eZdZdZGdd�de�Zdd�Zdd�Zdd	�Zd
d�Z	dS)
�
TimeoutHelperz�
    Timeout class using alarm signal.

    Raise a Timeout exception if a function timeout.
    Usage:

        try:
            with Timeout(3):
                foobar("Request 1")
        except TimeoutHelper.Timeout:
            print("Timeout")
    c@seZdZdS)zTimeoutHelper.TimeoutN)�__name__�
__module__�__qualname__�rr�C/usr/lib/python3/dist-packages/samba/tests/blackbox/check_output.py�Timeout&sr	cCs
||_dS�N)�sec)�selfrrrr�__init__)s
zTimeoutHelper.__init__cCs t�tj|j�t�|j�dSr
)�signal�SIGALRM�
raise_timeout�alarmr�rrrr�	__enter__,szTimeoutHelper.__enter__cGst�d�dS)Nr)rr�r�argsrrr�__exit__0szTimeoutHelper.__exit__cGst���r
)rr	rrrrr3szTimeoutHelper.raise_timeoutN)
rrr�__doc__�	Exceptionr	r
rrrrrrrrs
r�$�PcCsd�|||�S)z>Build a command to call gen_output.py to generate large outputz3gen_output.py --data {0} --repeat {1} --retcode {2})�format)�data�repeat�retcoderrr�
_make_cmdline7s�rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�CheckOutputTestsa
    Blackbox tests for check_xxx methods.

    The check_xxx methods in BlackboxTestCase will deadlock
    on large output from command which caused by Popen.wait().

    This is a test case to show the deadlock issue,
    will fix in another commit.
    cCsbztd��|�t��Wd�WdS1swYWdStjy0|jdd�YdSw)z!Call check_run with large output.�
N�Timeout!��msg)r�	check_runrr	�failrrrr�test_check_run_timeoutIs
&��z'CheckOutputTests.test_check_run_timeoutcC�hz"td��|�tdd�d�Wd�WdS1swYWdStjy3|jdd�YdSw)Nr!r�rr"r#�r�check_exit_coderr	r&rrrr�.test_check_exit_code_with_large_output_successQ�
&��z?CheckOutputTests.test_check_exit_code_with_large_output_successcCr()Nr!�r)r"r#r*rrrr�.test_check_exit_code_with_large_output_failureXr-z?CheckOutputTests.test_check_exit_code_with_large_output_failurecCs�d}d}||}t||d�}z'td��|�|�}|�||�d��Wd�WdS1s.wYWdStjyF|jdd�YdSw)N�@r)rrr!zutf-8r"r#)rr�check_output�assertEqual�encoder	r&)rrr�expected�cmdline�actualrrr�#test_check_output_with_large_output_s

&��z4CheckOutputTests.test_check_output_with_large_outputN)rrrrr'r,r/r7rrrrr >s
r )rrr)rr�samba.testsrrrr rrrr�<module>s