diff options
Diffstat (limited to 'lib/jinterface/test/nc_SUITE.erl')
-rw-r--r-- | lib/jinterface/test/nc_SUITE.erl | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/lib/jinterface/test/nc_SUITE.erl b/lib/jinterface/test/nc_SUITE.erl index c5f3198c21..81944f71d4 100644 --- a/lib/jinterface/test/nc_SUITE.erl +++ b/lib/jinterface/test/nc_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2013. All Rights Reserved. +%% Copyright Ericsson AB 2004-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ -include_lib("common_test/include/ct.hrl"). --include("test_server_line.hrl"). -define(VERSION_MAGIC, 131). @@ -32,6 +31,10 @@ -define(NEW_REFERENCE_EXT, 114). -define(ATOM_UTF8_EXT, 118). -define(SMALL_ATOM_UTF8_EXT, 119). +-define(NEW_PID_EXT, $X). +-define(NEW_PORT_EXT, $Y). +-define(NEWER_REFERENCE_EXT, $Z). + -export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2, init_per_suite/1, @@ -124,12 +127,13 @@ pid_roundtrip(doc) -> []; pid_roundtrip(suite) -> []; pid_roundtrip(Config) when is_list(Config)-> ThisNode = {node(), erlang:system_info(creation)}, - RemNode = {gurka@sallad, 2}, + RemPids = [mk_pid({gurka@sallad, Cr}, Num, Ser) + || Cr <- [1,2,3,4,16#adec0ded], + {Num, Ser} <- [{4711,4711},{32767, 8191}]], do_echo([self(), mk_pid(ThisNode, 4711, 4711), - mk_pid(ThisNode, 32767, 8191), - mk_pid(RemNode, 4711, 4711), - mk_pid(RemNode, 32767, 8191)], + mk_pid(ThisNode, 32767, 8191) + | RemPids], Config). fun_roundtrip(doc) -> []; @@ -145,26 +149,29 @@ port_roundtrip(doc) -> []; port_roundtrip(suite) -> []; port_roundtrip(Config) when is_list(Config)-> ThisNode = {node(), erlang:system_info(creation)}, - RemNode = {gurka@sallad, 2}, + RemPorts = [mk_port({gurka@sallad, Cr}, Num) + || Cr <- [1,2,3,4,16#adec0ded], + Num <- [4711, 268435455]], do_echo([hd(erlang:ports()), mk_port(ThisNode, 4711), - mk_port(ThisNode, 268435455), - mk_port(RemNode, 4711), - mk_port(RemNode, 268435455)], + mk_port(ThisNode, 268435455) + | RemPorts], Config). ref_roundtrip(doc) -> []; ref_roundtrip(suite) -> []; ref_roundtrip(Config) when is_list(Config)-> ThisNode = {node(), erlang:system_info(creation)}, - RemNode = {gurka@sallad, 2}, + RemRefs = [mk_ref({gurka@sallad, Cr}, Words) + || Cr <- [1,2,3,4,16#adec0ded], + Words <- [[4711], + [4711, 4711, 4711], + [262143, 4294967295, 4294967295]]], do_echo([make_ref(), mk_ref(ThisNode, [4711]), mk_ref(ThisNode, [4711, 4711, 4711]), - mk_ref(ThisNode, [262143, 4294967295, 4294967295]), - mk_ref(RemNode, [4711]), - mk_ref(RemNode, [4711, 4711, 4711]), - mk_ref(RemNode, [262143, 4294967295, 4294967295])], + mk_ref(ThisNode, [262143, 4294967295, 4294967295]) + | RemRefs], Config). new_float(doc) -> []; @@ -760,17 +767,22 @@ uint8(Uint) -> exit({badarg, uint8, [Uint]}). +pid_tag(Creation) when Creation =< 3 -> ?PID_EXT; +pid_tag(_Creation) -> ?NEW_PID_EXT. + +enc_creation(Creation) when Creation =< 3 -> uint8(Creation); +enc_creation(Creation) -> uint32_be(Creation). mk_pid({NodeName, Creation}, Number, Serial) when is_atom(NodeName) -> <<?VERSION_MAGIC, NodeNameExt/binary>> = term_to_binary(NodeName), mk_pid({NodeNameExt, Creation}, Number, Serial); mk_pid({NodeNameExt, Creation}, Number, Serial) -> case catch binary_to_term(list_to_binary([?VERSION_MAGIC, - ?PID_EXT, + pid_tag(Creation), NodeNameExt, uint32_be(Number), uint32_be(Serial), - uint8(Creation)])) of + enc_creation(Creation)])) of Pid when is_pid(Pid) -> Pid; {'EXIT', {badarg, _}} -> @@ -779,15 +791,18 @@ mk_pid({NodeNameExt, Creation}, Number, Serial) -> exit({unexpected_binary_to_term_result, Other}) end. +port_tag(Creation) when Creation =< 3 -> ?PORT_EXT; +port_tag(_Creation) -> ?NEW_PORT_EXT. + mk_port({NodeName, Creation}, Number) when is_atom(NodeName) -> <<?VERSION_MAGIC, NodeNameExt/binary>> = term_to_binary(NodeName), mk_port({NodeNameExt, Creation}, Number); mk_port({NodeNameExt, Creation}, Number) -> case catch binary_to_term(list_to_binary([?VERSION_MAGIC, - ?PORT_EXT, + port_tag(Creation), NodeNameExt, uint32_be(Number), - uint8(Creation)])) of + enc_creation(Creation)])) of Port when is_port(Port) -> Port; {'EXIT', {badarg, _}} -> @@ -796,12 +811,16 @@ mk_port({NodeNameExt, Creation}, Number) -> exit({unexpected_binary_to_term_result, Other}) end. +ref_tag(Creation) when Creation =< 3 -> ?NEW_REFERENCE_EXT; +ref_tag(_Creation) -> ?NEWER_REFERENCE_EXT. + mk_ref({NodeName, Creation}, [Number] = NL) when is_atom(NodeName), is_integer(Creation), is_integer(Number) -> <<?VERSION_MAGIC, NodeNameExt/binary>> = term_to_binary(NodeName), mk_ref({NodeNameExt, Creation}, NL); mk_ref({NodeNameExt, Creation}, [Number]) when is_integer(Creation), + Creation =< 3, is_integer(Number) -> case catch binary_to_term(list_to_binary([?VERSION_MAGIC, ?REFERENCE_EXT, @@ -823,10 +842,10 @@ mk_ref({NodeName, Creation}, Numbers) when is_atom(NodeName), mk_ref({NodeNameExt, Creation}, Numbers) when is_integer(Creation), is_list(Numbers) -> case catch binary_to_term(list_to_binary([?VERSION_MAGIC, - ?NEW_REFERENCE_EXT, + ref_tag(Creation), uint16_be(length(Numbers)), NodeNameExt, - uint8(Creation), + enc_creation(Creation), lists:map(fun (N) -> uint32_be(N) end, |