a ze @s.ddlZddlZddlmZmZddlZddlZedZedZeedze ddZ Wne yte dYnl0e e e ejd ZWdn1s0Yed edZeeedfvre d [ [[z ddlZWneydZYn0Gd d d ejZedkr*edS)N) import_module get_attributefcntltermios TIOCGPGRP/dev/ttyrbzUnable to open /dev/tty izBNeither the process group nor the session are attached to /dev/ttyc@s>eZdZddZdddZddZdd Zd d Zd d ZdS) IoctlTestscCslttdf}tdd<}t|tjd}t d|d}| ||Wdn1s^0YdS)Nrrrr r ) osgetpgrpgetsidopenrioctlrrstructunpackassertIn)selfidsttyrrpgrprC/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_ioctl.py test_ioctls  zIoctlTests.test_ioctlNc Cstd}|j}ttdf}d}|durX||g|||t|||n ||t dd"}t |t j |d}Wdn1s0Y|d}||d|||dS)Nr rirrT)arrayitemsizer r rextendZ assertEquallenappendrrrrrr) rnbytesbufZintsizerfillrrrrrr_check_ioctl_mutate_len&s   0 z"IoctlTests._check_ioctl_mutate_lencCs |dS)Nr$rrrrtest_ioctl_mutate8szIoctlTests.test_ioctl_mutatecCs|ddS)Nir%r&rrrtest_ioctl_mutate_1024;sz!IoctlTests.test_ioctl_mutate_1024cCs|ddS)Nir%r&rrrtest_ioctl_mutate_2048@sz!IoctlTests.test_ioctl_mutate_2048c Cststdt\}}ztjdkr8tj}tjd@}ntj}tdtdtj\}tddddd}t |||}t |||}Wt |t |nt |t |0dS) Nzpty module requiredrlr IZHHHHP) ptyunittestSkipTestopenptyrZ TIOCSWINSZrrpackrrr close)rZmfdZsfdZset_winsz_opcode_maybe_negZset_winsz_opcode_posZ our_winszZ new_winszrrr%test_ioctl_signed_unsigned_code_paramDs$       z0IoctlTests.test_ioctl_signed_unsigned_code_param)N) __name__ __module__ __qualname__rr$r'r(r)r3rrrrr s  r __main__)rr.Z test.supportrrr rrrrrOSErrorr/rrrrrr rr- ImportErrorZTestCaser r4mainrrrrs.  .   >