aboutsummaryrefslogtreecommitdiffstats
path: root/test/src/process-tests.el
diff options
context:
space:
mode:
authorMichael Albinus2020-12-29 18:40:23 +0100
committerMichael Albinus2020-12-29 18:40:23 +0100
commit154d4b856fb9cfbe8b595a7894e7318e29cefdea (patch)
tree62d7f6476302bde3bc56b3d42f4b52601dd69e43 /test/src/process-tests.el
parent16bb10889dfb9a4688b8c029038a09292fdba3ef (diff)
downloademacs-154d4b856fb9cfbe8b595a7894e7318e29cefdea.tar.gz
emacs-154d4b856fb9cfbe8b595a7894e7318e29cefdea.zip
Instrument process-tests.el for timeouts on emba
Diffstat (limited to 'test/src/process-tests.el')
-rw-r--r--test/src/process-tests.el57
1 files changed, 38 insertions, 19 deletions
diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index daf49759500..464541a9387 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -47,13 +47,15 @@
47 47
48(ert-deftest process-test-sentinel-accept-process-output () 48(ert-deftest process-test-sentinel-accept-process-output ()
49 (skip-unless (executable-find "bash")) 49 (skip-unless (executable-find "bash"))
50 (with-timeout (60)
50 (should (process-test-sentinel-wait-function-working-p 51 (should (process-test-sentinel-wait-function-working-p
51 #'accept-process-output))) 52 #'accept-process-output))))
52 53
53(ert-deftest process-test-sentinel-sit-for () 54(ert-deftest process-test-sentinel-sit-for ()
54 (skip-unless (executable-find "bash")) 55 (skip-unless (executable-find "bash"))
56 (with-timeout (60)
55 (should 57 (should
56 (process-test-sentinel-wait-function-working-p (lambda () (sit-for 0.01 t))))) 58 (process-test-sentinel-wait-function-working-p (lambda () (sit-for 0.01 t))))))
57 59
58(when (eq system-type 'windows-nt) 60(when (eq system-type 'windows-nt)
59 (ert-deftest process-test-quoted-batfile () 61 (ert-deftest process-test-quoted-batfile ()
@@ -79,6 +81,7 @@
79 81
80(ert-deftest process-test-stderr-buffer () 82(ert-deftest process-test-stderr-buffer ()
81 (skip-unless (executable-find "bash")) 83 (skip-unless (executable-find "bash"))
84 (with-timeout (60)
82 (let* ((stdout-buffer (generate-new-buffer "*stdout*")) 85 (let* ((stdout-buffer (generate-new-buffer "*stdout*"))
83 (stderr-buffer (generate-new-buffer "*stderr*")) 86 (stderr-buffer (generate-new-buffer "*stderr*"))
84 (proc (make-process :name "test" 87 (proc (make-process :name "test"
@@ -103,10 +106,11 @@
103 (looking-at "hello stdout!"))) 106 (looking-at "hello stdout!")))
104 (should (with-current-buffer stderr-buffer 107 (should (with-current-buffer stderr-buffer
105 (goto-char (point-min)) 108 (goto-char (point-min))
106 (looking-at "hello stderr!"))))) 109 (looking-at "hello stderr!"))))))
107 110
108(ert-deftest process-test-stderr-filter () 111(ert-deftest process-test-stderr-filter ()
109 (skip-unless (executable-find "bash")) 112 (skip-unless (executable-find "bash"))
113 (with-timeout (60)
110 (let* ((sentinel-called nil) 114 (let* ((sentinel-called nil)
111 (stderr-sentinel-called nil) 115 (stderr-sentinel-called nil)
112 (stdout-output nil) 116 (stdout-output nil)
@@ -145,10 +149,11 @@
145 (should (equal 1 (with-current-buffer stderr-buffer 149 (should (equal 1 (with-current-buffer stderr-buffer
146 (point-max)))) 150 (point-max))))
147 (should (equal "hello stderr!\n" 151 (should (equal "hello stderr!\n"
148 (mapconcat #'identity (nreverse stderr-output) ""))))) 152 (mapconcat #'identity (nreverse stderr-output) ""))))))
149 153
150(ert-deftest set-process-filter-t () 154(ert-deftest set-process-filter-t ()
151 "Test setting process filter to t and back." ;; Bug#36591 155 "Test setting process filter to t and back." ;; Bug#36591
156 (with-timeout (60)
152 (with-temp-buffer 157 (with-temp-buffer
153 (let* ((print-level nil) 158 (let* ((print-level nil)
154 (print-length nil) 159 (print-length nil)
@@ -180,11 +185,12 @@
180 (line-beginning-position) (point-max)) 185 (line-beginning-position) (point-max))
181 "2> ")) 186 "2> "))
182 (accept-process-output proc)) ; Read "Two". 187 (accept-process-output proc)) ; Read "Two".
183 (should (equal (buffer-string) "0> one\n1> two\n2> "))))) 188 (should (equal (buffer-string) "0> one\n1> two\n2> "))))))
184 189
185(ert-deftest start-process-should-not-modify-arguments () 190(ert-deftest start-process-should-not-modify-arguments ()
186 "`start-process' must not modify its arguments in-place." 191 "`start-process' must not modify its arguments in-place."
187 ;; See bug#21831. 192 ;; See bug#21831.
193 (with-timeout (60)
188 (let* ((path (pcase system-type 194 (let* ((path (pcase system-type
189 ((or 'windows-nt 'ms-dos) 195 ((or 'windows-nt 'ms-dos)
190 ;; Make sure the file name uses forward slashes. 196 ;; Make sure the file name uses forward slashes.
@@ -198,11 +204,12 @@
198 (should (process-live-p (condition-case nil 204 (should (process-live-p (condition-case nil
199 (start-process "" nil path) 205 (start-process "" nil path)
200 (error nil)))) 206 (error nil))))
201 (should (equal path samepath)))) 207 (should (equal path samepath)))))
202 208
203(ert-deftest make-process/noquery-stderr () 209(ert-deftest make-process/noquery-stderr ()
204 "Checks that Bug#30031 is fixed." 210 "Checks that Bug#30031 is fixed."
205 (skip-unless (executable-find "sleep")) 211 (skip-unless (executable-find "sleep"))
212 (with-timeout (60)
206 (with-temp-buffer 213 (with-temp-buffer
207 (let* ((previous-processes (process-list)) 214 (let* ((previous-processes (process-list))
208 (process (make-process :name "sleep" 215 (process (make-process :name "sleep"
@@ -217,7 +224,7 @@
217 (should new-processes) 224 (should new-processes)
218 (dolist (process new-processes) 225 (dolist (process new-processes)
219 (should-not (process-query-on-exit-flag process)))) 226 (should-not (process-query-on-exit-flag process))))
220 (kill-process process))))) 227 (kill-process process))))))
221 228
222;; Return t if OUTPUT could have been generated by merging the INPUTS somehow. 229;; Return t if OUTPUT could have been generated by merging the INPUTS somehow.
223(defun process-tests--mixable (output &rest inputs) 230(defun process-tests--mixable (output &rest inputs)
@@ -233,6 +240,7 @@
233(ert-deftest make-process/mix-stderr () 240(ert-deftest make-process/mix-stderr ()
234 "Check that `make-process' mixes the output streams if STDERR is nil." 241 "Check that `make-process' mixes the output streams if STDERR is nil."
235 (skip-unless (executable-find "bash")) 242 (skip-unless (executable-find "bash"))
243 (with-timeout (60)
236 ;; Frequent random (?) failures on hydra.nixos.org, with no process output. 244 ;; Frequent random (?) failures on hydra.nixos.org, with no process output.
237 ;; Maybe this test should be tagged unstable? See bug#31214. 245 ;; Maybe this test should be tagged unstable? See bug#31214.
238 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 246 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
@@ -251,11 +259,12 @@
251 (should (eq (process-exit-status process) 0)) 259 (should (eq (process-exit-status process) 0))
252 (should (process-tests--mixable (string-to-list (buffer-string)) 260 (should (process-tests--mixable (string-to-list (buffer-string))
253 (string-to-list "stdout\n") 261 (string-to-list "stdout\n")
254 (string-to-list "stderr\n")))))) 262 (string-to-list "stderr\n")))))))
255 263
256(ert-deftest make-process-w32-debug-spawn-error () 264(ert-deftest make-process-w32-debug-spawn-error ()
257 "Check that debugger runs on `make-process' failure (Bug#33016)." 265 "Check that debugger runs on `make-process' failure (Bug#33016)."
258 (skip-unless (eq system-type 'windows-nt)) 266 (skip-unless (eq system-type 'windows-nt))
267 (with-timeout (60)
259 (let* ((debug-on-error t) 268 (let* ((debug-on-error t)
260 (have-called-debugger nil) 269 (have-called-debugger nil)
261 (debugger (lambda (&rest _) 270 (debugger (lambda (&rest _)
@@ -271,11 +280,12 @@
271 ;; code. 280 ;; code.
272 (make-process :name "test" :command '("c:/No-Such-Command")) 281 (make-process :name "test" :command '("c:/No-Such-Command"))
273 (error :got-error)))) 282 (error :got-error))))
274 (should have-called-debugger))) 283 (should have-called-debugger))))
275 284
276(ert-deftest make-process/file-handler/found () 285(ert-deftest make-process/file-handler/found ()
277 "Check that the ‘:file-handler’ argument of ‘make-process’ 286 "Check that the ‘:file-handler’ argument of ‘make-process’
278works as expected if a file name handler is found." 287works as expected if a file name handler is found."
288 (with-timeout (60)
279 (let ((file-handler-calls 0)) 289 (let ((file-handler-calls 0))
280 (cl-flet ((file-handler 290 (cl-flet ((file-handler
281 (&rest args) 291 (&rest args)
@@ -292,27 +302,29 @@ works as expected if a file name handler is found."
292 :command '("/some/binary") 302 :command '("/some/binary")
293 :file-handler t) 303 :file-handler t)
294 'fake-process)) 304 'fake-process))
295 (should (= file-handler-calls 1)))))) 305 (should (= file-handler-calls 1)))))))
296 306
297(ert-deftest make-process/file-handler/not-found () 307(ert-deftest make-process/file-handler/not-found ()
298 "Check that the ‘:file-handler’ argument of ‘make-process’ 308 "Check that the ‘:file-handler’ argument of ‘make-process’
299works as expected if no file name handler is found." 309works as expected if no file name handler is found."
310 (with-timeout (60)
300 (let ((file-name-handler-alist ()) 311 (let ((file-name-handler-alist ())
301 (default-directory invocation-directory) 312 (default-directory invocation-directory)
302 (program (expand-file-name invocation-name invocation-directory))) 313 (program (expand-file-name invocation-name invocation-directory)))
303 (should (processp (make-process :name "name" 314 (should (processp (make-process :name "name"
304 :command (list program "--version") 315 :command (list program "--version")
305 :file-handler t))))) 316 :file-handler t))))))
306 317
307(ert-deftest make-process/file-handler/disable () 318(ert-deftest make-process/file-handler/disable ()
308 "Check ‘make-process’ works as expected if it shouldn’t use the 319 "Check ‘make-process’ works as expected if it shouldn’t use the
309file name handler." 320file name handler."
321 (with-timeout (60)
310 (let ((file-name-handler-alist (list (cons (rx bos "test-handler:") 322 (let ((file-name-handler-alist (list (cons (rx bos "test-handler:")
311 #'process-tests--file-handler))) 323 #'process-tests--file-handler)))
312 (default-directory "test-handler:/dir/") 324 (default-directory "test-handler:/dir/")
313 (program (expand-file-name invocation-name invocation-directory))) 325 (program (expand-file-name invocation-name invocation-directory)))
314 (should (processp (make-process :name "name" 326 (should (processp (make-process :name "name"
315 :command (list program "--version")))))) 327 :command (list program "--version")))))))
316 328
317(defun process-tests--file-handler (operation &rest _args) 329(defun process-tests--file-handler (operation &rest _args)
318 (cl-ecase operation 330 (cl-ecase operation
@@ -325,11 +337,12 @@ file name handler."
325(ert-deftest make-process/stop () 337(ert-deftest make-process/stop ()
326 "Check that `make-process' doesn't accept a `:stop' key. 338 "Check that `make-process' doesn't accept a `:stop' key.
327See Bug#30460." 339See Bug#30460."
340 (with-timeout (60)
328 (should-error 341 (should-error
329 (make-process :name "test" 342 (make-process :name "test"
330 :command (list (expand-file-name invocation-name 343 :command (list (expand-file-name invocation-name
331 invocation-directory)) 344 invocation-directory))
332 :stop t))) 345 :stop t))))
333 346
334;; All the following tests require working DNS, which appears not to 347;; All the following tests require working DNS, which appears not to
335;; be the case for hydra.nixos.org, so disable them there for now. 348;; be the case for hydra.nixos.org, so disable them there for now.
@@ -337,40 +350,46 @@ See Bug#30460."
337(ert-deftest lookup-family-specification () 350(ert-deftest lookup-family-specification ()
338 "network-lookup-address-info should only accept valid family symbols." 351 "network-lookup-address-info should only accept valid family symbols."
339 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 352 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
353 (with-timeout (60)
340 (should-error (network-lookup-address-info "google.com" 'both)) 354 (should-error (network-lookup-address-info "google.com" 'both))
341 (should (network-lookup-address-info "google.com" 'ipv4)) 355 (should (network-lookup-address-info "google.com" 'ipv4))
342 (when (featurep 'make-network-process '(:family ipv6)) 356 (when (featurep 'make-network-process '(:family ipv6))
343 (should (network-lookup-address-info "google.com" 'ipv6)))) 357 (should (network-lookup-address-info "google.com" 'ipv6)))))
344 358
345(ert-deftest lookup-unicode-domains () 359(ert-deftest lookup-unicode-domains ()
346 "Unicode domains should fail" 360 "Unicode domains should fail"
347 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 361 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
362 (with-timeout (60)
348 (should-error (network-lookup-address-info "faß.de")) 363 (should-error (network-lookup-address-info "faß.de"))
349 (should (network-lookup-address-info (puny-encode-domain "faß.de")))) 364 (should (network-lookup-address-info (puny-encode-domain "faß.de")))))
350 365
351(ert-deftest unibyte-domain-name () 366(ert-deftest unibyte-domain-name ()
352 "Unibyte domain names should work" 367 "Unibyte domain names should work"
353 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 368 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
354 (should (network-lookup-address-info (string-to-unibyte "google.com")))) 369 (with-timeout (60)
370 (should (network-lookup-address-info (string-to-unibyte "google.com")))))
355 371
356(ert-deftest lookup-google () 372(ert-deftest lookup-google ()
357 "Check that we can look up google IP addresses" 373 "Check that we can look up google IP addresses"
358 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 374 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
375 (with-timeout (60)
359 (let ((addresses-both (network-lookup-address-info "google.com")) 376 (let ((addresses-both (network-lookup-address-info "google.com"))
360 (addresses-v4 (network-lookup-address-info "google.com" 'ipv4))) 377 (addresses-v4 (network-lookup-address-info "google.com" 'ipv4)))
361 (should addresses-both) 378 (should addresses-both)
362 (should addresses-v4)) 379 (should addresses-v4))
363 (when (featurep 'make-network-process '(:family ipv6)) 380 (when (featurep 'make-network-process '(:family ipv6))
364 (should (network-lookup-address-info "google.com" 'ipv6)))) 381 (should (network-lookup-address-info "google.com" 'ipv6)))))
365 382
366(ert-deftest non-existent-lookup-failure () 383(ert-deftest non-existent-lookup-failure ()
367 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 384 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
385 (with-timeout (60)
368 "Check that looking up non-existent domain returns nil" 386 "Check that looking up non-existent domain returns nil"
369 (should (eq nil (network-lookup-address-info "emacs.invalid")))) 387 (should (eq nil (network-lookup-address-info "emacs.invalid")))))
370 388
371(ert-deftest process-tests/fd-setsize-no-crash () 389(ert-deftest process-tests/fd-setsize-no-crash ()
372 "Check that Emacs doesn't crash when trying to use more than 390 "Check that Emacs doesn't crash when trying to use more than
373FD_SETSIZE file descriptors (Bug#24325)." 391FD_SETSIZE file descriptors (Bug#24325)."
392 (with-timeout (60)
374 (let ((sleep (executable-find "sleep")) 393 (let ((sleep (executable-find "sleep"))
375 ;; FD_SETSIZE is typically 1024 on Unix-like systems. 394 ;; FD_SETSIZE is typically 1024 on Unix-like systems.
376 (fd-setsize 1024) 395 (fd-setsize 1024)
@@ -401,7 +420,7 @@ FD_SETSIZE file descriptors (Bug#24325)."
401 (while (accept-process-output process)) 420 (while (accept-process-output process))
402 (should (eq (process-status process) 'exit)) 421 (should (eq (process-status process) 'exit))
403 (should (eql (process-exit-status process) 0)) 422 (should (eql (process-exit-status process) 0))
404 (delete-process process)))) 423 (delete-process process)))))
405 424
406(provide 'process-tests) 425(provide 'process-tests)
407;; process-tests.el ends here. 426;; process-tests.el ends here.