Skip to content

Commit abb9ea2

Browse files
committed
Merge pull request #754 from pguyot/w32/fix-enif-test-s
Fix enif test As explained in comment, scheduler_terminate should be preferred to context_destroy Also list tests in README These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 9751d4d + 717d1af commit abb9ea2

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

README.Md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ $ ./src/AtomVM ./examples/erlang/hello_world.avm
5858
Run tests within build directory with:
5959
```
6060
$ ./tests/test-erlang
61+
$ ./tests/test-enif
62+
$ ./tests/test-mailbox
6163
$ ./tests/test-structs
6264
$ ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm
6365
$ ./src/AtomVM ./tests/libs/eavmlib/test_eavmlib.avm

tests/test-enif.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "erl_nif.h"
2626
#include "erl_nif_priv.h"
2727
#include "globalcontext.h"
28+
#include "scheduler.h"
2829
#include "utils.h"
2930

3031
static uint32_t cb_read_resource = 0;
@@ -87,7 +88,7 @@ void test_resource()
8788

8889
assert(cb_read_resource == 0);
8990

90-
context_destroy(ctx);
91+
scheduler_terminate(ctx);
9192
assert(cb_read_resource == 42);
9293
cb_read_resource = 0;
9394

@@ -116,7 +117,7 @@ void test_resource_destroyed_with_global()
116117
uint32_t *resource = (uint32_t *) ptr;
117118
*resource = 42;
118119

119-
context_destroy(ctx);
120+
scheduler_terminate(ctx);
120121
assert(cb_read_resource == 0);
121122

122123
globalcontext_destroy(glb);
@@ -163,7 +164,7 @@ void test_resource_keep_release()
163164

164165
cb_read_resource = 0;
165166

166-
context_destroy(ctx);
167+
scheduler_terminate(ctx);
167168
globalcontext_destroy(glb);
168169

169170
assert(cb_read_resource == 0);
@@ -205,7 +206,7 @@ void test_resource_monitor()
205206
assert(monitor_result == 0);
206207
assert(cb_read_resource == 0);
207208

208-
context_destroy(ctx);
209+
scheduler_terminate(ctx);
209210
assert(cb_read_resource == 42);
210211
assert(down_pid == pid);
211212
assert(enif_compare_monitors(&mon, &down_mon) == 0);
@@ -223,7 +224,7 @@ void test_resource_monitor()
223224
monitor_result = enif_demonitor_process(&env, ptr, &mon);
224225
assert(monitor_result == 0);
225226

226-
context_destroy(ctx);
227+
scheduler_terminate(ctx);
227228
assert(cb_read_resource == 0);
228229
assert(down_pid == 0);
229230

@@ -243,7 +244,7 @@ void test_resource_monitor()
243244

244245
cb_read_resource = 0;
245246

246-
context_destroy(ctx);
247+
scheduler_terminate(ctx);
247248
assert(cb_read_resource == 0);
248249
assert(down_pid == 0);
249250

0 commit comments

Comments
 (0)