aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-04-05 18:35:57 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2019-04-05 18:36:40 +0200
commitd2c7c584af75f86bcf203a601c60411dcba89004 (patch)
treef0f5863e3ba70bf05c86ee472e42a819f173cc65
parentRemove old termios bindings. (diff)
downloadcalp-d2c7c584af75f86bcf203a601c60411dcba89004.tar.gz
calp-d2c7c584af75f86bcf203a601c60411dcba89004.tar.xz
Add termios tests.
-rwxr-xr-xtests/termios.scm39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/termios.scm b/tests/termios.scm
new file mode 100755
index 00000000..707648d4
--- /dev/null
+++ b/tests/termios.scm
@@ -0,0 +1,39 @@
+;;; Commentary:
+
+;; Tests that my termios function works, at least somewhat.
+;; Note that this actually modifies the terminal it's run on, and might fail if
+;; the terminal doesn't support the wanted modes. See termios(3).
+;; It might also leave the terminal in a broken state if exited prematurely.
+
+;;; Code:
+
+(use-modules (terminal termios)
+ ((util) :select (mod!))
+ ((srfi srfi-60)
+ :renamer (lambda (symb)
+ (case symb
+ ((bitwise-ior) '||)
+ ((bitwise-not) '~)
+ ((bitwise-and) '&)
+ (else symb)))))
+
+(define-syntax-rule (&= lvalue val)
+ (mod! lvalue (lambda (v) (& v val))))
+
+(test-begin "termios")
+
+(define t (make-termios))
+
+(test-equal 0 (tcgetattr! t))
+(define ifl (lflag t))
+
+(define copy (copy-termios t))
+
+#!curly-infix { (lflag t) &= (~ (|| ECHO ICANON)) }
+
+(test-equal 0 (tcsetattr! t))
+(test-equal (& ifl (~ (|| ECHO ICANON)))
+ (lflag t))
+(test-equal 0 (tcsetattr! copy))
+
+(test-end "termios")