diff options
author | Ludovic Courtès <ludo@gnu.org> | 2016-05-01 23:59:05 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2016-05-02 00:05:36 +0200 |
commit | ae4ff9f359514937878cf82f4ac46dd14aac9056 (patch) | |
tree | dab4f54a6be817401a754e182e3475be773774a7 /tests | |
parent | 00cd41974e9579eccedb948d5eebed442efb600e (diff) | |
download | guix-ae4ff9f359514937878cf82f4ac46dd14aac9056.tar guix-ae4ff9f359514937878cf82f4ac46dd14aac9056.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) |