aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-02-08 14:35:07 +1100
committerLars Ingebrigtsen2016-02-08 14:35:07 +1100
commit4f50d8db8c54ca3fb80cd52c34099c4c0a8fb7dd (patch)
treed4f4e5bffbd2560aefc8245e5e4da4bf8b0fd425
parent0cc907100cbf6b730935cf5beeb943943ab518e3 (diff)
downloademacs-4f50d8db8c54ca3fb80cd52c34099c4c0a8fb7dd.tar.gz
emacs-4f50d8db8c54ca3fb80cd52c34099c4c0a8fb7dd.zip
Add more network tests
* test/lisp/net/network-stream-tests.el (echo-server-nowait): New test.
-rw-r--r--test/lisp/net/network-stream-tests.el33
1 files changed, 28 insertions, 5 deletions
diff --git a/test/lisp/net/network-stream-tests.el b/test/lisp/net/network-stream-tests.el
index 3e0821a8bd5..f52a69e05d6 100644
--- a/test/lisp/net/network-stream-tests.el
+++ b/test/lisp/net/network-stream-tests.el
@@ -75,7 +75,7 @@
75 :filter 'server-process-filter 75 :filter 'server-process-filter
76 :host host)) 76 :host host))
77 77
78(defun server-sentinel (proc msg) 78(defun server-sentinel (_proc _msg)
79 ) 79 )
80 80
81(defun server-process-filter (proc string) 81(defun server-process-filter (proc string)
@@ -95,7 +95,7 @@
95 )))) 95 ))))
96 96
97(ert-deftest echo-server-with-dns () 97(ert-deftest echo-server-with-dns ()
98 (let* ((server (make-server "mouse")) 98 (let* ((server (make-server (system-name)))
99 (port (aref (process-contact server :local) 4)) 99 (port (aref (process-contact server :local) 4))
100 (proc (make-network-process :name "foo" 100 (proc (make-network-process :name "foo"
101 :buffer (generate-new-buffer "*foo*") 101 :buffer (generate-new-buffer "*foo*")
@@ -104,7 +104,8 @@
104 (with-current-buffer "*foo*" 104 (with-current-buffer "*foo*"
105 (process-send-string proc "echo foo") 105 (process-send-string proc "echo foo")
106 (sleep-for 0.1) 106 (sleep-for 0.1)
107 (should (equal (buffer-string) "foo\n"))))) 107 (should (equal (buffer-string) "foo\n")))
108 (delete-process server)))
108 109
109(ert-deftest echo-server-with-localhost () 110(ert-deftest echo-server-with-localhost ()
110 (let* ((server (make-server 'local)) 111 (let* ((server (make-server 'local))
@@ -116,7 +117,8 @@
116 (with-current-buffer "*foo*" 117 (with-current-buffer "*foo*"
117 (process-send-string proc "echo foo") 118 (process-send-string proc "echo foo")
118 (sleep-for 0.1) 119 (sleep-for 0.1)
119 (should (equal (buffer-string) "foo\n"))))) 120 (should (equal (buffer-string) "foo\n")))
121 (delete-process server)))
120 122
121(ert-deftest echo-server-with-ip () 123(ert-deftest echo-server-with-ip ()
122 (let* ((server (make-server 'local)) 124 (let* ((server (make-server 'local))
@@ -128,6 +130,27 @@
128 (with-current-buffer "*foo*" 130 (with-current-buffer "*foo*"
129 (process-send-string proc "echo foo") 131 (process-send-string proc "echo foo")
130 (sleep-for 0.1) 132 (sleep-for 0.1)
131 (should (equal (buffer-string) "foo\n"))))) 133 (should (equal (buffer-string) "foo\n")))
134 (delete-process server)))
135
136(ert-deftest echo-server-nowait ()
137 (let* ((server (make-server 'local))
138 (port (aref (process-contact server :local) 4))
139 (proc (make-network-process :name "foo"
140 :buffer (generate-new-buffer "*foo*")
141 :host "localhost"
142 :nowait t
143 :service port)))
144 (should (eq (process-status proc) 'connect))
145 (should (null (ignore-errors
146 (process-send-string proc "echo bar")
147 t)))
148 (while (eq (process-status proc) 'connect)
149 (sit-for 0.1))
150 (with-current-buffer "*foo*"
151 (process-send-string proc "echo foo")
152 (sleep-for 0.1)
153 (should (equal (buffer-string) "foo\n")))
154 (delete-process server)))
132 155
133;;; network-stream-tests.el ends here 156;;; network-stream-tests.el ends here