aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/erl_process.c3
-rw-r--r--erts/emulator/nifs/common/socket_dbg.c40
-rw-r--r--erts/emulator/nifs/common/socket_nif.c33
-rw-r--r--erts/emulator/nifs/common/socket_util.c40
-rw-r--r--erts/emulator/test/nif_SUITE.erl37
-rw-r--r--erts/emulator/test/socket_SUITE.erl181
6 files changed, 227 insertions, 107 deletions
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index 0a099e69bb..3fa06d1407 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -9460,6 +9460,7 @@ Process *erts_schedule(ErtsSchedulerData *esdp, Process *p, int calls)
if (!is_normal_sched & !!(flags & ERTS_RUNQ_FLG_HALTING)) {
/* Wait for emulator to terminate... */
+ erts_runq_unlock(rq);
while (1)
erts_milli_sleep(1000*1000);
}
@@ -13403,10 +13404,10 @@ void erts_halt(int code)
if (-1 == erts_atomic32_cmpxchg_acqb(&erts_halt_progress,
erts_no_schedulers,
-1)) {
+ notify_reap_ports_relb();
ERTS_RUNQ_FLGS_SET(ERTS_DIRTY_CPU_RUNQ, ERTS_RUNQ_FLG_HALTING);
ERTS_RUNQ_FLGS_SET(ERTS_DIRTY_IO_RUNQ, ERTS_RUNQ_FLG_HALTING);
erts_halt_code = code;
- notify_reap_ports_relb();
}
}
diff --git a/erts/emulator/nifs/common/socket_dbg.c b/erts/emulator/nifs/common/socket_dbg.c
index fe9135e5a0..96f75a328f 100644
--- a/erts/emulator/nifs/common/socket_dbg.c
+++ b/erts/emulator/nifs/common/socket_dbg.c
@@ -38,8 +38,10 @@
static FILE* dbgout = NULL;
+#if defined(CLOCK_REALTIME)
static int realtime(struct timespec* tsP);
static int timespec2str(char *buf, unsigned int len, struct timespec *ts);
+#endif
extern
@@ -71,41 +73,48 @@ void esock_dbg_printf( const char* prefix, const char* format, ... )
{
va_list args;
char f[512 + sizeof(format)]; // This has to suffice...
+#if defined(CLOCK_REALTIME)
char stamp[30];
struct timespec ts;
+#endif
int res;
/*
- * We should really include self in the printout, so we can se which process
- * are executing the code. But then I must change the API....
- * ....something for later.
+ * We should really include self in the printout,
+ * so we can se which process are executing the code.
+ * But then I must change the API....something for later.
*/
- if (!realtime(&ts)) {
- if (timespec2str(stamp, sizeof(stamp), &ts) != 0) {
- res = enif_snprintf(f, sizeof(f), "%s [%s] %s", prefix, TSNAME(), format);
- // res = enif_snprintf(f, sizeof(f), "%s [%s]", prefix, format);
- } else {
- res = enif_snprintf(f, sizeof(f), "%s [%s] [%s] %s", prefix, stamp, TSNAME(), format);
- // res = enif_snprintf(f, sizeof(f), "%s [%s] %s", prefix, stamp, format);
- }
-
- if (res > 0) {
+#if defined(CLOCK_REALTIME)
+ if (!realtime(&ts) &&
+ (timespec2str(stamp, sizeof(stamp), &ts) == 0)) {
+ res = enif_snprintf(f, sizeof(f), "%s [%s] [%s] %s",
+ prefix, stamp, TSNAME(), format);
+ } else {
+ res = enif_snprintf(f, sizeof(f), "%s [%s] %s",
+ prefix, TSNAME(), format);
+ }
+#else
+ res = enif_snprintf(f, sizeof(f), "%s [%s] %s",
+ prefix, TSNAME(), format);
+#endif
+
+ if (res > 0) {
va_start (args, format);
enif_vfprintf (dbgout, f, args);
va_end (args);
fflush(stdout);
- }
}
return;
}
+#if defined(CLOCK_REALTIME)
static
int realtime(struct timespec* tsP)
{
- return clock_gettime(CLOCK_REALTIME, tsP);
+ return clock_gettime(CLOCK_REALTIME, tsP);
}
@@ -136,3 +145,4 @@ int timespec2str(char *buf, unsigned int len, struct timespec *ts)
return 0;
}
+#endif
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index 052c585032..870ab63bdf 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -2410,7 +2410,8 @@ static void socket_down_reader(ErlNifEnv* env,
const ErlNifPid* pid);
static char* esock_send_close_msg(ErlNifEnv* env,
- SocketDescriptor* descP);
+ SocketDescriptor* descP,
+ ERL_NIF_TERM sockRef);
static char* esock_send_abort_msg(ErlNifEnv* env,
ERL_NIF_TERM sockRef,
ERL_NIF_TERM recvRef,
@@ -16896,15 +16897,18 @@ char* send_msg_error(ErlNifEnv* env,
*/
static
char* esock_send_close_msg(ErlNifEnv* env,
- SocketDescriptor* descP)
-{
- ERL_NIF_TERM sockRef = enif_make_resource(descP->closeEnv, descP);
- char* res = esock_send_socket_msg(env,
- sockRef,
- esock_atom_close,
- descP->closeRef,
- &descP->closerPid,
- descP->closeEnv);
+ SocketDescriptor* descP,
+ ERL_NIF_TERM sockRef)
+{
+ ERL_NIF_TERM sr = ((descP->closeEnv != NULL) ?
+ enif_make_copy(descP->closeEnv, sockRef) :
+ sockRef);
+ char* res = esock_send_socket_msg(env,
+ sr,
+ esock_atom_close,
+ descP->closeRef,
+ &descP->closerPid,
+ descP->closeEnv);
descP->closeEnv = NULL;
@@ -17754,11 +17758,12 @@ void socket_stop(ErlNifEnv* env, void* obj, int fd, int is_direct_call)
if (descP->sock != INVALID_SOCKET) {
if (descP->closeLocal) {
+
if (!is_direct_call) {
/* +++ send close message to the waiting process +++ */
- esock_send_close_msg(env, descP);
+ esock_send_close_msg(env, descP, sockRef);
DEMONP("socket_stop -> closer", env, descP, &descP->closerMon);
@@ -17768,7 +17773,11 @@ void socket_stop(ErlNifEnv* env, void* obj, int fd, int is_direct_call)
* since the message send takes care of it if scheduled.
*/
- if (descP->closeEnv != NULL) enif_free_env(descP->closeEnv);
+ if (descP->closeEnv != NULL) {
+ enif_clear_env(descP->closeEnv);
+ enif_free_env(descP->closeEnv);
+ descP->closeEnv = NULL;
+ }
}
}
diff --git a/erts/emulator/nifs/common/socket_util.c b/erts/emulator/nifs/common/socket_util.c
index b817ae7636..5e18355308 100644
--- a/erts/emulator/nifs/common/socket_util.c
+++ b/erts/emulator/nifs/common/socket_util.c
@@ -51,8 +51,12 @@
extern char* erl_errno_id(int error); /* THIS IS JUST TEMPORARY??? */
+#if defined(CLOCK_REALTIME)
static int realtime(struct timespec* tsP);
-static int timespec2str(char *buf, unsigned int len, struct timespec *ts);
+static int timespec2str(char *buf,
+ unsigned int len,
+ struct timespec *ts);
+#endif
static char* make_sockaddr_in4(ErlNifEnv* env,
ERL_NIF_TERM port,
@@ -1506,39 +1510,46 @@ void esock_warning_msg( const char* format, ... )
{
va_list args;
char f[512 + sizeof(format)]; // This has to suffice...
+#if defined(CLOCK_REALTIME)
char stamp[64]; // Just in case...
struct timespec ts;
+#endif
int res;
/*
- * We should really include self in the printout, so we can se which process
- * are executing the code. But then I must change the API....
- * ....something for later.
+ * We should really include self in the printout,
+ * so we can se which process are executing the code.
+ * But then I must change the API....something for later.
*/
// 2018-06-29 12:13:21.232089
// 29-Jun-2018::13:47:25.097097
-
- if (!realtime(&ts)) {
- if (timespec2str(stamp, sizeof(stamp), &ts) != 0) {
- res = enif_snprintf(f, sizeof(f), "=WARNING MSG==== %s", format);
- } else {
- res = enif_snprintf(f, sizeof(f),
- "=WARNING MSG==== %s ===\r\n%s" , stamp, format);
- }
- if (res > 0) {
+#if defined(CLOCK_REALTIME)
+ if (!realtime(&ts) &&
+ (timespec2str(stamp, sizeof(stamp), &ts) == 0)) {
+ res = enif_snprintf(f, sizeof(f),
+ "=WARNING MSG==== %s ===\r\n%s",
+ stamp, format);
+ } else {
+ res = enif_snprintf(f, sizeof(f), "=WARNING MSG==== %s", format);
+ }
+#else
+ res = enif_snprintf(f, sizeof(f), "=WARNING MSG==== %s", format);
+#endif
+
+ if (res > 0) {
va_start (args, format);
enif_vfprintf (stdout, f, args);
va_end (args);
fflush(stdout);
- }
}
return;
}
+#if defined(CLOCK_REALTIME)
static
int realtime(struct timespec* tsP)
{
@@ -1574,6 +1585,7 @@ int timespec2str(char *buf, unsigned int len, struct timespec *ts)
return 0;
}
+#endif
/* =================================================================== *
diff --git a/erts/emulator/test/nif_SUITE.erl b/erts/emulator/test/nif_SUITE.erl
index 2309f844b9..62b7f77a52 100644
--- a/erts/emulator/test/nif_SUITE.erl
+++ b/erts/emulator/test/nif_SUITE.erl
@@ -1223,7 +1223,7 @@ maps(Config) when is_list(Config) ->
repeat_while(fun({35,_}) -> false;
({K,Map}) ->
Map = maps_from_list_nif(maps:to_list(Map)),
- Map = maps:filter(fun(K,V) -> V =:= K*100 end, Map),
+ Map = maps:filter(fun(K2,V) -> V =:= K2*100 end, Map),
{K+1, maps:put(K,K*100,Map)}
end,
{1,#{}}),
@@ -1294,24 +1294,29 @@ resource_hugo_do(Type) ->
release_resource(HugoPtr),
erlang:garbage_collect(),
{HugoPtr,HugoBin} = get_resource(Type,Hugo),
- Pid = spawn_link(fun() ->
- receive {Pid, Type, Resource, Ptr, Bin} ->
- Pid ! {self(), got_it},
- receive {Pid, check_it} ->
- {Ptr,Bin} = get_resource(Type,Resource),
- Pid ! {self(), ok}
- end
- end
- end),
+ {Pid,_} =
+ spawn_monitor(fun() ->
+ receive {Pid, Type, Resource, Ptr, Bin} ->
+ Pid ! {self(), got_it},
+ receive {Pid, check_it} ->
+ {Ptr,Bin} = get_resource(Type,Resource)
+ end
+ end,
+ gc_and_exit(ok)
+ end),
Pid ! {self(), Type, Hugo, HugoPtr, HugoBin},
{Pid, got_it} = receive_any(),
erlang:garbage_collect(), % just to make our ProcBin move in memory
Pid ! {self(), check_it},
- {Pid, ok} = receive_any(),
+ {'DOWN', _, process, Pid, ok} = receive_any(),
[] = last_resource_dtor_call(),
{HugoPtr,HugoBin} = get_resource(Type,Hugo),
{HugoPtr, HugoBin, 1}.
+gc_and_exit(Reason) ->
+ erlang:garbage_collect(),
+ exit(Reason).
+
resource_otto(Type) ->
{OttoPtr, OttoBin} = resource_otto_do(Type),
erlang:garbage_collect(),
@@ -1388,14 +1393,14 @@ resource_binary_do() ->
ResInfo = {Ptr,_} = get_resource(binary_resource_type,ResBin1),
Papa = self(),
- Forwarder = spawn_link(fun() -> forwarder(Papa) end),
+ {Forwarder,_} = spawn_monitor(fun() -> forwarder(Papa) end),
io:format("sending to forwarder pid=~p\n",[Forwarder]),
Forwarder ! ResBin1,
ResBin2 = receive_any(),
ResBin2 = ResBin1,
ResInfo = get_resource(binary_resource_type,ResBin2),
Forwarder ! terminate,
- {Forwarder, 1} = receive_any(),
+ {'DOWN', _, process, Forwarder, 1} = receive_any(),
erlang:garbage_collect(),
ResInfo = get_resource(binary_resource_type,ResBin1),
ResInfo = get_resource(binary_resource_type,ResBin2),
@@ -1915,11 +1920,11 @@ send2_do1(SendBlobF) ->
send2_do2(SendBlobF, self()),
Papa = self(),
- Forwarder = spawn_link(fun() -> forwarder(Papa) end),
+ {Forwarder,_} = spawn_monitor(fun() -> forwarder(Papa) end),
io:format("sending to forwarder pid=~p\n",[Forwarder]),
send2_do2(SendBlobF, Forwarder),
Forwarder ! terminate,
- {Forwarder, 4} = receive_any(),
+ {'DOWN', _, process, Forwarder, 4} = receive_any(),
ok.
send2_do2(SendBlobF, To) ->
@@ -1975,7 +1980,7 @@ forwarder(To) ->
forwarder(To, N) ->
case receive_any() of
terminate ->
- To ! {self(), N};
+ gc_and_exit(N);
Msg ->
To ! Msg,
forwarder(To, N+1)
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl
index 8a32efcd85..2e3f40a350 100644
--- a/erts/emulator/test/socket_SUITE.erl
+++ b/erts/emulator/test/socket_SUITE.erl
@@ -3404,7 +3404,9 @@ api_to_connect_tcp4(suite) ->
api_to_connect_tcp4(doc) ->
[];
api_to_connect_tcp4(_Config) when is_list(_Config) ->
+ Cond = fun() -> api_to_connect_cond() end,
tc_try(api_to_connect_tcp4,
+ Cond,
fun() ->
?TT(?SECS(10)),
InitState = #{domain => inet,
@@ -3414,6 +3416,41 @@ api_to_connect_tcp4(_Config) when is_list(_Config) ->
ok = api_to_connect_tcp(InitState)
end).
+api_to_connect_cond() ->
+ api_to_connect_cond(os:type(), os:version()).
+
+%% I don't know exactly at which version this starts to work.
+%% I know it does not work for 4.4.*, but is does for 4.15.
+%% So, just to simplify, we require atleast 4.15
+api_to_connect_cond({unix, linux}, {Maj, Min, _Rev}) ->
+ if
+ ((Maj >= 4) andalso (Min >= 15)) ->
+ ok;
+ true ->
+ skip("TC does not work")
+ end;
+%% Only test on one machine, which has version 6.3, and there it does
+%% not work, so disable for all.
+api_to_connect_cond({unix, openbsd}, _) ->
+ skip("TC does not work");
+api_to_connect_cond({unix, freebsd}, {Maj, Min, _Rev}) ->
+ if
+ ((Maj >= 10) andalso (Min >= 4)) ->
+ ok;
+ true ->
+ skip("TC may not work")
+ end;
+api_to_connect_cond({unix, sunos}, {Maj, Min, _Rev}) ->
+ if
+ ((Maj >= 5) andalso (Min >= 10)) ->
+ ok;
+ true ->
+ skip("TC may not work")
+ end;
+api_to_connect_cond(_, _) ->
+ skip("TC may not work").
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -3425,8 +3462,8 @@ api_to_connect_tcp6(doc) ->
[];
api_to_connect_tcp6(_Config) when is_list(_Config) ->
tc_try(api_to_connect_tcp6,
+ fun() -> has_support_ipv6(), api_to_connect_cond() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
InitState = #{domain => inet6,
backlog => 1,
@@ -3937,8 +3974,8 @@ api_to_accept_tcp6(doc) ->
[];
api_to_accept_tcp6(_Config) when is_list(_Config) ->
tc_try(api_to_accept_tcp4,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
InitState = #{domain => inet6, timeout => 5000},
ok = api_to_accept_tcp(InitState)
@@ -4053,8 +4090,8 @@ api_to_maccept_tcp6(doc) ->
api_to_maccept_tcp6(_Config) when is_list(_Config) ->
?TT(?SECS(20)),
tc_try(api_to_maccept_tcp4,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
InitState = #{domain => inet6, timeout => 5000},
ok = api_to_maccept_tcp(InitState)
end).
@@ -4556,8 +4593,8 @@ api_to_recv_tcp6(doc) ->
[];
api_to_recv_tcp6(_Config) when is_list(_Config) ->
tc_try(api_to_recv_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
case socket:supports(ipv6) of
true ->
?TT(?SECS(10)),
@@ -4915,8 +4952,8 @@ api_to_recvfrom_udp6(doc) ->
[];
api_to_recvfrom_udp6(_Config) when is_list(_Config) ->
tc_try(api_to_recvfrom_udp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
Recv = fun(Sock, To) -> socket:recvfrom(Sock, 0, To) end,
InitState = #{domain => inet6,
@@ -5031,8 +5068,8 @@ api_to_recvmsg_udp6(doc) ->
[];
api_to_recvmsg_udp6(_Config) when is_list(_Config) ->
tc_try(api_to_recvmsg_udp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
Recv = fun(Sock, To) -> socket:recvmsg(Sock, To) end,
InitState = #{domain => inet6,
@@ -5072,8 +5109,8 @@ api_to_recvmsg_tcp6(doc) ->
[];
api_to_recvmsg_tcp6(_Config) when is_list(_Config) ->
tc_try(api_to_recvmsg_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
Recv = fun(Sock, To) -> socket:recvmsg(Sock, To) end,
InitState = #{domain => inet6,
@@ -5104,7 +5141,6 @@ sc_cpe_socket_cleanup_tcp4(doc) ->
sc_cpe_socket_cleanup_tcp4(_Config) when is_list(_Config) ->
tc_try(sc_cpe_socket_cleanup_tcp4,
fun() ->
- %% not_yet_implemented(),
?TT(?SECS(5)),
InitState = #{domain => inet,
type => stream,
@@ -5124,8 +5160,8 @@ sc_cpe_socket_cleanup_tcp6(doc) ->
[];
sc_cpe_socket_cleanup_tcp6(_Config) when is_list(_Config) ->
tc_try(sc_cpe_socket_cleanup_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(5)),
InitState = #{domain => inet6,
type => stream,
@@ -5166,8 +5202,8 @@ sc_cpe_socket_cleanup_udp6(doc) ->
[];
sc_cpe_socket_cleanup_udp6(_Config) when is_list(_Config) ->
tc_try(sc_cpe_socket_cleanup_udp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(5)),
InitState = #{domain => inet6,
type => dgram,
@@ -5342,8 +5378,8 @@ sc_lc_recv_response_tcp6(doc) ->
[];
sc_lc_recv_response_tcp6(_Config) when is_list(_Config) ->
tc_try(sc_lc_recv_response_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
Recv = fun(Sock) -> socket:recv(Sock) end,
InitState = #{domain => inet6,
@@ -5958,8 +5994,8 @@ sc_lc_recvfrom_response_udp6(doc) ->
[];
sc_lc_recvfrom_response_udp6(_Config) when is_list(_Config) ->
tc_try(sc_lc_recvfrom_response_udp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(30)),
Recv = fun(Sock, To) -> socket:recvfrom(Sock, [], To) end,
InitState = #{domain => inet6,
@@ -6378,8 +6414,8 @@ sc_lc_recvmsg_response_tcp6(doc) ->
[];
sc_lc_recvmsg_response_tcp6(_Config) when is_list(_Config) ->
tc_try(sc_recvmsg_response_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
Recv = fun(Sock) -> socket:recvmsg(Sock) end,
InitState = #{domain => inet6,
@@ -6421,8 +6457,8 @@ sc_lc_recvmsg_response_udp6(doc) ->
[];
sc_lc_recvmsg_response_udp6(_Config) when is_list(_Config) ->
tc_try(sc_recvmsg_response_udp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
Recv = fun(Sock, To) -> socket:recvmsg(Sock, To) end,
InitState = #{domain => inet6,
@@ -6467,8 +6503,8 @@ sc_lc_acceptor_response_tcp6(doc) ->
[];
sc_lc_acceptor_response_tcp6(_Config) when is_list(_Config) ->
tc_try(sc_lc_acceptor_response_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
InitState = #{domain => inet,
type => stream,
@@ -6902,8 +6938,8 @@ sc_rc_recv_response_tcp6(doc) ->
[];
sc_rc_recv_response_tcp6(_Config) when is_list(_Config) ->
tc_try(sc_rc_recv_response_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
Recv = fun(Sock) -> socket:recv(Sock) end,
InitState = #{domain => inet6,
@@ -7783,8 +7819,8 @@ sc_rc_recvmsg_response_tcp6(doc) ->
[];
sc_rc_recvmsg_response_tcp6(_Config) when is_list(_Config) ->
tc_try(sc_rc_recvmsg_response_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
Recv = fun(Sock) -> socket:recvmsg(Sock) end,
InitState = #{domain => inet6,
@@ -7843,8 +7879,8 @@ sc_rs_recv_send_shutdown_receive_tcp6(doc) ->
[];
sc_rs_recv_send_shutdown_receive_tcp6(_Config) when is_list(_Config) ->
tc_try(sc_rs_recv_send_shutdown_receive_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
MsgData = ?DATA,
Recv = fun(Sock) ->
@@ -8667,8 +8703,8 @@ sc_rs_recvmsg_send_shutdown_receive_tcp6(doc) ->
[];
sc_rs_recvmsg_send_shutdown_receive_tcp6(_Config) when is_list(_Config) ->
tc_try(sc_rs_recvmsg_send_shutdown_receive_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(10)),
MsgData = ?DATA,
Recv = fun(Sock) ->
@@ -8728,8 +8764,8 @@ traffic_send_and_recv_chunks_tcp6(doc) ->
[];
traffic_send_and_recv_chunks_tcp6(_Config) when is_list(_Config) ->
tc_try(traffic_send_and_recv_chunks_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(30)),
InitState = #{domain => inet6},
ok = traffic_send_and_recv_chunks_tcp(InitState)
@@ -9730,8 +9766,8 @@ traffic_ping_pong_small_send_and_recv_tcp6(_Config) when is_list(_Config) ->
Msg = l2b(?TPP_SMALL),
Num = ?TPP_SMALL_NUM,
tc_try(traffic_ping_pong_small_send_and_recv_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(15)),
InitState = #{domain => inet6,
msg => Msg,
@@ -9783,8 +9819,8 @@ traffic_ping_pong_medium_send_and_recv_tcp6(_Config) when is_list(_Config) ->
Msg = l2b(?TPP_MEDIUM),
Num = ?TPP_MEDIUM_NUM,
tc_try(traffic_ping_pong_medium_send_and_recv_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(30)),
InitState = #{domain => inet6,
msg => Msg,
@@ -9837,8 +9873,8 @@ traffic_ping_pong_large_send_and_recv_tcp6(_Config) when is_list(_Config) ->
Msg = l2b(?TPP_LARGE),
Num = ?TPP_LARGE_NUM,
tc_try(traffic_ping_pong_large_send_and_recv_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(45)),
InitState = #{domain => inet6,
msg => Msg,
@@ -9944,8 +9980,8 @@ traffic_ping_pong_medium_sendto_and_recvfrom_udp6(_Config) when is_list(_Config)
Msg = l2b(?TPP_MEDIUM),
Num = ?TPP_MEDIUM_NUM,
tc_try(traffic_ping_pong_medium_sendto_and_recvfrom_udp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(45)),
InitState = #{domain => inet6,
msg => Msg,
@@ -9998,8 +10034,8 @@ traffic_ping_pong_small_sendmsg_and_recvmsg_tcp6(_Config) when is_list(_Config)
Msg = l2b(?TPP_SMALL),
Num = ?TPP_SMALL_NUM,
tc_try(traffic_ping_pong_small_sendmsg_and_recvmsg_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(20)),
InitState = #{domain => inet6,
msg => Msg,
@@ -10051,8 +10087,8 @@ traffic_ping_pong_medium_sendmsg_and_recvmsg_tcp6(_Config) when is_list(_Config)
Msg = l2b(?TPP_MEDIUM),
Num = ?TPP_MEDIUM_NUM,
tc_try(traffic_ping_pong_medium_sendmsg_and_recvmsg_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(20)),
InitState = #{domain => ine6,
msg => Msg,
@@ -10104,8 +10140,8 @@ traffic_ping_pong_large_sendmsg_and_recvmsg_tcp6(_Config) when is_list(_Config)
Msg = l2b(?TPP_LARGE),
Num = ?TPP_LARGE_NUM,
tc_try(traffic_ping_pong_large_sendmsg_and_recvmsg_tcp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(30)),
InitState = #{domain => inet6,
msg => Msg,
@@ -10158,8 +10194,8 @@ traffic_ping_pong_small_sendmsg_and_recvmsg_udp6(_Config) when is_list(_Config)
Msg = l2b(?TPP_SMALL),
Num = ?TPP_SMALL_NUM,
tc_try(traffic_ping_pong_small_sendmsg_and_recvmsg_udp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(20)),
InitState = #{domain => inet,
msg => Msg,
@@ -10211,8 +10247,8 @@ traffic_ping_pong_medium_sendmsg_and_recvmsg_udp6(_Config) when is_list(_Config)
Msg = l2b(?TPP_MEDIUM),
Num = ?TPP_MEDIUM_NUM,
tc_try(traffic_ping_pong_medium_sendmsg_and_recvmsg_udp6,
+ fun() -> has_support_ipv6() end,
fun() ->
- not_yet_implemented(),
?TT(?SECS(20)),
InitState = #{domain => ine6,
msg => Msg,
@@ -17172,17 +17208,17 @@ convert_time(TStrRev, Convert) ->
?TTEST_RUNTIME
end.
-ttest_tcp(TC,
- Domain,
- ServerMod, ServerActive,
- ClientMod, ClientActive,
- MsgID, MaxOutstanding) ->
- ttest_tcp(TC,
- ?TTEST_RUNTIME,
- Domain,
- ServerMod, ServerActive,
- ClientMod, ClientActive,
- MsgID, MaxOutstanding).
+%% ttest_tcp(TC,
+%% Domain,
+%% ServerMod, ServerActive,
+%% ClientMod, ClientActive,
+%% MsgID, MaxOutstanding) ->
+%% ttest_tcp(TC,
+%% ?TTEST_RUNTIME,
+%% Domain,
+%% ServerMod, ServerActive,
+%% ClientMod, ClientActive,
+%% MsgID, MaxOutstanding).
ttest_tcp(TC,
Runtime,
Domain,
@@ -17191,7 +17227,12 @@ ttest_tcp(TC,
MsgID, MaxOutstanding) ->
tc_try(TC,
fun() ->
- if (Domain =/= inet) -> not_yet_implemented(); true -> ok end,
+ if
+ (Domain =/= inet) -> has_support_ipv6();
+ true -> ok
+ end
+ end,
+ fun() ->
%% This may be overkill, depending on the runtime,
%% but better safe then sorry...
?TT(Runtime + ?SECS(60)),
@@ -17833,6 +17874,18 @@ which_addr2(Domain, [_|IFO]) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Here are all the *general* test vase condition functions.
+
+%% The idea is that this function shall test if the test host has
+%% support for IPv6. If not there is no point in running IPv6 tests.
+%% Currently we just skip.
+has_support_ipv6() ->
+ not_yet_implemented().
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
not_yet_implemented() ->
skip("not yet implemented").
@@ -17886,15 +17939,45 @@ tc_end(Result) when is_list(Result) ->
"", "----------------------------------------------------~n~n"),
ok.
-
-tc_try(Case, Fun) when is_atom(Case) andalso is_function(Fun, 0) ->
+%% *** tc_try/2,3 ***
+%% Case: Basically the test case name
+%% TCCondFun: A fun that is evaluated before the actual test case
+%% The point of this is that it can performs checks to
+%% see if we shall run the test case at all.
+%% For instance, the test case may only work in specific
+%% conditions.
+%% FCFun: The test case fun
+tc_try(Case, TCFun) ->
+ TCCondFun = fun() -> ok end,
+ tc_try(Case, TCCondFun, TCFun).
+
+tc_try(Case, TCCondFun, TCFun)
+ when is_atom(Case) andalso
+ is_function(TCCondFun, 0) andalso
+ is_function(TCFun, 0) ->
tc_begin(Case),
- try
- begin
- Fun(),
- ?SLEEP(?SECS(1)),
- tc_end("ok")
- end
+ try TCCondFun() of
+ ok ->
+ try
+ begin
+ TCFun(),
+ ?SLEEP(?SECS(1)),
+ tc_end("ok")
+ end
+ catch
+ throw:{skip, _} = SKIP ->
+ tc_end("skipping"),
+ SKIP;
+ Class:Error:Stack ->
+ tc_end("failed"),
+ erlang:raise(Class, Error, Stack)
+ end;
+ {skip, _} = SKIP ->
+ tc_end("skipping"),
+ SKIP;
+ {error, Reason} ->
+ tc_end("failed"),
+ exit({tc_cond_failed, Reason})
catch
throw:{skip, _} = SKIP ->
tc_end("skipping"),