diff options
| author | Eli Zaretskii | 2016-12-04 19:59:17 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-12-04 19:59:17 +0200 |
| commit | de4624c99ea5bbe38ad5aff7b6461cc5c740d0be (patch) | |
| tree | 1b57de9e769cdb695cb2cecf157b50f7dea9cfe5 /test | |
| parent | a486fabb41cdbaa5813c2687fd4008945297d71d (diff) | |
| parent | e7bde34e939451d87fb42a36195086bdbe48b5e1 (diff) | |
| download | emacs-de4624c99ea5bbe38ad5aff7b6461cc5c740d0be.tar.gz emacs-de4624c99ea5bbe38ad5aff7b6461cc5c740d0be.zip | |
Merge branch 'concurrency'
Conflicts (resolved):
configure.ac
src/Makefile.in
src/alloc.c
src/bytecode.c
src/emacs.c
src/eval.c
src/lisp.h
src/process.c
src/regex.c
src/regex.h
Diffstat (limited to 'test')
| -rw-r--r-- | test/automated/bindings.el | 99 | ||||
| -rw-r--r-- | test/automated/threads.el | 213 |
2 files changed, 312 insertions, 0 deletions
diff --git a/test/automated/bindings.el b/test/automated/bindings.el new file mode 100644 index 00000000000..4b88baeef40 --- /dev/null +++ b/test/automated/bindings.el | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | ;;; bindings.el --- tests for variable bindings | ||
| 2 | |||
| 3 | ;; Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (defvar binding-test-buffer-A (get-buffer-create "A")) | ||
| 23 | (defvar binding-test-buffer-B (get-buffer-create "B")) | ||
| 24 | |||
| 25 | (defvar binding-test-always-local 'always) | ||
| 26 | (make-variable-buffer-local 'binding-test-always-local) | ||
| 27 | |||
| 28 | (defvar binding-test-some-local 'some) | ||
| 29 | (with-current-buffer binding-test-buffer-A | ||
| 30 | (set (make-local-variable 'binding-test-some-local) 'local)) | ||
| 31 | |||
| 32 | (ert-deftest binding-test-manual () | ||
| 33 | "A test case from the elisp manual." | ||
| 34 | (save-excursion | ||
| 35 | (set-buffer binding-test-buffer-A) | ||
| 36 | (let ((binding-test-some-local 'something-else)) | ||
| 37 | (should (eq binding-test-some-local 'something-else)) | ||
| 38 | (set-buffer binding-test-buffer-B) | ||
| 39 | (should (eq binding-test-some-local 'some))) | ||
| 40 | (should (eq binding-test-some-local 'some)) | ||
| 41 | (set-buffer binding-test-buffer-A) | ||
| 42 | (should (eq binding-test-some-local 'local)))) | ||
| 43 | |||
| 44 | (ert-deftest binding-test-setq-default () | ||
| 45 | "Test that a setq-default has no effect when there is a local binding." | ||
| 46 | (save-excursion | ||
| 47 | (set-buffer binding-test-buffer-B) | ||
| 48 | ;; This variable is not local in this buffer. | ||
| 49 | (let ((binding-test-some-local 'something-else)) | ||
| 50 | (setq-default binding-test-some-local 'new-default)) | ||
| 51 | (should (eq binding-test-some-local 'some)))) | ||
| 52 | |||
| 53 | (ert-deftest binding-test-makunbound () | ||
| 54 | "Tests of makunbound, from the manual." | ||
| 55 | (save-excursion | ||
| 56 | (set-buffer binding-test-buffer-B) | ||
| 57 | (should (boundp 'binding-test-some-local)) | ||
| 58 | (let ((binding-test-some-local 'outer)) | ||
| 59 | (let ((binding-test-some-local 'inner)) | ||
| 60 | (makunbound 'binding-test-some-local) | ||
| 61 | (should (not (boundp 'binding-test-some-local)))) | ||
| 62 | (should (and (boundp 'binding-test-some-local) | ||
| 63 | (eq binding-test-some-local 'outer)))))) | ||
| 64 | |||
| 65 | (ert-deftest binding-test-defvar-bool () | ||
| 66 | "Test DEFVAR_BOOL" | ||
| 67 | (let ((display-hourglass 5)) | ||
| 68 | (should (eq display-hourglass t)))) | ||
| 69 | |||
| 70 | (ert-deftest binding-test-defvar-int () | ||
| 71 | "Test DEFVAR_INT" | ||
| 72 | (should-error (setq gc-cons-threshold 5.0) :type 'wrong-type-argument)) | ||
| 73 | |||
| 74 | (ert-deftest binding-test-set-constant-t () | ||
| 75 | "Test setting the constant t" | ||
| 76 | (should-error (setq t 'bob) :type 'setting-constant)) | ||
| 77 | |||
| 78 | (ert-deftest binding-test-set-constant-nil () | ||
| 79 | "Test setting the constant nil" | ||
| 80 | (should-error (setq nil 'bob) :type 'setting-constant)) | ||
| 81 | |||
| 82 | (ert-deftest binding-test-set-constant-keyword () | ||
| 83 | "Test setting a keyword constant" | ||
| 84 | (should-error (setq :keyword 'bob) :type 'setting-constant)) | ||
| 85 | |||
| 86 | (ert-deftest binding-test-set-constant-nil () | ||
| 87 | "Test setting a keyword to itself" | ||
| 88 | (should (setq :keyword :keyword))) | ||
| 89 | |||
| 90 | ;; More tests to write - | ||
| 91 | ;; kill-local-variable | ||
| 92 | ;; defconst; can modify | ||
| 93 | ;; defvar and defconst modify the local binding [ doesn't matter for us ] | ||
| 94 | ;; various kinds of special internal forwarding objects | ||
| 95 | ;; a couple examples in manual, not enough | ||
| 96 | ;; frame-local vars | ||
| 97 | ;; variable aliases | ||
| 98 | |||
| 99 | ;;; bindings.el ends here | ||
diff --git a/test/automated/threads.el b/test/automated/threads.el new file mode 100644 index 00000000000..c65b6425c3c --- /dev/null +++ b/test/automated/threads.el | |||
| @@ -0,0 +1,213 @@ | |||
| 1 | ;;; threads.el --- tests for threads. | ||
| 2 | |||
| 3 | ;; Copyright (C) 2012, 2013 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 <http://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (ert-deftest threads-is-one () | ||
| 23 | "test for existence of a thread" | ||
| 24 | (should (current-thread))) | ||
| 25 | |||
| 26 | (ert-deftest threads-threadp () | ||
| 27 | "test of threadp" | ||
| 28 | (should (threadp (current-thread)))) | ||
| 29 | |||
| 30 | (ert-deftest threads-type () | ||
| 31 | "test of thread type" | ||
| 32 | (should (eq (type-of (current-thread)) 'thread))) | ||
| 33 | |||
| 34 | (ert-deftest threads-name () | ||
| 35 | "test for name of a thread" | ||
| 36 | (should | ||
| 37 | (string= "hi bob" (thread-name (make-thread #'ignore "hi bob"))))) | ||
| 38 | |||
| 39 | (ert-deftest threads-alive () | ||
| 40 | "test for thread liveness" | ||
| 41 | (should | ||
| 42 | (thread-alive-p (make-thread #'ignore)))) | ||
| 43 | |||
| 44 | (ert-deftest threads-all-threads () | ||
| 45 | "simple test for all-threads" | ||
| 46 | (should (listp (all-threads)))) | ||
| 47 | |||
| 48 | (defvar threads-test-global nil) | ||
| 49 | |||
| 50 | (defun threads-test-thread1 () | ||
| 51 | (setq threads-test-global 23)) | ||
| 52 | |||
| 53 | (ert-deftest threads-basic () | ||
| 54 | "basic thread test" | ||
| 55 | (should | ||
| 56 | (progn | ||
| 57 | (setq threads-test-global nil) | ||
| 58 | (make-thread #'threads-test-thread1) | ||
| 59 | (while (not threads-test-global) | ||
| 60 | (thread-yield)) | ||
| 61 | threads-test-global))) | ||
| 62 | |||
| 63 | (ert-deftest threads-join () | ||
| 64 | "test of thread-join" | ||
| 65 | (should | ||
| 66 | (progn | ||
| 67 | (setq threads-test-global nil) | ||
| 68 | (let ((thread (make-thread #'threads-test-thread1))) | ||
| 69 | (thread-join thread) | ||
| 70 | (and threads-test-global | ||
| 71 | (not (thread-alive-p thread))))))) | ||
| 72 | |||
| 73 | (ert-deftest threads-join-self () | ||
| 74 | "cannot thread-join the current thread" | ||
| 75 | (should-error (thread-join (current-thread)))) | ||
| 76 | |||
| 77 | (defvar threads-test-binding nil) | ||
| 78 | |||
| 79 | (defun threads-test-thread2 () | ||
| 80 | (let ((threads-test-binding 23)) | ||
| 81 | (thread-yield)) | ||
| 82 | (setq threads-test-global 23)) | ||
| 83 | |||
| 84 | (ert-deftest threads-let-binding () | ||
| 85 | "simple test of threads and let bindings" | ||
| 86 | (should | ||
| 87 | (progn | ||
| 88 | (setq threads-test-global nil) | ||
| 89 | (make-thread #'threads-test-thread2) | ||
| 90 | (while (not threads-test-global) | ||
| 91 | (thread-yield)) | ||
| 92 | (and (not threads-test-binding) | ||
| 93 | threads-test-global)))) | ||
| 94 | |||
| 95 | (ert-deftest threads-mutexp () | ||
| 96 | "simple test of mutexp" | ||
| 97 | (should-not (mutexp 'hi))) | ||
| 98 | |||
| 99 | (ert-deftest threads-mutexp-2 () | ||
| 100 | "another simple test of mutexp" | ||
| 101 | (should (mutexp (make-mutex)))) | ||
| 102 | |||
| 103 | (ert-deftest threads-mutex-type () | ||
| 104 | "type-of mutex" | ||
| 105 | (should (eq (type-of (make-mutex)) 'mutex))) | ||
| 106 | |||
| 107 | (ert-deftest threads-mutex-lock-unlock () | ||
| 108 | "test mutex-lock and unlock" | ||
| 109 | (should | ||
| 110 | (let ((mx (make-mutex))) | ||
| 111 | (mutex-lock mx) | ||
| 112 | (mutex-unlock mx) | ||
| 113 | t))) | ||
| 114 | |||
| 115 | (ert-deftest threads-mutex-recursive () | ||
| 116 | "test mutex-lock and unlock" | ||
| 117 | (should | ||
| 118 | (let ((mx (make-mutex))) | ||
| 119 | (mutex-lock mx) | ||
| 120 | (mutex-lock mx) | ||
| 121 | (mutex-unlock mx) | ||
| 122 | (mutex-unlock mx) | ||
| 123 | t))) | ||
| 124 | |||
| 125 | (defvar threads-mutex nil) | ||
| 126 | (defvar threads-mutex-key nil) | ||
| 127 | |||
| 128 | (defun threads-test-mlock () | ||
| 129 | (mutex-lock threads-mutex) | ||
| 130 | (setq threads-mutex-key 23) | ||
| 131 | (while threads-mutex-key | ||
| 132 | (thread-yield)) | ||
| 133 | (mutex-unlock threads-mutex)) | ||
| 134 | |||
| 135 | (ert-deftest threads-mutex-contention () | ||
| 136 | "test of mutex contention" | ||
| 137 | (should | ||
| 138 | (progn | ||
| 139 | (setq threads-mutex (make-mutex)) | ||
| 140 | (setq threads-mutex-key nil) | ||
| 141 | (make-thread #'threads-test-mlock) | ||
| 142 | ;; Wait for other thread to get the lock. | ||
| 143 | (while (not threads-mutex-key) | ||
| 144 | (thread-yield)) | ||
| 145 | ;; Try now. | ||
| 146 | (setq threads-mutex-key nil) | ||
| 147 | (mutex-lock threads-mutex) | ||
| 148 | (mutex-unlock threads-mutex) | ||
| 149 | t))) | ||
| 150 | |||
| 151 | (defun threads-test-mlock2 () | ||
| 152 | (setq threads-mutex-key 23) | ||
| 153 | (mutex-lock threads-mutex)) | ||
| 154 | |||
| 155 | (ert-deftest threads-mutex-signal () | ||
| 156 | "test signalling a blocked thread" | ||
| 157 | (should | ||
| 158 | (progn | ||
| 159 | (setq threads-mutex (make-mutex)) | ||
| 160 | (setq threads-mutex-key nil) | ||
| 161 | (mutex-lock threads-mutex) | ||
| 162 | (let ((thr (make-thread #'threads-test-mlock2))) | ||
| 163 | (while (not threads-mutex-key) | ||
| 164 | (thread-yield)) | ||
| 165 | (thread-signal thr 'quit nil) | ||
| 166 | (thread-join thr)) | ||
| 167 | t))) | ||
| 168 | |||
| 169 | (defun threads-test-io-switch () | ||
| 170 | (setq threads-test-global 23)) | ||
| 171 | |||
| 172 | (ert-deftest threads-io-switch () | ||
| 173 | "test that accept-process-output causes thread switch" | ||
| 174 | (should | ||
| 175 | (progn | ||
| 176 | (setq threads-test-global nil) | ||
| 177 | (make-thread #'threads-test-io-switch) | ||
| 178 | (while (not threads-test-global) | ||
| 179 | (accept-process-output nil 1)) | ||
| 180 | threads-test-global))) | ||
| 181 | |||
| 182 | (ert-deftest threads-condvarp () | ||
| 183 | "simple test of condition-variable-p" | ||
| 184 | (should-not (condition-variable-p 'hi))) | ||
| 185 | |||
| 186 | (ert-deftest threads-condvarp-2 () | ||
| 187 | "another simple test of condition-variable-p" | ||
| 188 | (should (condition-variable-p (make-condition-variable (make-mutex))))) | ||
| 189 | |||
| 190 | (ert-deftest threads-condvar-type () | ||
| 191 | "type-of condvar" | ||
| 192 | (should (eq (type-of (make-condition-variable (make-mutex))) | ||
| 193 | 'condition-variable))) | ||
| 194 | |||
| 195 | (ert-deftest threads-condvar-mutex () | ||
| 196 | "simple test of condition-mutex" | ||
| 197 | (should | ||
| 198 | (let ((m (make-mutex))) | ||
| 199 | (eq m (condition-mutex (make-condition-variable m)))))) | ||
| 200 | |||
| 201 | (ert-deftest threads-condvar-name () | ||
| 202 | "simple test of condition-name" | ||
| 203 | (should | ||
| 204 | (eq nil (condition-name (make-condition-variable (make-mutex)))))) | ||
| 205 | |||
| 206 | (ert-deftest threads-condvar-name-2 () | ||
| 207 | "another simple test of condition-name" | ||
| 208 | (should | ||
| 209 | (string= "hi bob" | ||
| 210 | (condition-name (make-condition-variable (make-mutex) | ||
| 211 | "hi bob"))))) | ||
| 212 | |||
| 213 | ;;; threads.el ends here | ||