|
1 |
| -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. |
| 1 | +# Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. |
2 | 2 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
3 | 3 | #
|
4 | 4 | # The Universal Permissive License (UPL), Version 1.0
|
@@ -111,3 +111,26 @@ def test_flock_s_and_s(self):
|
111 | 111 | finally:
|
112 | 112 | fcntl.flock(file, fcntl.LOCK_UN)
|
113 | 113 | os.close(file)
|
| 114 | + |
| 115 | + |
| 116 | +class IoctlTests(unittest.TestCase): |
| 117 | + # Taken from CPython test_ioctl.py which unfortunately skips the whole file when not in a terminal |
| 118 | + def test_ioctl_signed_unsigned_code_param(self): |
| 119 | + import pty, termios, struct |
| 120 | + mfd, sfd = pty.openpty() |
| 121 | + try: |
| 122 | + if termios.TIOCSWINSZ < 0: |
| 123 | + set_winsz_opcode_maybe_neg = termios.TIOCSWINSZ |
| 124 | + set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffff |
| 125 | + else: |
| 126 | + set_winsz_opcode_pos = termios.TIOCSWINSZ |
| 127 | + set_winsz_opcode_maybe_neg, = struct.unpack("i", |
| 128 | + struct.pack("I", termios.TIOCSWINSZ)) |
| 129 | + |
| 130 | + our_winsz = struct.pack("HHHH",80,25,0,0) |
| 131 | + # test both with a positive and potentially negative ioctl code |
| 132 | + new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_pos, our_winsz) |
| 133 | + new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, our_winsz) |
| 134 | + finally: |
| 135 | + os.close(mfd) |
| 136 | + os.close(sfd) |
0 commit comments