summaryrefslogtreecommitdiff
path: root/tests/platform_tests/test_control_terminal.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/platform_tests/test_control_terminal.py')
-rwxr-xr-xtests/platform_tests/test_control_terminal.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/platform_tests/test_control_terminal.py b/tests/platform_tests/test_control_terminal.py
new file mode 100755
index 0000000..9598fd7
--- /dev/null
+++ b/tests/platform_tests/test_control_terminal.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+import termios, fcntl, struct, os, sys
+
+def getwinsize():
+ s = struct.pack("HHHH", 0, 0, 0, 0)
+ x = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, s)
+ rows, cols = struct.unpack("HHHH", x)[:2]
+ return rows, cols
+
+def setwinsize(r,c):
+ # Assume ws_xpixel and ws_ypixel are zero.
+ s = struct.pack("HHHH", r,c,0,0)
+ x = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCSWINSZ, s)
+print 'stdin tty:', os.ttyname(0)
+print 'stdout tty:', os.ttyname(1)
+print 'controlling terminal:', os.ctermid()
+print 'winsize %d,%d' % getwinsize()
+print 'ENDTEST'