aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorAndrea Corallo2021-01-02 10:11:15 +0100
committerAndrea Corallo2021-01-02 10:11:15 +0100
commit5db5064395c251a822e429e19ddecb74a974b6ef (patch)
tree2e04729a03d5fc68d0caef3a16e00349b6d413fc /test/src
parent9420ea6e0840bffcb140d3677dfdabb9251c1f63 (diff)
parent0f561ee55348ff451600cc6027db5940ee14606f (diff)
downloademacs-5db5064395c251a822e429e19ddecb74a974b6ef.tar.gz
emacs-5db5064395c251a822e429e19ddecb74a974b6ef.zip
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'test/src')
-rw-r--r--test/src/alloc-tests.el2
-rw-r--r--test/src/buffer-tests.el2
-rw-r--r--test/src/callint-tests.el2
-rw-r--r--test/src/callproc-tests.el2
-rw-r--r--test/src/casefiddle-tests.el2
-rw-r--r--test/src/charset-tests.el2
-rw-r--r--test/src/chartab-tests.el22
-rw-r--r--test/src/cmds-tests.el2
-rw-r--r--test/src/coding-tests.el2
-rw-r--r--test/src/data-tests.el2
-rw-r--r--test/src/decompress-tests.el2
-rw-r--r--test/src/editfns-tests.el2
-rw-r--r--test/src/emacs-module-resources/mod-test.c2
-rw-r--r--test/src/emacs-module-tests.el2
-rw-r--r--test/src/eval-tests.el2
-rw-r--r--test/src/fileio-tests.el2
-rw-r--r--test/src/floatfns-tests.el2
-rw-r--r--test/src/fns-tests.el2
-rw-r--r--test/src/font-tests.el2
-rw-r--r--test/src/indent-tests.el2
-rw-r--r--test/src/inotify-tests.el2
-rw-r--r--test/src/json-tests.el2
-rw-r--r--test/src/keyboard-tests.el2
-rw-r--r--test/src/keymap-tests.el2
-rw-r--r--test/src/lcms-tests.el2
-rw-r--r--test/src/lread-tests.el2
-rw-r--r--test/src/marker-tests.el2
-rw-r--r--test/src/minibuf-tests.el2
-rw-r--r--test/src/print-tests.el2
-rw-r--r--test/src/process-tests.el442
-rw-r--r--test/src/regex-emacs-tests.el2
-rw-r--r--test/src/syntax-tests.el2
-rw-r--r--test/src/textprop-tests.el2
-rw-r--r--test/src/thread-tests.el2
-rw-r--r--test/src/timefns-tests.el2
-rw-r--r--test/src/undo-tests.el2
-rw-r--r--test/src/xdisp-tests.el2
-rw-r--r--test/src/xfaces-tests.el2
-rw-r--r--test/src/xml-tests.el2
39 files changed, 472 insertions, 66 deletions
diff --git a/test/src/alloc-tests.el b/test/src/alloc-tests.el
index aa1ab1648f8..1324c2d3b4d 100644
--- a/test/src/alloc-tests.el
+++ b/test/src/alloc-tests.el
@@ -1,6 +1,6 @@
1;;; alloc-tests.el --- alloc tests -*- lexical-binding: t -*- 1;;; alloc-tests.el --- alloc tests -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2015-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
4 4
5;; Author: Daniel Colascione <dancol@dancol.org> 5;; Author: Daniel Colascione <dancol@dancol.org>
6;; Keywords: 6;; Keywords:
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index dd8927457ae..123f2e8eabb 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -1,6 +1,6 @@
1;;; buffer-tests.el --- tests for buffer.c functions -*- lexical-binding: t -*- 1;;; buffer-tests.el --- tests for buffer.c functions -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2015-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/callint-tests.el b/test/src/callint-tests.el
index 42dae424476..0df58877102 100644
--- a/test/src/callint-tests.el
+++ b/test/src/callint-tests.el
@@ -1,6 +1,6 @@
1;;; callint-tests.el --- unit tests for callint.c -*- lexical-binding: t; -*- 1;;; callint-tests.el --- unit tests for callint.c -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2018-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2018-2021 Free Software Foundation, Inc.
4 4
5;; Author: Philipp Stephani <phst@google.com> 5;; Author: Philipp Stephani <phst@google.com>
6 6
diff --git a/test/src/callproc-tests.el b/test/src/callproc-tests.el
index 1617d5e33d3..7262abbe0d0 100644
--- a/test/src/callproc-tests.el
+++ b/test/src/callproc-tests.el
@@ -1,6 +1,6 @@
1;;; callproc-tests.el --- callproc.c tests -*- lexical-binding: t -*- 1;;; callproc-tests.el --- callproc.c tests -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2016-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/casefiddle-tests.el b/test/src/casefiddle-tests.el
index 3eba4cfd78b..9fa54dcaf43 100644
--- a/test/src/casefiddle-tests.el
+++ b/test/src/casefiddle-tests.el
@@ -1,6 +1,6 @@
1;;; casefiddle-tests.el --- tests for casefiddle.c functions -*- lexical-binding: t -*- 1;;; casefiddle-tests.el --- tests for casefiddle.c functions -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2015-2016, 2018-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2015-2016, 2018-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/charset-tests.el b/test/src/charset-tests.el
index 86a0d6ffc1a..5c46627c163 100644
--- a/test/src/charset-tests.el
+++ b/test/src/charset-tests.el
@@ -1,6 +1,6 @@
1;;; charset-tests.el --- Tests for charset.c -*- lexical-binding: t -*- 1;;; charset-tests.el --- Tests for charset.c -*- lexical-binding: t -*-
2 2
3;; Copyright 2017-2020 Free Software Foundation, Inc. 3;; Copyright 2017-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/chartab-tests.el b/test/src/chartab-tests.el
index 4d52dc367c8..bf37fb51cf5 100644
--- a/test/src/chartab-tests.el
+++ b/test/src/chartab-tests.el
@@ -1,6 +1,6 @@
1;;; chartab-tests.el --- Tests for char-tab.c -*- lexical-binding: t -*- 1;;; chartab-tests.el --- Tests for char-tab.c -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2016-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
4 4
5;; Author: Eli Zaretskii <eliz@gnu.org> 5;; Author: Eli Zaretskii <eliz@gnu.org>
6 6
@@ -49,5 +49,25 @@
49 (#xe0e00 . #xe0ef6) 49 (#xe0e00 . #xe0ef6)
50 ))) 50 )))
51 51
52(ert-deftest chartab-test-char-table-p ()
53 (should (char-table-p (make-char-table 'foo)))
54 (should (not (char-table-p (make-hash-table)))))
55
56(ert-deftest chartab-test-char-table-subtype ()
57 (should (eq (char-table-subtype (make-char-table 'foo)) 'foo)))
58
59(ert-deftest chartab-test-char-table-parent ()
60 (should (eq (char-table-parent (make-char-table 'foo)) nil))
61 (let ((parent (make-char-table 'foo))
62 (child (make-char-table 'bar)))
63 (set-char-table-parent child parent)
64 (should (eq (char-table-parent child) parent))))
65
66(ert-deftest chartab-test-char-table-extra-slot ()
67 ;; Use any type with extra slots, e.g. 'case-table.
68 (let ((tbl (make-char-table 'case-table)))
69 (set-char-table-extra-slot tbl 1 'bar)
70 (should (eq (char-table-extra-slot tbl 1) 'bar))))
71
52(provide 'chartab-tests) 72(provide 'chartab-tests)
53;;; chartab-tests.el ends here 73;;; chartab-tests.el ends here
diff --git a/test/src/cmds-tests.el b/test/src/cmds-tests.el
index 302b00c6760..681bfb30164 100644
--- a/test/src/cmds-tests.el
+++ b/test/src/cmds-tests.el
@@ -1,6 +1,6 @@
1;;; cmds-tests.el --- Testing some Emacs commands -*- lexical-binding: t -*- 1;;; cmds-tests.el --- Testing some Emacs commands -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2013-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
4 4
5;; Author: Nicolas Richard <youngfrog@members.fsf.org> 5;; Author: Nicolas Richard <youngfrog@members.fsf.org>
6;; Keywords: 6;; Keywords:
diff --git a/test/src/coding-tests.el b/test/src/coding-tests.el
index 82883a045c8..0bdcff22ce5 100644
--- a/test/src/coding-tests.el
+++ b/test/src/coding-tests.el
@@ -1,6 +1,6 @@
1;;; coding-tests.el --- tests for text encoding and decoding -*- lexical-binding: t -*- 1;;; coding-tests.el --- tests for text encoding and decoding -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2013-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
4 4
5;; Author: Eli Zaretskii <eliz@gnu.org> 5;; Author: Eli Zaretskii <eliz@gnu.org>
6;; Author: Kenichi Handa <handa@gnu.org> 6;; Author: Kenichi Handa <handa@gnu.org>
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index c5fc3eaa11a..03d867f18a8 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -1,6 +1,6 @@
1;;; data-tests.el --- tests for src/data.c -*- lexical-binding:t -*- 1;;; data-tests.el --- tests for src/data.c -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 2013-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/decompress-tests.el b/test/src/decompress-tests.el
index 0a328396818..67a7fefb05e 100644
--- a/test/src/decompress-tests.el
+++ b/test/src/decompress-tests.el
@@ -1,6 +1,6 @@
1;;; decompress-tests.el --- Test suite for decompress. -*- lexical-binding: t -*- 1;;; decompress-tests.el --- Test suite for decompress. -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2013-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
4 4
5;; Author: Lars Ingebrigtsen <larsi@gnus.org> 5;; Author: Lars Ingebrigtsen <larsi@gnus.org>
6 6
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index de0aeabfe78..64f9137865b 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -1,6 +1,6 @@
1;;; editfns-tests.el -- tests for editfns.c -*- lexical-binding:t -*- 1;;; editfns-tests.el -- tests for editfns.c -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 2016-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/emacs-module-resources/mod-test.c b/test/src/emacs-module-resources/mod-test.c
index 30ad352cf8b..ad59cfc18cd 100644
--- a/test/src/emacs-module-resources/mod-test.c
+++ b/test/src/emacs-module-resources/mod-test.c
@@ -1,6 +1,6 @@
1/* Test GNU Emacs modules. 1/* Test GNU Emacs modules.
2 2
3Copyright 2015-2020 Free Software Foundation, Inc. 3Copyright 2015-2021 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
index bf26ffb935c..af5bc2a0baf 100644
--- a/test/src/emacs-module-tests.el
+++ b/test/src/emacs-module-tests.el
@@ -1,6 +1,6 @@
1;;; emacs-module-tests --- Test GNU Emacs modules. -*- lexical-binding: t; -*- 1;;; emacs-module-tests --- Test GNU Emacs modules. -*- lexical-binding: t; -*-
2 2
3;; Copyright 2015-2020 Free Software Foundation, Inc. 3;; Copyright 2015-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 297db81f5ab..b2b7dfefda5 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -1,6 +1,6 @@
1;;; eval-tests.el --- unit tests for src/eval.c -*- lexical-binding: t; -*- 1;;; eval-tests.el --- unit tests for src/eval.c -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2016-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
4 4
5;; Author: Philipp Stephani <phst@google.com> 5;; Author: Philipp Stephani <phst@google.com>
6 6
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el
index 8d46abf342a..7f193d4eeab 100644
--- a/test/src/fileio-tests.el
+++ b/test/src/fileio-tests.el
@@ -1,6 +1,6 @@
1;;; unit tests for src/fileio.c -*- lexical-binding: t; -*- 1;;; unit tests for src/fileio.c -*- lexical-binding: t; -*-
2 2
3;; Copyright 2017-2020 Free Software Foundation, Inc. 3;; Copyright 2017-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/floatfns-tests.el b/test/src/floatfns-tests.el
index 8c56674d4fd..4a3c03d833e 100644
--- a/test/src/floatfns-tests.el
+++ b/test/src/floatfns-tests.el
@@ -1,6 +1,6 @@
1;;; floatfns-tests.el --- tests for floating point operations -*- lexical-binding: t -*- 1;;; floatfns-tests.el --- tests for floating point operations -*- lexical-binding: t -*-
2 2
3;; Copyright 2017-2020 Free Software Foundation, Inc. 3;; Copyright 2017-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index e66dad44a1a..a9daf878b81 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -1,6 +1,6 @@
1;;; fns-tests.el --- tests for src/fns.c -*- lexical-binding:t -*- 1;;; fns-tests.el --- tests for src/fns.c -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 2014-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2014-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/font-tests.el b/test/src/font-tests.el
index cfc6f4c31b7..de153b8de9b 100644
--- a/test/src/font-tests.el
+++ b/test/src/font-tests.el
@@ -1,6 +1,6 @@
1;;; font-tests.el --- Test suite for font-related functions. -*- lexical-binding: t -*- 1;;; font-tests.el --- Test suite for font-related functions. -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2011-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2021 Free Software Foundation, Inc.
4 4
5;; Author: Chong Yidong <cyd@stupidchicken.com> 5;; Author: Chong Yidong <cyd@stupidchicken.com>
6;; Keywords: internal 6;; Keywords: internal
diff --git a/test/src/indent-tests.el b/test/src/indent-tests.el
index 7d1a6ce6dc3..10f1202949b 100644
--- a/test/src/indent-tests.el
+++ b/test/src/indent-tests.el
@@ -1,6 +1,6 @@
1;;; indent-tests.el --- tests for src/indent.c -*- lexical-binding:t -*- 1;;; indent-tests.el --- tests for src/indent.c -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 2020 Free Software Foundation, Inc. 3;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/inotify-tests.el b/test/src/inotify-tests.el
index d42fe1b0086..5572c7d7a0f 100644
--- a/test/src/inotify-tests.el
+++ b/test/src/inotify-tests.el
@@ -1,6 +1,6 @@
1;;; inotify-tests.el --- Test suite for inotify. -*- lexical-binding: t -*- 1;;; inotify-tests.el --- Test suite for inotify. -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2012-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2012-2021 Free Software Foundation, Inc.
4 4
5;; Author: Rüdiger Sonderfeld <ruediger@c-plusplus.de> 5;; Author: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
6;; Keywords: internal 6;; Keywords: internal
diff --git a/test/src/json-tests.el b/test/src/json-tests.el
index 028f92f29d3..4be11b8c81a 100644
--- a/test/src/json-tests.el
+++ b/test/src/json-tests.el
@@ -1,6 +1,6 @@
1;;; json-tests.el --- unit tests for json.c -*- lexical-binding: t; -*- 1;;; json-tests.el --- unit tests for json.c -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2017-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2017-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/keyboard-tests.el b/test/src/keyboard-tests.el
index 970a53555f9..607d2eafd45 100644
--- a/test/src/keyboard-tests.el
+++ b/test/src/keyboard-tests.el
@@ -1,6 +1,6 @@
1;;; keyboard-tests.el --- Tests for keyboard.c -*- lexical-binding: t -*- 1;;; keyboard-tests.el --- Tests for keyboard.c -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2017-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2017-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el
index f58dac87401..74fb3c892db 100644
--- a/test/src/keymap-tests.el
+++ b/test/src/keymap-tests.el
@@ -1,6 +1,6 @@
1;;; keymap-tests.el --- Test suite for src/keymap.c -*- lexical-binding: t -*- 1;;; keymap-tests.el --- Test suite for src/keymap.c -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2015-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
4 4
5;; Author: Juanma Barranquero <lekktu@gmail.com> 5;; Author: Juanma Barranquero <lekktu@gmail.com>
6;; Stefan Kangas <stefankangas@gmail.com> 6;; Stefan Kangas <stefankangas@gmail.com>
diff --git a/test/src/lcms-tests.el b/test/src/lcms-tests.el
index 4430d696807..40a48f1e9bb 100644
--- a/test/src/lcms-tests.el
+++ b/test/src/lcms-tests.el
@@ -1,6 +1,6 @@
1;;; lcms-tests.el --- tests for Little CMS interface -*- lexical-binding: t -*- 1;;; lcms-tests.el --- tests for Little CMS interface -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2017-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2017-2021 Free Software Foundation, Inc.
4 4
5;; Maintainer: emacs-devel@gnu.org 5;; Maintainer: emacs-devel@gnu.org
6 6
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el
index 825b74e6234..edf88214f97 100644
--- a/test/src/lread-tests.el
+++ b/test/src/lread-tests.el
@@ -1,6 +1,6 @@
1;;; lread-tests.el --- tests for lread.c -*- lexical-binding: t; -*- 1;;; lread-tests.el --- tests for lread.c -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2016-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
4 4
5;; Author: Philipp Stephani <phst@google.com> 5;; Author: Philipp Stephani <phst@google.com>
6 6
diff --git a/test/src/marker-tests.el b/test/src/marker-tests.el
index 37140f8a10b..234a0b35ea7 100644
--- a/test/src/marker-tests.el
+++ b/test/src/marker-tests.el
@@ -1,6 +1,6 @@
1;;; marker-tests.el --- tests for marker.c functions -*- lexical-binding: t -*- 1;;; marker-tests.el --- tests for marker.c functions -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2016-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/minibuf-tests.el b/test/src/minibuf-tests.el
index 13f5fac585b..b9cd255462d 100644
--- a/test/src/minibuf-tests.el
+++ b/test/src/minibuf-tests.el
@@ -1,6 +1,6 @@
1;;; minibuf-tests.el --- tests for minibuf.c functions -*- lexical-binding: t -*- 1;;; minibuf-tests.el --- tests for minibuf.c functions -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2016-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/print-tests.el b/test/src/print-tests.el
index 202555adb3b..0d2ea6e3834 100644
--- a/test/src/print-tests.el
+++ b/test/src/print-tests.el
@@ -1,6 +1,6 @@
1;;; print-tests.el --- tests for src/print.c -*- lexical-binding: t; -*- 1;;; print-tests.el --- tests for src/print.c -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2014-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2014-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index e15ad47f968..cddf955853e 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -1,6 +1,6 @@
1;;; process-tests.el --- Testing the process facilities -*- lexical-binding: t -*- 1;;; process-tests.el --- Testing the process facilities -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2013-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
@@ -23,8 +23,11 @@
23 23
24;;; Code: 24;;; Code:
25 25
26(require 'cl-lib)
26(require 'ert) 27(require 'ert)
27(require 'puny) 28(require 'puny)
29(require 'rx)
30(require 'subr-x)
28 31
29;; Timeout in seconds; the test fails if the timeout is reached. 32;; Timeout in seconds; the test fails if the timeout is reached.
30(defvar process-test-sentinel-wait-timeout 2.0) 33(defvar process-test-sentinel-wait-timeout 2.0)
@@ -47,13 +50,15 @@
47 50
48(ert-deftest process-test-sentinel-accept-process-output () 51(ert-deftest process-test-sentinel-accept-process-output ()
49 (skip-unless (executable-find "bash")) 52 (skip-unless (executable-find "bash"))
53 (with-timeout (60 (ert-fail "Test timed out"))
50 (should (process-test-sentinel-wait-function-working-p 54 (should (process-test-sentinel-wait-function-working-p
51 #'accept-process-output))) 55 #'accept-process-output))))
52 56
53(ert-deftest process-test-sentinel-sit-for () 57(ert-deftest process-test-sentinel-sit-for ()
54 (skip-unless (executable-find "bash")) 58 (skip-unless (executable-find "bash"))
59 (with-timeout (60 (ert-fail "Test timed out"))
55 (should 60 (should
56 (process-test-sentinel-wait-function-working-p (lambda () (sit-for 0.01 t))))) 61 (process-test-sentinel-wait-function-working-p (lambda () (sit-for 0.01 t))))))
57 62
58(when (eq system-type 'windows-nt) 63(when (eq system-type 'windows-nt)
59 (ert-deftest process-test-quoted-batfile () 64 (ert-deftest process-test-quoted-batfile ()
@@ -79,6 +84,7 @@
79 84
80(ert-deftest process-test-stderr-buffer () 85(ert-deftest process-test-stderr-buffer ()
81 (skip-unless (executable-find "bash")) 86 (skip-unless (executable-find "bash"))
87 (with-timeout (60 (ert-fail "Test timed out"))
82 (let* ((stdout-buffer (generate-new-buffer "*stdout*")) 88 (let* ((stdout-buffer (generate-new-buffer "*stdout*"))
83 (stderr-buffer (generate-new-buffer "*stderr*")) 89 (stderr-buffer (generate-new-buffer "*stderr*"))
84 (proc (make-process :name "test" 90 (proc (make-process :name "test"
@@ -103,10 +109,11 @@
103 (looking-at "hello stdout!"))) 109 (looking-at "hello stdout!")))
104 (should (with-current-buffer stderr-buffer 110 (should (with-current-buffer stderr-buffer
105 (goto-char (point-min)) 111 (goto-char (point-min))
106 (looking-at "hello stderr!"))))) 112 (looking-at "hello stderr!"))))))
107 113
108(ert-deftest process-test-stderr-filter () 114(ert-deftest process-test-stderr-filter ()
109 (skip-unless (executable-find "bash")) 115 (skip-unless (executable-find "bash"))
116 (with-timeout (60 (ert-fail "Test timed out"))
110 (let* ((sentinel-called nil) 117 (let* ((sentinel-called nil)
111 (stderr-sentinel-called nil) 118 (stderr-sentinel-called nil)
112 (stdout-output nil) 119 (stdout-output nil)
@@ -145,10 +152,11 @@
145 (should (equal 1 (with-current-buffer stderr-buffer 152 (should (equal 1 (with-current-buffer stderr-buffer
146 (point-max)))) 153 (point-max))))
147 (should (equal "hello stderr!\n" 154 (should (equal "hello stderr!\n"
148 (mapconcat #'identity (nreverse stderr-output) ""))))) 155 (mapconcat #'identity (nreverse stderr-output) ""))))))
149 156
150(ert-deftest set-process-filter-t () 157(ert-deftest set-process-filter-t ()
151 "Test setting process filter to t and back." ;; Bug#36591 158 "Test setting process filter to t and back." ;; Bug#36591
159 (with-timeout (60 (ert-fail "Test timed out"))
152 (with-temp-buffer 160 (with-temp-buffer
153 (let* ((print-level nil) 161 (let* ((print-level nil)
154 (print-length nil) 162 (print-length nil)
@@ -180,11 +188,12 @@
180 (line-beginning-position) (point-max)) 188 (line-beginning-position) (point-max))
181 "2> ")) 189 "2> "))
182 (accept-process-output proc)) ; Read "Two". 190 (accept-process-output proc)) ; Read "Two".
183 (should (equal (buffer-string) "0> one\n1> two\n2> "))))) 191 (should (equal (buffer-string) "0> one\n1> two\n2> "))))))
184 192
185(ert-deftest start-process-should-not-modify-arguments () 193(ert-deftest start-process-should-not-modify-arguments ()
186 "`start-process' must not modify its arguments in-place." 194 "`start-process' must not modify its arguments in-place."
187 ;; See bug#21831. 195 ;; See bug#21831.
196 (with-timeout (60 (ert-fail "Test timed out"))
188 (let* ((path (pcase system-type 197 (let* ((path (pcase system-type
189 ((or 'windows-nt 'ms-dos) 198 ((or 'windows-nt 'ms-dos)
190 ;; Make sure the file name uses forward slashes. 199 ;; Make sure the file name uses forward slashes.
@@ -198,11 +207,12 @@
198 (should (process-live-p (condition-case nil 207 (should (process-live-p (condition-case nil
199 (start-process "" nil path) 208 (start-process "" nil path)
200 (error nil)))) 209 (error nil))))
201 (should (equal path samepath)))) 210 (should (equal path samepath)))))
202 211
203(ert-deftest make-process/noquery-stderr () 212(ert-deftest make-process/noquery-stderr ()
204 "Checks that Bug#30031 is fixed." 213 "Checks that Bug#30031 is fixed."
205 (skip-unless (executable-find "sleep")) 214 (skip-unless (executable-find "sleep"))
215 (with-timeout (60 (ert-fail "Test timed out"))
206 (with-temp-buffer 216 (with-temp-buffer
207 (let* ((previous-processes (process-list)) 217 (let* ((previous-processes (process-list))
208 (process (make-process :name "sleep" 218 (process (make-process :name "sleep"
@@ -217,7 +227,7 @@
217 (should new-processes) 227 (should new-processes)
218 (dolist (process new-processes) 228 (dolist (process new-processes)
219 (should-not (process-query-on-exit-flag process)))) 229 (should-not (process-query-on-exit-flag process))))
220 (kill-process process))))) 230 (kill-process process))))))
221 231
222;; Return t if OUTPUT could have been generated by merging the INPUTS somehow. 232;; Return t if OUTPUT could have been generated by merging the INPUTS somehow.
223(defun process-tests--mixable (output &rest inputs) 233(defun process-tests--mixable (output &rest inputs)
@@ -233,6 +243,7 @@
233(ert-deftest make-process/mix-stderr () 243(ert-deftest make-process/mix-stderr ()
234 "Check that `make-process' mixes the output streams if STDERR is nil." 244 "Check that `make-process' mixes the output streams if STDERR is nil."
235 (skip-unless (executable-find "bash")) 245 (skip-unless (executable-find "bash"))
246 (with-timeout (60 (ert-fail "Test timed out"))
236 ;; Frequent random (?) failures on hydra.nixos.org, with no process output. 247 ;; Frequent random (?) failures on hydra.nixos.org, with no process output.
237 ;; Maybe this test should be tagged unstable? See bug#31214. 248 ;; Maybe this test should be tagged unstable? See bug#31214.
238 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 249 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
@@ -251,11 +262,12 @@
251 (should (eq (process-exit-status process) 0)) 262 (should (eq (process-exit-status process) 0))
252 (should (process-tests--mixable (string-to-list (buffer-string)) 263 (should (process-tests--mixable (string-to-list (buffer-string))
253 (string-to-list "stdout\n") 264 (string-to-list "stdout\n")
254 (string-to-list "stderr\n")))))) 265 (string-to-list "stderr\n")))))))
255 266
256(ert-deftest make-process-w32-debug-spawn-error () 267(ert-deftest make-process-w32-debug-spawn-error ()
257 "Check that debugger runs on `make-process' failure (Bug#33016)." 268 "Check that debugger runs on `make-process' failure (Bug#33016)."
258 (skip-unless (eq system-type 'windows-nt)) 269 (skip-unless (eq system-type 'windows-nt))
270 (with-timeout (60 (ert-fail "Test timed out"))
259 (let* ((debug-on-error t) 271 (let* ((debug-on-error t)
260 (have-called-debugger nil) 272 (have-called-debugger nil)
261 (debugger (lambda (&rest _) 273 (debugger (lambda (&rest _)
@@ -271,11 +283,12 @@
271 ;; code. 283 ;; code.
272 (make-process :name "test" :command '("c:/No-Such-Command")) 284 (make-process :name "test" :command '("c:/No-Such-Command"))
273 (error :got-error)))) 285 (error :got-error))))
274 (should have-called-debugger))) 286 (should have-called-debugger))))
275 287
276(ert-deftest make-process/file-handler/found () 288(ert-deftest make-process/file-handler/found ()
277 "Check that the ‘:file-handler’ argument of ‘make-process’ 289 "Check that the `:file-handler’ argument of `make-process’
278works as expected if a file name handler is found." 290works as expected if a file name handler is found."
291 (with-timeout (60 (ert-fail "Test timed out"))
279 (let ((file-handler-calls 0)) 292 (let ((file-handler-calls 0))
280 (cl-flet ((file-handler 293 (cl-flet ((file-handler
281 (&rest args) 294 (&rest args)
@@ -292,27 +305,29 @@ works as expected if a file name handler is found."
292 :command '("/some/binary") 305 :command '("/some/binary")
293 :file-handler t) 306 :file-handler t)
294 'fake-process)) 307 'fake-process))
295 (should (= file-handler-calls 1)))))) 308 (should (= file-handler-calls 1)))))))
296 309
297(ert-deftest make-process/file-handler/not-found () 310(ert-deftest make-process/file-handler/not-found ()
298 "Check that the ‘:file-handler’ argument of ‘make-process’ 311 "Check that the `:file-handler’ argument of `make-process’
299works as expected if no file name handler is found." 312works as expected if no file name handler is found."
313 (with-timeout (60 (ert-fail "Test timed out"))
300 (let ((file-name-handler-alist ()) 314 (let ((file-name-handler-alist ())
301 (default-directory invocation-directory) 315 (default-directory invocation-directory)
302 (program (expand-file-name invocation-name invocation-directory))) 316 (program (expand-file-name invocation-name invocation-directory)))
303 (should (processp (make-process :name "name" 317 (should (processp (make-process :name "name"
304 :command (list program "--version") 318 :command (list program "--version")
305 :file-handler t))))) 319 :file-handler t))))))
306 320
307(ert-deftest make-process/file-handler/disable () 321(ert-deftest make-process/file-handler/disable ()
308 "Check ‘make-process’ works as expected if it shouldn’t use the 322 "Check `make-process’ works as expected if it shouldn’t use the
309file name handler." 323file name handler."
324 (with-timeout (60 (ert-fail "Test timed out"))
310 (let ((file-name-handler-alist (list (cons (rx bos "test-handler:") 325 (let ((file-name-handler-alist (list (cons (rx bos "test-handler:")
311 #'process-tests--file-handler))) 326 #'process-tests--file-handler)))
312 (default-directory "test-handler:/dir/") 327 (default-directory "test-handler:/dir/")
313 (program (expand-file-name invocation-name invocation-directory))) 328 (program (expand-file-name invocation-name invocation-directory)))
314 (should (processp (make-process :name "name" 329 (should (processp (make-process :name "name"
315 :command (list program "--version")))))) 330 :command (list program "--version")))))))
316 331
317(defun process-tests--file-handler (operation &rest _args) 332(defun process-tests--file-handler (operation &rest _args)
318 (cl-ecase operation 333 (cl-ecase operation
@@ -325,48 +340,419 @@ file name handler."
325(ert-deftest make-process/stop () 340(ert-deftest make-process/stop ()
326 "Check that `make-process' doesn't accept a `:stop' key. 341 "Check that `make-process' doesn't accept a `:stop' key.
327See Bug#30460." 342See Bug#30460."
343 (with-timeout (60 (ert-fail "Test timed out"))
328 (should-error 344 (should-error
329 (make-process :name "test" 345 (make-process :name "test"
330 :command (list (expand-file-name invocation-name 346 :command (list (expand-file-name invocation-name
331 invocation-directory)) 347 invocation-directory))
332 :stop t))) 348 :stop t))))
333 349
334;; All the following tests require working DNS, which appears not to 350;; 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. 351;; be the case for hydra.nixos.org, so disable them there for now.
336 352
337(ert-deftest lookup-family-specification () 353(ert-deftest lookup-family-specification ()
338 "network-lookup-address-info should only accept valid family symbols." 354 "`network-lookup-address-info' should only accept valid family symbols."
339 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 355 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
356 (with-timeout (60 (ert-fail "Test timed out"))
340 (should-error (network-lookup-address-info "google.com" 'both)) 357 (should-error (network-lookup-address-info "google.com" 'both))
341 (should (network-lookup-address-info "google.com" 'ipv4)) 358 (should (network-lookup-address-info "google.com" 'ipv4))
342 (when (featurep 'make-network-process '(:family ipv6)) 359 (when (featurep 'make-network-process '(:family ipv6))
343 (should (network-lookup-address-info "google.com" 'ipv6)))) 360 (should (network-lookup-address-info "google.com" 'ipv6)))))
344 361
345(ert-deftest lookup-unicode-domains () 362(ert-deftest lookup-unicode-domains ()
346 "Unicode domains should fail" 363 "Unicode domains should fail."
347 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 364 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
365 (with-timeout (60 (ert-fail "Test timed out"))
348 (should-error (network-lookup-address-info "faß.de")) 366 (should-error (network-lookup-address-info "faß.de"))
349 (should (network-lookup-address-info (puny-encode-domain "faß.de")))) 367 (should (network-lookup-address-info (puny-encode-domain "faß.de")))))
350 368
351(ert-deftest unibyte-domain-name () 369(ert-deftest unibyte-domain-name ()
352 "Unibyte domain names should work" 370 "Unibyte domain names should work."
353 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 371 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
354 (should (network-lookup-address-info (string-to-unibyte "google.com")))) 372 (with-timeout (60 (ert-fail "Test timed out"))
373 (should (network-lookup-address-info (string-to-unibyte "google.com")))))
355 374
356(ert-deftest lookup-google () 375(ert-deftest lookup-google ()
357 "Check that we can look up google IP addresses" 376 "Check that we can look up google IP addresses."
358 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 377 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
378 (with-timeout (60 (ert-fail "Test timed out"))
359 (let ((addresses-both (network-lookup-address-info "google.com")) 379 (let ((addresses-both (network-lookup-address-info "google.com"))
360 (addresses-v4 (network-lookup-address-info "google.com" 'ipv4))) 380 (addresses-v4 (network-lookup-address-info "google.com" 'ipv4)))
361 (should addresses-both) 381 (should addresses-both)
362 (should addresses-v4)) 382 (should addresses-v4))
363 (when (featurep 'make-network-process '(:family ipv6)) 383 (when (featurep 'make-network-process '(:family ipv6))
364 (should (network-lookup-address-info "google.com" 'ipv6)))) 384 (should (network-lookup-address-info "google.com" 'ipv6)))))
365 385
366(ert-deftest non-existent-lookup-failure () 386(ert-deftest non-existent-lookup-failure ()
387 "Check that looking up non-existent domain returns nil."
367 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 388 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
368 "Check that looking up non-existent domain returns nil" 389 (with-timeout (60 (ert-fail "Test timed out"))
369 (should (eq nil (network-lookup-address-info "emacs.invalid")))) 390 (should (eq nil (network-lookup-address-info "emacs.invalid")))))
391
392(defmacro process-tests--ignore-EMFILE (&rest body)
393 "Evaluate BODY, ignoring EMFILE errors."
394 (declare (indent 0) (debug t))
395 (let ((err (make-symbol "err"))
396 (message (make-symbol "message")))
397 `(let ((,message (process-tests--EMFILE-message)))
398 (condition-case ,err
399 ,(macroexp-progn body)
400 (file-error
401 ;; If we couldn't determine the EMFILE message, just ignore
402 ;; all `file-error' signals.
403 (and ,message
404 (not (string-equal (caddr ,err) ,message))
405 (signal (car ,err) (cdr ,err))))))))
406
407(defmacro process-tests--with-buffers (var &rest body)
408 "Bind VAR to nil and evaluate BODY.
409Afterwards, kill all buffers in the list VAR. BODY should add
410some buffer objects to VAR."
411 (declare (indent 1) (debug (symbolp body)))
412 (cl-check-type var symbol)
413 `(let ((,var nil))
414 (unwind-protect
415 ,(macroexp-progn body)
416 (mapc #'kill-buffer ,var))))
417
418(defmacro process-tests--with-processes (var &rest body)
419 "Bind VAR to nil and evaluate BODY.
420Afterwards, delete all processes in the list VAR. BODY should
421add some process objects to VAR."
422 (declare (indent 1) (debug (symbolp body)))
423 (cl-check-type var symbol)
424 `(let ((,var nil))
425 (unwind-protect
426 ,(macroexp-progn body)
427 (mapc #'delete-process ,var))))
428
429(defmacro process-tests--with-raised-rlimit (&rest body)
430 "Evaluate BODY using a higher limit for the number of open files.
431Attempt to set the resource limit for the number of open files
432temporarily to the highest possible value."
433 (declare (indent 0) (debug t))
434 (let ((prlimit (make-symbol "prlimit"))
435 (soft (make-symbol "soft"))
436 (hard (make-symbol "hard"))
437 (pid-arg (make-symbol "pid-arg")))
438 `(let ((,prlimit (executable-find "prlimit"))
439 (,pid-arg (format "--pid=%d" (emacs-pid)))
440 (,soft nil) (,hard nil))
441 (cl-flet ((set-limit
442 (value)
443 (cl-check-type value natnum)
444 (when ,prlimit
445 (call-process ,prlimit nil nil nil
446 ,pid-arg
447 (format "--nofile=%d:" value)))))
448 (when ,prlimit
449 (with-temp-buffer
450 (when (eql (call-process ,prlimit nil t nil
451 ,pid-arg "--nofile"
452 "--raw" "--noheadings"
453 "--output=SOFT,HARD")
454 0)
455 (goto-char (point-min))
456 (when (looking-at (rx (group (+ digit)) (+ blank)
457 (group (+ digit)) ?\n))
458 (setq ,soft (string-to-number
459 (match-string-no-properties 1))
460 ,hard (string-to-number
461 (match-string-no-properties 2))))))
462 (and ,soft ,hard (< ,soft ,hard)
463 (set-limit ,hard)))
464 (unwind-protect
465 ,(macroexp-progn body)
466 (when ,soft (set-limit ,soft)))))))
467
468(defmacro process-tests--fd-setsize-test (&rest body)
469 "Run BODY as a test for FD_SETSIZE overflow.
470Try to generate pipe processes until we are close to the
471FD_SETSIZE limit. Within BODY, only a small number of file
472descriptors should still be available. Furthermore, raise the
473maximum number of open files in the Emacs process above
474FD_SETSIZE."
475 (declare (indent 0) (debug t))
476 (let ((process (make-symbol "process"))
477 (processes (make-symbol "processes"))
478 (buffer (make-symbol "buffer"))
479 (buffers (make-symbol "buffers"))
480 ;; FD_SETSIZE is typically 1024 on Unix-like systems. On
481 ;; MS-Windows we artificially limit FD_SETSIZE to 64, see the
482 ;; commentary in w32proc.c.
483 (fd-setsize (if (eq system-type 'windows-nt) 64 1024)))
484 `(process-tests--with-raised-rlimit
485 (process-tests--with-buffers ,buffers
486 (process-tests--with-processes ,processes
487 ;; First, allocate enough pipes to definitely exceed the
488 ;; FD_SETSIZE limit.
489 (cl-loop for i from 1 to ,(1+ fd-setsize)
490 for ,buffer = (generate-new-buffer
491 (format " *pipe %d*" i))
492 do (push ,buffer ,buffers)
493 for ,process = (process-tests--ignore-EMFILE
494 (make-pipe-process
495 :name (format "pipe %d" i)
496 ;; Prevent delete-process from
497 ;; trying to read from pipe
498 ;; processes that didn't exit
499 ;; yet, because no one is
500 ;; writing to those pipes, and
501 ;; the read will stall.
502 :stop (eq system-type 'windows-nt)
503 :buffer ,buffer
504 :coding 'no-conversion
505 :noquery t))
506 while ,process
507 do (push ,process ,processes))
508 (unless (cddr ,processes)
509 (ert-fail "Couldn't allocate enough pipes"))
510 ;; Delete two pipes to test more edge cases.
511 (delete-process (pop ,processes))
512 (delete-process (pop ,processes))
513 ,@body)))))
514
515(defmacro process-tests--with-temp-file (var &rest body)
516 "Bind VAR to the name of a new regular file and evaluate BODY.
517Afterwards, delete the file."
518 (declare (indent 1) (debug (symbolp body)))
519 (cl-check-type var symbol)
520 (let ((file (make-symbol "file")))
521 `(let ((,file (make-temp-file "emacs-test-")))
522 (unwind-protect
523 (let ((,var ,file))
524 ,@body)
525 (delete-file ,file)))))
526
527(defmacro process-tests--with-temp-directory (var &rest body)
528 "Bind VAR to the name of a new directory and evaluate BODY.
529Afterwards, delete the directory."
530 (declare (indent 1) (debug (symbolp body)))
531 (cl-check-type var symbol)
532 (let ((dir (make-symbol "dir")))
533 `(let ((,dir (make-temp-file "emacs-test-" :dir)))
534 (unwind-protect
535 (let ((,var ,dir))
536 ,@body)
537 (delete-directory ,dir :recursive)))))
538
539;; Tests for FD_SETSIZE overflow (Bug#24325). The following tests
540;; generate lots of process objects of the various kinds. Running the
541;; tests with assertions enabled should not result in any crashes due
542;; to file descriptor set overflow. These tests first generate lots
543;; of unused pipe processes to fill up the file descriptor space.
544;; Then, they create a few instances of the process type under test.
545
546(ert-deftest process-tests/fd-setsize-no-crash/make-process ()
547 "Check that Emacs doesn't crash when trying to use more than
548FD_SETSIZE file descriptors (Bug#24325)."
549 (with-timeout (60 (ert-fail "Test timed out"))
550 (let ((sleep (executable-find "sleep")))
551 (skip-unless sleep)
552 (dolist (conn-type '(pipe pty))
553 (ert-info ((format "Connection type `%s'" conn-type))
554 (process-tests--fd-setsize-test
555 (process-tests--with-processes processes
556 ;; Start processes until we exhaust the file descriptor
557 ;; set size. We assume that each process requires at
558 ;; least one file descriptor.
559 (dotimes (i 10)
560 (let ((process
561 ;; Failure to allocate more file descriptors
562 ;; should signal `file-error', but not crash.
563 ;; Since we don't know the exact limit, we
564 ;; ignore `file-error'.
565 (process-tests--ignore-EMFILE
566 (make-process :name (format "test %d" i)
567 :command (list sleep "5")
568 :connection-type conn-type
569 :coding 'no-conversion
570 :noquery t))))
571 (when process (push process processes))))
572 ;; We should have managed to start at least one process.
573 (should processes)
574 (dolist (process processes)
575 (while (accept-process-output process))
576 (should (eq (process-status process) 'exit))
577 ;; If there's an error between fork and exec, Emacs
578 ;; will use exit statuses between 125 and 127, see
579 ;; process.h. This can happen if the child process
580 ;; tries to set up terminal device but fails due to
581 ;; file number limits. We don't treat this as an
582 ;; error.
583 (should (memql (process-exit-status process)
584 '(0 125 126 127)))))))))))
585
586(ert-deftest process-tests/fd-setsize-no-crash/make-pipe-process ()
587 "Check that Emacs doesn't crash when trying to use more than
588FD_SETSIZE file descriptors (Bug#24325)."
589 (with-timeout (60 (ert-fail "Test timed out"))
590 (process-tests--fd-setsize-test
591 (process-tests--with-buffers buffers
592 (process-tests--with-processes processes
593 ;; Start processes until we exhaust the file descriptor set
594 ;; size. We assume that each process requires at least one
595 ;; file descriptor.
596 (dotimes (i 10)
597 (let ((buffer (generate-new-buffer (format " *%d*" i))))
598 (push buffer buffers)
599 (let ((process
600 ;; Failure to allocate more file descriptors
601 ;; should signal `file-error', but not crash.
602 ;; Since we don't know the exact limit, we ignore
603 ;; `file-error'.
604 (process-tests--ignore-EMFILE
605 (make-pipe-process :name (format "test %d" i)
606 :buffer buffer
607 :coding 'no-conversion
608 :noquery t))))
609 (when process (push process processes)))))
610 ;; We should have managed to start at least one process.
611 (should processes))))))
612
613(ert-deftest process-tests/fd-setsize-no-crash/make-network-process ()
614 "Check that Emacs doesn't crash when trying to use more than
615FD_SETSIZE file descriptors (Bug#24325)."
616 (skip-unless (featurep 'make-network-process '(:server t)))
617 (skip-unless (featurep 'make-network-process '(:family local)))
618 (with-timeout (60 (ert-fail "Test timed out"))
619 (process-tests--with-temp-directory directory
620 (process-tests--with-processes processes
621 (let* ((num-clients 10)
622 (socket-name (expand-file-name "socket" directory))
623 ;; Run a UNIX server to connect to.
624 (server (make-network-process :name "server"
625 :server num-clients
626 :buffer nil
627 :service socket-name
628 :family 'local
629 :coding 'no-conversion
630 :noquery t)))
631 (push server processes)
632 (process-tests--fd-setsize-test
633 ;; Start processes until we exhaust the file descriptor
634 ;; set size. We assume that each process requires at
635 ;; least one file descriptor.
636 (dotimes (i num-clients)
637 (let ((client
638 ;; Failure to allocate more file descriptors
639 ;; should signal `file-error', but not crash.
640 ;; Since we don't know the exact limit, we ignore
641 ;; `file-error'.
642 (process-tests--ignore-EMFILE
643 (make-network-process
644 :name (format "client %d" i)
645 :service socket-name
646 :family 'local
647 :coding 'no-conversion
648 :noquery t))))
649 (when client (push client processes))))
650 ;; We should have managed to start at least one process.
651 (should processes)))))))
652
653(ert-deftest process-tests/fd-setsize-no-crash/make-serial-process ()
654 "Check that Emacs doesn't crash when trying to use more than
655FD_SETSIZE file descriptors (Bug#24325)."
656 (with-timeout (60 (ert-fail "Test timed out"))
657 (skip-unless (file-executable-p shell-file-name))
658 (skip-unless (executable-find "tty"))
659 (skip-unless (executable-find "sleep"))
660 ;; `process-tests--new-pty' probably only works with GNU Bash.
661 (skip-unless (string-equal
662 (file-name-nondirectory shell-file-name) "bash"))
663 (process-tests--with-processes processes
664 ;; In order to use `make-serial-process', we need to create some
665 ;; pseudoterminals. The easiest way to do that is to start a
666 ;; normal process using the `pty' connection type. We need to
667 ;; ensure that the terminal stays around while we connect to it.
668 ;; Create the host processes before the dummy pipes so we have a
669 ;; high chance of succeeding here.
670 (let ((tty-names ()))
671 (dotimes (_ 10)
672 (cl-destructuring-bind
673 (host tty-name) (process-tests--new-pty)
674 (should (processp host))
675 (push host processes)
676 (should tty-name)
677 (should (file-exists-p tty-name))
678 (push tty-name tty-names)))
679 (process-tests--fd-setsize-test
680 (process-tests--with-processes processes
681 (process-tests--with-buffers buffers
682 (dolist (tty-name tty-names)
683 (let ((buffer (generate-new-buffer
684 (format " *%s*" tty-name))))
685 (push buffer buffers)
686 ;; Failure to allocate more file descriptors should
687 ;; signal `file-error', but not crash. Since we
688 ;; don't know the exact limit, we ignore
689 ;; `file-error'.
690 (let ((process (process-tests--ignore-EMFILE
691 (make-serial-process
692 :name (format "test %s" tty-name)
693 :port tty-name
694 :speed 9600
695 :buffer buffer
696 :coding 'no-conversion
697 :noquery t))))
698 (when process (push process processes))))))
699 ;; We should have managed to start at least one process.
700 (should processes)))))))
701
702(defvar process-tests--EMFILE-message :unknown
703 "Cached result of the function `process-tests--EMFILE-message'.")
704
705(defun process-tests--EMFILE-message ()
706 "Return the error message for the EMFILE POSIX error.
707Return nil if that can't be determined."
708 (when (eq process-tests--EMFILE-message :unknown)
709 (setq process-tests--EMFILE-message
710 (with-temp-buffer
711 (when (eql (ignore-error 'file-error
712 (call-process "errno" nil t nil "EMFILE"))
713 0)
714 (goto-char (point-min))
715 (when (looking-at (rx "EMFILE" (+ blank) (+ digit)
716 (+ blank) (group (+ nonl))))
717 (match-string-no-properties 1))))))
718 process-tests--EMFILE-message)
719
720(defun process-tests--new-pty ()
721 "Allocate a new pseudoterminal.
722Return a list (PROCESS TTY-NAME)."
723 ;; The command below will typically only work with GNU Bash.
724 (should (string-equal (file-name-nondirectory shell-file-name)
725 "bash"))
726 (process-tests--with-temp-file temp-file
727 (should-not (file-remote-p temp-file))
728 (let* ((command (list shell-file-name shell-command-switch
729 (format "tty > %s && sleep 60"
730 (shell-quote-argument
731 (file-name-unquote temp-file)))))
732 (process (make-process :name "tty host"
733 :command command
734 :buffer nil
735 :coding 'utf-8-unix
736 :connection-type 'pty
737 :noquery t))
738 (tty-name nil)
739 (coding-system-for-read 'utf-8-unix)
740 (coding-system-for-write 'utf-8-unix))
741 ;; Wait until TTY name has arrived.
742 (with-timeout (2 (message "Timed out waiting for TTY name"))
743 (while (and (process-live-p process) (not tty-name))
744 (sleep-for 0.1)
745 (when-let ((attributes (file-attributes temp-file)))
746 (when (cl-plusp (file-attribute-size attributes))
747 (with-temp-buffer
748 (insert-file-contents temp-file)
749 (goto-char (point-max))
750 ;; `tty' has printed a trailing newline.
751 (skip-chars-backward "\n")
752 (unless (bobp)
753 (setq tty-name (buffer-substring-no-properties
754 (point-min) (point)))))))))
755 (list process tty-name))))
370 756
371(provide 'process-tests) 757(provide 'process-tests)
372;; process-tests.el ends here. 758;;; process-tests.el ends here
diff --git a/test/src/regex-emacs-tests.el b/test/src/regex-emacs-tests.el
index 34d4067db47..0607eacf397 100644
--- a/test/src/regex-emacs-tests.el
+++ b/test/src/regex-emacs-tests.el
@@ -1,6 +1,6 @@
1;;; regex-emacs-tests.el --- tests for regex-emacs.c -*- lexical-binding: t -*- 1;;; regex-emacs-tests.el --- tests for regex-emacs.c -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2015-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/syntax-tests.el b/test/src/syntax-tests.el
index edee01ec585..479b818935f 100644
--- a/test/src/syntax-tests.el
+++ b/test/src/syntax-tests.el
@@ -1,6 +1,6 @@
1;;; syntax-tests.el --- tests for syntax.c functions -*- lexical-binding: t -*- 1;;; syntax-tests.el --- tests for syntax.c functions -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2017-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2017-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/textprop-tests.el b/test/src/textprop-tests.el
index 365d2c7a7b7..b083588e645 100644
--- a/test/src/textprop-tests.el
+++ b/test/src/textprop-tests.el
@@ -1,6 +1,6 @@
1;;; textprop-tests.el --- Test suite for text properties. -*- lexical-binding: t -*- 1;;; textprop-tests.el --- Test suite for text properties. -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2015-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
4 4
5;; Author: Wolfgang Jenkner <wjenkner@inode.at> 5;; Author: Wolfgang Jenkner <wjenkner@inode.at>
6;; Keywords: internal 6;; Keywords: internal
diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el
index df34a2b66eb..f14d2426ef0 100644
--- a/test/src/thread-tests.el
+++ b/test/src/thread-tests.el
@@ -1,6 +1,6 @@
1;;; threads.el --- tests for threads. -*- lexical-binding: t -*- 1;;; threads.el --- tests for threads. -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2012-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2012-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el
index b35a5287946..e55bd1eb4ee 100644
--- a/test/src/timefns-tests.el
+++ b/test/src/timefns-tests.el
@@ -1,6 +1,6 @@
1;;; timefns-tests.el -- tests for timefns.c -*- lexical-binding: t -*- 1;;; timefns-tests.el -- tests for timefns.c -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2016-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/undo-tests.el b/test/src/undo-tests.el
index 182e2df93bc..055bf102dfc 100644
--- a/test/src/undo-tests.el
+++ b/test/src/undo-tests.el
@@ -1,6 +1,6 @@
1;;; undo-tests.el --- Tests of primitive-undo -*- lexical-binding: t -*- 1;;; undo-tests.el --- Tests of primitive-undo -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2012-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2012-2021 Free Software Foundation, Inc.
4 4
5;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com> 5;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com>
6 6
diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el
index a7e05a57de9..d13ce77a997 100644
--- a/test/src/xdisp-tests.el
+++ b/test/src/xdisp-tests.el
@@ -1,6 +1,6 @@
1;;; xdisp-tests.el --- tests for xdisp.c functions -*- lexical-binding: t -*- 1;;; xdisp-tests.el --- tests for xdisp.c functions -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2020 Free Software Foundation, Inc. 3;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/xfaces-tests.el b/test/src/xfaces-tests.el
index bde3a354229..0a7ef55b2b6 100644
--- a/test/src/xfaces-tests.el
+++ b/test/src/xfaces-tests.el
@@ -1,6 +1,6 @@
1;;; xfaces-tests.el --- tests for xfaces.c -*- lexical-binding: t -*- 1;;; xfaces-tests.el --- tests for xfaces.c -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2020 Free Software Foundation, Inc. 3;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/src/xml-tests.el b/test/src/xml-tests.el
index 800f400b3ca..632cf965fa2 100644
--- a/test/src/xml-tests.el
+++ b/test/src/xml-tests.el
@@ -1,6 +1,6 @@
1;;; xml-tests.el --- Test suite for libxml parsing. -*- lexical-binding: t -*- 1;;; xml-tests.el --- Test suite for libxml parsing. -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2014-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2014-2021 Free Software Foundation, Inc.
4 4
5;; Author: Ulf Jasper <ulf.jasper@web.de> 5;; Author: Ulf Jasper <ulf.jasper@web.de>
6;; Keywords: internal 6;; Keywords: internal