aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-12-16 19:30:22 +0100
committerSverker Eriksson <[email protected]>2016-12-19 19:18:57 +0100
commit4c5d33114edea787833d6aa1b0d51ea9d98b3321 (patch)
tree3cddbd9bd14a04f5c008f272d7b99dbce5610623 /erts/emulator/test
parent861b276f27952ecbb5a89748b86b7513946617f3 (diff)
downloadotp-4c5d33114edea787833d6aa1b0d51ea9d98b3321.tar.gz
otp-4c5d33114edea787833d6aa1b0d51ea9d98b3321.tar.bz2
otp-4c5d33114edea787833d6aa1b0d51ea9d98b3321.zip
Add ErlNifSelectReturn
Diffstat (limited to 'erts/emulator/test')
-rw-r--r--erts/emulator/test/nif_SUITE.erl18
-rw-r--r--erts/emulator/test/nif_SUITE_data/nif_SUITE.c4
2 files changed, 15 insertions, 7 deletions
diff --git a/erts/emulator/test/nif_SUITE.erl b/erts/emulator/test/nif_SUITE.erl
index c2429c3405..8795a3b24a 100644
--- a/erts/emulator/test/nif_SUITE.erl
+++ b/erts/emulator/test/nif_SUITE.erl
@@ -440,6 +440,13 @@ t_on_load(Config) when is_list(Config) ->
-define(ERL_NIF_SELECT_WRITE, (1 bsl 1)).
-define(ERL_NIF_SELECT_STOP, (1 bsl 2)).
+-define(ERL_NIF_SELECT_ERROR, (1 bsl 0)).
+-define(ERL_NIF_SELECT_STOP_CALLED, (1 bsl 1)).
+-define(ERL_NIF_SELECT_STOP_SCHEDULED, (1 bsl 2)).
+-define(ERL_NIF_SELECT_INVALID_EVENT, (1 bsl 3)).
+-define(ERL_NIF_SELECT_FAILED, (1 bsl 4)).
+
+
select(Config) when is_list(Config) ->
ensure_lib_loaded(Config),
@@ -470,7 +477,7 @@ select(Config) when is_list(Config) ->
%% Close write and wait for EOF
eagain = read_nif(R, 1),
- 0 = select_nif(W,?ERL_NIF_SELECT_STOP,W,Ref),
+ check_stop_ret(select_nif(W,?ERL_NIF_SELECT_STOP,W,Ref)),
timer:sleep(10),
{1, {W_ptr,_}} = last_fd_stop_call(),
true = is_closed_nif(W),
@@ -479,7 +486,7 @@ select(Config) when is_list(Config) ->
[{select, R, Ref, ready_input}] = flush(),
eof = read_nif(R,1),
- 0 = select_nif(R,?ERL_NIF_SELECT_STOP,R,Ref),
+ check_stop_ret(select_nif(R,?ERL_NIF_SELECT_STOP,R,Ref)),
timer:sleep(10),
{1, {R_ptr,_}} = last_fd_stop_call(),
true = is_closed_nif(R),
@@ -521,12 +528,12 @@ select_2(Config) ->
done = receive_any(),
[] = flush(),
- 0 = select_nif(R,?ERL_NIF_SELECT_STOP,R,Ref1),
+ check_stop_ret(select_nif(R,?ERL_NIF_SELECT_STOP,R,Ref1)),
timer:sleep(10),
{1, {R_ptr,_}} = last_fd_stop_call(),
true = is_closed_nif(R),
- 0 = select_nif(W,?ERL_NIF_SELECT_STOP,W,Ref1),
+ ?ERL_NIF_SELECT_STOP_CALLED = select_nif(W,?ERL_NIF_SELECT_STOP,W,Ref1),
timer:sleep(10),
{1, {W_ptr,1}} = last_fd_stop_call(),
true = is_closed_nif(W),
@@ -538,7 +545,8 @@ select_3(Config) ->
{_,_,2} = last_resource_dtor_call(),
ok.
-
+check_stop_ret(?ERL_NIF_SELECT_STOP_CALLED) -> ok;
+check_stop_ret(?ERL_NIF_SELECT_STOP_SCHEDULED) -> ok.
write_full(W, C) ->
write_full(W, C, <<>>).
diff --git a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
index 813d19ae90..d2af081a22 100644
--- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
+++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
@@ -2042,7 +2042,7 @@ static ERL_NIF_TERM select_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv
enum ErlNifSelectFlags mode;
void* obj;
ERL_NIF_TERM ref;
- int retval;
+ enum ErlNifSelectReturn retval;
if (!get_fd(env, argv[0], &fdr)
|| !enif_get_uint(env, argv[1], &mode)
@@ -2056,7 +2056,7 @@ static ERL_NIF_TERM select_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv
fdr->was_selected = 1;
retval = enif_select(env, fdr->fd, mode, obj, ref);
- return enif_make_int(env, retval);
+ return enif_make_int(env, (int)retval);
}
static ERL_NIF_TERM pipe_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])