diff options
author | Ludovic Courtès <ludo@gnu.org> | 2016-05-01 23:59:05 +0200 |
---|---|---|
committer | 宋文武 <iyzsong@gmail.com> | 2016-05-02 22:05:54 +0800 |
commit | 29d457c209bbc1a5371025b3247e2db36027c56d (patch) | |
tree | db216316489fbc2d966c52045becd91872a6cbb3 /tests | |
parent | ba369abe588d8420631f3540a51db98f6cc30d93 (diff) | |
download | guix-29d457c209bbc1a5371025b3247e2db36027c56d.tar guix-29d457c209bbc1a5371025b3247e2db36027c56d.tar.gz |
syscalls: Add 'tcgetattr' and 'tcsetattr' bindings.
* guix/build/syscalls.scm (bits->symbols-body, define-bits)
(local-flags): New macros.
(TCSANOW, TCSADRAIN, TCSAFLUSH): New variables.
(<termios>): New record type.
(%termios): New C structure.
(tcgetattr, tcsetattr): New procedures.
* tests/syscalls.scm ("tcgetattr ENOTTY", "tcgetattr")
("tcsetattr"): New tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/syscalls.scm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/syscalls.scm b/tests/syscalls.scm index 71bcbc4d32..ab1e13984d 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm @@ -259,6 +259,31 @@ (#f #f) (lo (interface-address lo))))))) +(test-equal "tcgetattr ENOTTY" + ENOTTY + (catch 'system-error + (lambda () + (call-with-input-file "/dev/null" + (lambda (port) + (tcgetattr (fileno port))))) + (compose system-error-errno list))) + +(test-skip (if (and (file-exists? "/proc/self/fd/0") + (string-prefix? "/dev/pts/" (readlink "/proc/self/fd/0"))) + 0 + 2)) + +(test-assert "tcgetattr" + (let ((termios (tcgetattr 0))) + (and (termios? termios) + (> (termios-input-speed termios) 0) + (> (termios-output-speed termios) 0)))) + +(test-assert "tcsetattr" + (let ((first (tcgetattr 0))) + (tcsetattr 0 TCSANOW first) + (equal? first (tcgetattr 0)))) + (test-assert "terminal-window-size ENOTTY" (call-with-input-file "/dev/null" (lambda (port) |