aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGlenn Morris2018-08-26 15:10:50 -0700
committerGlenn Morris2018-08-26 15:10:50 -0700
commit1afd313334c93cb5b0a7a378bd635a54dc1d6a9e (patch)
treecb95ad44d35f9b32a8acc8bb00b7291f38549c52 /test
parent18d52b90a1692a47cea5b5e905a58a3b2c6c9a64 (diff)
parent54fb383af6f6af7b72c28f38b308d9b24d2af4f6 (diff)
downloademacs-1afd313334c93cb5b0a7a378bd635a54dc1d6a9e.tar.gz
emacs-1afd313334c93cb5b0a7a378bd635a54dc1d6a9e.zip
Merge from origin/emacs-26
54fb383 (origin/emacs-26) Fix detection of freed emacs_values (Bug#32... 769d0cd ; Fix out-of-tree build for mod-test.so 9a1329e Avoid crashes with very wide TTY frames on MS-Windows 9a613d3 Prevent `modify-file-local-variable-prop-line' from adding ex... 624e7dc Update GNOME bugtracker URLs 51ef6d5 Clarify in the Emacs manual that ChangeLog files are not used 6e08019 Recognize codepage 65001 as a valid encoding 1a350d7 ; * etc/NEWS: Fix format of first lines of some entries. 22d1f53 Avoid compilation warning in nt/addpm.c 7bc9ce7 Fix duplicate custom group names in bibtex.el a9cf938 Fix outdated text in the Calc manual Conflicts: etc/NEWS etc/PROBLEMS src/emacs-module.c src/gtkutil.c src/image.c src/xterm.c test/Makefile.in
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in4
-rw-r--r--test/data/emacs-module/mod-test.c19
-rw-r--r--test/src/emacs-module-tests.el3
3 files changed, 25 insertions, 1 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index 0bc893bc0c6..a1f43882881 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -246,12 +246,14 @@ else
246FPIC_CFLAGS = -fPIC 246FPIC_CFLAGS = -fPIC
247endif 247endif
248 248
249# Note: emacs-module.h is generated from emacs-module.h.in, hence we
250# look in ../src, not $(srcdir)/../src.
249MODULE_CFLAGS = -I../src $(FPIC_CFLAGS) $(PROFILING_CFLAGS) \ 251MODULE_CFLAGS = -I../src $(FPIC_CFLAGS) $(PROFILING_CFLAGS) \
250 $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS) 252 $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS)
251 253
252test_module = $(test_module_dir)/mod-test${SO} 254test_module = $(test_module_dir)/mod-test${SO}
253src/emacs-module-tests.log: $(test_module) 255src/emacs-module-tests.log: $(test_module)
254$(test_module): $(test_module:${SO}=.c) $(srcdir)/../src/emacs-module.h 256$(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h
255 $(AM_V_at)${MKDIR_P} $(dir $@) 257 $(AM_V_at)${MKDIR_P} $(dir $@)
256 $(AM_V_CCLD)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \ 258 $(AM_V_CCLD)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \
257 -o $@ $< 259 -o $@ $<
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c
index db05e90bc49..a9b459b4cc4 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -156,6 +156,24 @@ Fmod_test_globref_make (emacs_env *env, ptrdiff_t nargs, emacs_value args[],
156 return env->make_global_ref (env, lisp_str); 156 return env->make_global_ref (env, lisp_str);
157} 157}
158 158
159/* Create a few global references from arguments and free them. */
160static emacs_value
161Fmod_test_globref_free (emacs_env *env, ptrdiff_t nargs, emacs_value args[],
162 void *data)
163{
164 emacs_value refs[10];
165 for (int i = 0; i < 10; i++)
166 {
167 refs[i] = env->make_global_ref (env, args[i % nargs]);
168 }
169 for (int i = 0; i < 10; i++)
170 {
171 env->free_global_ref (env, refs[i]);
172 }
173 return env->intern (env, "ok");
174}
175
176
159 177
160/* Return a copy of the argument string where every 'a' is replaced 178/* Return a copy of the argument string where every 'a' is replaced
161 with 'b'. */ 179 with 'b'. */
@@ -339,6 +357,7 @@ emacs_module_init (struct emacs_runtime *ert)
339 DEFUN ("mod-test-non-local-exit-funcall", Fmod_test_non_local_exit_funcall, 357 DEFUN ("mod-test-non-local-exit-funcall", Fmod_test_non_local_exit_funcall,
340 1, 1, NULL, NULL); 358 1, 1, NULL, NULL);
341 DEFUN ("mod-test-globref-make", Fmod_test_globref_make, 0, 0, NULL, NULL); 359 DEFUN ("mod-test-globref-make", Fmod_test_globref_make, 0, 0, NULL, NULL);
360 DEFUN ("mod-test-globref-free", Fmod_test_globref_free, 4, 4, NULL, NULL);
342 DEFUN ("mod-test-string-a-to-b", Fmod_test_string_a_to_b, 1, 1, NULL, NULL); 361 DEFUN ("mod-test-string-a-to-b", Fmod_test_string_a_to_b, 1, 1, NULL, NULL);
343 DEFUN ("mod-test-userptr-make", Fmod_test_userptr_make, 1, 1, NULL, NULL); 362 DEFUN ("mod-test-userptr-make", Fmod_test_userptr_make, 1, 1, NULL, NULL);
344 DEFUN ("mod-test-userptr-get", Fmod_test_userptr_get, 1, 1, NULL, NULL); 363 DEFUN ("mod-test-userptr-get", Fmod_test_userptr_get, 1, 1, NULL, NULL);
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
index 90cd37a98a5..c67190be5cb 100644
--- a/test/src/emacs-module-tests.el
+++ b/test/src/emacs-module-tests.el
@@ -148,6 +148,9 @@ changes."
148 (garbage-collect) ;; XXX: not enough to really test but it's something.. 148 (garbage-collect) ;; XXX: not enough to really test but it's something..
149 (should (string= ref-str mod-str)))) 149 (should (string= ref-str mod-str))))
150 150
151(ert-deftest mod-test-globref-free-test ()
152 (should (eq (mod-test-globref-free 1 'a "test" 'b) 'ok)))
153
151(ert-deftest mod-test-string-a-to-b-test () 154(ert-deftest mod-test-string-a-to-b-test ()
152 (should (string= (mod-test-string-a-to-b "aaa") "bbb"))) 155 (should (string= (mod-test-string-a-to-b "aaa") "bbb")))
153 156