aboutsummaryrefslogtreecommitdiffstats
path: root/test/data
diff options
context:
space:
mode:
Diffstat (limited to 'test/data')
-rw-r--r--test/data/emacs-module/mod-test.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c
index 309179d1501..fc29a0d6b9a 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -213,6 +213,28 @@ Fmod_test_vector_eq (emacs_env *env, ptrdiff_t nargs, emacs_value args[],
213 return env->intern (env, "t"); 213 return env->intern (env, "t");
214} 214}
215 215
216static emacs_value invalid_stored_value;
217
218/* The next two functions perform a possibly-invalid operation: they
219 store a value in a static variable and load it. This causes
220 undefined behavior if the environment that the value was created
221 from is no longer live. The module assertions check for this
222 error. */
223
224static emacs_value
225Fmod_test_invalid_store (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
226 void *data)
227{
228 return invalid_stored_value = env->make_integer (env, 123);
229}
230
231static emacs_value
232Fmod_test_invalid_load (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
233 void *data)
234{
235 return invalid_stored_value;
236}
237
216 238
217/* Lisp utilities for easier readability (simple wrappers). */ 239/* Lisp utilities for easier readability (simple wrappers). */
218 240
@@ -260,6 +282,8 @@ emacs_module_init (struct emacs_runtime *ert)
260 DEFUN ("mod-test-userptr-get", Fmod_test_userptr_get, 1, 1, NULL, NULL); 282 DEFUN ("mod-test-userptr-get", Fmod_test_userptr_get, 1, 1, NULL, NULL);
261 DEFUN ("mod-test-vector-fill", Fmod_test_vector_fill, 2, 2, NULL, NULL); 283 DEFUN ("mod-test-vector-fill", Fmod_test_vector_fill, 2, 2, NULL, NULL);
262 DEFUN ("mod-test-vector-eq", Fmod_test_vector_eq, 2, 2, NULL, NULL); 284 DEFUN ("mod-test-vector-eq", Fmod_test_vector_eq, 2, 2, NULL, NULL);
285 DEFUN ("mod-test-invalid-store", Fmod_test_invalid_store, 0, 0, NULL, NULL);
286 DEFUN ("mod-test-invalid-load", Fmod_test_invalid_load, 0, 0, NULL, NULL);
263 287
264#undef DEFUN 288#undef DEFUN
265 289