diff options
| author | Andrea Corallo | 2021-04-19 18:46:50 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2021-04-19 18:46:50 +0200 |
| commit | b5c76530fab4b99e76249bfb9a105b30bef4ce67 (patch) | |
| tree | 319d7a65b6f818cebed9833534a423fbcb79a9b5 /test/src | |
| parent | e54066f3d459f67a1ee4e44552bf0356d010e03f (diff) | |
| parent | 0a4dc70830f5e8286b47120cabc750cca07a75c1 (diff) | |
| download | emacs-b5c76530fab4b99e76249bfb9a105b30bef4ce67.tar.gz emacs-b5c76530fab4b99e76249bfb9a105b30bef4ce67.zip | |
Merge remote-tracking branch 'savannah/master' into native-comp
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/character-tests.el | 45 | ||||
| -rw-r--r-- | test/src/editfns-tests.el | 2 | ||||
| -rw-r--r-- | test/src/emacs-module-tests.el | 2 | ||||
| -rw-r--r-- | test/src/emacs-tests.el | 60 | ||||
| -rw-r--r-- | test/src/fileio-tests.el | 2 | ||||
| -rw-r--r-- | test/src/thread-tests.el | 2 | ||||
| -rw-r--r-- | test/src/timefns-tests.el | 2 |
7 files changed, 102 insertions, 13 deletions
diff --git a/test/src/character-tests.el b/test/src/character-tests.el new file mode 100644 index 00000000000..f630b32a5ee --- /dev/null +++ b/test/src/character-tests.el | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | ;;; character-tests.el --- tests for character.c -*- lexical-binding:t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2021 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | |||
| 24 | (ert-deftest character-test-string-width () | ||
| 25 | "Test `string-width' with and without compositions." | ||
| 26 | (should (= (string-width "1234") 4)) | ||
| 27 | (should (= (string-width "12\t34") (+ 4 tab-width))) | ||
| 28 | (should (= (string-width "áëòç") 4)) | ||
| 29 | (should (= (string-width "áëòç") 4)) | ||
| 30 | (should (= (string-width "הַרְבֵּה אַהֲבָה") 9)) | ||
| 31 | (should (= (string-width "1234" 1 3) 2)) | ||
| 32 | (should (= (string-width "1234" nil -1) 3)) | ||
| 33 | (should (= (string-width "1234" 2) 2)) | ||
| 34 | (should-error (string-width "1234" nil 5)) | ||
| 35 | (should-error (string-width "1234" -5)) | ||
| 36 | (should (= (string-width "12\t34") (+ 4 tab-width))) | ||
| 37 | (should (= (string-width "1234\t56") (+ 6 tab-width))) | ||
| 38 | (should (= (string-width "áëòç") 4)) | ||
| 39 | (should (= (string-width "áëòç" nil 3) 3)) | ||
| 40 | (should (= (string-width "áëòç" 1 3) 2)) | ||
| 41 | (should (= (string-width "áëòç" nil 2) 1)) | ||
| 42 | (should (= (string-width "áëòç" nil 3) 2)) | ||
| 43 | (should (= (string-width "áëòç" nil 4) 2)) | ||
| 44 | (should (= (string-width "הַרְבֵּה אַהֲבָה") 9)) | ||
| 45 | (should (= (string-width "הַרְבֵּה אַהֲבָה" nil 8) 4))) | ||
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index ea80da4819c..a731a95ccf0 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el | |||
| @@ -1,4 +1,4 @@ | |||
| 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-2021 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2016-2021 Free Software Foundation, Inc. |
| 4 | 4 | ||
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el index af5bc2a0baf..0a68d51e3eb 100644 --- a/test/src/emacs-module-tests.el +++ b/test/src/emacs-module-tests.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; emacs-module-tests --- Test GNU Emacs modules. -*- lexical-binding: t; -*- | 1 | ;;; emacs-module-tests.el --- Test GNU Emacs modules. -*- lexical-binding: t; -*- |
| 2 | 2 | ||
| 3 | ;; Copyright 2015-2021 Free Software Foundation, Inc. | 3 | ;; Copyright 2015-2021 Free Software Foundation, Inc. |
| 4 | 4 | ||
diff --git a/test/src/emacs-tests.el b/test/src/emacs-tests.el index 09f9a248efb..87c3e84cdd2 100644 --- a/test/src/emacs-tests.el +++ b/test/src/emacs-tests.el | |||
| @@ -144,12 +144,14 @@ to `make-temp-file', which see." | |||
| 144 | (should-not (file-remote-p filter)) | 144 | (should-not (file-remote-p filter)) |
| 145 | (cl-callf file-name-unquote filter) | 145 | (cl-callf file-name-unquote filter) |
| 146 | (with-temp-buffer | 146 | (with-temp-buffer |
| 147 | (let ((status (call-process | 147 | (let ((start-time (current-time)) |
| 148 | (status (call-process | ||
| 148 | emacs nil t nil | 149 | emacs nil t nil |
| 149 | "--quick" "--batch" | 150 | "--quick" "--batch" |
| 150 | (concat "--seccomp=" filter) | 151 | (concat "--seccomp=" filter) |
| 151 | (format "--eval=%S" '(message "Hi"))))) | 152 | (format "--eval=%S" '(message "Hi")))) |
| 152 | (ert-info ((format "Process output: %s" (buffer-string))) | 153 | (end-time (current-time))) |
| 154 | (ert-info ((emacs-tests--seccomp-debug start-time end-time)) | ||
| 153 | (should (eql status 0))) | 155 | (should (eql status 0))) |
| 154 | (should (equal (string-trim (buffer-string)) "Hi")))))) | 156 | (should (equal (string-trim (buffer-string)) "Hi")))))) |
| 155 | 157 | ||
| @@ -167,14 +169,16 @@ to `make-temp-file', which see." | |||
| 167 | (should-not (file-remote-p filter)) | 169 | (should-not (file-remote-p filter)) |
| 168 | (cl-callf file-name-unquote filter) | 170 | (cl-callf file-name-unquote filter) |
| 169 | (with-temp-buffer | 171 | (with-temp-buffer |
| 170 | (let ((status | 172 | (let ((start-time (current-time)) |
| 173 | (status | ||
| 171 | (call-process | 174 | (call-process |
| 172 | emacs nil t nil | 175 | emacs nil t nil |
| 173 | "--quick" "--batch" | 176 | "--quick" "--batch" |
| 174 | (concat "--seccomp=" filter) | 177 | (concat "--seccomp=" filter) |
| 175 | (format "--eval=%S" `(call-process ,emacs nil nil nil | 178 | (format "--eval=%S" `(call-process ,emacs nil nil nil |
| 176 | "--version"))))) | 179 | "--version")))) |
| 177 | (ert-info ((format "Process output: %s" (buffer-string))) | 180 | (end-time (current-time))) |
| 181 | (ert-info ((emacs-tests--seccomp-debug start-time end-time)) | ||
| 178 | (should-not (eql status 0))))))) | 182 | (should-not (eql status 0))))))) |
| 179 | 183 | ||
| 180 | (ert-deftest emacs-tests/bwrap/allows-stdout () | 184 | (ert-deftest emacs-tests/bwrap/allows-stdout () |
| @@ -205,9 +209,49 @@ to `make-temp-file', which see." | |||
| 205 | " ") | 209 | " ") |
| 206 | " 20< " | 210 | " 20< " |
| 207 | (shell-quote-argument (file-name-unquote filter)))) | 211 | (shell-quote-argument (file-name-unquote filter)))) |
| 208 | (status (call-process bash nil t nil "-c" command))) | 212 | (start-time (current-time)) |
| 209 | (ert-info ((format "Process output: %s" (buffer-string))) | 213 | (status (call-process bash nil t nil "-c" command)) |
| 214 | (end-time (current-time))) | ||
| 215 | (ert-info ((emacs-tests--seccomp-debug start-time end-time)) | ||
| 210 | (should (eql status 0))) | 216 | (should (eql status 0))) |
| 211 | (should (equal (string-trim (buffer-string)) "Hi")))))) | 217 | (should (equal (string-trim (buffer-string)) "Hi")))))) |
| 212 | 218 | ||
| 219 | (defun emacs-tests--seccomp-debug (start-time end-time) | ||
| 220 | "Return potentially useful debugging information for Seccomp. | ||
| 221 | Assume that the current buffer contains subprocess output for the | ||
| 222 | failing process. START-TIME and END-TIME are time values between | ||
| 223 | which the process was running." | ||
| 224 | ;; Add a bit of slack for the timestamps. | ||
| 225 | (cl-callf time-subtract start-time 5) | ||
| 226 | (cl-callf time-add end-time 5) | ||
| 227 | (with-output-to-string | ||
| 228 | (princ "Process output:") | ||
| 229 | (terpri) | ||
| 230 | (princ (buffer-substring-no-properties (point-min) (point-max))) | ||
| 231 | ;; Search audit logs for Seccomp messages. | ||
| 232 | (when-let ((ausearch (executable-find "ausearch"))) | ||
| 233 | (terpri) | ||
| 234 | (princ "Potentially relevant Seccomp audit events:") | ||
| 235 | (terpri) | ||
| 236 | (let ((process-environment '("LC_TIME=C"))) | ||
| 237 | (call-process ausearch nil standard-output nil | ||
| 238 | "--message" "SECCOMP" | ||
| 239 | "--start" | ||
| 240 | (format-time-string "%D" start-time) | ||
| 241 | (format-time-string "%T" start-time) | ||
| 242 | "--end" | ||
| 243 | (format-time-string "%D" end-time) | ||
| 244 | (format-time-string "%T" end-time) | ||
| 245 | "--interpret"))) | ||
| 246 | ;; Print coredump information if available. | ||
| 247 | (when-let ((coredumpctl (executable-find "coredumpctl"))) | ||
| 248 | (terpri) | ||
| 249 | (princ "Potentially useful coredump information:") | ||
| 250 | (terpri) | ||
| 251 | (call-process coredumpctl nil standard-output nil | ||
| 252 | "info" | ||
| 253 | "--since" (format-time-string "%F %T" start-time) | ||
| 254 | "--until" (format-time-string "%F %T" end-time) | ||
| 255 | "--no-pager")))) | ||
| 256 | |||
| 213 | ;;; emacs-tests.el ends here | 257 | ;;; emacs-tests.el ends here |
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 7f193d4eeab..b989c97fe6b 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; unit tests for src/fileio.c -*- lexical-binding: t; -*- | 1 | ;;; fileio-tests.el --- unit tests for src/fileio.c -*- lexical-binding: t; -*- |
| 2 | 2 | ||
| 3 | ;; Copyright 2017-2021 Free Software Foundation, Inc. | 3 | ;; Copyright 2017-2021 Free Software Foundation, Inc. |
| 4 | 4 | ||
diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el index 0e1ca76fd9c..fc7bc7441b7 100644 --- a/test/src/thread-tests.el +++ b/test/src/thread-tests.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; threads.el --- tests for threads. -*- lexical-binding: t -*- | 1 | ;;; thread-tests.el --- tests for threads. -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2012-2021 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2012-2021 Free Software Foundation, Inc. |
| 4 | 4 | ||
diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el index e55bd1eb4ee..0a450a7573f 100644 --- a/test/src/timefns-tests.el +++ b/test/src/timefns-tests.el | |||
| @@ -1,4 +1,4 @@ | |||
| 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-2021 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2016-2021 Free Software Foundation, Inc. |
| 4 | 4 | ||