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) | |
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 71bcbc4d324..ab1e13984d6 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm | |||
| @@ -259,6 +259,31 @@ | |||
| 259 | (#f #f) | 259 | (#f #f) |
| 260 | (lo (interface-address lo))))))) | 260 | (lo (interface-address lo))))))) |
| 261 | 261 | ||
| 262 | (test-equal "tcgetattr ENOTTY" | ||
| 263 | ENOTTY | ||
| 264 | (catch 'system-error | ||
| 265 | (lambda () | ||
| 266 | (call-with-input-file "/dev/null" | ||
| 267 | (lambda (port) | ||
| 268 | (tcgetattr (fileno port))))) | ||
| 269 | (compose system-error-errno list))) | ||
| 270 | |||
| 271 | (test-skip (if (and (file-exists? "/proc/self/fd/0") | ||
| 272 | (string-prefix? "/dev/pts/" (readlink "/proc/self/fd/0"))) | ||
| 273 | 0 | ||
| 274 | 2)) | ||
| 275 | |||
| 276 | (test-assert "tcgetattr" | ||
| 277 | (let ((termios (tcgetattr 0))) | ||
| 278 | (and (termios? termios) | ||
| 279 | (> (termios-input-speed termios) 0) | ||
| 280 | (> (termios-output-speed termios) 0)))) | ||
| 281 | |||
| 282 | (test-assert "tcsetattr" | ||
| 283 | (let ((first (tcgetattr 0))) | ||
| 284 | (tcsetattr 0 TCSANOW first) | ||
| 285 | (equal? first (tcgetattr 0)))) | ||
| 286 | |||
| 262 | (test-assert "terminal-window-size ENOTTY" | 287 | (test-assert "terminal-window-size ENOTTY" |
| 263 | (call-with-input-file "/dev/null" | 288 | (call-with-input-file "/dev/null" |
| 264 | (lambda (port) | 289 | (lambda (port) |
