diff options
74 files changed, 1564 insertions, 1057 deletions
diff --git a/erts/doc/src/erl.xml b/erts/doc/src/erl.xml index 27a23174d5..4aa3033f40 100644 --- a/erts/doc/src/erl.xml +++ b/erts/doc/src/erl.xml @@ -535,12 +535,15 @@ </item> <tag><marker id="file_name_encoding"></marker><c><![CDATA[+fnl]]></c></tag> <item> - <p>The VM works with file names as if they are encoded using the ISO-latin-1 encoding, disallowing Unicode characters with codepoints beyond 255. This is default on operating systems that have transparent file naming, i.e. all Unixes except MacOSX.</p> + <p>The VM works with file names as if they are encoded using the ISO-latin-1 encoding, disallowing Unicode characters with codepoints beyond 255.</p> <p>See <seealso marker="stdlib:unicode_usage#unicode_file_names">STDLIB User's Guide</seealso> for more infomation about unicode file names.</p> </item> <tag><c><![CDATA[+fnu[{w|i|e}]]]></c></tag> <item> - <p>The VM works with file names as if they are encoded using UTF-8 (or some other system specific Unicode encoding). This is the default on operating systems that enforce Unicode encoding, i.e. Windows and MacOSX.</p> + <p>The VM works with file names as if they are encoded using + UTF-8 (or some other system specific Unicode encoding). This + is the default on operating systems that enforce Unicode + encoding, i.e. Windows and MacOS X.</p> <p>The <c>+fnu</c> switch can be followed by <c>w</c>, <c>i</c>, or <c>e</c> to control the way wrongly encoded file names are to be reported. <c>w</c> means that a warning is @@ -556,7 +559,12 @@ </item> <tag><c><![CDATA[+fna[{w|i|e}]]]></c></tag> <item> - <p>Selection between <c>+fnl</c> and <c>+fnu</c> is done based on the current locale settings in the OS, meaning that if you have set your terminal for UTF-8 encoding, the filesystem is expected to use the same encoding for file names (use with care).</p> + <p>Selection between <c>+fnl</c> and <c>+fnu</c> is done based + on the current locale settings in the OS, meaning that if you + have set your terminal for UTF-8 encoding, the filesystem is + expected to use the same encoding for file names. This is + default on all operating systems except MacOS X and + Windows.</p> <p>The <c>+fna</c> switch can be followed by <c>w</c>, <c>i</c>, or <c>e</c>. This will have effect if the locale settings cause the behavior of <c>+fnu</c> to be selected. diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in index 54365f279c..f88a4ccc24 100644 --- a/erts/emulator/Makefile.in +++ b/erts/emulator/Makefile.in @@ -665,7 +665,6 @@ endif ifneq ($(filter tile-%,$(TARGET)),) $(OBJDIR)/beam_emu.o: beam/beam_emu.c $(V_CC) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) \ - -OPT:Olimit=0 -WOPT:lpre=off:spre=off:epre=off \ $(INCLUDES) -c $< -o $@ else # Usually the same as the default rule, but certain platforms (e.g. win32) mix diff --git a/erts/emulator/drivers/common/efile_drv.c b/erts/emulator/drivers/common/efile_drv.c index dca979c13a..e040864d24 100644 --- a/erts/emulator/drivers/common/efile_drv.c +++ b/erts/emulator/drivers/common/efile_drv.c @@ -167,7 +167,7 @@ dt_private *get_dt_private(int); #ifdef USE_THREADS -#define IF_THRDS if (sys_info.async_threads > 0) +#define THRDS_AVAILABLE (sys_info.async_threads > 0) #ifdef HARDDEBUG /* HARDDEBUG in io.c is expected too */ #define TRACE_DRIVER fprintf(stderr, "Efile: ") #else @@ -177,24 +177,26 @@ dt_private *get_dt_private(int); #define MUTEX_LOCK(m) do { IF_THRDS { TRACE_DRIVER; driver_pdl_lock(m); } } while (0) #define MUTEX_UNLOCK(m) do { IF_THRDS { TRACE_DRIVER; driver_pdl_unlock(m); } } while (0) #else -#define IF_THRDS if (0) +#define THRDS_AVAILABLE (0) #define MUTEX_INIT(m, p) #define MUTEX_LOCK(m) #define MUTEX_UNLOCK(m) #endif +#define IF_THRDS if (THRDS_AVAILABLE) +#define SENDFILE_FLGS_USE_THREADS (1 << 0) /** * On DARWIN sendfile can deadlock with close if called in * different threads. So until Apple fixes so that sendfile * is not buggy we disable usage of the async pool for * DARWIN. The testcase t_sendfile_crashduring reproduces - * this error when using +A 10. + * this error when using +A 10 and enabling SENDFILE_FLGS_USE_THREADS. */ #if defined(__APPLE__) && defined(__MACH__) -#define USE_THRDS_FOR_SENDFILE 0 +#define USE_THRDS_FOR_SENDFILE(DATA) 0 #else -#define USE_THRDS_FOR_SENDFILE (sys_info.async_threads > 0) +#define USE_THRDS_FOR_SENDFILE(DATA) (DATA->flags & SENDFILE_FLGS_USE_THREADS) #endif /* defined(__APPLE__) && defined(__MACH__) */ @@ -300,7 +302,7 @@ static void file_stop_select(ErlDrvEvent event, void* _); enum e_timer {timer_idle, timer_again, timer_write}; #ifdef HAVE_SENDFILE enum e_sendfile {sending, not_sending}; -static void free_sendfile(void *data); +#define SENDFILE_USE_THREADS (1 << 0) #endif /* HAVE_SENDFILE */ struct t_data; @@ -1932,7 +1934,7 @@ static void invoke_sendfile(void *data) d->c.sendfile.written += nbytes; - if (result == 1 || (result == 0 && USE_THRDS_FOR_SENDFILE)) { + if (result == 1 || (result == 0 && USE_THRDS_FOR_SENDFILE(d))) { d->result_ok = 0; } else if (result == 0 && (d->errInfo.posix_errno == EAGAIN || d->errInfo.posix_errno == EINTR)) { @@ -1949,7 +1951,7 @@ static void invoke_sendfile(void *data) static void free_sendfile(void *data) { struct t_data *d = (struct t_data *)data; - if (USE_THRDS_FOR_SENDFILE) { + if (USE_THRDS_FOR_SENDFILE(d)) { SET_NONBLOCKING(d->c.sendfile.out_fd); } else { MUTEX_LOCK(d->c.sendfile.q_mtx); @@ -4122,8 +4124,16 @@ file_outputv(ErlDrvData e, ErlIOVec *ev) { goto done; } - if (hd_len != 0 || tl_len != 0 || flags != 0) { - /* We do not allow header, trailers and/or flags right now */ + if (hd_len != 0 || tl_len != 0) { + /* We do not allow header, trailers */ + reply_posix_error(desc, EINVAL); + goto done; + } + + + if (flags & SENDFILE_FLGS_USE_THREADS && !THRDS_AVAILABLE) { + /* We do not allow use_threads flag on a system where + no threads are available. */ reply_posix_error(desc, EINVAL); goto done; } @@ -4133,6 +4143,7 @@ file_outputv(ErlDrvData e, ErlIOVec *ev) { d->command = command; d->invoke = invoke_sendfile; d->free = free_sendfile; + d->flags = flags; d->level = 2; d->c.sendfile.out_fd = (int) out_fd; @@ -4152,7 +4163,7 @@ file_outputv(ErlDrvData e, ErlIOVec *ev) { d->c.sendfile.nbytes = nbytes; - if (USE_THRDS_FOR_SENDFILE) { + if (USE_THRDS_FOR_SENDFILE(d)) { SET_BLOCKING(d->c.sendfile.out_fd); } else { /** diff --git a/erts/emulator/sys/common/erl_sys_common_misc.c b/erts/emulator/sys/common/erl_sys_common_misc.c index 31ad3b82d5..e3ba741058 100644 --- a/erts/emulator/sys/common/erl_sys_common_misc.c +++ b/erts/emulator/sys/common/erl_sys_common_misc.c @@ -52,7 +52,7 @@ static int filename_warning = ERL_FILENAME_WARNING_WARNING; /* Default unicode on windows and MacOS X */ static int user_filename_encoding = ERL_FILENAME_UTF8; #else -static int user_filename_encoding = ERL_FILENAME_LATIN1; +static int user_filename_encoding = ERL_FILENAME_UNKNOWN; #endif /* This controls the heuristic in printing characters in shell and w/ io:format("~tp", ...) etc. */ diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c index 59e34eb819..a5294ad84e 100644 --- a/erts/emulator/sys/unix/sys.c +++ b/erts/emulator/sys/unix/sys.c @@ -409,8 +409,10 @@ void sys_tty_reset(int exit_code) #ifdef __tile__ /* Direct malloc to spread memory around the caches of multiple tiles. */ #include <malloc.h> +#if defined(MALLOC_USE_HASH) MALLOC_USE_HASH(1); #endif +#endif #ifdef USE_THREADS diff --git a/erts/preloaded/ebin/prim_file.beam b/erts/preloaded/ebin/prim_file.beam Binary files differindex d5a1ec766d..e40e33b332 100644 --- a/erts/preloaded/ebin/prim_file.beam +++ b/erts/preloaded/ebin/prim_file.beam diff --git a/erts/preloaded/src/prim_file.erl b/erts/preloaded/src/prim_file.erl index 5999e98340..34679404a2 100644 --- a/erts/preloaded/src/prim_file.erl +++ b/erts/preloaded/src/prim_file.erl @@ -27,7 +27,7 @@ %% Generic file contents operations -export([open/2, close/1, datasync/1, sync/1, advise/4, position/2, truncate/1, write/2, pwrite/2, pwrite/3, read/2, read_line/1, pread/2, pread/3, - copy/3, sendfile/10, allocate/3]). + copy/3, sendfile/8, allocate/3]). %% Specialized file operations -export([open/1, open/3]). @@ -149,6 +149,9 @@ -define(POSIX_FADV_DONTNEED, 4). -define(POSIX_FADV_NOREUSE, 5). +%% Sendfile flags +-define(EFILE_SENDFILE_USE_THREADS, 1). + %%% BIFs @@ -582,13 +585,14 @@ write_file(_, _) -> % {error, enotsup}; sendfile(#file_descriptor{module = ?MODULE, data = {Port, _}}, Dest, Offset, Bytes, _ChunkSize, Headers, Trailers, - _Nodiskio, _MNowait, _Sync) -> + Flags) -> case erlang:port_get_data(Dest) of Data when Data == inet_tcp; Data == inet6_tcp -> ok = inet:lock_socket(Dest,true), {ok, DestFD} = prim_inet:getfd(Dest), + IntFlags = translate_sendfile_flags(Flags), try drv_command(Port, [<<?FILE_SENDFILE, DestFD:32, - 0:8, + IntFlags:8, Offset:64/unsigned, Bytes:64/unsigned, (iolist_size(Headers)):32/unsigned, @@ -601,6 +605,13 @@ sendfile(#file_descriptor{module = ?MODULE, data = {Port, _}}, {error,badarg} end. +translate_sendfile_flags([{use_threads,true}|T]) -> + ?EFILE_SENDFILE_USE_THREADS bor translate_sendfile_flags(T); +translate_sendfile_flags([_|T]) -> + translate_sendfile_flags(T); +translate_sendfile_flags([]) -> + 0. + %%%----------------------------------------------------------------- %%% Functions operating on files without handle to the file. ?DRV. diff --git a/erts/vsn.mk b/erts/vsn.mk index 8e77a9a26e..88a393f3d5 100644 --- a/erts/vsn.mk +++ b/erts/vsn.mk @@ -22,7 +22,7 @@ VSN = 6.0 # OTP major version SYSTEM_VSN = 17 # OTP correction package version -SYSTEM_CP_VSN = 17.0-rc0 +SYSTEM_CP_VSN = 17.0-rc1 # Port number 4365 in 4.2 # Port number 4366 in 4.3 diff --git a/lib/asn1/doc/src/asn1_ug.xml b/lib/asn1/doc/src/asn1_ug.xml index 74c4aa9948..eb9f000e75 100644 --- a/lib/asn1/doc/src/asn1_ug.xml +++ b/lib/asn1/doc/src/asn1_ug.xml @@ -653,7 +653,7 @@ Day1 = saturday, Bits1 ::= BIT STRING Bits2 ::= BIT STRING {foo(0),bar(1),gnu(2),gnome(3),punk(14)} </pre> - <p>There are five different notations available for representation of + <p>There are two notations available for representation of BIT STRING values in Erlang and as input to the encode functions.</p> <list type="ordered"> <item>A bitstring. By default, a BIT STRING with no @@ -661,43 +661,10 @@ Bits2 ::= BIT STRING {foo(0),bar(1),gnu(2),gnome(3),punk(14)} <item>A list of atoms corresponding to atoms in the <c>NamedBitList</c> in the BIT STRING definition. A BIT STRING with symbolic names will always be decoded to this format.</item> - <item>A list of binary digits (0 or 1). This format is always - accepted as input to the encode functions. A BIT STRING will - be decoded to this format if <em>legacy_bit_string</em> option - has been given. <em>This format may be withdrawn in a future - release.</em> - </item> - <item>As <c>{Unused,Binary}</c> where <c>Unused</c> denotes how - many trailing zero-bits 0 to 7 that are unused in the least - significant byte in <c>Binary</c>. This format is always - accepted as input to the encode functions. A BIT STRING will - be decoded to this format if <em>compact_bit_string</em> has - been given. <em>This format may be withdrawn in a future - release.</em> - </item> - <item>A hexadecimal number (or an integer). This format should be - avoided, since it is easy to misinterpret a <c>BIT STRING</c> - value in this format. <em>This format may be withdrawn in a future - release.</em> - </item> </list> - <note> - <p>It is recommended to either use the bitstring format (for - BIT STRINGs with no symbolic names) or a list of symbolic - names (for BIT STRINGs with symbolic names). The other formats - should be avoided since they may be withdrawn in a future - release. - </p> - </note> + <p>Example:</p> <pre> Bits1Val1 = <<0:1,1:1,0:1,1:1,1:1>>, -Bits1Val2 = 16#1A, -Bits1Val3 = {3,<<0:1,1:1,0:1,1:1,1:1,0:3>>}, -Bits1Val4 = [0,1,0,1,1] - </pre> - <p>Note that <c>Bits1Val1</c>, <c>Bits1Val2</c>, <c>Bits1Val3</c>, - and <c>Bits1Val1</c> denote the same value.</p> - <pre> Bits2Val1 = [gnu,punk], Bits2Val2 = <<2#1110:4>>, Bits2Val3 = [bar,gnu,gnome], @@ -708,37 +675,60 @@ Bits2Val3 = [bar,gnu,gnome], 2 and 14 are set to 1 and the rest set to 0. The symbolic values appear as a list of values. If a named value appears, which is not specified in the type definition, a run-time error will occur.</p> - <p>The compact notation equivalent to the empty BIT STRING is - <c><![CDATA[{0,<<>>}]]></c>, which in the other notations is - <c><![CDATA[<<>>]]></c>, <c>[]</c>, or - <c>0</c>.</p> <p>BIT STRINGS may also be sub-typed with, for example, a SIZE specification:</p> <pre> Bits3 ::= BIT STRING (SIZE(0..31)) </pre> <p>This means that no bit higher than 31 can ever be set.</p> + + <section> + <title>Deprecated representations for BIT STRING</title> + <p>In addition to the representations described above, the + following deprecated representations are available if the + specification has been compiled with the + <c>legacy_erlang_types</c> option:</p> + <list type="ordered"> + <item>A list of binary digits (0 or 1). This format is + accepted as input to the encode functions, and a BIT STRING + will be decoded to this format if the + <em>legacy_bit_string</em> option has been given. + </item> + <item>As <c>{Unused,Binary}</c> where <c>Unused</c> denotes + how many trailing zero-bits 0 to 7 that are unused in the + least significant byte in <c>Binary</c>. This format is + accepted as input to the encode functions, and a <c>BIT + STRING</c> will be decoded to this format if + <em>compact_bit_string</em> has been given. + </item> + <item>A hexadecimal number (or an integer). This format + should be avoided, since it is easy to misinterpret a BIT + STRING value in this format. + </item> + </list> + </section> </section> <section> <marker id="OCTET STRING"></marker> <title>OCTET STRING</title> - <p>The OCTET STRING is the simplest of all ASN.1 types The OCTET STRING - only moves or transfers e.g. binary files or other unstructured - information complying to two rules. - Firstly, the bytes consist of octets and secondly, encoding is - not required.</p> + <p>The OCTET STRING is the simplest of all ASN.1 types. The + OCTET STRING only moves or transfers e.g. binary files or other + unstructured information complying to two rules. Firstly, the + bytes consist of octets and secondly, encoding is not + required.</p> <p>It is possible to have the following ASN.1 type definitions:</p> <pre> O1 ::= OCTET STRING O2 ::= OCTET STRING (SIZE(28)) </pre> <p>With the following example assignments in Erlang:</p> <pre> -O1Val = [17,13,19,20,0,0,255,254], -O2Val = "must be exactly 28 chars....", </pre> - <p>Observe that <c>O1Val</c> is assigned a series of numbers between 0 - and 255 i.e. octets. - <c>O2Val</c> is assigned using the string notation. - </p> +O1Val = <<17,13,19,20,0,0,255,254>>, +O2Val = <<"must be exactly 28 chars....">>,</pre> + <p>By default, an OCTET STRING is always represented as + an Erlang binary. If the specification has been compiled with + the <c>legacy_erlang_types</c> option, the encode functions + will accept both lists and binaries, and the decode functions + will decode an OCTET STRING to a list.</p> </section> <section> diff --git a/lib/asn1/doc/src/asn1ct.xml b/lib/asn1/doc/src/asn1ct.xml index ada2aace87..5871c8ad68 100644 --- a/lib/asn1/doc/src/asn1ct.xml +++ b/lib/asn1/doc/src/asn1ct.xml @@ -42,6 +42,17 @@ can be used in during development of applications which handles ASN.1 data (encoded as BER or PER).</p> <note> + <p>By default in OTP 17, the representation of the BIT STRING + and OCTET STRING types as Erlang terms have changed. BIT + STRING values are now Erlang bitstrings and OCTET STRING values + are binaries. For details see <seealso + marker="asn1_ug#BIT STRING">BIT STRING</seealso> and <seealso + marker="asn1_ug#OCTET STRING">OCTET STRING</seealso> in User's + Guide.</p> + <p>To revert to the old representation of the types, use the + <c>legacy_erlang_types</c> option.</p> + </note> + <note> <p>In R16, the options have been simplified. The back-end is chosen using one of the options <c>ber</c>, <c>per</c>, or <c>uper</c>. The options <c>optimize</c>, <c>nif</c>, and <c>driver</c> options @@ -64,7 +75,7 @@ <v>Asn1module = atom() | string()</v> <v>Options = [Option| OldOption]</v> <v>Option = ber | per | uper | der | compact_bit_string | - legacy_bit_string | + legacy_bit_string | legacy_erlang_types | noobj | {n2n, EnumTypeName} |{outdir, Dir} | {i, IncludeDir} | asn1config | undec_rest | no_ok_wrapper | {macro_name_prefix, Prefix} | {record_name_prefix, Prefix} | verbose | warnings_as_errors</v> @@ -163,6 +174,7 @@ File3.asn </pre> BIT STRING type section in the Users Guide </seealso>. </p> + <p>This option implies the <c>legacy_erlang_types</c> option.</p> </item> <tag><c>legacy_bit_string</c></tag> <item> @@ -175,8 +187,19 @@ File3.asn </pre> <seealso marker="asn1_ug#BIT STRING"> BIT STRING type section in the Users Guide </seealso>. + <p>This option implies the <c>legacy_erlang_types</c> option.</p> </p> </item> + <tag><c>legacy_erlang_types</c></tag> + <item> + <p>Use the same Erlang types to represent BIT STRING and + OCTET STRING as in R16. For details see <seealso + marker="asn1_ug#BIT STRING">BIT STRING</seealso> and + <seealso marker="asn1_ug#OCTET STRING">OCTET + STRING</seealso> in User's Guide.</p> + <p><em>This option is not recommended for + new code.</em></p> + </item> <tag><c>{n2n, EnumTypeName}</c></tag> <item> <p> diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl index f2e9606ccb..531a4935fe 100644 --- a/lib/asn1/src/asn1ct.erl +++ b/lib/asn1/src/asn1ct.erl @@ -40,7 +40,7 @@ maybe_rename_function/3,current_sindex/0, set_current_sindex/1,maybe_saved_sindex/2, parse_and_save/2,verbose/3,warning/3,warning/4,error/3]). --export([get_bit_string_format/0]). +-export([get_bit_string_format/0,use_legacy_types/0]). -include("asn1_records.hrl"). -include_lib("stdlib/include/erl_compile.hrl"). @@ -841,6 +841,7 @@ delete_double_of_symbol1([],Acc) -> generate({M,GenTOrV}, OutFile, EncodingRule, Options) -> debug_on(Options), setup_bit_string_format(Options), + setup_legacy_erlang_types(Options), put(encoding_options,Options), asn1ct_table:new(check_functions), @@ -869,6 +870,31 @@ generate({M,GenTOrV}, OutFile, EncodingRule, Options) -> asn1ct_table:delete(check_functions), Result. +setup_legacy_erlang_types(Opts) -> + F = case lists:member(legacy_erlang_types, Opts) of + false -> + case get_bit_string_format() of + bitstring -> + false; + compact -> + legacy_forced_info(compact_bit_string), + true; + legacy -> + legacy_forced_info(legacy_bit_string), + true + end; + true -> + true + end, + put(use_legacy_erlang_types, F). + +legacy_forced_info(Opt) -> + io:format("Info: The option 'legacy_erlang_types' " + "is implied by the '~s' option.\n", [Opt]). + +use_legacy_types() -> + get(use_legacy_erlang_types). + setup_bit_string_format(Opts) -> Format = case {lists:member(compact_bit_string, Opts), lists:member(legacy_bit_string, Opts)} of @@ -1075,6 +1101,7 @@ remove_asn_flags(Options) -> X /= optimize, X /= compact_bit_string, X /= legacy_bit_string, + X /= legacy_erlang_types, X /= debug, X /= asn1config, X /= record_name_prefix]. diff --git a/lib/asn1/src/asn1ct_check.erl b/lib/asn1/src/asn1ct_check.erl index 0a13801e08..f94f3b56bc 100644 --- a/lib/asn1/src/asn1ct_check.erl +++ b/lib/asn1/src/asn1ct_check.erl @@ -2574,6 +2574,18 @@ normalize_bitstring(S, Value, Type)-> Bs end. +hstring_to_binary(L) -> + byte_align(hstring_to_bitstring(L)). + +bstring_to_binary(L) -> + byte_align(bstring_to_bitstring(L)). + +byte_align(Bs) -> + case bit_size(Bs) rem 8 of + 0 -> Bs; + N -> <<Bs/bitstring,0:(8-N)>> + end. + hstring_to_bitstring(L) -> << <<(hex_to_int(D)):4>> || D <- L >>. @@ -2592,9 +2604,9 @@ hex_to_int(D) when $A =< D, D =< $F -> D - ($A - 10). normalize_octetstring(S,Value,CType) -> case Value of {bstring,String} -> - bstring_to_octetlist(String); + bstring_to_binary(String); {hstring,String} -> - hstring_to_octetlist(String); + hstring_to_binary(String); Rec when is_record(Rec,'Externalvaluereference') -> get_normalized_value(S,Value,CType, fun normalize_octetstring/3,[]); @@ -2616,35 +2628,6 @@ normalize_octetstring(S,Value,CType) -> Value end. - -bstring_to_octetlist([]) -> - []; -bstring_to_octetlist([H|T]) when H == $0 ; H == $1 -> - bstring_to_octetlist(T,6,[(H - $0) bsl 7]). -bstring_to_octetlist([H|T],0,[Hacc|Tacc]) when H == $0; H == $1 -> - bstring_to_octetlist(T, 7, [0,Hacc + (H -$0)| Tacc]); -bstring_to_octetlist([H|T],BSL,[Hacc|Tacc]) when H == $0; H == $1 -> - bstring_to_octetlist(T, BSL-1, [Hacc + ((H - $0) bsl BSL)| Tacc]); -bstring_to_octetlist([],7,[0|Acc]) -> - lists:reverse(Acc); -bstring_to_octetlist([],_,Acc) -> - lists:reverse(Acc). - -hstring_to_octetlist([]) -> - []; -hstring_to_octetlist(L) -> - hstring_to_octetlist(L,4,[]). -hstring_to_octetlist([H|T],0,[Hacc|Tacc]) when H >= $A, H =< $F -> - hstring_to_octetlist(T,4,[Hacc + (H - $A + 10)|Tacc]); -hstring_to_octetlist([H|T],BSL,Acc) when H >= $A, H =< $F -> - hstring_to_octetlist(T,0,[(H - $A + 10) bsl BSL|Acc]); -hstring_to_octetlist([H|T],0,[Hacc|Tacc]) when H >= $0; H =< $9 -> - hstring_to_octetlist(T,4,[Hacc + (H - $0)|Tacc]); -hstring_to_octetlist([H|T],BSL,Acc) when H >= $0; H =< $9 -> - hstring_to_octetlist(T,0,[(H - $0) bsl BSL|Acc]); -hstring_to_octetlist([],_,Acc) -> - lists:reverse(Acc). - normalize_objectidentifier(S, Value) -> {ok,Val} = validate_objectidentifier(S, o_id, Value, []), Val. diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl index c224f4c9fa..ed3f6f886e 100644 --- a/lib/asn1/src/asn1ct_constructed_per.erl +++ b/lib/asn1/src/asn1ct_constructed_per.erl @@ -450,8 +450,13 @@ dec_objset_default(N, C, LeadingAttr, false) -> "{value,Bytes}," "{unique_name_and_value,",{asis,LeadingAttr},",Id}}}).",nl,nl]); dec_objset_default(N, _, _, true) -> - emit([{asis,N},"(Bytes, Id) ->",nl, - "Bytes.",nl,nl]). + emit([{asis,N},"(Bytes, Id) ->",nl| + case asn1ct:use_legacy_types() of + false -> + ["{asn1_OPENTYPE,Bytes}.",nl,nl]; + true -> + ["Bytes.",nl,nl] + end]). dec_objset_1(Erule, N, {Id,Obj}, RestFields, Typename) -> emit([{asis,N},"(Bytes, ",{asis,Id},") ->",nl]), @@ -906,26 +911,36 @@ def_values(#type{def=#'Externaltypereference'{module=Mod,type=Type}}, Def) -> #typedef{typespec=T} = asn1_db:dbget(Mod, Type), def_values(T, Def); def_values(#type{def={'BIT STRING',[]}}, Bs) when is_bitstring(Bs) -> - ListBs = [B || <<B:1>> <= Bs], - IntBs = lists:foldl(fun(B, A) -> - (A bsl 1) bor B - end, 0, lists:reverse(ListBs)), - Sz = bit_size(Bs), - Compact = case 8 - Sz rem 8 of - 8 -> - {0,Bs}; - Unused -> - {Unused,<<Bs:Sz/bits,0:Unused>>} - end, - [asn1_DEFAULT,Bs,Compact,ListBs,IntBs]; + case asn1ct:use_legacy_types() of + false -> + [asn1_DEFAULT,Bs]; + true -> + ListBs = [B || <<B:1>> <= Bs], + IntBs = lists:foldl(fun(B, A) -> + (A bsl 1) bor B + end, 0, lists:reverse(ListBs)), + Sz = bit_size(Bs), + Compact = case 8 - Sz rem 8 of + 8 -> + {0,Bs}; + Unused -> + {Unused,<<Bs:Sz/bits,0:Unused>>} + end, + [asn1_DEFAULT,Bs,Compact,ListBs,IntBs] + end; def_values(#type{def={'BIT STRING',[_|_]=Ns}}, List) when is_list(List) -> Bs = asn1ct_gen:named_bitstring_value(List, Ns), - ListBs = [B || <<B:1>> <= Bs], - IntBs = lists:foldl(fun(B, A) -> - (A bsl 1) bor B - end, 0, lists:reverse(ListBs)), - Args = [List,Bs,ListBs,IntBs], - {call,per_common,is_default_bitstring,Args}; + As = case asn1ct:use_legacy_types() of + false -> + [List,Bs]; + true -> + ListBs = [B || <<B:1>> <= Bs], + IntBs = lists:foldl(fun(B, A) -> + (A bsl 1) bor B + end, 0, lists:reverse(ListBs)), + [List,Bs,ListBs,IntBs] + end, + {call,per_common,is_default_bitstring,As}; def_values(#type{def={'INTEGER',Ns}}, Def) -> [asn1_DEFAULT,Def|case lists:keyfind(Def, 2, Ns) of false -> []; @@ -1059,8 +1074,17 @@ enc_objset_imm(Erule, Component, ObjSet, RestFieldNames, Extensible) -> enc_obj(Erule, Obj, RestFieldNames, Aligned)] || {Key,Obj} <- ObjSet] ++ [['_',case Extensible of - false -> E; - true -> {put_bits,{var,"Val"},binary,[1]} + false -> + E; + true -> + case asn1ct:use_legacy_types() of + false -> + {call,per_common,open_type_to_binary, + [{var,"Val"}]}; + true -> + {call,per_common,legacy_open_type_to_binary, + [{var,"Val"}]} + end end]]}]. enc_obj(Erule, Obj, RestFieldNames0, Aligned) -> diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl index 37b33194d0..71d870b4ce 100644 --- a/lib/asn1/src/asn1ct_gen.erl +++ b/lib/asn1/src/asn1ct_gen.erl @@ -790,7 +790,8 @@ gen_decode_constructed(Erules,Typename,InnerType,D) when is_record(D,typedef) -> pgen_exports(Erules,_Module,{Types,Values,_,_,Objects,ObjectSets}) -> - emit(["-export([encoding_rule/0,bit_string_format/0]).",nl]), + emit(["-export([encoding_rule/0,bit_string_format/0," + " legacy_erlang_types/0]).",nl]), case Types of [] -> ok; _ -> @@ -1022,7 +1023,9 @@ gen_info_functions(Erules) -> emit(["encoding_rule() -> ", {asis,Erules},".",nl,nl, "bit_string_format() -> ", - {asis,asn1ct:get_bit_string_format()},".",nl,nl]). + {asis,asn1ct:get_bit_string_format()},".",nl,nl, + "legacy_erlang_types() -> ", + {asis,asn1ct:use_legacy_types()},".",nl,nl]). gen_decode_partial_incomplete(ber) -> case {asn1ct:read_config_data(partial_incomplete_decode), diff --git a/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl b/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl index de81259fcb..bea0ec8968 100644 --- a/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl +++ b/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl @@ -206,10 +206,32 @@ gen_encode_prim(_Erules, #type{}=D, DoTag, Value) -> {call,ber,encode_tags, [DoTag,{curr,realval},{curr,realsize}]},nl, "end"]); + {'BIT STRING',[]} -> + case asn1ct:use_legacy_types() of + false when BitStringConstraint =:= [] -> + call(encode_unnamed_bit_string, [Value,DoTag]); + false -> + call(encode_unnamed_bit_string, + [{asis,BitStringConstraint},Value,DoTag]); + true -> + call(encode_bit_string, + [{asis,BitStringConstraint},Value, + {asis,[]},DoTag]) + end; {'BIT STRING',NamedNumberList} -> - call(encode_bit_string, - [{asis,BitStringConstraint},Value, - {asis,NamedNumberList},DoTag]); + case asn1ct:use_legacy_types() of + false when BitStringConstraint =:= [] -> + call(encode_named_bit_string, + [Value,{asis,NamedNumberList},DoTag]); + false -> + call(encode_named_bit_string, + [{asis,BitStringConstraint},Value, + {asis,NamedNumberList},DoTag]); + true -> + call(encode_bit_string, + [{asis,BitStringConstraint},Value, + {asis,NamedNumberList},DoTag]) + end; 'NULL' -> call(encode_null, [Value,DoTag]); 'OBJECT IDENTIFIER' -> @@ -471,7 +493,6 @@ gen_dec_prim(_Erules, Att, BytesVar, DoTag, _TagIn, _Form, _OptOrMand) -> _ -> "" end, NewTypeName = case Typename of - 'OCTET STRING' -> restricted_string; 'NumericString' -> restricted_string; 'TeletexString' -> restricted_string; 'T61String' -> restricted_string; @@ -529,6 +550,19 @@ gen_dec_prim(_Erules, Att, BytesVar, DoTag, _TagIn, _Form, _OptOrMand) -> 'RELATIVE-OID' -> emit(["decode_relative_oid(",BytesVar,","]), need(decode_relative_oid, 2); + 'OCTET STRING' -> + F = case asn1ct:use_legacy_types() of + false -> decode_octet_string; + true -> decode_restricted_string + end, + emit([{asis,F},"(",BytesVar,","]), + case Constraint of + [] -> + need(F, 2); + _ -> + emit([{asis,Constraint},","]), + need(F, 3) + end; restricted_string -> emit(["decode_restricted_string",AsBin,"(",BytesVar,","]), case Constraint of @@ -1090,13 +1124,11 @@ gen_objset_enc(Erules, ObjSetName, UniqueName, %% See X.681 Annex E for the following case gen_objset_enc(_,ObjSetName,_UniqueName,['EXTENSIONMARK'],_ClName, _ClFields,_NthObj,Acc) -> - emit(["'getenc_",ObjSetName,"'(_) ->",nl]), - emit({indent(3),"fun(_, Val, _RestPrimFieldName) ->",nl}), - emit({indent(6),"Len = case Val of",nl,indent(9), - "Bin when is_binary(Bin) -> byte_size(Bin);",nl,indent(9), - "_ -> length(Val)",nl,indent(6),"end,"}), - emit({indent(6),"{Val,Len}",nl}), - emit({indent(3),"end.",nl,nl}), + emit(["'getenc_",ObjSetName,"'(_) ->",nl, + indent(2),"fun(_, Val, _RestPrimFieldName) ->",nl]), + emit_enc_open_type(4), + emit([nl, + indent(2),"end.",nl,nl]), Acc; gen_objset_enc(_, ObjSetName, UniqueName, [], _, _, _, Acc) -> emit_default_getenc(ObjSetName, UniqueName), @@ -1158,13 +1190,8 @@ gen_inlined_enc_funs1(Fields, [{typefield,Name,_}|Rest], ObjSetName, %% were no type in the table and we therefore generate %% code that returns the input for application %% treatment. - emit([indent(9),{asis,Name}," ->",nl, - indent(12),"Len = case Val of",nl, - indent(15),"Bin when is_binary(Bin) -> " - "byte_size(Bin);",nl, - indent(15),"_ -> length(Val)",nl, - indent(12),"end,",nl, - indent(12),"{Val,Len}"]), + emit([indent(9),{asis,Name}," ->",nl]), + emit_enc_open_type(11), {Acc0,0} end, gen_inlined_enc_funs1(Fields, Rest, ObjSetName, Sep, NthObj+NAdd, Acc); @@ -1175,6 +1202,25 @@ gen_inlined_enc_funs1(_, [], _, _, NthObj, Acc) -> indent(3),"end"]), {Acc,NthObj}. +emit_enc_open_type(I) -> + Indent = indent(I), + S = [Indent, "case Val of",nl, + Indent,indent(2),"{asn1_OPENTYPE,Bin} when is_binary(Bin) ->",nl, + Indent,indent(4),"{Bin,byte_size(Bin)}"| + case asn1ct:use_legacy_types() of + false -> + [nl, + Indent,"end"]; + true -> + [";",nl, + Indent,indent(2),"Bin when is_binary(Bin) ->",nl, + Indent,indent(4),"{Bin,byte_size(Bin)};",nl, + Indent,indent(2),"_ ->",nl, + Indent,indent(4),"{Val,length(Val)}",nl, + Indent, "end"] + end], + emit(S). + emit_inner_of_fun(TDef=#typedef{name={ExtMod,Name},typespec=Type}, InternalDefFunName) -> OTag = Type#type.tag, @@ -1258,14 +1304,9 @@ gen_objset_dec(_,ObjSetName,_UniqueName,['EXTENSIONMARK'],_ClName, _ClFields,_NthObj) -> emit(["'getdec_",ObjSetName,"'(_) ->",nl]), emit([indent(2),"fun(_,Bytes, _RestPrimFieldName) ->",nl]), - - emit([indent(4),"case Bytes of",nl, - indent(6),"Bin when is_binary(Bin) -> ",nl, - indent(8),"Bin;",nl, - indent(6),"_ ->",nl, - indent(8),{call,ber,ber_encode,["Bytes"]},nl, - indent(4),"end",nl]), - emit([indent(2),"end.",nl,nl]), + emit_dec_open_type(4), + emit([nl, + indent(2),"end.",nl,nl]), ok; gen_objset_dec(_, ObjSetName, UniqueName, [], _, _, _) -> emit_default_getdec(ObjSetName, UniqueName), @@ -1312,12 +1353,8 @@ gen_inlined_dec_funs1(Fields, [{typefield,Name,Prop}|Rest], end, 0; false -> - emit([indent(9),{asis,Name}," ->",nl, - indent(12),"Len = case Bytes of",nl, - indent(15),"B when is_binary(B) -> byte_size(B);",nl, - indent(15),"_ -> length(Bytes)",nl, - indent(12),"end,",nl, - indent(12),"{Bytes,[],Len}"]), + emit([indent(9),{asis,Name}," ->",nl]), + emit_dec_open_type(11), 0 end, gen_inlined_dec_funs1(Fields, Rest, ObjSetName, Sep, NthObj+N); @@ -1328,6 +1365,27 @@ gen_inlined_dec_funs1(_, [], _, _, NthObj) -> indent(3),"end"]), NthObj. +emit_dec_open_type(I) -> + Indent = indent(I), + S = case asn1ct:use_legacy_types() of + false -> + [Indent, "case Bytes of",nl, + Indent,indent(2),"Bin when is_binary(Bin) -> ",nl, + Indent,indent(4),"{asn1_OPENTYPE,Bin};",nl, + Indent,indent(2),"_ ->",nl, + Indent,indent(4),"{asn1_OPENTYPE,", + {call,ber,ber_encode,["Bytes"]},"}",nl, + Indent, "end"]; + true -> + [Indent, "case Bytes of",nl, + Indent,indent(2),"Bin when is_binary(Bin) -> ",nl, + Indent,indent(4),"Bin;",nl, + Indent,indent(2),"_ ->",nl, + Indent,indent(4),{call,ber,ber_encode,["Bytes"]},nl, + Indent, "end"] + end, + emit(S). + emit_inner_of_decfun(#typedef{name={ExtName,Name},typespec=Type},Prop, InternalDefFunName) -> OTag = Type#type.tag, diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl index 7ba649c874..519ce9f054 100644 --- a/lib/asn1/src/asn1ct_gen_per.erl +++ b/lib/asn1/src/asn1ct_gen_per.erl @@ -132,7 +132,14 @@ gen_encode_prim_imm(Val, #type{def=Type0,constraint=Constraint}, Aligned) -> ToBinary = {real_common,encode_real}, asn1ct_imm:per_enc_restricted_string(Val, ToBinary, Aligned); {'BIT STRING',NNL} -> - asn1ct_imm:per_enc_bit_string(Val, NNL, Constraint, Aligned); + case asn1ct:use_legacy_types() of + false -> + asn1ct_imm:per_enc_bit_string(Val, NNL, + Constraint, Aligned); + true -> + asn1ct_imm:per_enc_legacy_bit_string(Val, NNL, + Constraint, Aligned) + end; 'NULL' -> asn1ct_imm:per_enc_null(Val, Aligned); 'OBJECT IDENTIFIER' -> @@ -144,7 +151,13 @@ gen_encode_prim_imm(Val, #type{def=Type0,constraint=Constraint}, Aligned) -> 'BOOLEAN' -> asn1ct_imm:per_enc_boolean(Val, Aligned); 'OCTET STRING' -> - asn1ct_imm:per_enc_octet_string(Val, Constraint, Aligned); + case asn1ct:use_legacy_types() of + false -> + asn1ct_imm:per_enc_octet_string(Val, Constraint, Aligned); + true -> + asn1ct_imm:per_enc_legacy_octet_string(Val, Constraint, + Aligned) + end; 'ASN1_OPEN_TYPE' -> case Constraint of [#'Externaltypereference'{type=Tname}] -> @@ -325,7 +338,10 @@ gen_dec_imm_1('GeneralizedTime', Constraint, Aligned) -> gen_dec_imm_1('OCTET STRING', Constraint, Aligned) -> SzConstr = asn1ct_imm:effective_constraint(bitstring, Constraint), Imm = asn1ct_imm:per_dec_octet_string(SzConstr, Aligned), - {convert,binary_to_list,Imm}; + case asn1ct:use_legacy_types() of + false -> {convert,{binary,copy},Imm}; + true -> {convert,binary_to_list,Imm} + end; gen_dec_imm_1('TeletexString', _Constraint, Aligned) -> gen_dec_restricted_string(Aligned); gen_dec_imm_1('T61String', _Constraint, Aligned) -> diff --git a/lib/asn1/src/asn1ct_imm.erl b/lib/asn1/src/asn1ct_imm.erl index c14f0b889f..fde39c674e 100644 --- a/lib/asn1/src/asn1ct_imm.erl +++ b/lib/asn1/src/asn1ct_imm.erl @@ -26,11 +26,13 @@ per_dec_octet_string/2,per_dec_open_type/1,per_dec_real/1, per_dec_restricted_string/1]). -export([per_dec_constrained/3,per_dec_normally_small_number/1]). --export([per_enc_bit_string/4,per_enc_boolean/2, +-export([per_enc_bit_string/4,per_enc_legacy_bit_string/4, + per_enc_boolean/2, per_enc_choice/3,per_enc_enumerated/3, per_enc_integer/3,per_enc_integer/4, per_enc_null/2, per_enc_k_m_string/4,per_enc_octet_string/3, + per_enc_legacy_octet_string/3, per_enc_open_type/2, per_enc_restricted_string/3, per_enc_small_number/2]). @@ -157,7 +159,35 @@ per_dec_restricted_string(Aligned) -> %%% Encoding. %%% -per_enc_bit_string(Val0, [], Constraint0, Aligned) -> +per_enc_bit_string(Val, [], Constraint0, Aligned) -> + {B,[[],Bits]} = mk_vars([], [bits]), + Constraint = effective_constraint(bitstring, Constraint0), + B ++ [{call,erlang,bit_size,[Val],Bits}| + per_enc_length(Val, 1, Bits, Constraint, Aligned, 'BIT STRING')]; +per_enc_bit_string(Val0, NNL0, Constraint0, Aligned) -> + {B,[Val,Bs,Bits,Positions]} = mk_vars(Val0, [bs,bits,positions]), + NNL = lists:keysort(2, NNL0), + Constraint = effective_constraint(bitstring, Constraint0), + ExtraArgs = case constr_min_size(Constraint) of + no -> []; + Lb -> [Lb] + end, + ToBs = case ExtraArgs of + [] -> + {call,per_common,bs_drop_trailing_zeroes,[Val]}; + [Lower] -> + {call,per_common,adjust_trailing_zeroes,[Val,Lower]} + end, + B ++ [{'try', + [bit_string_name2pos_fun(NNL, Val)], + {Positions, + [{call,per_common,bitstring_from_positions, + [Positions|ExtraArgs]}]}, + [ToBs],Bs}, + {call,erlang,bit_size,[Bs],Bits}| + per_enc_length(Bs, 1, Bits, Constraint, Aligned, 'BIT STRING')]. + +per_enc_legacy_bit_string(Val0, [], Constraint0, Aligned) -> {B,[Val,Bs,Bits]} = mk_vars(Val0, [bs,bits]), Constraint = effective_constraint(bitstring, Constraint0), ExtraArgs = case constr_min_size(Constraint) of @@ -167,7 +197,7 @@ per_enc_bit_string(Val0, [], Constraint0, Aligned) -> B ++ [{call,per_common,to_bitstring,[Val|ExtraArgs],Bs}, {call,erlang,bit_size,[Bs],Bits}| per_enc_length(Bs, 1, Bits, Constraint, Aligned, 'BIT STRING')]; -per_enc_bit_string(Val0, NNL0, Constraint0, Aligned) -> +per_enc_legacy_bit_string(Val0, NNL0, Constraint0, Aligned) -> {B,[Val,Bs,Bits,Positions]} = mk_vars(Val0, [bs,bits,positions]), NNL = lists:keysort(2, NNL0), Constraint = effective_constraint(bitstring, Constraint0), @@ -276,7 +306,13 @@ per_enc_open_type(Imm0, Aligned) -> {call,erlang,byte_size,[Bin],Len}| per_enc_length(Bin, 8, Len, Aligned)]. -per_enc_octet_string(Val0, Constraint0, Aligned) -> +per_enc_octet_string(Bin, Constraint0, Aligned) -> + {B,[[],Len]} = mk_vars([], [len]), + Constraint = effective_constraint(bitstring, Constraint0), + B ++ [{call,erlang,byte_size,[Bin],Len}| + per_enc_length(Bin, 8, Len, Constraint, Aligned, 'OCTET STRING')]. + +per_enc_legacy_octet_string(Val0, Constraint0, Aligned) -> {B,[Val,Bin,Len]} = mk_vars(Val0, [bin,len]), Constraint = effective_constraint(bitstring, Constraint0), B ++ [{call,erlang,iolist_to_binary,[Val],Bin}, @@ -874,6 +910,9 @@ dcg_list_outside([{call,Fun,{V,Buf},{Dst,DstBuf}}|T]) -> emit(["{",Dst,",",DstBuf,"} = "]), Fun(V, Buf), iter_dcg_list_outside(T); +dcg_list_outside([{convert,{M,F},V,Dst}|T]) -> + emit([Dst," = ",{asis,M},":",{asis,F},"(",V,")"]), + iter_dcg_list_outside(T); dcg_list_outside([{convert,Op,V,Dst}|T]) -> emit([Dst," = ",Op,"(",V,")"]), iter_dcg_list_outside(T); diff --git a/lib/asn1/src/asn1ct_value.erl b/lib/asn1/src/asn1ct_value.erl index 862b3c4ea5..a86c963b9d 100644 --- a/lib/asn1/src/asn1ct_value.erl +++ b/lib/asn1/src/asn1ct_value.erl @@ -260,7 +260,11 @@ from_type_prim(M, D) -> 'BOOLEAN' -> true; 'OCTET STRING' -> - adjust_list(size_random(C),c_string(C,"OCTET STRING")); + S0 = adjust_list(size_random(C), c_string(C, "OCTET STRING")), + case M:legacy_erlang_types() of + false -> list_to_binary(S0); + true -> S0 + end; 'NumericString' -> adjust_list(size_random(C),c_string(C,"0123456789")); 'TeletexString' -> diff --git a/lib/asn1/src/asn1rtt_ber.erl b/lib/asn1/src/asn1rtt_ber.erl index 583ff790b7..4bd814769f 100644 --- a/lib/asn1/src/asn1rtt_ber.erl +++ b/lib/asn1/src/asn1rtt_ber.erl @@ -29,6 +29,8 @@ decode_integer/2,decode_integer/3, decode_named_integer/3,decode_named_integer/4, encode_enumerated/2,decode_enumerated/3, + encode_unnamed_bit_string/2,encode_unnamed_bit_string/3, + encode_named_bit_string/3,encode_named_bit_string/4, encode_bit_string/4, decode_named_bit_string/3, decode_compact_bit_string/3, @@ -38,6 +40,7 @@ encode_relative_oid/2,decode_relative_oid/2, encode_object_identifier/2,decode_object_identifier/2, encode_restricted_string/2, + decode_octet_string/2,decode_octet_string/3, decode_restricted_string/2,decode_restricted_string/3, encode_universal_string/2,decode_universal_string/3, encode_UTF8_string/2,decode_UTF8_string/2, @@ -780,6 +783,55 @@ decode_enumerated1(Val, NamedNumberList) -> {asn1_enum,Val} end. +%%============================================================================ +%% Bitstring value, ITU_T X.690 Chapter 8.6 +%% +%% encode bitstring value +%%============================================================================ + +encode_unnamed_bit_string(Bits, TagIn) -> + Unused = (8 - (bit_size(Bits) band 7)) band 7, + Bin = <<Unused,Bits/bitstring,0:Unused>>, + encode_tags(TagIn, Bin, byte_size(Bin)). + +encode_unnamed_bit_string(C, Bits, TagIn) -> + NumBits = bit_size(Bits), + Unused = (8 - (NumBits band 7)) band 7, + Bin = <<Unused,Bits/bitstring,0:Unused>>, + case C of + {_Min,Max} -> + if + NumBits > Max -> + exit({error,{asn1, + {bitstring_length, + {{was,NumBits},{maximum,Max}}}}}); + true -> + ok + end; + Size -> + if NumBits =< Size -> + ok; + true -> + exit({error,{asn1, + {bitstring_length, + {{was,NumBits},{should_be,Size}}}}}) + end + end, + encode_tags(TagIn, Bin, byte_size(Bin)). + +encode_named_bit_string([H|_]=Bits, NamedBitList, TagIn) when is_atom(H) -> + encode_bit_string_named([], Bits, NamedBitList, TagIn); +encode_named_bit_string([{bit,_}|_]=Bits, NamedBitList, TagIn) -> + encode_bit_string_named([], Bits, NamedBitList, TagIn); +encode_named_bit_string(Bits, _NamedBitList, TagIn) when is_bitstring(Bits) -> + encode_unnamed_bit_string(Bits, TagIn). + +encode_named_bit_string(C, [H|_]=Bits, NamedBitList, TagIn) when is_atom(H) -> + encode_bit_string_named(C, Bits, NamedBitList, TagIn); +encode_named_bit_string(C, [{bit,_}|_]=Bits, NamedBitList, TagIn) -> + encode_bit_string_named(C, Bits, NamedBitList, TagIn); +encode_named_bit_string(C, Bits, _NamedBitList, TagIn) when is_bitstring(Bits) -> + encode_unnamed_bit_string(C, Bits, TagIn). %%============================================================================ %% Bitstring value, ITU_T X.690 Chapter 8.6 @@ -1251,6 +1303,19 @@ encode_restricted_string(OctetList, TagIn) when is_list(OctetList) -> encode_tags(TagIn, OctetList, length(OctetList)). %%============================================================================ +%% decode OCTET STRING to binary +%%============================================================================ + +decode_octet_string(Tlv, TagsIn) -> + Bin = match_and_collect(Tlv, TagsIn), + binary:copy(Bin). + +decode_octet_string(Tlv, Range, TagsIn) -> + Bin0 = match_and_collect(Tlv, TagsIn), + Bin = binary:copy(Bin0), + check_restricted_string(Bin, byte_size(Bin), Range). + +%%============================================================================ %% decode Numeric Printable Teletex Videotex Visible IA5 Graphic General strings %%============================================================================ diff --git a/lib/asn1/src/asn1rtt_ext.erl b/lib/asn1/src/asn1rtt_ext.erl index 46adb2007d..f3eee1cdd5 100644 --- a/lib/asn1/src/asn1rtt_ext.erl +++ b/lib/asn1/src/asn1rtt_ext.erl @@ -38,7 +38,7 @@ transform_to_EXTERNAL1990([{'context-negotiation',Context_negot}|Rest], Acc) -> transform_to_EXTERNAL1990([asn1_NOVALUE|Rest], Acc) -> transform_to_EXTERNAL1990(Rest, [asn1_NOVALUE|Acc]); transform_to_EXTERNAL1990([Data_val_desc,Data_value], Acc) - when is_list(Data_value)-> + when is_list(Data_value); is_binary(Data_value) -> list_to_tuple(lists:reverse([{'octet-aligned',Data_value}, Data_val_desc|Acc])); transform_to_EXTERNAL1990([Data_val_desc,Data_value], Acc) diff --git a/lib/asn1/src/asn1rtt_per_common.erl b/lib/asn1/src/asn1rtt_per_common.erl index 3309e6a4ca..71fec411a0 100644 --- a/lib/asn1/src/asn1rtt_per_common.erl +++ b/lib/asn1/src/asn1rtt_per_common.erl @@ -37,8 +37,10 @@ bitstring_from_positions/1,bitstring_from_positions/2, to_bitstring/1,to_bitstring/2, to_named_bitstring/1,to_named_bitstring/2, - is_default_bitstring/5, - extension_bitmap/3]). + bs_drop_trailing_zeroes/1,adjust_trailing_zeroes/2, + is_default_bitstring/3,is_default_bitstring/5, + extension_bitmap/3, + open_type_to_binary/1,legacy_open_type_to_binary/1]). -define('16K',16384). @@ -272,6 +274,25 @@ to_named_bitstring(Val, Lb) -> %% for correctness, not speed. adjust_trailing_zeroes(to_bitstring(Val), Lb). +is_default_bitstring(asn1_DEFAULT, _, _) -> + true; +is_default_bitstring(Named, Named, _) -> + true; +is_default_bitstring(Bs, _, Bs) -> + true; +is_default_bitstring(Val, _, Def) when is_bitstring(Val) -> + Sz = bit_size(Def), + case Val of + <<Def:Sz/bitstring,T/bitstring>> -> + NumZeroes = bit_size(T), + case T of + <<0:NumZeroes>> -> true; + _ -> false + end; + _ -> + false + end. + is_default_bitstring(asn1_DEFAULT, _, _, _, _) -> true; is_default_bitstring({Unused,Bin}, V0, V1, V2, V3) when is_integer(Unused) -> @@ -306,6 +327,16 @@ is_default_bitstring(_, _, _, _, _) -> false. extension_bitmap(Val, Pos, Limit) -> extension_bitmap(Val, Pos, Limit, 0). +open_type_to_binary({asn1_OPENTYPE,Bin}) when is_binary(Bin) -> + Bin. + +legacy_open_type_to_binary({asn1_OPENTYPE,Bin}) when is_binary(Bin) -> + Bin; +legacy_open_type_to_binary(Bin) when is_binary(Bin) -> + Bin; +legacy_open_type_to_binary(List) when is_list(List) -> + List. + %%% %%% Internal functions. %%% @@ -438,6 +469,8 @@ adjust_trailing_zeroes(Bs0, Lb) -> bs_drop_trailing_zeroes(Bs) -> bs_drop_trailing_zeroes(Bs, bit_size(Bs)). +bs_drop_trailing_zeroes(Bs, 0) -> + Bs; bs_drop_trailing_zeroes(Bs0, Sz0) when Sz0 < 8 -> <<Byte:Sz0>> = Bs0, Sz = Sz0 - ntz(Byte), diff --git a/lib/asn1/test/asn1_SUITE.erl b/lib/asn1/test/asn1_SUITE.erl index 83bd66a631..3b34feb5a3 100644 --- a/lib/asn1/test/asn1_SUITE.erl +++ b/lib/asn1/test/asn1_SUITE.erl @@ -328,6 +328,10 @@ testCompactBitString(Config, Rule, Opts) -> testPrimStrings(Config) -> test(Config, fun testPrimStrings/3, [ber,{ber,[der]},per,uper]). testPrimStrings(Config, Rule, Opts) -> + LegacyOpts = [legacy_erlang_types|Opts], + asn1_test_lib:compile_all(["PrimStrings", "BitStr"], Config, + [Rule|LegacyOpts]), + testPrimStrings_cases(Rule, LegacyOpts), asn1_test_lib:compile_all(["PrimStrings", "BitStr"], Config, [Rule|Opts]), testPrimStrings_cases(Rule, Opts), asn1_test_lib:compile_all(["PrimStrings", "BitStr"], Config, @@ -432,7 +436,8 @@ testDef(Config, Rule, Opts) -> testDEFAULT(Config) -> test(Config, fun testDEFAULT/3, [ber,{ber,[der]},per,uper]). testDEFAULT(Config, Rule, Opts) -> - asn1_test_lib:compile_all(["Def","Default"], Config, [Rule|Opts]), + asn1_test_lib:compile_all(["Def","Default"], Config, + [legacy_erlang_types,Rule|Opts]), testDef:main(Rule), testSeqSetDefaultVal:main(Rule, Opts). @@ -766,7 +771,10 @@ testParameterizedInfObj(Config) -> testParameterizedInfObj(Config, Rule, Opts) -> Files = ["Param","Param2"], asn1_test_lib:compile_all(Files, Config, [Rule|Opts]), - testParameterizedInfObj:main(Config, Rule). + testParameterizedInfObj:main(Config, Rule), + asn1_test_lib:compile("Param", Config, + [legacy_erlang_types,Rule|Opts]), + testParameterizedInfObj:param(Rule). testFragmented(Config) -> test(Config, fun testFragmented/3). @@ -784,7 +792,8 @@ testMergeCompile(Config, Rule, Opts) -> testobj(Config) -> test(Config, fun testobj/3). testobj(Config, Rule, Opts) -> - asn1_test_lib:compile("RANAP", Config, [Rule|Opts]), + asn1_test_lib:compile("RANAP", Config, [legacy_erlang_types, + Rule|Opts]), asn1_test_lib:compile_erlang("testobj", Config, []), ok = testobj:run(), ok = testParameterizedInfObj:ranap(Rule). @@ -811,7 +820,8 @@ testImport(Config, Rule, Opts) -> testMegaco(Config) -> test(Config, fun testMegaco/3). testMegaco(Config, Rule, Opts) -> - {ok, Module1, Module2} = testMegaco:compile(Config, Rule, Opts), + {ok, Module1, Module2} = testMegaco:compile(Config, Rule, + [legacy_erlang_types|Opts]), ok = testMegaco:main(Module1, Config), ok = testMegaco:main(Module2, Config). @@ -892,7 +902,8 @@ specialized_decodes(Config, Rule, Opts) -> "PartialDecMyHTTP.asn", "MEDIA-GATEWAY-CONTROL.asn", "P-Record"], - Config, [Rule, asn1config|Opts]), + Config, + [Rule,legacy_erlang_types,asn1config|Opts]), test_partial_incomplete_decode:test(Config), test_selective_decode:test(). @@ -1022,7 +1033,8 @@ test_x691(Config, Rule, Opts) -> test_x691:cases(Rule), %% OTP-7708. - asn1_test_lib:compile("EUTRA-extract-55", Config, [Rule|Opts]), + asn1_test_lib:compile("EUTRA-extract-55", Config, + [legacy_erlang_types,Rule|Opts]), %% OTP-7763. Val = {'Seq',15,lists:duplicate(8, 0),[0],lists:duplicate(28, 0),15,true}, @@ -1128,21 +1140,21 @@ END ok = asn1ct:compile(File, [{outdir, PrivDir}]). -timer_compile(Config, Rule, Opts) -> +timer_compile(Config, Rule) -> asn1_test_lib:compile_all(["H235-SECURITY-MESSAGES", "H323-MESSAGES"], - Config, [Rule|Opts]). + Config, [no_ok_wrapper,Rule]). testTimer_ber(Config) -> - timer_compile(Config,ber,[]), - testTimer:go(Config,ber). + timer_compile(Config, ber), + testTimer:go(). testTimer_per(Config) -> - timer_compile(Config,per,[]), - testTimer:go(Config,per). + timer_compile(Config, per), + testTimer:go(). testTimer_uper(Config) -> - timer_compile(Config,uper,[]), - {comment,_} = testTimer:go(Config,uper). + timer_compile(Config, uper), + testTimer:go(). %% Test of multiple-line comment, OTP-8043 testComment(suite) -> []; @@ -1200,8 +1212,8 @@ ticket_7407_code(FinalPadding) -> eutra1(msg) -> {'BCCH-BCH-Message', - {'MasterInformationBlock',[0,1,0,1],[1,0,1,0], - {'PHICH-Configuration',short,ffs},[1,0,1,0,0,0,0,0]}}. + {'MasterInformationBlock',<<2#0101:4>>,<<2#1010:4>>, + {'PHICH-Configuration',short,ffs},<<2#10100000>>}}. eutra1(result, true) -> <<90,80,0>>; diff --git a/lib/asn1/test/asn1_SUITE_data/TCAPPackage_msg.erl b/lib/asn1/test/asn1_SUITE_data/TCAPPackage_msg.erl index 06eba8b6eb..0bf4425263 100644 --- a/lib/asn1/test/asn1_SUITE_data/TCAPPackage_msg.erl +++ b/lib/asn1/test/asn1_SUITE_data/TCAPPackage_msg.erl @@ -47,7 +47,7 @@ val('TransactionPDU') -> dialoguePortion=val('DialoguePortion'), componentPortion=val('ComponentSequence')}; val('TransactionID') -> - "OCTET STRING"; + <<"OCTET STRING">>; val('DialoguePortion') -> #'DialoguePortion'{version=val('ProtocolVersion'), applicationContext={integerApplicationId,12}, @@ -57,23 +57,23 @@ val('DialoguePortion') -> val('Confidentiality') -> #'Confidentiality'{confidentialityId={integerConfidentialityId,14}}; val('ProtocolVersion') -> - "K"; + <<"K">>; val('UserInformation') -> [val('EXTERNAL'),val('EXTERNAL')]; val('EXTERNAL') -> #'EXTERNAL'{'direct-reference'={0,1,2}, - encoding={'single-ASN1-type',[1,2,3,4]}}; + encoding={'single-ASN1-type',<<1,2,3,4>>}}; val('ComponentSequence') -> [val('ComponentPDU',1),val('ComponentPDU',2),val('ComponentPDU',3)]; val('Invoke') -> - #'Invoke'{componentIDs="AB", + #'Invoke'{componentIDs = <<"AB">>, opcode={local,-2}, parameter=running}; val('ReturnResult') -> - #'ReturnResult'{componentID="C", + #'ReturnResult'{componentID = <<"C">>, parameter=[1,2,3,4]}; val('ReturnError') -> - #'ReturnError'{componentID="D", + #'ReturnError'{componentID = <<"D">>, errorCode={local,21}, parameter=true}; val('Abort') -> @@ -87,8 +87,8 @@ val(Type) -> check_result('PackageType',unidirectional,Res) -> {unidirectional, {'UniTransactionPDU', - "OCTET STRING", - {'DialoguePortion',"K", + <<"OCTET STRING">>, + {'DialoguePortion',<<"K">>, {integerApplicationId,12}, [_,%{'EXTERNAL',{syntax,{0,1,2}},asn1_NOVALUE,OTVal}, _],%{'EXTERNAL',{syntax,{0,1,2}},asn1_NOVALUE,OTVal}], @@ -96,14 +96,14 @@ check_result('PackageType',unidirectional,Res) -> {'Confidentiality', {integerConfidentialityId,14}}}, [{invokeLast, - {_,"AB",{local,-2},running}}, - {returnResultLast,{_,"C",_}}, - {returnError,{_,"D",{local,21},true}}]}} = Res, + {_,<<"AB">>,{local,-2},running}}, + {returnResultLast,{_,<<"C">>,_}}, + {returnError,{_,<<"D">>,{local,21},true}}]}} = Res, ok; %% check_OT_val(OTVal); check_result('PackageType',abort,Res)-> - {abort,{'Abort',"OCTET STRING", - {'DialoguePortion',"K", + {abort,{'Abort',<<"OCTET STRING">>, + {'DialoguePortion',<<"K">>, {integerApplicationId,12}, [_,%{'EXTERNAL',{syntax,{0,1,2}},asn1_NOVALUE,OTVal}, _],%{'EXTERNAL',{syntax,{0,1,2}},asn1_NOVALUE,OTVal}], @@ -114,9 +114,9 @@ check_result('PackageType',abort,Res)-> ok; %% check_OT_val(OTVal); check_result('PackageType',response,Res) -> - {response,{'TransactionPDU',"OCTET STRING", + {response,{'TransactionPDU',<<"OCTET STRING">>, {'DialoguePortion', - "K", + <<"K">>, {integerApplicationId,12}, [_,%{'EXTERNAL',{syntax,{0,1,2}},asn1_NOVALUE,OTVal}, _],%{'EXTERNAL',{syntax,{0,1,2}},asn1_NOVALUE,OTVal}], @@ -124,11 +124,11 @@ check_result('PackageType',response,Res) -> {'Confidentiality', {integerConfidentialityId,14}}}, [{invokeLast, - {_,"AB",{local,-2},running}}, + {_,<<"AB">>,{local,-2},running}}, {returnResultLast, - {_,"C",_}}, + {_,<<"C">>,_}}, {returnError, - {_,"D",{local,21},true}}]}} = Res, + {_,<<"D">>,{local,21},true}}]}} = Res, ok. %% check_OT_val(OTVal). diff --git a/lib/asn1/test/asn1_SUITE_data/extensionAdditionGroup.erl b/lib/asn1/test/asn1_SUITE_data/extensionAdditionGroup.erl index 8e21e6ca84..a1e563f6be 100644 --- a/lib/asn1/test/asn1_SUITE_data/extensionAdditionGroup.erl +++ b/lib/asn1/test/asn1_SUITE_data/extensionAdditionGroup.erl @@ -67,8 +67,8 @@ run3(Erule) -> asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE, asn1_NOVALUE,asn1_NOVALUE}, asn1_NOVALUE, - [[80,66,0,5,10,0,5,0,24,11,7,84,54,33,0,1,1,0,0,0,1,39,5,66,127,0,0,1], - []], + [<<80,66,0,5,10,0,5,0,24,11,7,84,54,33,0,1,1,0,0,0,1,39,5,66,127,0,0,1>>, + <<>>], {'RRC-RadioResourceConfigDedicated', [{'RRC-SRB-ToAddMod',1, {explicitValue, diff --git a/lib/asn1/test/h323test.erl b/lib/asn1/test/h323test.erl index 3baaa994ea..7577928493 100644 --- a/lib/asn1/test/h323test.erl +++ b/lib/asn1/test/h323test.erl @@ -42,7 +42,7 @@ alerting_val() -> {'TerminalInfo',asn1_NOVALUE}, false,false}, asn1_NOVALUE, - {'CallIdentifier',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}, + {'CallIdentifier',<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>}, asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}}, asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}, asn1_NOVALUE}. @@ -57,18 +57,18 @@ connect_val() -> {'Connect-UUIE', {0,0,8,2250,0,2}, {ipAddress, - {'TransportAddress_ipAddress',[136,225,41,58],1187}}, + {'TransportAddress_ipAddress',<<136,225,41,58>>,1187}}, {'EndpointType',asn1_NOVALUE, {'VendorIdentifier', {'H221NonStandard',181,0,21324}, - [77,105,99,114,111,115,111,102,116,174,32,78,101,116, - 77,101,100,116,105,110,103,174,0], - [51,46,48,0]}, + <<77,105,99,114,111,115,111,102,116,174,32,78,101,116, + 77,101,100,116,105,110,103,174,0>>, + <<51,46,48,0>>}, asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE, {'TerminalInfo',asn1_NOVALUE}, false,false}, - [22,137,237,197,191,35,211,17,140,45,0,192,79,75,28,208], - {'CallIdentifier',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}, + <<22,137,237,197,191,35,211,17,140,45,0,192,79,75,28,208>>, + {'CallIdentifier',<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>}, asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}}, asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}, asn1_NOVALUE}. diff --git a/lib/asn1/test/testChoExtension.erl b/lib/asn1/test/testChoExtension.erl index e54cbe825b..09e19ceebb 100644 --- a/lib/asn1/test/testChoExtension.erl +++ b/lib/asn1/test/testChoExtension.erl @@ -31,13 +31,13 @@ extension(_Rules) -> %% A trick to encode with another compatible CHOICE type to test reception %% extension alternative - roundtrip('ChoExt1x', {str,"abc"}), + roundtrip('ChoExt1x', {str,<<"abc">>}), roundtrip('ChoExt2', {bool,true}), roundtrip('ChoExt2', {int,33}), roundtrip('ChoExt3', {bool,true}), roundtrip('ChoExt3', {int,33}), - roundtrip('ChoExt4', {str,"abc"}), + roundtrip('ChoExt4', {str,<<"abc">>}), roundtrip('ChoEmptyRoot', {bool,false}), roundtrip('ChoEmptyRoot', {bool,true}), diff --git a/lib/asn1/test/testChoExternal.erl b/lib/asn1/test/testChoExternal.erl index 12abdbb2bc..0914d54f33 100644 --- a/lib/asn1/test/testChoExternal.erl +++ b/lib/asn1/test/testChoExternal.erl @@ -31,16 +31,16 @@ external(_Rules) -> roundtrip('ChoXBool', {xboolImp,true}), roundtrip('ChoXBool', {xboolExp,true}), - roundtrip('NT', {os,"kalle"}), - roundtrip('Exp', {os,"kalle"}), - roundtrip('NTNT', {os,"kalle"}), - roundtrip('NTExp', {os,"kalle"}), - roundtrip('ExpNT', {os,"kalle"}), - roundtrip('ExpExp', {os,"kalle"}), - roundtrip('XNTNT', {os,"kalle"}), - roundtrip('XNTExp', {os,"kalle"}), - roundtrip('XExpNT', {os,"kalle"}), - roundtrip('XExpExp', {os,"kalle"}), + roundtrip('NT', {os,<<"kalle">>}), + roundtrip('Exp', {os,<<"kalle">>}), + roundtrip('NTNT', {os,<<"kalle">>}), + roundtrip('NTExp', {os,<<"kalle">>}), + roundtrip('ExpNT', {os,<<"kalle">>}), + roundtrip('ExpExp', {os,<<"kalle">>}), + roundtrip('XNTNT', {os,<<"kalle">>}), + roundtrip('XNTExp', {os,<<"kalle">>}), + roundtrip('XExpNT', {os,<<"kalle">>}), + roundtrip('XExpExp', {os,<<"kalle">>}), ok. diff --git a/lib/asn1/test/testChoOptional.erl b/lib/asn1/test/testChoOptional.erl index f5e77cb721..71a7346e3f 100644 --- a/lib/asn1/test/testChoOptional.erl +++ b/lib/asn1/test/testChoOptional.erl @@ -27,16 +27,20 @@ run() -> roundtrip('Seq1', #'Seq1'{bool=true,int=asn1_NOVALUE,cho=asn1_NOVALUE}), roundtrip('Seq1', #'Seq1'{bool=true,int=233,cho=asn1_NOVALUE}), - roundtrip('Seq1', #'Seq1'{bool=true,int=asn1_NOVALUE,cho={vsCho,"Vs Str"}}), - roundtrip('Seq1', #'Seq1'{bool=true,int=asn1_NOVALUE,cho={ocStrCho,"Oct Str"}}), + roundtrip('Seq1', #'Seq1'{bool=true,int=asn1_NOVALUE, + cho={vsCho,"Vs Str"}}), + roundtrip('Seq1', #'Seq1'{bool=true,int=asn1_NOVALUE, + cho={ocStrCho,<<"Oct Str">>}}), roundtrip('Seq2', #'Seq2'{int=asn1_NOVALUE,cho=asn1_NOVALUE,bool=true}), roundtrip('Seq2', #'Seq2'{int=233,cho=asn1_NOVALUE,bool=true}), roundtrip('Seq2', #'Seq2'{int=asn1_NOVALUE,cho={vsCho,"Vs Str"},bool=true}), - roundtrip('Seq2', #'Seq2'{int=asn1_NOVALUE,cho={ocStrCho,"Oct Str"},bool=true}), + roundtrip('Seq2', #'Seq2'{int=asn1_NOVALUE,cho={ocStrCho,<<"Oct Str">>}, + bool=true}), roundtrip('Seq3', #'Seq3'{cho=asn1_NOVALUE,int=asn1_NOVALUE,bool=true}), roundtrip('Seq3', #'Seq3'{cho=asn1_NOVALUE,int=233,bool=true}), roundtrip('Seq3', #'Seq3'{cho={vsCho,"Vs Str"},int=asn1_NOVALUE,bool=true}), - roundtrip('Seq3', #'Seq3'{cho={ocStrCho,"Oct Str"},int=asn1_NOVALUE,bool=true}), + roundtrip('Seq3', #'Seq3'{cho={ocStrCho,<<"Oct Str">>}, + int=asn1_NOVALUE,bool=true}), ok. roundtrip(Type, Value) -> diff --git a/lib/asn1/test/testChoRecursive.erl b/lib/asn1/test/testChoRecursive.erl index 593b845949..ccd60c2897 100644 --- a/lib/asn1/test/testChoRecursive.erl +++ b/lib/asn1/test/testChoRecursive.erl @@ -31,13 +31,13 @@ recursive(_Rules) -> roundtrip('ChoRec', {something, #'ChoRec_something'{a = 77, - b = "some octets here", + b = <<"some octets here">>, c = {nothing,'NULL'}}}), roundtrip('ChoRec', {nothing,'NULL'}), roundtrip('ChoRec2', {something, #'ChoRec2_something'{a = 77, - b = "some octets here", + b = <<"some octets here">>, c = {nothing,'NULL'}}}), roundtrip('ChoRec2', {nothing,'NULL'}), ok. diff --git a/lib/asn1/test/testChoTypeRefCho.erl b/lib/asn1/test/testChoTypeRefCho.erl index cd2672add0..636c301403 100644 --- a/lib/asn1/test/testChoTypeRefCho.erl +++ b/lib/asn1/test/testChoTypeRefCho.erl @@ -30,7 +30,7 @@ choice(_Rules) -> roundtrip('ChoTRcho', {'choChoE-E',{choInt,88}}), roundtrip('ChoChoInline', {bool1,true}), roundtrip('ChoChoInline', {choCho,{bool,true}}), - roundtrip('ChoChoInline', {choCho,{octStr,"kk"}}), + roundtrip('ChoChoInline', {choCho,{octStr,<<"kk">>}}), roundtrip('ChoChoInline', {choCho,{int,55}}), ok. diff --git a/lib/asn1/test/testChoTypeRefPrim.erl b/lib/asn1/test/testChoTypeRefPrim.erl index 8a2bc7bd8e..747baeddd8 100644 --- a/lib/asn1/test/testChoTypeRefPrim.erl +++ b/lib/asn1/test/testChoTypeRefPrim.erl @@ -25,18 +25,18 @@ prim(_Rules) -> roundtrip('ChoTR', {bool,true}), - roundtrip('ChoTR', {octStr,[11,12,13,14,15,16,17]}), + roundtrip('ChoTR', {octStr,<<11,12,13,14,15,16,17>>}), roundtrip('ChoTR', {int,233}), - roundtrip('ChoTR', {octStr,"Stringing in the rain"}), - roundtrip('ChoTR2', {octStr,"A string"}), - roundtrip('ChoTR2', {octStrI,"A string"}), - roundtrip('ChoTR2', {octStrE,"A string"}), - roundtrip('ChoTR2', {'octStr-I',"A string"}), - roundtrip('ChoTR2', {'octStrI-I',"A string"}), - roundtrip('ChoTR2', {'octStrE-I',"A string"}), - roundtrip('ChoTR2', {'octStr-E',"A string"}), - roundtrip('ChoTR2', {'octStrI-E',"A string"}), - roundtrip('ChoTR2', {'octStrE-E',"A string"}), + roundtrip('ChoTR', {octStr,<<"Stringing in the rain">>}), + roundtrip('ChoTR2', {octStr,<<"A string">>}), + roundtrip('ChoTR2', {octStrI,<<"A string">>}), + roundtrip('ChoTR2', {octStrE,<<"A string">>}), + roundtrip('ChoTR2', {'octStr-I',<<"A string">>}), + roundtrip('ChoTR2', {'octStrI-I',<<"A string">>}), + roundtrip('ChoTR2', {'octStrE-I',<<"A string">>}), + roundtrip('ChoTR2', {'octStr-E',<<"A string">>}), + roundtrip('ChoTR2', {'octStrI-E',<<"A string">>}), + roundtrip('ChoTR2', {'octStrE-E',<<"A string">>}), ok. roundtrip(Type, Value) -> diff --git a/lib/asn1/test/testChoTypeRefSeq.erl b/lib/asn1/test/testChoTypeRefSeq.erl index 86c22619aa..91d0b45e89 100644 --- a/lib/asn1/test/testChoTypeRefSeq.erl +++ b/lib/asn1/test/testChoTypeRefSeq.erl @@ -28,15 +28,24 @@ -record('ChoSeqExp', {seqInt, seqOs}). seq(_Rules) -> - roundtrip('ChoTRseq', {choSeq,#'ChoSeq'{seqInt=88,seqOs="A string"}}), - roundtrip('ChoTRseq', {choSeqI,#'ChoSeq'{seqInt=88,seqOs="A string"}}), - roundtrip('ChoTRseq', {choSeqE,#'ChoSeq'{seqInt=88,seqOs="A string"}}), - roundtrip('ChoTRseq', {'choSeq-I',#'ChoSeqImp'{seqInt=88,seqOs="A string"}}), - roundtrip('ChoTRseq', {'choSeqI-I',#'ChoSeqImp'{seqInt=88,seqOs="A string"}}), - roundtrip('ChoTRseq', {'choSeqE-I',#'ChoSeqImp'{seqInt=88,seqOs="A string"}}), - roundtrip('ChoTRseq', {'choSeq-E',#'ChoSeqExp'{seqInt=88,seqOs="A string"}}), - roundtrip('ChoTRseq', {'choSeqI-E',#'ChoSeqExp'{seqInt=88,seqOs="A string"}}), - roundtrip('ChoTRseq', {'choSeqE-E',#'ChoSeqExp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {choSeq,#'ChoSeq'{seqInt=88, + seqOs = <<"A string">>}}), + roundtrip('ChoTRseq', {choSeqI,#'ChoSeq'{seqInt=88, + seqOs = <<"A string">>}}), + roundtrip('ChoTRseq', {choSeqE,#'ChoSeq'{seqInt=88, + seqOs = <<"A string">>}}), + roundtrip('ChoTRseq', {'choSeq-I',#'ChoSeqImp'{seqInt=88, + seqOs = <<"A string">>}}), + roundtrip('ChoTRseq', {'choSeqI-I',#'ChoSeqImp'{seqInt=88, + seqOs = <<"A string">>}}), + roundtrip('ChoTRseq', {'choSeqE-I',#'ChoSeqImp'{seqInt=88, + seqOs = <<"A string">>}}), + roundtrip('ChoTRseq', {'choSeq-E',#'ChoSeqExp'{seqInt=88, + seqOs = <<"A string">>}}), + roundtrip('ChoTRseq', {'choSeqI-E',#'ChoSeqExp'{seqInt=88, + seqOs = <<"A string">>}}), + roundtrip('ChoTRseq', {'choSeqE-E',#'ChoSeqExp'{seqInt=88, + seqOs = <<"A string">>}}), ok. roundtrip(Type, Value) -> diff --git a/lib/asn1/test/testChoTypeRefSet.erl b/lib/asn1/test/testChoTypeRefSet.erl index fd3d75cbcb..bd9068b53e 100644 --- a/lib/asn1/test/testChoTypeRefSet.erl +++ b/lib/asn1/test/testChoTypeRefSet.erl @@ -28,15 +28,24 @@ -record('ChoSetExp', {setInt, setOs}). set(_Rules) -> - roundtrip('ChoTRset', {choSet,#'ChoSet'{setInt=88,setOs="A string"}}), - roundtrip('ChoTRset', {choSetI,#'ChoSet'{setInt=88,setOs="A string"}}), - roundtrip('ChoTRset', {choSetE,#'ChoSet'{setInt=88,setOs="A string"}}), - roundtrip('ChoTRset', {'choSet-I',#'ChoSetImp'{setInt=88,setOs="A string"}}), - roundtrip('ChoTRset', {'choSetI-I',#'ChoSetImp'{setInt=88,setOs="A string"}}), - roundtrip('ChoTRset', {'choSetE-I',#'ChoSetImp'{setInt=88,setOs="A string"}}), - roundtrip('ChoTRset', {'choSet-E',#'ChoSetExp'{setInt=88,setOs="A string"}}), - roundtrip('ChoTRset', {'choSetI-E',#'ChoSetExp'{setInt=88,setOs="A string"}}), - roundtrip('ChoTRset', {'choSetE-E',#'ChoSetExp'{setInt=88,setOs="A string"}}), + roundtrip('ChoTRset', {choSet,#'ChoSet'{setInt=88, + setOs = <<"A string">>}}), + roundtrip('ChoTRset', {choSetI,#'ChoSet'{setInt=88, + setOs = <<"A string">>}}), + roundtrip('ChoTRset', {choSetE,#'ChoSet'{setInt=88, + setOs = <<"A string">>}}), + roundtrip('ChoTRset', {'choSet-I',#'ChoSetImp'{setInt=88, + setOs = <<"A string">>}}), + roundtrip('ChoTRset', {'choSetI-I',#'ChoSetImp'{setInt=88, + setOs = <<"A string">>}}), + roundtrip('ChoTRset', {'choSetE-I',#'ChoSetImp'{setInt=88, + setOs = <<"A string">>}}), + roundtrip('ChoTRset', {'choSet-E',#'ChoSetExp'{setInt=88, + setOs = <<"A string">>}}), + roundtrip('ChoTRset', {'choSetI-E',#'ChoSetExp'{setInt=88, + setOs = <<"A string">>}}), + roundtrip('ChoTRset', {'choSetE-E',#'ChoSetExp'{setInt=88, + setOs = <<"A string">>}}), ok. roundtrip(Type, Value) -> diff --git a/lib/asn1/test/testConstraints.erl b/lib/asn1/test/testConstraints.erl index 54ba748519..3ccf883bd6 100644 --- a/lib/asn1/test/testConstraints.erl +++ b/lib/asn1/test/testConstraints.erl @@ -208,14 +208,14 @@ int_constraints(Rules) -> %% More SIZE Constraints %%========================================================== - roundtrip('FixedSize', "0123456789"), - roundtrip('FixedSize2', "0123456789"), - roundtrip('FixedSize2', "0123456789abcdefghij"), + roundtrip('FixedSize', <<"0123456789">>), + roundtrip('FixedSize2', <<"0123456789">>), + roundtrip('FixedSize2', <<"0123456789abcdefghij">>), range_error(Rules, 'FixedSize', "short"), range_error(Rules, 'FixedSize2', "short"), - [roundtrip('VariableSize', lists:seq($A, $A+L-1)) || + [roundtrip('VariableSize', list_to_binary(lists:seq($A, $A+L-1))) || L <- lists:seq(1, 10)], roundtrip_enc('ShorterExt', "a", shorter_ext(Rules, "a")), diff --git a/lib/asn1/test/testFragmented.erl b/lib/asn1/test/testFragmented.erl index 8d5fa07a5b..35b21f90a9 100644 --- a/lib/asn1/test/testFragmented.erl +++ b/lib/asn1/test/testFragmented.erl @@ -22,10 +22,10 @@ -export([main/1]). main(_Erule) -> - roundtrip('PDU', {'PDU',1,false,["abc","def"]}), + roundtrip('PDU', {'PDU',1,false,[<<"abc">>,<<"def">>]}), B256 = lists:seq(0, 255), K1 = lists:duplicate(4, B256), - K8 = binary_to_list(iolist_to_binary(lists:duplicate(8, K1))), + K8 = iolist_to_binary(lists:duplicate(8, K1)), roundtrip('PDU', {'PDU',1,false,[K8,K8]}), roundtrip('PDU', {'PDU',1,false,[K8,K8,K8,K8]}), roundtrip('PDU', {'PDU',1,false,[K8,K8,K8,K8,K8,K8]}), diff --git a/lib/asn1/test/testInfObj.erl b/lib/asn1/test/testInfObj.erl index cd335e1023..311595cfda 100644 --- a/lib/asn1/test/testInfObj.erl +++ b/lib/asn1/test/testInfObj.erl @@ -49,7 +49,7 @@ main(_Erule) -> roundtrip('RANAPextract1', 'InitiatingMessage2', Val3), roundtrip('InfObj', 'MyPdu', {'MyPdu',42,12,false,"string"}), - roundtrip('InfObj', 'MyPdu', {'MyPdu',{'Seq',1023,"hello"}, + roundtrip('InfObj', 'MyPdu', {'MyPdu',{'Seq',1023,<<"hello">>}, 42,true,"longer string"}), roundtrip('InfObj', 'MyPdu', {'MyPdu',"75712346",43,true,"string"}), @@ -110,11 +110,11 @@ main(_Erule) -> enc_dec('InfObj', 'DefaultInSeq', {'DefaultInSeq',3,asn1_DEFAULT}), roundtrip('InfObj', 'Multiple-Optionals', - {'Multiple-Optionals',1,42,true,"abc"}), + {'Multiple-Optionals',1,42,true,<<"abc">>}), roundtrip('InfObj', 'Multiple-Optionals', - {'Multiple-Optionals',1,asn1_NOVALUE,true,"abc"}), + {'Multiple-Optionals',1,asn1_NOVALUE,true,<<"abc">>}), roundtrip('InfObj', 'Multiple-Optionals', - {'Multiple-Optionals',1,42,asn1_NOVALUE,"abc"}), + {'Multiple-Optionals',1,42,asn1_NOVALUE,<<"abc">>}), roundtrip('InfObj', 'Multiple-Optionals', {'Multiple-Optionals',1,42,true,asn1_NOVALUE}), roundtrip('InfObj', 'Multiple-Optionals', diff --git a/lib/asn1/test/testMergeCompile.erl b/lib/asn1/test/testMergeCompile.erl index 7cda71c441..b21897cfc2 100644 --- a/lib/asn1/test/testMergeCompile.erl +++ b/lib/asn1/test/testMergeCompile.erl @@ -30,12 +30,12 @@ main(Erule) -> %% test of module MS.set.asn that tests OTP-4492: different tagdefault in %% modules and types with same name in modules - MSVal = {'Type4M2',8,true,three,"OCTET STRING"}, + MSVal = {'Type4M2',8,true,three,<<"OCTET STRING">>}, asn1_test_lib:roundtrip('MS', 'Type4M2', MSVal), %% test of RANAP.set.asn1 PIEVal2 = [{'ProtocolIE-Field',4,ignore,{radioNetwork,'rab-pre-empted'}}], - EncVal = + EncVal0 = case Erule of per -> <<1,100>>; @@ -44,6 +44,7 @@ main(Erule) -> ber -> <<2,1,1>> end, + EncVal = {asn1_OPENTYPE,EncVal0}, PEVal2 = [{'ProtocolExtensionField',1,ignore,EncVal}, {'ProtocolExtensionField',2,reject,EncVal}], Val2 = @@ -142,7 +143,40 @@ test('InsertSubscriberDataArg') -> ok. test(mvrasn6,'InsertSubscriberDataArg') -> - Val = {'InsertSubscriberDataArg',"IMSI","Address","C",serviceGranted,["abc","cde"],["tele","serv","ice"],asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,{'NAEA-PreferredCI',"NCC",asn1_NOVALUE},{'GPRSSubscriptionData','NULL',[{'PDP-Context',49,"PT","PDP-Address","QoS",'NULL',"APN",asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}],asn1_NOVALUE},'NULL',onlyMSC,{'LSAInformation','NULL',accessOutsideLSAsAllowed,[{'LSAData',"LSA","L",'NULL',asn1_NOVALUE},{'LSAData',"LSA","L",'NULL',asn1_NOVALUE}],asn1_NOVALUE},'NULL',{'LCSInformation',["Addr","ess","string"],[{'LCS-PrivacyClass',"S","ExtSS",notifyLocationAllowed,[{'ExternalClient',{'LCSClientExternalID',"Addr",asn1_NOVALUE},asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}],[broadcastService,anonymousLocation,targetMSsubscribedService],asn1_NOVALUE}],asn1_NOVALUE},100,"age",{'MC-SS-Info',"S","ExtSS",5,4,asn1_NOVALUE},"C",{'SGSN-CAMEL-SubscriptionInfo',{'GPRS-CSI',[{'GPRS-CamelTDPData',attach,13,"Addr",continueTransaction,asn1_NOVALUE}],11,asn1_NOVALUE,'NULL','NULL'},{'SMS-CSI',[{'SMS-CAMEL-TDP-DataList','sms-CollectedInfo',13,"Addr",continueTransaction,asn1_NOVALUE}],11,asn1_NOVALUE,'NULL','NULL'},asn1_NOVALUE},"ON"}, - {ok,Bytes} = 'Mvrasn6':encode('InsertSubscriberDataArg', Val), - {ok,_} = 'Mvrasn6':decode('InsertSubscriberDataArg', Bytes), + Val = {'InsertSubscriberDataArg',<<"IMSI">>,<<"Address">>,<<"C">>, + serviceGranted,[<<"abc">>,<<"cde">>], + [<<"tele">>,<<"serv">>,<<"ice">>], + asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE, + asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE, + {'NAEA-PreferredCI',<<"NCC">>,asn1_NOVALUE}, + {'GPRSSubscriptionData','NULL', + [{'PDP-Context',49,<<"PT">>,<<"PDP-Address">>,<<"QoS">>, + 'NULL',<<"APN">>,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}], + asn1_NOVALUE},'NULL',onlyMSC, + {'LSAInformation','NULL',accessOutsideLSAsAllowed, + [{'LSAData',<<"LSA">>,<<"L">>,'NULL',asn1_NOVALUE}, + {'LSAData',<<"LSA">>,<<"L">>,'NULL',asn1_NOVALUE}], + asn1_NOVALUE},'NULL', + {'LCSInformation',[<<"Addr">>,<<"ess">>,<<"string">>], + [{'LCS-PrivacyClass',<<"S">>,<<"ExtSS">>,notifyLocationAllowed, + [{'ExternalClient', + {'LCSClientExternalID',<<"Addr">>,asn1_NOVALUE}, + asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}], + [broadcastService,anonymousLocation,targetMSsubscribedService], + asn1_NOVALUE}],asn1_NOVALUE}, + 100,<<"age">>, + {'MC-SS-Info',<<"S">>,<<"ExtSS">>,5,4,asn1_NOVALUE}, + <<"C">>, + {'SGSN-CAMEL-SubscriptionInfo', + {'GPRS-CSI', + [{'GPRS-CamelTDPData',attach,13,<<"Addr">>, + continueTransaction,asn1_NOVALUE}], + 11,asn1_NOVALUE,'NULL','NULL'}, + {'SMS-CSI', + [{'SMS-CAMEL-TDP-Data','sms-CollectedInfo', + 13,<<"Addr">>,continueTransaction,asn1_NOVALUE}], + 11,asn1_NOVALUE,'NULL','NULL'}, + asn1_NOVALUE}, + <<"ON">>}, + asn1_test_lib:roundtrip('Mvrasn6', 'InsertSubscriberDataArg', Val), ok. diff --git a/lib/asn1/test/testParameterizedInfObj.erl b/lib/asn1/test/testParameterizedInfObj.erl index f3b4f9b170..2fe900792d 100644 --- a/lib/asn1/test/testParameterizedInfObj.erl +++ b/lib/asn1/test/testParameterizedInfObj.erl @@ -20,7 +20,7 @@ -module(testParameterizedInfObj). --export([main/2,ranap/1]). +-export([main/2,param/1,ranap/1]). -include_lib("test_server/include/test_server.hrl"). @@ -36,31 +36,29 @@ main(Config, Erule) -> param2(Config, Erule). param(Erule) -> - PERVal = #'AllocationOrRetentionPriority' - {priorityLevel = true, - iE_Extensions = - [#'ProtocolExtensionField'{id=14, - criticality=reject, - extensionValue= <<0>>}, - #'ProtocolExtensionField'{id=2, - criticality=ignore, - extensionValue= <<1>>}]}, - BERVal = #'AllocationOrRetentionPriority' - {priorityLevel = true, - iE_Extensions = - [#'ProtocolExtensionField'{id=14, - criticality=reject, - extensionValue= <<2,1,0>>}, - #'ProtocolExtensionField'{id=2, - criticality=ignore, - extensionValue= <<2,1,1>>}]}, - case Erule of - ber -> - roundtrip('AllocationOrRetentionPriority', BERVal); - per -> - roundtrip('AllocationOrRetentionPriority', PERVal); - uper -> - roundtrip('AllocationOrRetentionPriority', PERVal) + Exts0 = case Erule of + ber -> + %% As implemented, the open type must contain + %% valid BER-encoded data. + [{14,<<2,1,0>>},{2,<<2,1,0>>}]; + _ -> + %% The PER decoder will not look inside the open type. + [{14,<<0>>},{2,<<"anything goes">>}] + end, + case 'Param':legacy_erlang_types() of + false -> + Exts = [#'ProtocolExtensionField'{id=Id, + criticality=reject, + extensionValue={asn1_OPENTYPE, + Eval}} || + {Id,Eval} <- Exts0], + aor_roundtrip(Exts); + true -> + Exts = [#'ProtocolExtensionField'{id=Id, + criticality=reject, + extensionValue=Eval} || + {Id,Eval} <- Exts0], + aor_roundtrip(Exts) end, %% test code for OTP-4242, ValueFromObject @@ -72,8 +70,13 @@ param(Erule) -> {error,_Reason2} = 'Param':decode('OS2',[4,4,1,2,3,4]), {ok,_Val4} = 'Param':decode('OS1',[4,2,1,2]); _ -> %per/uper - roundtrip('OS1', [1,2]), - {error,_Reason3} = 'Param':encode('OS1', [1,2,3,4]) + case 'Param':legacy_erlang_types() of + false -> + roundtrip('OS1', <<1,2>>), + {error,_Reason3} = 'Param':encode('OS1', <<1,2,3,4>>); + true -> + ok + end end, roundtrip('Scl', {'Scl',42,{a,9738654}}), @@ -82,6 +85,11 @@ param(Erule) -> ok. +aor_roundtrip(Exts) -> + Val = #'AllocationOrRetentionPriority'{priorityLevel = true, + iE_Extensions = Exts}, + roundtrip('AllocationOrRetentionPriority', Val). + roundtrip(T, V) -> asn1_test_lib:roundtrip('Param', T, V). @@ -102,11 +110,11 @@ ranap(_Erule) -> param2(Config, Erule) -> roundtrip2('HandoverRequired', {'HandoverRequired', - [{'ProtocolIE-Field',1,"ABC"}, + [{'ProtocolIE-Field',1,<<"ABC">>}, {'ProtocolIE-Field',2,577799}]}), Enc = roundtrip2('HandoverRequired', {'HandoverRequired', - [{'ProtocolIE-Field',1,"ABC"}, + [{'ProtocolIE-Field',1,<<"ABC">>}, {'ProtocolIE-Field',2,-42}, {'ProtocolIE-Field',100,533}, {'ProtocolIE-Field',101,true}]}), @@ -127,17 +135,19 @@ param2(Config, Erule) -> [{i,DataDir},{outdir,CaseDir},Erule]), %% Decompile extended data. - {ok,{'HandoverRequired',[{'ProtocolIE-Field',1,"ABC"}, + {ok,{'HandoverRequired',[{'ProtocolIE-Field',1,<<"ABC">>}, {'ProtocolIE-Field',2,-42}, - {'ProtocolIE-Field',100,Open100}, - {'ProtocolIE-Field',101,Open101}]}} = + {'ProtocolIE-Field',100, + {asn1_OPENTYPE,Open100}}, + {'ProtocolIE-Field',101, + {asn1_OPENTYPE,Open101}}]}} = 'Param2':decode('HandoverRequired', Enc), true = is_binary(Open100), true = is_binary(Open101), %% Test single root. roundtrip2('SingleRoot', - {'SingleRoot',[{'ProtocolIE-Field',1,"ABC"}, + {'SingleRoot',[{'ProtocolIE-Field',1,<<"ABC">>}, {'ProtocolIE-Field',2,9999}]}), ok. diff --git a/lib/asn1/test/testPrimExternal.erl b/lib/asn1/test/testPrimExternal.erl index 07a1de931f..a03760976d 100644 --- a/lib/asn1/test/testPrimExternal.erl +++ b/lib/asn1/test/testPrimExternal.erl @@ -45,6 +45,6 @@ external(_Rules) -> 'XExpNT', 'XExpImp', 'XExpExp'], - _ = [asn1_test_lib:roundtrip('PrimExternal', T, "kalle") || + _ = [asn1_test_lib:roundtrip('PrimExternal', T, <<"kalle">>) || T <- Types], ok. diff --git a/lib/asn1/test/testPrimStrings.erl b/lib/asn1/test/testPrimStrings.erl index 2fe0780701..3262d61a4d 100644 --- a/lib/asn1/test/testPrimStrings.erl +++ b/lib/asn1/test/testPrimStrings.erl @@ -34,14 +34,11 @@ fragmented(Rules) -> Lens = fragmented_lengths(), - fragmented_octet_string(Rules, Lens), - case Rules of - per -> - %% NYI. - ok; - _ -> - fragmented_strings(Lens) - end. + case 'PrimStrings':legacy_erlang_types() of + false -> fragmented_octet_string(Rules, Lens); + true -> ok + end, + fragmented_strings(Lens). fragmented_strings(Lens) -> Types = ['Ns','Ps','Ps11','Vis','IA5'], @@ -74,33 +71,37 @@ bit_string(Rules, Opts) -> %% Bs1 ::= BIT STRING %%========================================================== - bs_roundtrip('Bs1', 0, <<>>), - bs_roundtrip('Bs1', 4, <<1:3>>), - bs_roundtrip('Bs1', 15, <<15:4>>), - bs_roundtrip('Bs1', 255, <<255:8>>), - - bs_roundtrip('Bs1', 256, [0,0,0,0,0,0,0,0,1]), - bs_roundtrip('Bs1', 257, [1,0,0,0,0,0,0,0,1]), - bs_roundtrip('Bs1', 444, [0,0,1,1,1,1,0,1,1]), - - {ok,Enc1} = 'PrimStrings':encode('Bs1', 12345678901234567890), - {ok,_} = 'PrimStrings':decode('Bs1', Enc1), + bs_roundtrip('Bs1', <<>>), + bs_roundtrip('Bs1', <<1:3>>), + bs_roundtrip('Bs1', <<15:4>>), + bs_roundtrip('Bs1', <<2#010010:6>>), + bs_roundtrip('Bs1', <<2#11111111:8>>), + bs_roundtrip('Bs1', <<2#100000000:9>>), + bs_roundtrip('Bs1', <<2#100000001:9>>), + bs_roundtrip('Bs1', <<2#001111011:9>>), + bs_roundtrip('Bs1', <<2#0100101111100010011:19>>), - bs_roundtrip('Bs1', [1,1,1,1,1,1,1,1]), - bs_roundtrip('Bs1', [0,1,0,0,1,0]), - bs_roundtrip('Bs1', [1,0,0,0,0,0,0,0,0]), - bs_roundtrip('Bs1', [0,1,0,0,1,0,1,1,1,1,1,0,0,0,1,0,0,1,1]), + case 'PrimStrings':legacy_erlang_types() of + false -> + ok; + true -> + {ok,Enc1} = 'PrimStrings':encode('Bs1', 12345678901234567890), + {ok,_} = 'PrimStrings':decode('Bs1', Enc1) + end, case {Rules,Opts} of - {ber,[]} -> + {ber,[legacy_erlang_types]} -> bs_decode('Bs1', <<35,8,3,2,0,73,3,2,4,32>>, [0,1,0,0,1,0,0,1,0,0,1,0]), bs_decode('Bs1', <<35,9,3,2,0,234,3,3,7,156,0>>, [1,1,1,0,1,0,1,0,1,0,0,1,1,1,0,0,0]), bs_decode('Bs1', <<35,128,3,2,0,234,3,3,7,156,0,0,0>>, [1,1,1,0,1,0,1,0,1,0,0,1,1,1,0,0,0]); - _ -> + {ber,[]} -> + %% XXX + ok; + {_,_} -> %% DER, PER, UPER consistent_def_enc('BsDef1', [2#111101, @@ -120,30 +121,39 @@ bit_string(Rules, Opts) -> %%========================================================== roundtrip('Bs2', [mo,tu,fr]), - roundtrip('Bs2', [0,1,1,0,0,1,0], [mo,tu,fr]), + bs_roundtrip('Bs2', <<2#0110010:7>>, [mo,tu,fr]), + bs_roundtrip('Bs2', <<2#0110011:7>>, [mo,tu,fr,sa]), %%========================================================== %% Bs3 ::= BIT STRING {su(0), mo(1), tu(2), we(3), th(4), fr(5), sa(6) } (SIZE (1..7)) %%========================================================== roundtrip('Bs3', [mo,tu,fr]), - bs_roundtrip('Bs3', [0,1,1,0,0,1,0], [mo,tu,fr]), + bs_roundtrip('Bs3', <<2#0110010:7>>, [mo,tu,fr]), + bs_roundtrip('Bs3', <<2#0110010:7>>, [mo,tu,fr]), + bs_roundtrip('Bs2', <<2#0110011:7>>, [mo,tu,fr,sa]), + bs_roundtrip('Bs3', <<2#011001:6>>, [mo,tu,fr]), + bs_roundtrip('Bs3', <<2#11:2>>, [su,mo]), %%========================================================== %% Bs7 ::= BIT STRING (SIZE (24)) %%========================================================== - bs_roundtrip('Bs7', 53245, - [1,0,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0]), - bs_roundtrip('Bs7', [1,0,1,0], - [1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]), + bs_roundtrip('Bs7', <<23563:24>>), + case 'PrimStrings':legacy_erlang_types() of + false -> +%% {error,_} = 'PrimStrings':encode('Bs7', <<2#1010:4>>); + ok; + true -> + ok + end, %%========================================================== %% BsPri ::= [PRIVATE 61] BIT STRING %%========================================================== - bs_roundtrip('BsPri', 45, [1,0,1,1,0,1]), - bs_roundtrip('BsPri', 211, [1,1,0,0,1,0,1,1]), + bs_roundtrip('BsPri', <<2#101101:6>>), + bs_roundtrip('BsPri', <<2#11001011:8>>), case Rules of ber -> @@ -164,8 +174,8 @@ bit_string(Rules, Opts) -> %% BsExpPri ::= [PRIVATE 61] EXPLICIT BIT STRING %%========================================================== - bs_roundtrip('BsExpPri', 45, [1,0,1,1,0,1]), - bs_roundtrip('BsExpPri', 211, [1,1,0,0,1,0,1,1]), + bs_roundtrip('BsExpPri', <<2#101101:6>>), + bs_roundtrip('BsExpPri', <<2#11001011:8>>), case Rules of ber -> @@ -186,14 +196,14 @@ bit_string(Rules, Opts) -> %% veteran(2), collegeGraduate(3)}, test case for OTP-5710 %%========================================================== - {ok,Bytes54} = 'BitStr':encode('PersonalStatus', []), + {ok,Bytes54} = 'BitStr':encode('PersonalStatus', <<>>), {ok,[]} = 'BitStr':decode('PersonalStatus', Bytes54), %%========================================================== %% BS5932 ::= BIT STRING (SIZE (5..MAX)) %% test case for OTP-5932 %%========================================================== - bs_roundtrip('BSMAX', [1,0,1,0,1]), + bs_roundtrip('BSMAX', <<2#10101:5>>), case Rules of ber -> {error,_} = 'PrimStrings':encode('BSMAX', [1,0,1]); @@ -207,28 +217,35 @@ bit_string(Rules, Opts) -> %% BS1024 ::= BIT STRING (SIZE (1024)) %% test case for OTP-7602 %%========================================================== - BSmaker = - fun(_F,S,S,_,Acc) -> - Acc; - (F,Ix,S,{A,B},Acc) -> - F(F,Ix+1,S,{B,A},[A|Acc]) - end, - - BSList255 = BSmaker(BSmaker,0,255,{1,0},[]), - bs_roundtrip('BS255', BSList255), - BSList256 = BSmaker(BSmaker,0,256,{1,0},[]), - bs_roundtrip('BS256', BSList256), - BSList1024 = BSmaker(BSmaker,0,1024,{1,0},[]), - bs_roundtrip('BS1024', BSList1024), - bs_roundtrip('TransportLayerAddress', [0,1,1,0]), + bs_roundtrip('BS255', random_bits(255)), + bs_roundtrip('BS256', random_bits(256)), + bs_roundtrip('BS1024', random_bits(1024)), + + bs_roundtrip('TransportLayerAddress', <<2#0110:4>>), case Rules of ber -> ok; _ -> per_bs_strings() end. -consistent_def_enc(Type, Vs) -> +random_bits(N) -> + Seed = integer_to_list(erlang:phash2(erlang:now())), + random_bits(<<>>, N, Seed). + +random_bits(Bin, N, Seed) -> + RandomBits = erlang:md5(Seed), + Bits = bit_size(RandomBits), + if + Bits < N -> + random_bits(<<Bin/bitstring,RandomBits/bitstring>>, + N-Bits, RandomBits); + true -> + <<LastBits:N/bitstring,_/bitstring>> = RandomBits, + <<Bin/bitstring,LastBits/bitstring>> + end. + +consistent_def_enc(Type, Vs0) -> M = 'PrimStrings', {ok,Enc} = M:encode(Type, {Type,asn1_DEFAULT}), {ok,Val} = M:decode(Type, Enc), @@ -241,6 +258,13 @@ consistent_def_enc(Type, Vs) -> {legacy,{_,Bs}} when is_list(Bs) -> ok end, + %% If this is not the legacy format, only bitstrings are + %% allowed. + Vs = case M:legacy_erlang_types() of + false -> [V || V <- Vs0, is_bitstring(V)]; + true -> Vs0 + end, + %% All values should be recognized and encoded as the %% the default value (i.e. not encoded at all). _ = [{ok,Enc} = M:encode(Type, {Type,V}) || V <- Vs], @@ -252,18 +276,9 @@ consistent_def_enc(Type, Vs) -> %% a SIZE constraint). per_bs_strings() -> - bs_roundtrip('Bs3', [0,0,1,0,0,0,0], [tu]), bs_roundtrip('Bs3', <<2#0010000:7>>, [tu]), - bs_roundtrip('Bs3', {1,<<2#00100000:8>>}, [tu]), - - bs_roundtrip('Bs4', [0,1,1,0,0,1,0], [mo,tu,fr]), bs_roundtrip('Bs4', <<2#0110010:7>>, [mo,tu,fr]), - bs_roundtrip('Bs4', {1,<<2#01100100:8>>}, [mo,tu,fr]), - - bs_roundtrip('Bs4', [0,1,1,0,0,0,0], [mo,tu]), bs_roundtrip('Bs4', <<2#011:3,0:32>>, [mo,tu]), - bs_roundtrip('Bs4', {5,<<2#011:3,0:32,0:5>>}, [mo,tu]), - [per_trailing_zeroes(B) || B <- lists:seq(0, 255)], ok. @@ -279,10 +294,6 @@ per_trailing_zeroes(Byte) -> {bit,LastBitPos} -> LastBitPos+1 end, - %% List of zeroes and ones. - named_roundtrip(L, Pos, ExpectedSz), - named_roundtrip(L++[0,0,0,0,0], Pos, ExpectedSz), - %% Bitstrings. Bs = << <<B:1>> || B <- L >>, Sz = bit_size(Bs), @@ -290,14 +301,22 @@ per_trailing_zeroes(Byte) -> Bin = <<Bs:Sz/bits,0:16,0:7>>, named_roundtrip(Bin, Pos, ExpectedSz), - %% Compact bitstring. - named_roundtrip({7,Bin}, Pos, ExpectedSz), + case 'PrimStrings':legacy_erlang_types() of + false -> + ok; + true -> + %% List of zeroes and ones. + named_roundtrip(L, Pos, ExpectedSz), + named_roundtrip(L++[0,0,0,0,0], Pos, ExpectedSz), - %% Integer bitstring (obsolete). - IntBs = intlist_to_integer(L, 0, 0), - named_roundtrip(IntBs, Pos, ExpectedSz), + %% Compact bitstring. + named_roundtrip({7,Bin}, Pos, ExpectedSz), - ok. + %% Integer bitstring (obsolete). + IntBs = intlist_to_integer(L, 0, 0), + named_roundtrip(IntBs, Pos, ExpectedSz), + ok + end. make_bit_list(0) -> []; make_bit_list(B) -> [B band 1|make_bit_list(B bsr 1)]. @@ -331,61 +350,62 @@ octet_string(Rules) -> %% Os ::= OCTET STRING %%========================================================== + Legacy = 'PrimStrings':legacy_erlang_types(), case Rules of - ber -> - {ok,"Jones"} = + ber when not Legacy -> + {ok,<<"Jones">>} = 'PrimStrings':decode('Os', <<4,5,16#4A,16#6F,16#6E,16#65,16#73>>), - {ok,"Jones"} = + {ok,<<"Jones">>} = 'PrimStrings':decode('Os', <<36,9,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73>>), - {ok,"Jones"} = + {ok,<<"Jones">>} = 'PrimStrings':decode('Os', <<36,128,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73,0,0>>), ok; _ -> ok end, - roundtrip('Os', [47,23,99,255,1]), - roundtrip('OsCon', [47,23,99,255,1]), - roundtrip('OsPri', [47,23,99,255,1]), - roundtrip('OsApp', [47,23,99,255,1]), + os_roundtrip('Os', <<47,23,99,255,1>>), + os_roundtrip('OsCon', <<47,23,99,255,1>>), + os_roundtrip('OsPri', <<47,23,99,255,1>>), + os_roundtrip('OsApp', <<47,23,99,255,1>>), - roundtrip('OsExpCon', [47,23,99,255,1]), - roundtrip('OsExpPri', [47,23,99,255,1]), - roundtrip('OsExpApp', [47,23,99,255,1]), + os_roundtrip('OsExpCon', <<47,23,99,255,1>>), + os_roundtrip('OsExpPri', <<47,23,99,255,1>>), + os_roundtrip('OsExpApp', <<47,23,99,255,1>>), - roundtrip('Os', []), - roundtrip('OsApp', []), - roundtrip('OsExpApp',[]), + os_roundtrip('Os', <<>>), + os_roundtrip('OsApp', <<>>), + os_roundtrip('OsExpApp', <<>>), - OsR = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + OsR = <<"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890">>, - roundtrip('Os', OsR), - roundtrip('OsCon', OsR), - roundtrip('OsExpApp', OsR), + os_roundtrip('Os', OsR), + os_roundtrip('OsCon', OsR), + os_roundtrip('OsExpApp', OsR), case Rules of - ber -> - {ok,"Jones"} = 'PrimStrings':decode('OsExpApp', <<127,62,7,4,5,16#4A,16#6F,16#6E,16#65,16#73>>), - {ok,"Jones"} = 'PrimStrings':decode('OsExpApp', <<127,62,11,36,9,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73>>), - {ok,"Jones"} = 'PrimStrings':decode('OsExpApp', <<127,62,13,36,128,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73,0,0>>), - {ok,"Jones"} = 'PrimStrings':decode('OsExpApp', <<127,62,128,36,128,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73,0,0,0,0>>), - {ok,"JonesJones"} = 'PrimStrings':decode('OsExpApp', <<127,62,128,36,128,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73,0,0,36,128,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73,0,0,0,0>>), + ber when not Legacy -> + {ok,<<"Jones">>} = 'PrimStrings':decode('OsExpApp', <<127,62,7,4,5,16#4A,16#6F,16#6E,16#65,16#73>>), + {ok,<<"Jones">>} = 'PrimStrings':decode('OsExpApp', <<127,62,11,36,9,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73>>), + {ok,<<"Jones">>} = 'PrimStrings':decode('OsExpApp', <<127,62,13,36,128,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73,0,0>>), + {ok,<<"Jones">>} = 'PrimStrings':decode('OsExpApp', <<127,62,128,36,128,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73,0,0,0,0>>), + {ok,<<"JonesJones">>} = 'PrimStrings':decode('OsExpApp', <<127,62,128,36,128,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73,0,0,36,128,4,3,16#4A,16#6F,16#6E,4,2,16#65,16#73,0,0,0,0>>), ok; - - _-> + _ -> ok end, S255 = lists:seq(1, 255), - Strings = {type,true,"","1","12","345",true, - S255,[$a|S255],[$a,$b|S255],397}, - p_roundtrip('OsFixedStrings', Strings), - p_roundtrip('OsFixedStringsExt', Strings), - p_roundtrip('OsVarStringsExt', Strings), + Strings = {type,true,<<"">>,<<"1">>,<<"12">>,<<"345">>,true, + list_to_binary(S255),list_to_binary([$a|S255]), + list_to_binary([$a,$b|S255]),397}, + p_os_roundtrip('OsFixedStrings', Strings), + p_os_roundtrip('OsFixedStringsExt', Strings), + p_os_roundtrip('OsVarStringsExt', Strings), ShortenedStrings = shorten_by_two(Strings), - p_roundtrip('OsFixedStringsExt', ShortenedStrings), - p_roundtrip('OsVarStringsExt', ShortenedStrings), + p_os_roundtrip('OsFixedStringsExt', ShortenedStrings), + p_os_roundtrip('OsVarStringsExt', ShortenedStrings), ok. fragmented_octet_string(Erules, Lens) -> @@ -414,13 +434,14 @@ fragmented_octet_string(Erules, Types, L) -> ok. enc_frag(Erules, Type, Value) -> - {ok,Encoded} = 'PrimStrings':encode(Type, Value), + M = 'PrimStrings', + {ok,Encoded} = M:encode(Type, Value), case Erules of ber -> Encoded; _ -> %% Validate encoding with our own encoder. - Encoded = enc_frag_1(<<>>, list_to_binary(Value)) + Encoded = enc_frag_1(<<>>, Value) end. enc_frag_1(Res, Bin0) -> @@ -439,12 +460,12 @@ enc_frag_1(Res, Bin0) -> end. make_value(L) -> - make_value(L, 0, []). + make_value(L, 0, <<>>). make_value(0, _, Acc) -> Acc; make_value(N, Byte, Acc) when Byte =< 255 -> - make_value(N-1, Byte+7, [Byte|Acc]); + make_value(N-1, Byte+7, <<Acc/binary,Byte:8>>); make_value(N, Byte, Acc) -> make_value(N, Byte band 16#FF, Acc). @@ -742,10 +763,32 @@ utf8_string(_Rules) -> shorten_by_two(Tuple) -> L = [case E of [_,_|T] -> T; + <<_:16,T/binary>> -> T; _ -> E end || E <- tuple_to_list(Tuple)], list_to_tuple(L). +p_os_roundtrip(Type, Value0) -> + Value = setelement(1, Value0, Type), + p_os_roundtrip_1(Type, Value). + +p_os_roundtrip_1(Type, Value) -> + M = 'PrimStrings', + case M:legacy_erlang_types() of + false -> + asn1_test_lib:roundtrip(M, Type, Value); + true -> + {ok,Encoded} = M:encode(Type, Value), + Es0 = tuple_to_list(Value), + Es1 = [if + is_binary(E) -> binary_to_list(E); + true -> E + end || E <- Es0], + ListValue = list_to_tuple(Es1), + {ok,Encoded} = M:encode(Type, ListValue), + {ok,ListValue} = M:decode(Type, Encoded) + end. + p_roundtrip(Type, Value0) -> Value = setelement(1, Value0, Type), roundtrip(Type, Value). @@ -759,15 +802,57 @@ roundtrip(Type, Value, Expected) -> bs_roundtrip(Type, Value) -> bs_roundtrip(Type, Value, Value). -bs_roundtrip(Type, Value, Expected) -> +os_roundtrip(Type, Bin) when is_binary(Bin) -> M = 'PrimStrings', - {ok,Encoded} = M:encode(Type, Value), - {ok,Encoded} = M:encode(Type, Expected), - case M:decode(Type, Encoded) of - {ok,Expected} -> - ok; - {ok,Other} -> - Expected = convert(Other, Expected) + case M:legacy_erlang_types() of + false -> + asn1_test_lib:roundtrip(M, Type, Bin); + true -> + {ok,Encoded} = M:encode(Type, Bin), + List = binary_to_list(Bin), + {ok,Encoded} = M:encode(Type, List), + {ok,List} = M:decode(Type, Encoded) + end. + +bs_roundtrip(Type, Value, Expected) when is_bitstring(Value) -> + M = 'PrimStrings', + case M:legacy_erlang_types() of + false -> + asn1_test_lib:roundtrip(M, Type, Value, Expected); + true -> + {ok,Encoded} = M:encode(Type, Value), + BitList = [B || <<B:1>> <= Value], + {ok,Encoded} = M:encode(Type, BitList), + case BitList of + [] -> + {ok,Encoded} = M:encode(Type, 0); + [_|_] -> + case lists:last(BitList) of + 1 -> + Int = lists:foldr(fun(B, A) -> + (A bsl 1) bor B + end, 0, BitList), + {ok,Encoded} = M:encode(Type, Int); + 0 -> + %% This BIT STRING cannot be represented + %% as an integer. + ok + end + end, + Compact = case bit_size(Value) of + Bits when Bits rem 8 =:= 0 -> + {0,Value}; + Bits -> + Unused = 8 - Bits rem 8, + {Unused,<<Value:Bits/bitstring,0:Unused>>} + end, + {ok,Encoded} = M:encode(Type, Compact), + case M:decode(Type, Encoded) of + {ok,Expected} -> + ok; + {ok,Other} -> + Expected = convert(Other, Expected) + end end. bs_decode(Type, Encoded, Expected) -> diff --git a/lib/asn1/test/testSeqExtension.erl b/lib/asn1/test/testSeqExtension.erl index 8473459c36..c16e9fcd4c 100644 --- a/lib/asn1/test/testSeqExtension.erl +++ b/lib/asn1/test/testSeqExtension.erl @@ -44,7 +44,7 @@ main(Erule, DataDir, Opts) -> roundtrip('SeqExt4', #'SeqExt4'{bool=true,int=12345}), roundtrip('SeqExt4', #'SeqExt4'{bool=false,int=123456}), - roundtrip('SeqExt5', #'SeqExt5'{name="Arne",shoesize=47}), + roundtrip('SeqExt5', #'SeqExt5'{name = <<"Arne">>,shoesize=47}), %% Encode a value with this version of the specification. BigInt = 128638468966, @@ -52,7 +52,7 @@ main(Erule, DataDir, Opts) -> s2=#'SeqExt2'{bool=true,int=2345}, s3=#'SeqExt3'{bool=false,int=17}, s4=#'SeqExt4'{bool=true,int=38739739}, - s5=#'SeqExt5'{name="Arne",shoesize=47}, + s5=#'SeqExt5'{name = <<"Arne">>,shoesize=47}, s6=#'SeqExt6'{i1=531,i2=601,i3=999, i4=777,i5=11953, i6=13553,i7=77777}, diff --git a/lib/asn1/test/testSeqExternal.erl b/lib/asn1/test/testSeqExternal.erl index a8e0902244..0b1d305054 100644 --- a/lib/asn1/test/testSeqExternal.erl +++ b/lib/asn1/test/testSeqExternal.erl @@ -29,15 +29,15 @@ -record('SeqXSet3',{bool, int, set}). main(_Rules) -> - roundtrip('XNTNT', #'XSeqNT'{os="kalle",bool=true}), - roundtrip('XImpNT', #'XSeqNT'{os="kalle",bool=true}), - roundtrip('XExpNT', #'XSeqNT'{os="kalle",bool=true}), - roundtrip('XNTImp', #'XSeqImp'{os="kalle",bool=true}), - roundtrip('XImpImp', #'XSeqImp'{os="kalle",bool=true}), - roundtrip('XExpImp', #'XSeqImp'{os="kalle",bool=true}), - roundtrip('XNTExp', #'XSeqExp'{os="kalle",bool=true}), - roundtrip('XImpExp', #'XSeqExp'{os="kalle",bool=true}), - roundtrip('XExpExp', #'XSeqExp'{os="kalle",bool=true}), + roundtrip('XNTNT', #'XSeqNT'{os = <<"kalle">>,bool=true}), + roundtrip('XImpNT', #'XSeqNT'{os = <<"kalle">>,bool=true}), + roundtrip('XExpNT', #'XSeqNT'{os = <<"kalle">>,bool=true}), + roundtrip('XNTImp', #'XSeqImp'{os = <<"kalle">>,bool=true}), + roundtrip('XImpImp', #'XSeqImp'{os = <<"kalle">>,bool=true}), + roundtrip('XExpImp', #'XSeqImp'{os = <<"kalle">>,bool=true}), + roundtrip('XNTExp', #'XSeqExp'{os = <<"kalle">>,bool=true}), + roundtrip('XImpExp', #'XSeqExp'{os = <<"kalle">>,bool=true}), + roundtrip('XExpExp', #'XSeqExp'{os = <<"kalle">>,bool=true}), roundtrip('SeqXSet1', #'SeqXSet1'{set=#'XSet1'{bool1=true,int1=77, set1=#'XSetIn'{boolIn=false,intIn=88}}, diff --git a/lib/asn1/test/testSeqOf.erl b/lib/asn1/test/testSeqOf.erl index 7f8f4079b4..25059d6052 100644 --- a/lib/asn1/test/testSeqOf.erl +++ b/lib/asn1/test/testSeqOf.erl @@ -85,10 +85,10 @@ main(_Rules) -> seq43=SeqIn3}), roundtrip('Seq5', {'Seq5',true,[],77}), - roundtrip('Seq5', {'Seq5',true,[""],77}), - roundtrip('Seq5', {'Seq5',true,["a"],77}), - roundtrip('Seq5', {'Seq5',true,["ab"],77}), - roundtrip('Seq5', {'Seq5',true,["abc"],77}), + roundtrip('Seq5', {'Seq5',true,[<<"">>],77}), + roundtrip('Seq5', {'Seq5',true,[<<"a">>],77}), + roundtrip('Seq5', {'Seq5',true,[<<"ab">>],77}), + roundtrip('Seq5', {'Seq5',true,[<<"abc">>],77}), roundtrip('Seq6', {'Seq6',[],[],101}), roundtrip('Seq6', {'Seq6',[],[7],101}), @@ -100,15 +100,15 @@ main(_Rules) -> roundtrip('Seq8', {'Seq8',[],37}), roundtrip('Seq9', {'Seq9',true,[],97}), - roundtrip('Seq9', {'Seq9',true,[""],97}), - roundtrip('Seq9', {'Seq9',true,["x"],97}), - roundtrip('Seq9', {'Seq9',true,["xy"],97}), - roundtrip('Seq9', {'Seq9',true,["xyz"],97}), - - roundtrip('Seq10', {'Seq10',true,[""],97}), - roundtrip('Seq10', {'Seq10',true,["a"],97}), - roundtrip('Seq10', {'Seq10',true,["a","b"],97}), - roundtrip('Seq10', {'Seq10',true,["a","b","c"],97}), + roundtrip('Seq9', {'Seq9',true,[<<"">>],97}), + roundtrip('Seq9', {'Seq9',true,[<<"x">>],97}), + roundtrip('Seq9', {'Seq9',true,[<<"xy">>],97}), + roundtrip('Seq9', {'Seq9',true,[<<"xyz">>],97}), + + roundtrip('Seq10', {'Seq10',true,[<<"">>],97}), + roundtrip('Seq10', {'Seq10',true,[<<"a">>],97}), + roundtrip('Seq10', {'Seq10',true,[<<"a">>,<<"b">>],97}), + roundtrip('Seq10', {'Seq10',true,[<<"a">>,<<"b">>,<<"c">>],97}), roundtrip('SeqEmp', #'SeqEmp'{seq1=[#'Empty'{}]}), diff --git a/lib/asn1/test/testSeqOfExternal.erl b/lib/asn1/test/testSeqOfExternal.erl index 2e60f441c1..38b9f0ce7c 100644 --- a/lib/asn1/test/testSeqOfExternal.erl +++ b/lib/asn1/test/testSeqOfExternal.erl @@ -29,50 +29,59 @@ main(_Rules) -> roundtrip('NTNT', - [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), + [#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]), roundtrip('ImpNT', - [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), + [#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]), roundtrip('ExpNT', - [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), + [#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]), roundtrip('NTImp', - [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), + [#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]), roundtrip('ImpImp', - [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), + [#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]), roundtrip('ExpImp', - [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), + [#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]), roundtrip('NTExp', - [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), + [#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]), roundtrip('ImpExp', - [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), + [#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]), roundtrip('ExpExp', - [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), + [#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]), roundtrip('XNTNT', - [#'XSeqNT'{os="kalle",bool=true}, - #'XSeqNT'{os="kalle",bool=true}]), + [#'XSeqNT'{os = <<"kalle">>,bool=true}, + #'XSeqNT'{os = <<"kalle">>,bool=true}]), roundtrip('XImpNT', - [#'XSeqNT'{os="kalle",bool=true}, - #'XSeqNT'{os="kalle",bool=true}]), + [#'XSeqNT'{os = <<"kalle">>,bool=true}, + #'XSeqNT'{os = <<"kalle">>,bool=true}]), roundtrip('XExpNT', - [#'XSeqNT'{os="kalle",bool=true}, - #'XSeqNT'{os="kalle",bool=true}]), + [#'XSeqNT'{os = <<"kalle">>,bool=true}, + #'XSeqNT'{os = <<"kalle">>,bool=true}]), roundtrip('XNTImp', - [#'XSeqImp'{os="kalle",bool=true}, - #'XSeqImp'{os="kalle",bool=true}]), + [#'XSeqImp'{os = <<"kalle">>,bool=true}, + #'XSeqImp'{os = <<"kalle">>,bool=true}]), roundtrip('XImpImp', - [#'XSeqImp'{os="kalle",bool=true}, - #'XSeqImp'{os="kalle",bool=true}]), + [#'XSeqImp'{os = <<"kalle">>,bool=true}, + #'XSeqImp'{os = <<"kalle">>,bool=true}]), roundtrip('XExpImp', - [#'XSeqImp'{os="kalle",bool=true}, - #'XSeqImp'{os="kalle",bool=true}]), + [#'XSeqImp'{os = <<"kalle">>,bool=true}, + #'XSeqImp'{os = <<"kalle">>,bool=true}]), roundtrip('XNTExp', - [#'XSeqExp'{os="kalle",bool=true}, - #'XSeqExp'{os="kalle",bool=true}]), + [#'XSeqExp'{os = <<"kalle">>,bool=true}, + #'XSeqExp'{os = <<"kalle">>,bool=true}]), roundtrip('XImpExp', - [#'XSeqExp'{os="kalle",bool=true}, - #'XSeqExp'{os="kalle",bool=true}]), + [#'XSeqExp'{os = <<"kalle">>,bool=true}, + #'XSeqExp'{os = <<"kalle">>,bool=true}]), roundtrip('XExpExp', - [#'XSeqExp'{os="kalle",bool=true}, - #'XSeqExp'{os="kalle",bool=true}]), + [#'XSeqExp'{os = <<"kalle">>,bool=true}, + #'XSeqExp'{os = <<"kalle">>,bool=true}]), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSeqOfTag.erl b/lib/asn1/test/testSeqOfTag.erl index 38c1dcb90f..f66e29e91d 100644 --- a/lib/asn1/test/testSeqOfTag.erl +++ b/lib/asn1/test/testSeqOfTag.erl @@ -44,47 +44,47 @@ -record('Exp',{os, bool}). main(_Rules) -> - roundtrip('SeqTagNt', #'SeqTagNt'{nt=[#'NT'{os="kalle",bool=true}, - #'NT'{os="kalle",bool=true}]}), - roundtrip('SeqTagNtI', #'SeqTagNtI'{imp=[#'Imp'{os="kalle",bool=true}, - #'Imp'{os="kalle",bool=true}]}), - roundtrip('SeqTagNtE', #'SeqTagNtE'{exp=[#'Exp'{os="kalle",bool=true}, - #'Exp'{os="kalle",bool=true}]}), - roundtrip('SeqTagI', #'SeqTagI'{nt=[#'NT'{os="kalle",bool=true}, - #'NT'{os="kalle",bool=true}]}), - roundtrip('SeqTagII', #'SeqTagII'{imp=[#'Imp'{os="kalle",bool=true}, - #'Imp'{os="kalle",bool=true}]}), - roundtrip('SeqTagIE', #'SeqTagIE'{exp=[#'Exp'{os="kalle",bool=true}, - #'Exp'{os="kalle",bool=true}]}), - roundtrip('SeqTagE', #'SeqTagE'{nt=[#'NT'{os="kalle",bool=true}, - #'NT'{os="kalle",bool=true}]}), - roundtrip('SeqTagEI', #'SeqTagEI'{imp=[#'Imp'{os="kalle",bool=true}, - #'Imp'{os="kalle",bool=true}]}), - roundtrip('SeqTagEE', #'SeqTagEE'{exp=[#'Exp'{os="kalle",bool=true}, - #'Exp'{os="kalle",bool=true}]}), + roundtrip('SeqTagNt', #'SeqTagNt'{nt=[#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]}), + roundtrip('SeqTagNtI', #'SeqTagNtI'{imp=[#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SeqTagNtE', #'SeqTagNtE'{exp=[#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SeqTagI', #'SeqTagI'{nt=[#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]}), + roundtrip('SeqTagII', #'SeqTagII'{imp=[#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SeqTagIE', #'SeqTagIE'{exp=[#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SeqTagE', #'SeqTagE'{nt=[#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]}), + roundtrip('SeqTagEI', #'SeqTagEI'{imp=[#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SeqTagEE', #'SeqTagEE'{exp=[#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]}), roundtrip('SeqTagXNt', - #'SeqTagXNt'{xnt=[#'XSeqNT'{os="kalle",bool=true}, - #'XSeqNT'{os="kalle",bool=true}]}), + #'SeqTagXNt'{xnt=[#'XSeqNT'{os = <<"kalle">>,bool=true}, + #'XSeqNT'{os = <<"kalle">>,bool=true}]}), roundtrip('SeqTagXI', - #'SeqTagXI'{ximp=[#'XSeqImp'{os="kalle",bool=true}, - #'XSeqImp'{os="kalle",bool=true}]}), + #'SeqTagXI'{ximp=[#'XSeqImp'{os = <<"kalle">>,bool=true}, + #'XSeqImp'{os = <<"kalle">>,bool=true}]}), roundtrip('SeqTagXE', - #'SeqTagXE'{xexp=[#'XSeqExp'{os="kalle",bool=true}, - #'XSeqExp'{os="kalle",bool=true}]}), + #'SeqTagXE'{xexp=[#'XSeqExp'{os = <<"kalle">>,bool=true}, + #'XSeqExp'{os = <<"kalle">>,bool=true}]}), roundtrip('SeqTagImpX', - #'SeqTagImpX'{xnt=[#'XSeqNT'{os="kalle",bool=true}, - #'XSeqNT'{os="kalle",bool=true}], - ximp=[#'XSeqImp'{os="kalle",bool=true}, - #'XSeqImp'{os="kalle",bool=true}], - xexp=[#'XSeqExp'{os="kalle",bool=true}, - #'XSeqExp'{os="kalle",bool=true}]}), + #'SeqTagImpX'{xnt=[#'XSeqNT'{os = <<"kalle">>,bool=true}, + #'XSeqNT'{os = <<"kalle">>,bool=true}], + ximp=[#'XSeqImp'{os = <<"kalle">>,bool=true}, + #'XSeqImp'{os = <<"kalle">>,bool=true}], + xexp=[#'XSeqExp'{os = <<"kalle">>,bool=true}, + #'XSeqExp'{os = <<"kalle">>,bool=true}]}), roundtrip('SeqTagExpX', - #'SeqTagExpX'{xnt=[#'XSeqNT'{os="kalle",bool=true}, - #'XSeqNT'{os="kalle",bool=true}], - ximp=[#'XSeqImp'{os="kalle",bool=true}, - #'XSeqImp'{os="kalle",bool=true}], - xexp=[#'XSeqExp'{os="kalle",bool=true}, - #'XSeqExp'{os="kalle",bool=true}]}), + #'SeqTagExpX'{xnt=[#'XSeqNT'{os = <<"kalle">>,bool=true}, + #'XSeqNT'{os = <<"kalle">>,bool=true}], + ximp=[#'XSeqImp'{os = <<"kalle">>,bool=true}, + #'XSeqImp'{os = <<"kalle">>,bool=true}], + xexp=[#'XSeqExp'{os = <<"kalle">>,bool=true}, + #'XSeqExp'{os = <<"kalle">>,bool=true}]}), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSeqPrim.erl b/lib/asn1/test/testSeqPrim.erl index 46bac77910..7f3ef86ac5 100644 --- a/lib/asn1/test/testSeqPrim.erl +++ b/lib/asn1/test/testSeqPrim.erl @@ -36,9 +36,9 @@ main(_Rules) -> roundtrip('Seq', #'Seq'{bool=false,boolCon=true,boolPri=false,boolApp=true, boolExpCon=false,boolExpPri=true,boolExpApp=false}), roundtrip('Empty', #'Empty'{}), - roundtrip('Big', #'Big'{os1=lists:duplicate(120, 16#A5), - os2=lists:duplicate(128, 16#A7), - os3=lists:duplicate(17777, 16#F5)}), + roundtrip('Big', #'Big'{os1=list_to_binary(lists:duplicate(120, 16#A5)), + os2=list_to_binary(lists:duplicate(128, 16#A7)), + os3=list_to_binary(lists:duplicate(17777, 16#F5))}), ok. roundtrip(Type, Value) -> diff --git a/lib/asn1/test/testSeqSetDefaultVal.erl b/lib/asn1/test/testSeqSetDefaultVal.erl index 044099199f..79992a0a94 100644 --- a/lib/asn1/test/testSeqSetDefaultVal.erl +++ b/lib/asn1/test/testSeqSetDefaultVal.erl @@ -162,7 +162,7 @@ main(Rule, Opts) -> {#'SeqOS'{}, [{#'SeqOS'.a, [asn1_DEFAULT, - [172]]}]}, + <<172>>]}]}, {#'SeqOI'{}, [{#'SeqOI'.a, @@ -314,17 +314,10 @@ der() -> c=[second], d = <<>>}), roundtrip(<<48,0>>, 'SeqOS', - #'SeqOS'{a=[172],b=[16#A8,16#A0],c='NULL'}), - roundtrip(<<48,0>>, - 'SeqOS', - #'SeqOS'{a=172,b=43168,c='NULL'}, - #'SeqOS'{a=[172],b=[16#A8,16#A0],c='NULL'}), + #'SeqOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}), - roundtrip(<<49,0>>, 'SetOS', #'SetOS'{a=[172],b=[16#A8,16#A0],c='NULL'}), - roundtrip(<<49,0>>, - 'SetOS', - #'SetOS'{a=172,b=43168,c='NULL'}, - #'SetOS'{a=[172],b=[16#A8,16#A0],c='NULL'}), + roundtrip(<<49,0>>, 'SetOS', + #'SetOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}), roundtrip(<<48,0>>, 'SeqOI', diff --git a/lib/asn1/test/testSeqTag.erl b/lib/asn1/test/testSeqTag.erl index 2f127b3e97..6bacca6808 100644 --- a/lib/asn1/test/testSeqTag.erl +++ b/lib/asn1/test/testSeqTag.erl @@ -35,24 +35,24 @@ -record('Exp',{os, bool}). main(_Rules) -> - roundtrip('SeqTag', #'SeqTag'{nt=#'NT'{os="kalle",bool=true}, - imp=#'Imp'{os="kalle",bool=true}, - exp=#'Exp'{os="kalle",bool=true}}), - roundtrip('SeqTagImp', #'SeqTagImp'{nt=#'NT'{os="kalle",bool=true}, - imp=#'Imp'{os="kalle",bool=true}, - exp=#'Exp'{os="kalle",bool=true}}), - roundtrip('SeqTagExp', #'SeqTagExp'{nt=#'NT'{os="kalle",bool=true}, - imp=#'Imp'{os="kalle",bool=true}, - exp=#'Exp'{os="kalle",bool=true}}), - roundtrip('SeqTagX', #'SeqTagX'{xnt=#'XSeqNT'{os="kalle",bool=true}, - ximp=#'XSeqImp'{os="kalle",bool=true}, - xexp=#'XSeqExp'{os="kalle",bool=true}}), - roundtrip('SeqTagImpX', #'SeqTagImpX'{xnt=#'XSeqNT'{os="kalle",bool=true}, - ximp=#'XSeqImp'{os="kalle",bool=true}, - xexp=#'XSeqExp'{os="kalle",bool=true}}), - roundtrip('SeqTagExpX', #'SeqTagExpX'{xnt=#'XSeqNT'{os="kalle",bool=true}, - ximp=#'XSeqImp'{os="kalle",bool=true}, - xexp=#'XSeqExp'{os="kalle",bool=true}}), + roundtrip('SeqTag', #'SeqTag'{nt=#'NT'{os = <<"kalle">>,bool=true}, + imp=#'Imp'{os = <<"kalle">>,bool=true}, + exp=#'Exp'{os = <<"kalle">>,bool=true}}), + roundtrip('SeqTagImp', #'SeqTagImp'{nt=#'NT'{os = <<"kalle">>,bool=true}, + imp=#'Imp'{os = <<"kalle">>,bool=true}, + exp=#'Exp'{os = <<"kalle">>,bool=true}}), + roundtrip('SeqTagExp', #'SeqTagExp'{nt=#'NT'{os = <<"kalle">>,bool=true}, + imp=#'Imp'{os = <<"kalle">>,bool=true}, + exp=#'Exp'{os = <<"kalle">>,bool=true}}), + roundtrip('SeqTagX', #'SeqTagX'{xnt=#'XSeqNT'{os = <<"kalle">>,bool=true}, + ximp=#'XSeqImp'{os = <<"kalle">>,bool=true}, + xexp=#'XSeqExp'{os = <<"kalle">>,bool=true}}), + roundtrip('SeqTagImpX', #'SeqTagImpX'{xnt=#'XSeqNT'{os = <<"kalle">>,bool=true}, + ximp=#'XSeqImp'{os = <<"kalle">>,bool=true}, + xexp=#'XSeqExp'{os = <<"kalle">>,bool=true}}), + roundtrip('SeqTagExpX', #'SeqTagExpX'{xnt=#'XSeqNT'{os = <<"kalle">>,bool=true}, + ximp=#'XSeqImp'{os = <<"kalle">>,bool=true}, + xexp=#'XSeqExp'{os = <<"kalle">>,bool=true}}), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSeqTypeRefCho.erl b/lib/asn1/test/testSeqTypeRefCho.erl index b008bc46b8..1a921c6f38 100644 --- a/lib/asn1/test/testSeqTypeRefCho.erl +++ b/lib/asn1/test/testSeqTypeRefCho.erl @@ -28,10 +28,10 @@ main(_Rules) -> roundtrip('SeqTRcho', - #'SeqTRcho'{'seqCho' = {choOs,"A string 1"}, - 'seqChoE' = {choOs,"A string 3"}, - 'seqCho-E' = {choOs,"A string 7"}, - 'seqChoE-E' = {choOs,"A string 9"}}), + #'SeqTRcho'{'seqCho' = {choOs,<<"A string 1">>}, + 'seqChoE' = {choOs,<<"A string 3">>}, + 'seqCho-E' = {choOs,<<"A string 7">>}, + 'seqChoE-E' = {choOs,<<"A string 9">>}}), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSeqTypeRefPrim.erl b/lib/asn1/test/testSeqTypeRefPrim.erl index b63882ae99..d66d1ebcfe 100644 --- a/lib/asn1/test/testSeqTypeRefPrim.erl +++ b/lib/asn1/test/testSeqTypeRefPrim.erl @@ -26,15 +26,15 @@ main(_Rules) -> roundtrip('SeqTR', - #'SeqTR'{'octStr' = "A string 1", - 'octStrI' = "A string 2", - 'octStrE' = "A string 3", - 'octStr-I' = "A string 4", - 'octStrI-I' = "A string 5", - 'octStrE-I' = "A string 6", - 'octStr-E' = "A string 7", - 'octStrI-E' = "A string 8", - 'octStrE-E' = "A string 9"}), + #'SeqTR'{'octStr' = <<"A string 1">>, + 'octStrI' = <<"A string 2">>, + 'octStrE' = <<"A string 3">>, + 'octStr-I' = <<"A string 4">>, + 'octStrI-I' = <<"A string 5">>, + 'octStrE-I' = <<"A string 6">>, + 'octStr-E' = <<"A string 7">>, + 'octStrI-E' = <<"A string 8">>, + 'octStrE-E' = <<"A string 9">>}), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSeqTypeRefSeq.erl b/lib/asn1/test/testSeqTypeRefSeq.erl index fc2e0a67c9..3288511f0a 100644 --- a/lib/asn1/test/testSeqTypeRefSeq.erl +++ b/lib/asn1/test/testSeqTypeRefSeq.erl @@ -71,15 +71,15 @@ main(_Rules) -> seqS2=#'SeqSTag_seqS2'{b2=true,i2=22}, seqS3=#'SeqSTag_seqS3'{b3=true,i3=33}}), roundtrip('SeqTRseq', - #'SeqTRseq'{seqSeq=#'SeqSeq'{seqInt=2,seqOs="A1"}, - seqSeqI=#'SeqSeq'{seqInt=2,seqOs="A2"}, - seqSeqE=#'SeqSeq'{seqInt=2,seqOs="A3"}, - 'seqSeq-I'=#'SeqSeqImp'{seqInt=2,seqOs="A4"}, - 'seqSeqI-I'=#'SeqSeqImp'{seqInt=2,seqOs="A5"}, - 'seqSeqE-I'=#'SeqSeqImp'{seqInt=2,seqOs="A6"}, - 'seqSeq-E'=#'SeqSeqExp'{seqInt=2,seqOs="A7"}, - 'seqSeqI-E'=#'SeqSeqExp'{seqInt=2,seqOs="A8"}, - 'seqSeqE-E'=#'SeqSeqExp'{seqInt=2,seqOs="A9"}}), + #'SeqTRseq'{seqSeq=#'SeqSeq'{seqInt=2,seqOs = <<"A1">>}, + seqSeqI=#'SeqSeq'{seqInt=2,seqOs = <<"A2">>}, + seqSeqE=#'SeqSeq'{seqInt=2,seqOs = <<"A3">>}, + 'seqSeq-I'=#'SeqSeqImp'{seqInt=2,seqOs = <<"A4">>}, + 'seqSeqI-I'=#'SeqSeqImp'{seqInt=2,seqOs = <<"A5">>}, + 'seqSeqE-I'=#'SeqSeqImp'{seqInt=2,seqOs = <<"A6">>}, + 'seqSeq-E'=#'SeqSeqExp'{seqInt=2,seqOs = <<"A7">>}, + 'seqSeqI-E'=#'SeqSeqExp'{seqInt=2,seqOs = <<"A8">>}, + 'seqSeqE-E'=#'SeqSeqExp'{seqInt=2,seqOs = <<"A9">>}}), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSeqTypeRefSet.erl b/lib/asn1/test/testSeqTypeRefSet.erl index 911a4b7a47..d73423284b 100644 --- a/lib/asn1/test/testSeqTypeRefSet.erl +++ b/lib/asn1/test/testSeqTypeRefSet.erl @@ -32,15 +32,15 @@ main(_Rules) -> roundtrip('SeqTRset', - #'SeqTRset'{seqSet=#'SeqSet'{setInt=2,setOs="A1"}, - seqSetI=#'SeqSet'{setInt=2,setOs="A2"}, - seqSetE=#'SeqSet'{setInt=2,setOs="A3"}, - 'seqSet-I'=#'SeqSetImp'{setInt=2,setOs="A4"}, - 'seqSetI-I'=#'SeqSetImp'{setInt=2,setOs="A5"}, - 'seqSetE-I'=#'SeqSetImp'{setInt=2,setOs="A6"}, - 'seqSet-E'=#'SeqSetExp'{setInt=2,setOs="A7"}, - 'seqSetI-E'=#'SeqSetExp'{setInt=2,setOs="A8"}, - 'seqSetE-E'=#'SeqSetExp'{setInt=2,setOs="A9"}}), + #'SeqTRset'{seqSet=#'SeqSet'{setInt=2,setOs = <<"A1">>}, + seqSetI=#'SeqSet'{setInt=2,setOs = <<"A2">>}, + seqSetE=#'SeqSet'{setInt=2,setOs = <<"A3">>}, + 'seqSet-I'=#'SeqSetImp'{setInt=2,setOs = <<"A4">>}, + 'seqSetI-I'=#'SeqSetImp'{setInt=2,setOs = <<"A5">>}, + 'seqSetE-I'=#'SeqSetImp'{setInt=2,setOs = <<"A6">>}, + 'seqSet-E'=#'SeqSetExp'{setInt=2,setOs = <<"A7">>}, + 'seqSetI-E'=#'SeqSetExp'{setInt=2,setOs = <<"A8">>}, + 'seqSetE-E'=#'SeqSetExp'{setInt=2,setOs = <<"A9">>}}), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSetExternal.erl b/lib/asn1/test/testSetExternal.erl index e17d7053aa..626adc5822 100644 --- a/lib/asn1/test/testSetExternal.erl +++ b/lib/asn1/test/testSetExternal.erl @@ -28,15 +28,15 @@ -record('SetXSeq3',{bool, int, seq}). main(_Rules) -> - roundtrip('XNTNT', #'XSetNT'{os="kalle",bool=true}), - roundtrip('XImpNT', #'XSetNT'{os="kalle",bool=true}), - roundtrip('XExpNT', #'XSetNT'{os="kalle",bool=true}), - roundtrip('XNTImp', #'XSetImp'{os="kalle",bool=true}), - roundtrip('XImpImp', #'XSetImp'{os="kalle",bool=true}), - roundtrip('XExpImp', #'XSetImp'{os="kalle",bool=true}), - roundtrip('XNTExp', #'XSetExp'{os="kalle",bool=true}), - roundtrip('XImpExp', #'XSetExp'{os="kalle",bool=true}), - roundtrip('XExpExp', #'XSetExp'{os="kalle",bool=true}), + roundtrip('XNTNT', #'XSetNT'{os = <<"kalle">>,bool=true}), + roundtrip('XImpNT', #'XSetNT'{os = <<"kalle">>,bool=true}), + roundtrip('XExpNT', #'XSetNT'{os = <<"kalle">>,bool=true}), + roundtrip('XNTImp', #'XSetImp'{os = <<"kalle">>,bool=true}), + roundtrip('XImpImp', #'XSetImp'{os = <<"kalle">>,bool=true}), + roundtrip('XExpImp', #'XSetImp'{os = <<"kalle">>,bool=true}), + roundtrip('XNTExp', #'XSetExp'{os = <<"kalle">>,bool=true}), + roundtrip('XImpExp', #'XSetExp'{os = <<"kalle">>,bool=true}), + roundtrip('XExpExp', #'XSetExp'{os = <<"kalle">>,bool=true}), roundtrip('SetXSeq1', #'SetXSeq1'{seq=#'XSeq1'{bool1=true,int1=77, seq1=#'XSeqIn'{boolIn=false,intIn=88}}, bool=true,int=66}), diff --git a/lib/asn1/test/testSetOf.erl b/lib/asn1/test/testSetOf.erl index 54c42c1f21..0f82a14625 100644 --- a/lib/asn1/test/testSetOf.erl +++ b/lib/asn1/test/testSetOf.erl @@ -121,9 +121,9 @@ main(_Rules) -> #'SetIn'{boolIn=false,intIn=125}, #'SetIn'{boolIn=false,intIn=225}]}), - roundtrip('SetOs', ["First","Second","Third"]), - roundtrip('SetOsImp', ["First","Second","Third"]), - roundtrip('SetOsExp', ["First","Second","Third"]), + roundtrip('SetOs', [<<"First">>,<<"Second">>,<<"Third">>]), + roundtrip('SetOsImp', [<<"First">>,<<"Second">>,<<"Third">>]), + roundtrip('SetOsExp', [<<"First">>,<<"Second">>,<<"Third">>]), roundtrip('SetEmp', #'SetEmp'{set1=[#'Empty'{}]}), ok. diff --git a/lib/asn1/test/testSetOfExternal.erl b/lib/asn1/test/testSetOfExternal.erl index a380ba5ac1..cc5fe10710 100644 --- a/lib/asn1/test/testSetOfExternal.erl +++ b/lib/asn1/test/testSetOfExternal.erl @@ -28,24 +28,42 @@ -record('Exp',{os, bool}). main(_Rules) -> - roundtrip('NTNT', [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), - roundtrip('ImpNT', [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), - roundtrip('ExpNT', [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), - roundtrip('NTImp', [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), - roundtrip('ImpImp', [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), - roundtrip('ExpImp', [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), - roundtrip('NTExp', [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), - roundtrip('ImpExp', [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), - roundtrip('ExpExp', [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), - roundtrip('XNTNT', [#'XSetNT'{os="kalle",bool=true},#'XSetNT'{os="kalle",bool=true}]), - roundtrip('XImpNT', [#'XSetNT'{os="kalle",bool=true},#'XSetNT'{os="kalle",bool=true}]), - roundtrip('XExpNT', [#'XSetNT'{os="kalle",bool=true},#'XSetNT'{os="kalle",bool=true}]), - roundtrip('XNTImp', [#'XSetImp'{os="kalle",bool=true},#'XSetImp'{os="kalle",bool=true}]), - roundtrip('XImpImp', [#'XSetImp'{os="kalle",bool=true},#'XSetImp'{os="kalle",bool=true}]), - roundtrip('XExpImp', [#'XSetImp'{os="kalle",bool=true},#'XSetImp'{os="kalle",bool=true}]), - roundtrip('XNTExp', [#'XSetExp'{os="kalle",bool=true},#'XSetExp'{os="kalle",bool=true}]), - roundtrip('XImpExp', [#'XSetExp'{os="kalle",bool=true},#'XSetExp'{os="kalle",bool=true}]), - roundtrip('XExpExp', [#'XSetExp'{os="kalle",bool=true},#'XSetExp'{os="kalle",bool=true}]), + roundtrip('NTNT', [#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]), + roundtrip('ImpNT', [#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]), + roundtrip('ExpNT', [#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]), + roundtrip('NTImp', [#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]), + roundtrip('ImpImp', [#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]), + roundtrip('ExpImp', [#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]), + roundtrip('NTExp', [#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]), + roundtrip('ImpExp', [#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]), + roundtrip('ExpExp', [#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]), + roundtrip('XNTNT', [#'XSetNT'{os = <<"kalle">>,bool=true}, + #'XSetNT'{os = <<"kalle">>,bool=true}]), + roundtrip('XImpNT', [#'XSetNT'{os = <<"kalle">>,bool=true}, + #'XSetNT'{os = <<"kalle">>,bool=true}]), + roundtrip('XExpNT', [#'XSetNT'{os = <<"kalle">>,bool=true}, + #'XSetNT'{os = <<"kalle">>,bool=true}]), + roundtrip('XNTImp', [#'XSetImp'{os = <<"kalle">>,bool=true}, + #'XSetImp'{os = <<"kalle">>,bool=true}]), + roundtrip('XImpImp', [#'XSetImp'{os = <<"kalle">>,bool=true}, + #'XSetImp'{os = <<"kalle">>,bool=true}]), + roundtrip('XExpImp', [#'XSetImp'{os = <<"kalle">>,bool=true}, + #'XSetImp'{os = <<"kalle">>,bool=true}]), + roundtrip('XNTExp', [#'XSetExp'{os = <<"kalle">>,bool=true}, + #'XSetExp'{os = <<"kalle">>,bool=true}]), + roundtrip('XImpExp', [#'XSetExp'{os = <<"kalle">>,bool=true}, + #'XSetExp'{os = <<"kalle">>,bool=true}]), + roundtrip('XExpExp', [#'XSetExp'{os = <<"kalle">>,bool=true}, + #'XSetExp'{os = <<"kalle">>,bool=true}]), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSetOfTag.erl b/lib/asn1/test/testSetOfTag.erl index 81bc467abb..0d656f05a6 100644 --- a/lib/asn1/test/testSetOfTag.erl +++ b/lib/asn1/test/testSetOfTag.erl @@ -42,42 +42,42 @@ -record('Exp',{os, bool}). main(_Rules) -> - roundtrip('SetTagNt', #'SetTagNt'{nt=[#'NT'{os="kalle",bool=true}, - #'NT'{os="kalle",bool=true}]}), - roundtrip('SetTagNtI', #'SetTagNtI'{imp=[#'Imp'{os="kalle",bool=true}, - #'Imp'{os="kalle",bool=true}]}), - roundtrip('SetTagNtE', #'SetTagNtE'{exp=[#'Exp'{os="kalle",bool=true}, - #'Exp'{os="kalle",bool=true}]}), - roundtrip('SetTagI', #'SetTagI'{nt=[#'NT'{os="kalle",bool=true}, - #'NT'{os="kalle",bool=true}]}), - roundtrip('SetTagII', #'SetTagII'{imp=[#'Imp'{os="kalle",bool=true}, - #'Imp'{os="kalle",bool=true}]}), - roundtrip('SetTagIE', #'SetTagIE'{exp=[#'Exp'{os="kalle",bool=true}, - #'Exp'{os="kalle",bool=true}]}), - roundtrip('SetTagE', #'SetTagE'{nt=[#'NT'{os="kalle",bool=true}, - #'NT'{os="kalle",bool=true}]}), - roundtrip('SetTagEI', #'SetTagEI'{imp=[#'Imp'{os="kalle",bool=true}, - #'Imp'{os="kalle",bool=true}]}), - roundtrip('SetTagEE', #'SetTagEE'{exp=[#'Exp'{os="kalle",bool=true}, - #'Exp'{os="kalle",bool=true}]}), - roundtrip('SetTagXNt', #'SetTagXNt'{xnt=[#'XSetNT'{os="kalle",bool=true}, - #'XSetNT'{os="kalle",bool=true}]}), - roundtrip('SetTagXI', #'SetTagXI'{ximp=[#'XSetImp'{os="kalle",bool=true}, - #'XSetImp'{os="kalle",bool=true}]}), - roundtrip('SetTagXE', #'SetTagXE'{xexp=[#'XSetExp'{os="kalle",bool=true}, - #'XSetExp'{os="kalle",bool=true}]}), - roundtrip('SetTagImpX', #'SetTagImpX'{xnt=[#'XSetNT'{os="kalle",bool=true}, - #'XSetNT'{os="kalle",bool=true}], - ximp=[#'XSetImp'{os="kalle",bool=true}, - #'XSetImp'{os="kalle",bool=true}], - xexp=[#'XSetExp'{os="kalle",bool=true}, - #'XSetExp'{os="kalle",bool=true}]}), - roundtrip('SetTagExpX', #'SetTagExpX'{xnt=[#'XSetNT'{os="kalle",bool=true}, - #'XSetNT'{os="kalle",bool=true}], - ximp=[#'XSetImp'{os="kalle",bool=true}, - #'XSetImp'{os="kalle",bool=true}], - xexp=[#'XSetExp'{os="kalle",bool=true}, - #'XSetExp'{os="kalle",bool=true}]}), + roundtrip('SetTagNt', #'SetTagNt'{nt=[#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagNtI', #'SetTagNtI'{imp=[#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagNtE', #'SetTagNtE'{exp=[#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagI', #'SetTagI'{nt=[#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagII', #'SetTagII'{imp=[#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagIE', #'SetTagIE'{exp=[#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagE', #'SetTagE'{nt=[#'NT'{os = <<"kalle">>,bool=true}, + #'NT'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagEI', #'SetTagEI'{imp=[#'Imp'{os = <<"kalle">>,bool=true}, + #'Imp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagEE', #'SetTagEE'{exp=[#'Exp'{os = <<"kalle">>,bool=true}, + #'Exp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagXNt', #'SetTagXNt'{xnt=[#'XSetNT'{os = <<"kalle">>,bool=true}, + #'XSetNT'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagXI', #'SetTagXI'{ximp=[#'XSetImp'{os = <<"kalle">>,bool=true}, + #'XSetImp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagXE', #'SetTagXE'{xexp=[#'XSetExp'{os = <<"kalle">>,bool=true}, + #'XSetExp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagImpX', #'SetTagImpX'{xnt=[#'XSetNT'{os = <<"kalle">>,bool=true}, + #'XSetNT'{os = <<"kalle">>,bool=true}], + ximp=[#'XSetImp'{os = <<"kalle">>,bool=true}, + #'XSetImp'{os = <<"kalle">>,bool=true}], + xexp=[#'XSetExp'{os = <<"kalle">>,bool=true}, + #'XSetExp'{os = <<"kalle">>,bool=true}]}), + roundtrip('SetTagExpX', #'SetTagExpX'{xnt=[#'XSetNT'{os = <<"kalle">>,bool=true}, + #'XSetNT'{os = <<"kalle">>,bool=true}], + ximp=[#'XSetImp'{os = <<"kalle">>,bool=true}, + #'XSetImp'{os = <<"kalle">>,bool=true}], + xexp=[#'XSetExp'{os = <<"kalle">>,bool=true}, + #'XSetExp'{os = <<"kalle">>,bool=true}]}), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSetTag.erl b/lib/asn1/test/testSetTag.erl index 5863a149b9..fa1d84f50d 100644 --- a/lib/asn1/test/testSetTag.erl +++ b/lib/asn1/test/testSetTag.erl @@ -34,24 +34,24 @@ -record('Exp',{os, bool}). main(_Rules) -> - roundtrip('SetTag', #'SetTag'{nt=#'NT'{os="kalle",bool=true}, - imp=#'Imp'{os="kalle",bool=true}, - exp=#'Exp'{os="kalle",bool=true}}), - roundtrip('SetTagImp', #'SetTagImp'{nt=#'NT'{os="kalle",bool=true}, - imp=#'Imp'{os="kalle",bool=true}, - exp=#'Exp'{os="kalle",bool=true}}), - roundtrip('SetTagExp', #'SetTagExp'{nt=#'NT'{os="kalle",bool=true}, - imp=#'Imp'{os="kalle",bool=true}, - exp=#'Exp'{os="kalle",bool=true}}), - roundtrip('SetTagX', #'SetTagX'{xnt=#'XSetNT'{os="kalle",bool=true}, - ximp=#'XSetImp'{os="kalle",bool=true}, - xexp=#'XSetExp'{os="kalle",bool=true}}), - roundtrip('SetTagImpX', #'SetTagImpX'{xnt=#'XSetNT'{os="kalle",bool=true}, - ximp=#'XSetImp'{os="kalle",bool=true}, - xexp=#'XSetExp'{os="kalle",bool=true}}), - roundtrip('SetTagExpX', #'SetTagExpX'{xnt=#'XSetNT'{os="kalle",bool=true}, - ximp=#'XSetImp'{os="kalle",bool=true}, - xexp=#'XSetExp'{os="kalle",bool=true}}), + roundtrip('SetTag', #'SetTag'{nt=#'NT'{os = <<"kalle">>,bool=true}, + imp=#'Imp'{os = <<"kalle">>,bool=true}, + exp=#'Exp'{os = <<"kalle">>,bool=true}}), + roundtrip('SetTagImp', #'SetTagImp'{nt=#'NT'{os = <<"kalle">>,bool=true}, + imp=#'Imp'{os = <<"kalle">>,bool=true}, + exp=#'Exp'{os = <<"kalle">>,bool=true}}), + roundtrip('SetTagExp', #'SetTagExp'{nt=#'NT'{os = <<"kalle">>,bool=true}, + imp=#'Imp'{os = <<"kalle">>,bool=true}, + exp=#'Exp'{os = <<"kalle">>,bool=true}}), + roundtrip('SetTagX', #'SetTagX'{xnt=#'XSetNT'{os = <<"kalle">>,bool=true}, + ximp=#'XSetImp'{os = <<"kalle">>,bool=true}, + xexp=#'XSetExp'{os = <<"kalle">>,bool=true}}), + roundtrip('SetTagImpX', #'SetTagImpX'{xnt=#'XSetNT'{os = <<"kalle">>,bool=true}, + ximp=#'XSetImp'{os = <<"kalle">>,bool=true}, + xexp=#'XSetExp'{os = <<"kalle">>,bool=true}}), + roundtrip('SetTagExpX', #'SetTagExpX'{xnt=#'XSetNT'{os = <<"kalle">>,bool=true}, + ximp=#'XSetImp'{os = <<"kalle">>,bool=true}, + xexp=#'XSetExp'{os = <<"kalle">>,bool=true}}), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSetTypeRefCho.erl b/lib/asn1/test/testSetTypeRefCho.erl index 8d62f45bfa..97bbd557e0 100644 --- a/lib/asn1/test/testSetTypeRefCho.erl +++ b/lib/asn1/test/testSetTypeRefCho.erl @@ -29,10 +29,10 @@ main(_Rules) -> roundtrip('SetTRcho', - #'SetTRcho'{'setCho' = {choOs,"A string 1"}, - 'setChoE' = {choOs,"A string 3"}, - 'setCho-E' = {choOs,"A string 7"}, - 'setChoE-E' = {choOs,"A string 9"}}), + #'SetTRcho'{'setCho' = {choOs,<<"A string 1">>}, + 'setChoE' = {choOs,<<"A string 3">>}, + 'setCho-E' = {choOs,<<"A string 7">>}, + 'setChoE-E' = {choOs,<<"A string 9">>}}), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSetTypeRefPrim.erl b/lib/asn1/test/testSetTypeRefPrim.erl index cc2e157e68..d441fb789d 100644 --- a/lib/asn1/test/testSetTypeRefPrim.erl +++ b/lib/asn1/test/testSetTypeRefPrim.erl @@ -28,15 +28,15 @@ main(_Rules) -> roundtrip('SetTR', - #'SetTR'{'octStr' = "A string 1", - 'octStrI' = "A string 2", - 'octStrE' = "A string 3", - 'octStr-I' = "A string 4", - 'octStrI-I' = "A string 5", - 'octStrE-I' = "A string 6", - 'octStr-E' = "A string 7", - 'octStrI-E' = "A string 8", - 'octStrE-E' = "A string 9"}), + #'SetTR'{'octStr' = <<"A string 1">>, + 'octStrI' = <<"A string 2">>, + 'octStrE' = <<"A string 3">>, + 'octStr-I' = <<"A string 4">>, + 'octStrI-I' = <<"A string 5">>, + 'octStrE-I' = <<"A string 6">>, + 'octStr-E' = <<"A string 7">>, + 'octStrI-E' = <<"A string 8">>, + 'octStrE-E' = <<"A string 9">>}), ok. roundtrip(T, V) -> diff --git a/lib/asn1/test/testSetTypeRefSeq.erl b/lib/asn1/test/testSetTypeRefSeq.erl index 17af5c2922..a2b5f5745e 100644 --- a/lib/asn1/test/testSetTypeRefSeq.erl +++ b/lib/asn1/test/testSetTypeRefSeq.erl @@ -30,23 +30,23 @@ main(_Rules) -> roundtrip('SetTRseq', - #'SetTRseq'{'setSeq' = #'SetSeq'{seqOs = "A1", + #'SetTRseq'{'setSeq' = #'SetSeq'{seqOs = <<"A1">>, seqInt = 2}, - 'setSeqI' = #'SetSeq'{seqOs = "A2", + 'setSeqI' = #'SetSeq'{seqOs = <<"A2">>, seqInt = 2}, - 'setSeqE' = #'SetSeq'{seqOs = "A3", + 'setSeqE' = #'SetSeq'{seqOs = <<"A3">>, seqInt = 2}, - 'setSeq-I' = #'SetSeqImp'{seqOs = "A4", + 'setSeq-I' = #'SetSeqImp'{seqOs = <<"A4">>, seqInt = 2}, - 'setSeqI-I' = #'SetSeqImp'{seqOs = "A5", + 'setSeqI-I' = #'SetSeqImp'{seqOs = <<"A5">>, seqInt = 2}, - 'setSeqE-I' = #'SetSeqImp'{seqOs = "A6", + 'setSeqE-I' = #'SetSeqImp'{seqOs = <<"A6">>, seqInt = 2}, - 'setSeq-E' = #'SetSeqExp'{seqOs = "A7", + 'setSeq-E' = #'SetSeqExp'{seqOs = <<"A7">>, seqInt = 2}, - 'setSeqI-E' = #'SetSeqExp'{seqOs = "A8", + 'setSeqI-E' = #'SetSeqExp'{seqOs = <<"A8">>, seqInt = 2}, - 'setSeqE-E' = #'SetSeqExp'{seqOs = "A9", + 'setSeqE-E' = #'SetSeqExp'{seqOs = <<"A9">>, seqInt = 2}}), ok. diff --git a/lib/asn1/test/testSetTypeRefSet.erl b/lib/asn1/test/testSetTypeRefSet.erl index 8786e0fb4d..80a6be58c9 100644 --- a/lib/asn1/test/testSetTypeRefSet.erl +++ b/lib/asn1/test/testSetTypeRefSet.erl @@ -71,15 +71,15 @@ main(_Rules) -> setS2=#'SetSTag_setS2'{b2=true,i2=22}, setS3=#'SetSTag_setS3'{b3=true,i3=33}}), roundtrip('SetTRset', - #'SetTRset'{setSet=#'SetSet'{setInt=2,setOs="A1"}, - setSetI=#'SetSet'{setInt=2,setOs="A2"}, - setSetE=#'SetSet'{setInt=2,setOs="A3"}, - 'setSet-I'=#'SetSetImp'{setInt=2,setOs="A4"}, - 'setSetI-I'=#'SetSetImp'{setInt=2,setOs="A5"}, - 'setSetE-I'=#'SetSetImp'{setInt=2,setOs="A6"}, - 'setSet-E'=#'SetSetExp'{setInt=2,setOs="A7"}, - 'setSetI-E'=#'SetSetExp'{setInt=2,setOs="A8"}, - 'setSetE-E'=#'SetSetExp'{setInt=2,setOs="A9"}}), + #'SetTRset'{setSet=#'SetSet'{setInt=2,setOs = <<"A1">>}, + setSetI=#'SetSet'{setInt=2,setOs = <<"A2">>}, + setSetE=#'SetSet'{setInt=2,setOs = <<"A3">>}, + 'setSet-I'=#'SetSetImp'{setInt=2,setOs = <<"A4">>}, + 'setSetI-I'=#'SetSetImp'{setInt=2,setOs = <<"A5">>}, + 'setSetE-I'=#'SetSetImp'{setInt=2,setOs = <<"A6">>}, + 'setSet-E'=#'SetSetExp'{setInt=2,setOs = <<"A7">>}, + 'setSetI-E'=#'SetSetExp'{setInt=2,setOs = <<"A8">>}, + 'setSetE-E'=#'SetSetExp'{setInt=2,setOs = <<"A9">>}}), ok. diff --git a/lib/asn1/test/testTimer.erl b/lib/asn1/test/testTimer.erl index 0f02bab6e0..89bc2b463d 100644 --- a/lib/asn1/test/testTimer.erl +++ b/lib/asn1/test/testTimer.erl @@ -18,163 +18,141 @@ %% %% -module(testTimer). --export([go/2]). +-export([go/0]). -include_lib("test_server/include/test_server.hrl"). -define(times, 5000). val() -> - _Value = {'H323-UserInformation',{'H323-UU-PDU', - {callProceeding, - {'CallProceeding-UUIE', - {0,8,222}, - {'EndpointType', - {'NonStandardParameter', - {object,{0,9,237}}, - "O"}, - {'VendorIdentifier', - {'H221NonStandard',62,63,16282}, - "OC", - "OC"}, - {'GatekeeperInfo', - {'NonStandardParameter', - {object,{0,10,260}}, - "O"}}, - {'GatewayInfo', - [{h320, - {'H320Caps', - {'NonStandardParameter', - {object,{0,11,282}}, - "O"}, - [{'DataRate', - {'NonStandardParameter', - {object, - {0,11,295}}, - "O"}, - 1290470518, - 78}], - [{'SupportedPrefix', - {'NonStandardParameter', - {object, - {0,12,312}}, - "O"}, - {'h323-ID',"BM"}}]}}], - {'NonStandardParameter', - {object,{0,13,326}}, - "O"}}, - {'McuInfo', - {'NonStandardParameter', - {object,{1,13,340,340}}, - "OC"}}, - {'TerminalInfo', - {'NonStandardParameter', - {object,{1,14,353,354}}, - "OC"}}, - true, - true}, - {ipxAddress, - {'TransportAddress_ipxAddress', - "OCTET ", - "OCTE", - "OC"}}, - {'CallIdentifier',"OCTET STRINGOCTE"}, - {noSecurity,'NULL'}, - [{'ClearToken', - 1667517741, - "BM", - {'DHset',[1],[1],[1]}, - "OCTET STR", - -26430296, - {'TypedCertificate', - {1,16,405,406}, - "OC"}, - "BMP", - {'NonStandardParameter', - {1,16,414,415}, - "OC"}}, - {'ClearToken', - 1817656756, - "BMP", - {'DHset',[1],[1],[1]}, - "OCTET STRI", - -16356110, - {'TypedCertificate', - {1,17,442,443}, - "OC"}, - "BMP", - {'NonStandardParameter', - {1,18,452,452}, - "OC"}}], - [{cryptoGKPwdEncr, - {'CryptoH323Token_cryptoGKPwdEncr', - {1,18,467,467}, - {'Params',-7477016,"OCTET ST"}, - "OC"}}, - {cryptoGKPwdEncr, - {'CryptoH323Token_cryptoGKPwdEncr', - {1,19,486,486}, - {'Params',-2404513,"OCTET ST"}, - []}}], - []}}, - {'NonStandardParameter',{object,{0,3,84}},[]}, - [], - true, - [], - []}, - {'H323-UserInformation_user-data',24,"O"}}. + {'H323-UserInformation',{'H323-UU-PDU', + {callProceeding, + {'CallProceeding-UUIE', + {0,8,222}, + {'EndpointType', + {'NonStandardParameter', + {object,{0,9,237}}, + <<"O">>}, + {'VendorIdentifier', + {'H221NonStandard',62,63,16282}, + <<"OC">>, + <<"OC">>}, + {'GatekeeperInfo', + {'NonStandardParameter', + {object,{0,10,260}}, + <<"O">>}}, + {'GatewayInfo', + [{h320, + {'H320Caps', + {'NonStandardParameter', + {object,{0,11,282}}, + <<"O">>}, + [{'DataRate', + {'NonStandardParameter', + {object, + {0,11,295}}, + <<"O">>}, + 1290470518, + 78}], + [{'SupportedPrefix', + {'NonStandardParameter', + {object, + {0,12,312}}, + <<"O">>}, + {'h323-ID',"BM"}}]}}], + {'NonStandardParameter', + {object,{0,13,326}}, + <<"O">>}}, + {'McuInfo', + {'NonStandardParameter', + {object,{1,13,340,340}}, + <<"OC">>}}, + {'TerminalInfo', + {'NonStandardParameter', + {object,{1,14,353,354}}, + <<"OC">>}}, + true, + true}, + {ipxAddress, + {'TransportAddress_ipxAddress', + <<"OCTET ">>, + <<"OCTE">>, + <<"OC">>}}, + {'CallIdentifier',<<"OCTET STRINGOCTE">>}, + {noSecurity,'NULL'}, + [{'ClearToken', + 1667517741, + "BM", + {'DHset',<<1:1>>,<<1:1>>,<<1:1>>}, + <<"OCTET STR">>, + -26430296, + {'TypedCertificate', + {1,16,405,406}, + <<"OC">>}, + "BMP", + {'NonStandardParameter', + {1,16,414,415}, + <<"OC">>}}, + {'ClearToken', + 1817656756, + "BMP", + {'DHset',<<1:1>>,<<1:1>>,<<1:1>>}, + <<"OCTET STRI">>, + -16356110, + {'TypedCertificate', + {1,17,442,443}, + <<"OC">>}, + "BMP", + {'NonStandardParameter', + {1,18,452,452}, + <<"OC">>}}], + [{cryptoGKPwdEncr, + {'CryptoH323Token_cryptoGKPwdEncr', + {1,18,467,467}, + {'Params',-7477016,<<"OCTET ST">>}, + <<"OC">>}}, + {cryptoGKPwdEncr, + {'CryptoH323Token_cryptoGKPwdEncr', + {1,19,486,486}, + {'Params',-2404513,<<"OCTET ST">>}, + <<>>}}], + []}}, + {'NonStandardParameter',{object,{0,3,84}},<<>>}, + [], + true, + [], + []}, + {'H323-UserInformation_user-data',24,<<"O">>}}. -go(Config, _Enc) -> - ?line true = code:add_patha(?config(priv_dir,Config)), - +go() -> Module = 'H323-MESSAGES', Type = 'H323-UserInformation', Value = val(), - {ok,Bytes} = asn1rt:encode(Module,Type,Value), + Bytes = Module:encode(Type, Value), + Value = Module:decode(Type, Bytes), - CompileOptions = compile_options(), - {ValWr,done} = timer:tc(fun() -> encode(?times, Module, Type, Value) end), - ?line io:format("ASN1 encode ~p: ~p micro~n", [CompileOptions, ValWr / ?times]), + io:format("ASN.1 encoding: ~p micro~n", [ValWr / ?times]), done = decode(2, Module, Type, Bytes), {ValRead,done} = timer:tc(fun() -> decode(?times, Module, Type, Bytes) end), - ?line io:format("ASN1 decode ~p: ~p micro~n", [CompileOptions, ValRead /?times]), - + io:format("ASN.1 decoding: ~p micro~n", [ValRead /?times]), - ?line Comment = "encode: "++integer_to_list(round(ValWr/?times))++ - " micro, decode: "++integer_to_list(round(ValRead /?times))++ - " micro. " ++ CompileOptions, + Comment = "encode: "++integer_to_list(round(ValWr/?times)) ++ + " micro, decode: "++integer_to_list(round(ValRead /?times)) ++ + " micro. [" ++ atom_to_list(Module:encoding_rule()) ++ "]", {comment,Comment}. encode(0, _Module,_Type,_Value) -> done; encode(N, Module,Type,Value) -> - ?line {ok,B} = asn1rt:encode(Module,Type,Value), - _B2 = if - is_list(B) -> list_to_binary(B); - true -> B - end, - encode(N-1, Module,Type,Value). + Module:encode(Type, Value), + encode(N-1, Module, Type, Value). decode(0, _Module, _Type, _Value) -> done; decode(N, Module, Type, Value) -> - {ok,_B} = asn1rt:decode(Module, Type, Value), + Module:decode(Type, Value), decode(N-1, Module, Type, Value). - -compile_options() -> - {ok,Info} = asn1rt:info('H323-MESSAGES'), - case lists:keyfind(options, 1, Info) of - {_,Opts0} -> - Opts1 = [X || X <- Opts0, - (X =:= ber orelse - X =:= per orelse - X =:= uper)], - lists:flatten(io_lib:format("~p", [Opts1])); - _ -> - "[]" - end. - diff --git a/lib/asn1/test/testTypeValueNotation.erl b/lib/asn1/test/testTypeValueNotation.erl index b46d7177f5..2b5f3f74c1 100644 --- a/lib/asn1/test/testTypeValueNotation.erl +++ b/lib/asn1/test/testTypeValueNotation.erl @@ -24,7 +24,7 @@ -record('Seq', {octstr, int, bool, enum, bitstr, null, oid, vstr}). main(_Rule, _Option) -> - Value = #'Seq'{octstr = [1, 2, 3, 4], + Value = #'Seq'{octstr = <<1,2,3,4>>, int = 12, bool = true, enum = a, diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml index 0a4dd3ba47..7b8d2940c1 100644 --- a/lib/kernel/doc/src/file.xml +++ b/lib/kernel/doc/src/file.xml @@ -37,54 +37,48 @@ the file operations. See the command line flag <c>+A</c> in <seealso marker="erts:erl">erl(1)</seealso>.</p> - <p>The Erlang VM supports file names in Unicode to a limited - extent. Depending on how the VM is started (with the parameter - <c>+fnu</c> or <c>+fnl</c>), file names given can contain - characters > 255 and the VM system will convert file names - back and forth to the native file name encoding.</p> + <p>With regard to file name encoding, the Erlang VM can operate in + two modes. The current mode can be queried using the <seealso + marker="#native_name_encoding">native_name_encoding/0</seealso> + function. It returns either <c>latin1</c> or <c>utf8</c>.</p> - <p>The default behavior for Unicode character translation depends - on to what extent the underlying OS/filesystem enforces consistent - naming. On OSes where all file names are ensured to be in one or - another encoding, Unicode is the default (currently this holds for - Windows and MacOSX). On OSes with completely transparent file - naming (i.e. all Unixes except MacOSX), ISO-latin-1 file naming is - the default. The reason for the ISO-latin-1 default is that - file names are not guaranteed to be possible to interpret according to - the Unicode encoding expected (i.e. UTF-8), and file names that - cannot be decoded will only be accessible by using "raw - file names", in other word file names given as binaries.</p> - - <p>As file names are traditionally not binaries in Erlang, - applications that need to handle raw file names need to be - converted, why the Unicode mode for file names is not default on - systems having completely transparent file naming.</p> + <p>In the <c>latin1</c> mode, the Erlang VM does not change the + encoding of file names. In the <c>utf8</c> mode, file names can + contain Unicode characters greater than 255 and the VM will + convert file names back and forth to the native file name encoding + (usually UTF-8, but UTF-16 on Windows).</p> - <p>Raw file names is a new feature in OTP R14B01, which allows the - user to supply completely uninterpreted file names to the - underlying OS/filesystem. They are supplied as binaries, where it - is up to the user to supply a correct encoding for the - environment. The function <c>file:native_name_encoding()</c> can - be used to check what encoding the VM is working in. If the - function returns <c>latin1</c> file names are not in any way - converted to Unicode, if it is <c>utf8</c>, raw file names should - be encoded as UTF-8 if they are to follow the convention of the VM - (and usually the convention of the OS as well). Using raw - file names is useful if you have a filesystem with inconsistent - file naming, where some files are named in UTF-8 encoding while - others are not. A file:list_dir on such mixed file name systems - when the VM is in Unicode file name mode might return file names as - raw binaries as they cannot be interpreted as Unicode - file names. Raw file names can also be used to give UTF-8 encoded - file names even though the VM is not started in Unicode file name - translation mode.</p> + <p>The default mode depends on the operating system. Windows and + MacOS X enforce consistent file name encoding and therefore the + VM uses the <c>utf8</c> mode.</p> + + <p>On operating systems with transparent naming (i.e. all Unix + systems except MacOS X), the default will be <c>utf8</c> if the + terminal supports UTF-8, otherwise <c>latin1</c>. The default may + be overridden using the <c>+fnl</c> (to force <c>latin1</c> mode) + or <c>+fnu</c> (to force <c>utf8</c> mode) when starting <seealso + marker="erts:erl">erl</seealso>.</p> + + <p>On operating systems with transparent naming, files could be + inconsistently named, i.e. some files are encoded in UTF-8 while + others are encoded in (for example) iso-latin1. To be able to + handle file systems with inconsistent naming when running in the + <c>utf8</c> mode, the concept of "raw file names" has been + introduced.</p> + + <p>A raw file name is a file name given as a binary. The Erlang VM + will perform no translation of a file name given as a binary on + systems with transparent naming.</p> + + <p>When running in the <c>utf8</c> mode, the + <c>file:list_dir/1</c> and <c>file:read_link/1</c> functions will + never return raw file names. Use the <seealso + marker="#list_dir_all">list_dir_all/1</seealso> and <seealso + marker="#read_link_all">read_link_all/1</seealso> functions to + return all file names including raw file names.</p> + + <p>Also see <seealso marker="stdlib:unicode_usage#notes-about-raw-filenames">Notes about raw file names</seealso>.</p> - <p>Note that on Windows, <c>file:native_name_encoding()</c> - returns <c>utf8</c> per default, which is the format for raw - file names even on Windows, although the underlying OS specific - code works in a limited version of little endian UTF16. As far as - the Erlang programmer is concerned, Windows native Unicode format - is UTF-8...</p> </description> <datatypes> @@ -535,8 +529,8 @@ <name name="list_dir_all" arity="1"/> <fsummary>List all files in a directory</fsummary> <desc> - <p>Lists all the files in a directory, including files with - "raw" names. + <p><marker id="list_dir_all"/>Lists all the files in a directory, + including files with "raw" names. Returns <c>{ok, <anno>Filenames</anno>}</c> if successful. Otherwise, it returns <c>{error, <anno>Reason</anno>}</c>. <c><anno>Filenames</anno></c> is a list of @@ -653,11 +647,14 @@ </func> <func> <name name="native_name_encoding" arity="0"/> - <fsummary>Return the VM's configured filename encoding.</fsummary> + <fsummary>Return the VM's configured filename encoding</fsummary> <desc> - <p>This function returns the configured default file name encoding to use for raw file names. Generally an application supplying file names raw (as binaries), should obey the character encoding returned by this function.</p> - <p>By default, the VM uses ISO-latin-1 file name encoding on filesystems and/or OSes that use completely transparent file naming. This includes all Unix versions except MacOSX, where the vfs layer enforces UTF-8 file naming. By giving the experimental option <c>+fnu</c> when starting Erlang, UTF-8 translation of file names can be turned on even for those systems. If Unicode file name translation is in effect, the system behaves as usual as long as file names conform to the encoding, but will return file names that are not properly encoded in UTF-8 as raw file names (i.e. binaries).</p> - <p>On Windows, this function also returns <c>utf8</c> by default. The OS uses a pure Unicode naming scheme and file names are always possible to interpret as valid Unicode. The fact that the underlying Windows OS actually encodes file names using little endian UTF-16 can be ignored by the Erlang programmer. Windows and MacOSX are the only operating systems where the VM operates in Unicode file name mode by default.</p> + <p><marker id="native_name_encoding"/>This function returns + the file name encoding mode. If it is <c>latin1</c>, the + system does no translation of file names. If it is + <c>utf8</c>, file names will be converted back and forth to + the native file name encoding (usually UTF-8, but UTF-16 on + Windows).</p> </desc> </func> <func> @@ -1450,7 +1447,8 @@ <name name="read_link" arity="1"/> <fsummary>See what a link is pointing to</fsummary> <desc> - <p>This function returns <c>{ok, <anno>Filename</anno>}</c> if + <p><marker id="read_link_all"/>This function returns + <c>{ok, <anno>Filename</anno>}</c> if <c><anno>Name</anno></c> refers to a symbolic link that is not a "raw" file name, or <c>{error, <anno>Reason</anno>}</c> otherwise. @@ -1746,16 +1744,16 @@ <item>The chunk size used by the erlang fallback to send data. If using the fallback, this should be set to a value which comfortably fits in the systems memory. Default is 20 MB.</item> + <tag><c>use_threads</c></tag> + <item>Instruct the emulator to use the async thread pool for the + sendfile system call. This could be usefull if the OS you are running + on does not properly support non-blocking sendfile calls. Do note that + using async threads potentially makes your system volnerable to slow + client attacks. If set to true and no async threads are available, + the sendfile call will return <c>{error,einval}</c>. + Introduced in 17.0. Default is false.</item> </taglist> </p> - <p>On operating systems with thread support, it is recommended to use - async threads. See the command line flag - <c>+A</c> in <seealso marker="erts:erl">erl(1)</seealso>. If it is not - possible to use async threads for sendfile, it is recommended to use - a relatively small value for the send buffer on the socket. Otherwise - the Erlang VM might loose some of its soft realtime guarantees. - Which size to use depends on the OS/hardware and the requirements - of the application.</p> </desc> </func> <func> diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index b5152018e0..23cf74f80f 100644 --- a/lib/kernel/src/file.erl +++ b/lib/kernel/src/file.erl @@ -111,7 +111,8 @@ -type date_time() :: calendar:datetime(). -type posix_file_advise() :: 'normal' | 'sequential' | 'random' | 'no_reuse' | 'will_need' | 'dont_need'. --type sendfile_option() :: {chunk_size, non_neg_integer()}. +-type sendfile_option() :: {chunk_size, non_neg_integer()} + | {use_threads, boolean()}. -type file_info_option() :: {'time', 'local'} | {'time', 'universal'} | {'time', 'posix'}. %%% BIFs @@ -1229,8 +1230,7 @@ change_time(Name, {{AY, AM, AD}, {AH, AMin, ASec}}=Atime, sendfile(File, _Sock, _Offet, _Bytes, _Opts) when is_pid(File) -> {error, badarg}; sendfile(File, Sock, Offset, Bytes, []) -> - sendfile(File, Sock, Offset, Bytes, ?MAX_CHUNK_SIZE, [], [], - false, false, false); + sendfile(File, Sock, Offset, Bytes, ?MAX_CHUNK_SIZE, [], [], []); sendfile(File, Sock, Offset, Bytes, Opts) -> ChunkSize0 = proplists:get_value(chunk_size, Opts, ?MAX_CHUNK_SIZE), ChunkSize = if ChunkSize0 > ?MAX_CHUNK_SIZE -> @@ -1240,8 +1240,7 @@ sendfile(File, Sock, Offset, Bytes, Opts) -> %% Support for headers, trailers and options has been removed because the %% Darwin and BSD API for using it does not play nice with %% non-blocking sockets. See unix_efile.c for more info. - sendfile(File, Sock, Offset, Bytes, ChunkSize, [], [], - false,false,false). + sendfile(File, Sock, Offset, Bytes, ChunkSize, [], [], Opts). %% sendfile/2 -spec sendfile(Filename, Socket) -> @@ -1261,17 +1260,17 @@ sendfile(Filename, Sock) -> %% Internal sendfile functions sendfile(#file_descriptor{ module = Mod } = Fd, Sock, Offset, Bytes, - ChunkSize, Headers, Trailers, Nodiskio, MNowait, Sync) + ChunkSize, Headers, Trailers, Opts) when is_port(Sock) -> case Mod:sendfile(Fd, Sock, Offset, Bytes, ChunkSize, Headers, Trailers, - Nodiskio, MNowait, Sync) of + Opts) of {error, enotsup} -> sendfile_fallback(Fd, Sock, Offset, Bytes, ChunkSize, Headers, Trailers); Else -> Else end; -sendfile(_,_,_,_,_,_,_,_,_,_) -> +sendfile(_,_,_,_,_,_,_,_) -> {error, badarg}. %%% diff --git a/lib/kernel/test/kernel_SUITE.erl b/lib/kernel/test/kernel_SUITE.erl index 0f29d895e5..75f51eb076 100644 --- a/lib/kernel/test/kernel_SUITE.erl +++ b/lib/kernel/test/kernel_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2011. All Rights Reserved. +%% Copyright Ericsson AB 1997-2014. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -81,53 +81,59 @@ app_test(Config) when is_list(Config) -> %% Test that appup allows upgrade from/downgrade to a maximum of two %% major releases back. appup_test(_Config) -> + do_appup_tests(create_test_vsns()). + +do_appup_tests({[],[]}) -> + {skip,"no previous releases available"}; +do_appup_tests({OkVsns,NokVsns}) -> application:load(kernel), {_,_,Vsn} = lists:keyfind(kernel,1,application:loaded_applications()), AppupFile = filename:join([code:lib_dir(kernel),ebin,"kernel.appup"]), {ok,[{Vsn,UpFrom,DownTo}=AppupScript]} = file:consult(AppupFile), ct:log("~p~n",[AppupScript]), - {OkVsns,NokVsns} = create_test_vsns(Vsn), + ct:log("Testing ok versions: ~p~n",[OkVsns]), check_appup(OkVsns,UpFrom,{ok,[restart_new_emulator]}), check_appup(OkVsns,DownTo,{ok,[restart_new_emulator]}), + ct:log("Testing not ok versions: ~p~n",[NokVsns]), check_appup(NokVsns,UpFrom,error), check_appup(NokVsns,DownTo,error), ok. -create_test_vsns(Current) -> - [XStr,YStr|Rest] = string:tokens(Current,"."), - X = list_to_integer(XStr), - Y = list_to_integer(YStr), - SecondMajor = vsn(X,Y-2), - SecondMinor = SecondMajor ++ ".1.3", - FirstMajor = vsn(X,Y-1), - FirstMinor = FirstMajor ++ ".57", - ThisMajor = vsn(X,Y), - This = - case Rest of - [] -> - []; - ["1"] -> - [ThisMajor]; - _ -> - ThisMinor = ThisMajor ++ ".1", - [ThisMajor,ThisMinor] - end, - OkVsns = This ++ [FirstMajor, FirstMinor, SecondMajor, SecondMinor], - - ThirdMajor = vsn(X,Y-3), - ThirdMinor = ThirdMajor ++ ".10.12", - Illegal = ThisMajor ++ ",1", - Newer1Major = vsn(X,Y+1), - Newer1Minor = Newer1Major ++ ".1", - Newer2Major = ThisMajor ++ "1", - NokVsns = [ThirdMajor,ThirdMinor, - Illegal, - Newer1Major,Newer1Minor, - Newer2Major], - {OkVsns,NokVsns}. - -vsn(X,Y) -> - integer_to_list(X) ++ "." ++ integer_to_list(Y). +create_test_vsns() -> + This = erlang:system_info(otp_release), + FirstMajor = previous_major(This), + SecondMajor = previous_major(FirstMajor), + ThirdMajor = previous_major(SecondMajor), + Ok = kernel_vsn([FirstMajor,SecondMajor]), + Nok0 = kernel_vsn([ThirdMajor]), + Nok = case Ok of + [Ok1|_] -> + [Ok1 ++ ",1" | Nok0]; % illegal + _ -> + Nok0 + end, + {Ok,Nok}. + +previous_major("17") -> + "r16"; +previous_major("r"++Rel) -> + "r"++previous_major(Rel); +previous_major(Rel) -> + integer_to_list(list_to_integer(Rel)-1). + +kernel_vsn([R|Rs]) -> + case test_server:is_release_available(R) of + true -> + {ok,N} = test_server:start_node(prevrel,peer,[{erl,[{release,R}]}]), + As = rpc:call(N,application,which_applications,[]), + {_,_,KV} = lists:keyfind(kernel,1,As), + test_server:stop_node(N), + [KV|kernel_vsn(Rs)]; + false -> + kernel_vsn(Rs) + end; +kernel_vsn([]) -> + []. check_appup([Vsn|Vsns],Instrs,Expected) -> case systools_relup:appup_search_for_version(Vsn, Instrs) of diff --git a/lib/kernel/test/sendfile_SUITE.erl b/lib/kernel/test/sendfile_SUITE.erl index 24884bada5..2c741232c4 100644 --- a/lib/kernel/test/sendfile_SUITE.erl +++ b/lib/kernel/test/sendfile_SUITE.erl @@ -24,7 +24,14 @@ -compile(export_all). -all() -> +all() -> [{group,async_threads}, + {group,no_async_threads}]. + +groups() -> + [{async_threads,[],tcs()}, + {no_async_threads,[],tcs()}]. + +tcs() -> [t_sendfile_small ,t_sendfile_big_all ,t_sendfile_big_size @@ -64,6 +71,14 @@ init_per_suite(Config) -> end_per_suite(Config) -> file:delete(proplists:get_value(big_file, Config)). +init_per_group(async_threads,Config) -> + [{sendfile_opts,[{use_threads,true}]}|Config]; +init_per_group(no_async_threads,Config) -> + [{sendfile_opts,[{use_threads,false}]}|Config]. + +end_per_group(_,_Config) -> + ok. + init_per_testcase(TC,Config) when TC == t_sendfile_recvduring; TC == t_sendfile_sendduring -> Filename = proplists:get_value(small_file, Config), @@ -72,7 +87,7 @@ init_per_testcase(TC,Config) when TC == t_sendfile_recvduring; {_Size, Data} = sendfile_file_info(Filename), {ok,D} = file:open(Filename, [raw,binary,read]), prim_file:sendfile(D, Sock, 0, 0, 0, - [],[],false,false,false), + [],[],[]), Data end, @@ -93,6 +108,7 @@ t_sendfile_small(Config) when is_list(Config) -> Send = fun(Sock) -> {Size, Data} = sendfile_file_info(Filename), + %% Here we make sure to test the sendfile/2 api {ok, Size} = file:sendfile(Filename, Sock), Data end, @@ -102,6 +118,7 @@ t_sendfile_small(Config) when is_list(Config) -> t_sendfile_many_small(Config) when is_list(Config) -> Filename = proplists:get_value(small_file, Config), FileOpts = proplists:get_value(file_opts, Config, []), + SendfileOpts = proplists:get_value(sendfile_opts, Config), error_logger:add_report_handler(?MODULE,[self()]), @@ -110,7 +127,7 @@ t_sendfile_many_small(Config) when is_list(Config) -> N = 10000, {ok,D} = file:open(Filename,[read|FileOpts]), [begin - {ok,Size} = file:sendfile(D,Sock,0,0,[]) + {ok,Size} = file:sendfile(D,Sock,0,0,SendfileOpts) end || _I <- lists:seq(1,N)], file:close(D), Size*N @@ -128,11 +145,12 @@ t_sendfile_many_small(Config) when is_list(Config) -> t_sendfile_big_all(Config) when is_list(Config) -> Filename = proplists:get_value(big_file, Config), + SendfileOpts = proplists:get_value(sendfile_opts, Config), Send = fun(Sock) -> {ok, #file_info{size = Size}} = file:read_file_info(Filename), - {ok, Size} = file:sendfile(Filename, Sock), + {ok, Size} = sendfile(Filename, Sock, SendfileOpts), Size end, @@ -141,12 +159,13 @@ t_sendfile_big_all(Config) when is_list(Config) -> t_sendfile_big_size(Config) -> Filename = proplists:get_value(big_file, Config), FileOpts = proplists:get_value(file_opts, Config, []), + SendfileOpts = proplists:get_value(sendfile_opts, Config), SendAll = fun(Sock) -> {ok, #file_info{size = Size}} = file:read_file_info(Filename), {ok,D} = file:open(Filename,[read|FileOpts]), - {ok, Size} = file:sendfile(D, Sock,0,Size,[]), + {ok, Size} = file:sendfile(D, Sock,0,Size,SendfileOpts), Size end, @@ -155,12 +174,13 @@ t_sendfile_big_size(Config) -> t_sendfile_partial(Config) -> Filename = proplists:get_value(small_file, Config), FileOpts = proplists:get_value(file_opts, Config, []), + SendfileOpts = proplists:get_value(sendfile_opts, Config), SendSingle = fun(Sock) -> {_Size, <<Data:5/binary,_/binary>>} = sendfile_file_info(Filename), {ok,D} = file:open(Filename,[read|FileOpts]), - {ok,5} = file:sendfile(D,Sock,0,5,[]), + {ok,5} = file:sendfile(D,Sock,0,5,SendfileOpts), file:close(D), Data end, @@ -171,14 +191,14 @@ t_sendfile_partial(Config) -> {ok,D} = file:open(Filename,[read|FileOpts]), {ok, <<FData/binary>>} = file:read(D,5), FSend = fun(Sock) -> - {ok,5} = file:sendfile(D,Sock,0,5,[]), + {ok,5} = file:sendfile(D,Sock,0,5,SendfileOpts), FData end, ok = sendfile_send(FSend), SSend = fun(Sock) -> - {ok,3} = file:sendfile(D,Sock,5,3,[]), + {ok,3} = file:sendfile(D,Sock,5,3,SendfileOpts), SData end, @@ -191,12 +211,13 @@ t_sendfile_partial(Config) -> t_sendfile_offset(Config) -> Filename = proplists:get_value(small_file, Config), FileOpts = proplists:get_value(file_opts, Config, []), + SendfileOpts = proplists:get_value(sendfile_opts, Config), Send = fun(Sock) -> {_Size, <<_:5/binary,Data:3/binary,_/binary>> = AllData} = sendfile_file_info(Filename), {ok,D} = file:open(Filename,[read|FileOpts]), - {ok,3} = file:sendfile(D,Sock,5,3,[]), + {ok,3} = file:sendfile(D,Sock,5,3,SendfileOpts), {ok, AllData} = file:read(D,100), file:close(D), Data @@ -206,10 +227,11 @@ t_sendfile_offset(Config) -> t_sendfile_sendafter(Config) -> Filename = proplists:get_value(small_file, Config), + SendfileOpts = proplists:get_value(sendfile_opts, Config), Send = fun(Sock) -> {Size, Data} = sendfile_file_info(Filename), - {ok, Size} = file:sendfile(Filename, Sock), + {ok, Size} = sendfile(Filename, Sock, SendfileOpts), ok = gen_tcp:send(Sock, <<2>>), <<Data/binary,2>> end, @@ -218,10 +240,11 @@ t_sendfile_sendafter(Config) -> t_sendfile_recvafter(Config) -> Filename = proplists:get_value(small_file, Config), + SendfileOpts = proplists:get_value(sendfile_opts, Config), Send = fun(Sock) -> {Size, Data} = sendfile_file_info(Filename), - {ok, Size} = file:sendfile(Filename, Sock), + {ok, Size} = sendfile(Filename, Sock, SendfileOpts), ok = gen_tcp:send(Sock, <<1>>), {ok,<<1>>} = gen_tcp:recv(Sock, 1), <<Data/binary,1>> @@ -250,6 +273,7 @@ t_sendfile_recvafter_remoteclose(Config) -> t_sendfile_sendduring(Config) -> Filename = proplists:get_value(big_file, Config), + SendfileOpts = proplists:get_value(sendfile_opts, Config), Send = fun(Sock) -> {ok, #file_info{size = Size}} = @@ -258,7 +282,7 @@ t_sendfile_sendduring(Config) -> timer:sleep(50), ok = gen_tcp:send(Sock, <<2>>) end), - {ok, Size} = file:sendfile(Filename, Sock), + {ok, Size} = sendfile(Filename, Sock, SendfileOpts), Size+1 end, @@ -266,6 +290,7 @@ t_sendfile_sendduring(Config) -> t_sendfile_recvduring(Config) -> Filename = proplists:get_value(big_file, Config), + SendfileOpts = proplists:get_value(sendfile_opts, Config), Send = fun(Sock) -> {ok, #file_info{size = Size}} = @@ -275,7 +300,7 @@ t_sendfile_recvduring(Config) -> ok = gen_tcp:send(Sock, <<1>>), {ok,<<1>>} = gen_tcp:recv(Sock, 1) end), - {ok, Size} = file:sendfile(Filename, Sock), + {ok, Size} = sendfile(Filename, Sock, SendfileOpts), timer:sleep(1000), Size+1 end, @@ -284,6 +309,7 @@ t_sendfile_recvduring(Config) -> t_sendfile_closeduring(Config) -> Filename = proplists:get_value(big_file, Config), + SendfileOpts = proplists:get_value(sendfile_opts, Config), Send = fun(Sock,SFServPid) -> spawn_link(fun() -> @@ -292,13 +318,14 @@ t_sendfile_closeduring(Config) -> end), case erlang:system_info(thread_pool_size) of 0 -> - {error, closed} = file:sendfile(Filename, Sock); + {error, closed} = sendfile(Filename, Sock, + SendfileOpts); _Else -> %% This can return how much has been sent or %% {error,closed} depending on OS. %% How much is sent impossible to know as %% the socket was closed mid sendfile - case file:sendfile(Filename, Sock) of + case sendfile(Filename, Sock, SendfileOpts) of {error, closed} -> ok; {ok, Size} when is_integer(Size) -> @@ -312,6 +339,7 @@ t_sendfile_closeduring(Config) -> t_sendfile_crashduring(Config) -> Filename = proplists:get_value(big_file, Config), + SendfileOpts = proplists:get_value(sendfile_opts, Config), error_logger:add_report_handler(?MODULE,[self()]), @@ -320,7 +348,7 @@ t_sendfile_crashduring(Config) -> timer:sleep(50), exit(die) end), - {error, closed} = file:sendfile(Filename, Sock), + {error, closed} = sendfile(Filename, Sock, SendfileOpts), -1 end, process_flag(trap_exit,true), @@ -415,6 +443,16 @@ sendfile_file_info(File) -> {ok, Data} = file:read_file(File), {Size, Data}. +sendfile(Filename,Sock,Opts) -> + case file:open(Filename, [read, raw, binary]) of + {error, Reason} -> + {error, Reason}; + {ok, Fd} -> + Res = file:sendfile(Fd, Sock, 0, 0, Opts), + _ = file:close(Fd), + Res + end. + %% Error handler diff --git a/lib/megaco/src/binary/depend.mk b/lib/megaco/src/binary/depend.mk index b9b86d3183..4225bc69dc 100644 --- a/lib/megaco/src/binary/depend.mk +++ b/lib/megaco/src/binary/depend.mk @@ -28,7 +28,7 @@ # This means that the ASN.1 runtime library will be inlined. # -ASN1_CT_OPTS += +noobj +ASN1_CT_OPTS += +noobj +legacy_erlang_types ifeq ($(MEGACO_INLINE_ASN1_RT),true) # We need atleast version 1.4.6 of the ANS.1 application ASN1_CT_OPTS += +inline diff --git a/lib/sasl/test/sasl_SUITE.erl b/lib/sasl/test/sasl_SUITE.erl index e8f6a4a2eb..e799230338 100644 --- a/lib/sasl/test/sasl_SUITE.erl +++ b/lib/sasl/test/sasl_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2011-2013. All Rights Reserved. +%% Copyright Ericsson AB 2011-2014. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -34,7 +34,7 @@ log_mf_h_env/1]). all() -> - [app_test, appup_test, log_mf_h_env]. + [log_mf_h_env, app_test, appup_test]. groups() -> []. @@ -61,54 +61,60 @@ app_test(Config) when is_list(Config) -> %% Test that appup allows upgrade from/downgrade to a maximum of two %% major releases back. appup_test(_Config) -> + do_appup_tests(create_test_vsns()). + +do_appup_tests({[],[]}) -> + {skip,"no previous releases available"}; +do_appup_tests({OkVsns,NokVsns}) -> application:load(sasl), - {sasl,_,SaslVsn} = lists:keyfind(sasl,1,application:loaded_applications()), - Ebin = filename:join(code:lib_dir(sasl),ebin), - {ok,[{SaslVsn,UpFrom,DownTo}=Appup]} = - file:consult(filename:join(Ebin,"sasl.appup")), - ct:log("~p~n",[Appup]), - {OkVsns,NokVsns} = create_test_vsns(SaslVsn), + {_,_,Vsn} = lists:keyfind(sasl,1,application:loaded_applications()), + AppupFile = filename:join([code:lib_dir(sasl),ebin,"sasl.appup"]), + {ok,[{Vsn,UpFrom,DownTo}=AppupScript]} = file:consult(AppupFile), + ct:log("~p~n",[AppupScript]), + ct:log("Testing ok versions: ~p~n",[OkVsns]), check_appup(OkVsns,UpFrom,{ok,[restart_new_emulator]}), check_appup(OkVsns,DownTo,{ok,[restart_new_emulator]}), + ct:log("Testing not ok versions: ~p~n",[NokVsns]), check_appup(NokVsns,UpFrom,error), check_appup(NokVsns,DownTo,error), ok. -create_test_vsns(Current) -> - [XStr,YStr|Rest] = string:tokens(Current,"."), - X = list_to_integer(XStr), - Y = list_to_integer(YStr), - SecondMajor = vsn(X,Y-2), - SecondMinor = SecondMajor ++ ".1.3", - FirstMajor = vsn(X,Y-1), - FirstMinor = FirstMajor ++ ".57", - ThisMajor = vsn(X,Y), - This = - case Rest of - [] -> - []; - ["1"] -> - [ThisMajor]; - _ -> - ThisMinor = ThisMajor ++ ".1", - [ThisMajor,ThisMinor] - end, - OkVsns = This ++ [FirstMajor, FirstMinor, SecondMajor, SecondMinor], - - ThirdMajor = vsn(X,Y-3), - ThirdMinor = ThirdMajor ++ ".10.12", - Illegal = ThisMajor ++ ",1", - Newer1Major = vsn(X,Y+1), - Newer1Minor = Newer1Major ++ ".1", - Newer2Major = ThisMajor ++ "1", - NokVsns = [ThirdMajor,ThirdMinor, - Illegal, - Newer1Major,Newer1Minor, - Newer2Major], - {OkVsns,NokVsns}. - -vsn(X,Y) -> - integer_to_list(X) ++ "." ++ integer_to_list(Y). +create_test_vsns() -> + This = erlang:system_info(otp_release), + FirstMajor = previous_major(This), + SecondMajor = previous_major(FirstMajor), + ThirdMajor = previous_major(SecondMajor), + Ok = sasl_vsn([FirstMajor,SecondMajor]), + Nok0 = sasl_vsn([ThirdMajor]), + Nok = case Ok of + [Ok1|_] -> + [Ok1 ++ ",1" | Nok0]; % illegal + _ -> + Nok0 + end, + {Ok,Nok}. + +previous_major("17") -> + "r16"; +previous_major("r"++Rel) -> + "r"++previous_major(Rel); +previous_major(Rel) -> + integer_to_list(list_to_integer(Rel)-1). + +sasl_vsn([R|Rs]) -> + case test_server:is_release_available(R) of + true -> + {ok,N} = test_server:start_node(prevrel,peer,[{erl,[{release,R}]}]), + _ = rpc:call(N,application,load,[sasl]), + As = rpc:call(N,application,loaded_applications,[]), + {_,_,V} = lists:keyfind(sasl,1,As), + test_server:stop_node(N), + [V|sasl_vsn(Rs)]; + false -> + sasl_vsn(Rs) + end; +sasl_vsn([]) -> + []. check_appup([Vsn|Vsns],Instrs,Expected) -> case systools_relup:appup_search_for_version(Vsn, Instrs) of @@ -119,7 +125,6 @@ check_appup([],_,_) -> ok. - %% OTP-9185 - fail sasl start if some but not all log_mf_h env vars %% are given. log_mf_h_env(Config) -> diff --git a/lib/ssl/src/ssl.erl b/lib/ssl/src/ssl.erl index 4646468cb6..8c2b84bc1e 100644 --- a/lib/ssl/src/ssl.erl +++ b/lib/ssl/src/ssl.erl @@ -697,11 +697,9 @@ validate_option(verify_fun, Fun) when is_function(Fun) -> end, Fun}; validate_option(verify_fun, {Fun, _} = Value) when is_function(Fun) -> Value; -validate_option(fail_if_no_peer_cert, Value) - when Value == true; Value == false -> +validate_option(fail_if_no_peer_cert, Value) when is_boolean(Value) -> Value; -validate_option(verify_client_once, Value) - when Value == true; Value == false -> +validate_option(verify_client_once, Value) when is_boolean(Value) -> Value; validate_option(depth, Value) when is_integer(Value), Value >= 0, Value =< 255-> @@ -781,12 +779,10 @@ validate_option(ciphers, Value) when is_list(Value) -> end; validate_option(reuse_session, Value) when is_function(Value) -> Value; -validate_option(reuse_sessions, Value) when Value == true; - Value == false -> +validate_option(reuse_sessions, Value) when is_boolean(Value) -> Value; -validate_option(secure_renegotiate, Value) when Value == true; - Value == false -> +validate_option(secure_renegotiate, Value) when is_boolean(Value) -> Value; validate_option(renegotiate_at, Value) when is_integer(Value) -> erlang:min(Value, ?DEFAULT_RENEGOTIATE_AT); @@ -795,8 +791,7 @@ validate_option(hibernate_after, undefined) -> undefined; validate_option(hibernate_after, Value) when is_integer(Value), Value >= 0 -> Value; -validate_option(erl_dist,Value) when Value == true; - Value == false -> +validate_option(erl_dist,Value) when is_boolean(Value) -> Value; validate_option(client_preferred_next_protocols = Opt, {Precedence, PreferredProtocols} = Value) when is_list(PreferredProtocols) -> @@ -822,8 +817,7 @@ validate_option(client_preferred_next_protocols = Opt, {Precedence, PreferredPro validate_option(client_preferred_next_protocols, undefined) -> undefined; -validate_option(log_alert, Value) when Value == true; - Value == false -> +validate_option(log_alert, Value) when is_boolean(Value) -> Value; validate_option(next_protocols_advertised = Opt, Value) when is_list(Value) -> case tls_record:highest_protocol_version([]) of diff --git a/lib/stdlib/doc/src/unicode_usage.xml b/lib/stdlib/doc/src/unicode_usage.xml index 33cd70e0b7..ee7dd128f1 100644 --- a/lib/stdlib/doc/src/unicode_usage.xml +++ b/lib/stdlib/doc/src/unicode_usage.xml @@ -52,8 +52,8 @@ for UTF-8 and more support for Unicode character sets in the I/O-system.</p> - <p>In R17, the encoding default for Erlang source files will be - switched to UTF-8 and in R18 Erlang will support atoms in the full + <p>In 17.0, the encoding default for Erlang source files was + switched to UTF-8 and in 18.0 Erlang will support atoms in the full Unicode range, meaning full Unicode function and module names</p> @@ -290,7 +290,7 @@ <item>Having the source code in UTF-8 also allows you to write string literals containing Unicode characters with code points > 255, although atoms, module names and function names will be - restricted to the ISO-Latin-1 range until the R18 release. Binary + restricted to the ISO-Latin-1 range until the 18.0 release. Binary literals where you use the <c>/utf8</c> type, can also be expressed using Unicode characters > 255. Having module names using characters other than 7-bit ASCII can cause trouble on @@ -385,7 +385,7 @@ external_charlist() = maybe_improper_list(char() | using characters from the ISO-latin-1 character set and atoms are restricted to the same ISO-latin-1 range. These restrictions in the language are of course independent of the encoding of the source - file. Erlang/OTP R18 is expected to handle functions named in + file. Erlang/OTP 18.0 is expected to handle functions named in Unicode as well as Unicode atoms.</p> <section> <title>Bit-syntax</title> @@ -662,11 +662,14 @@ Eshell V5.10.1 (abort with ^G) containing characters having code points between 128 and 255 may be named either as plain ISO-latin-1 or using UTF-8 encoding. As no consistency is enforced, the Erlang VM can do no consistent - translation of all file names. If the VM would automatically - select encoding based on heuristics, one could get unexpected - behavior on these systems. By default, Erlang starts in "latin1" - file name mode on such systems, meaning bytewise encoding in file - names. This allows for list representation of all file names in + translation of all file names.</p> + + <p>By default on such systems, Erlang starts in <c>utf8</c> file + name mode if the terminal supports UTF-8, otherwise in + <c>latin1</c> mode.</p> + + <p>In the <c>latin1</c> mode, file names are bytewise endcoded. + This allows for list representation of all file names in the system, but, for example, a file named "Ă–stersund.txt", will appear in <c>file:list_dir/1</c> as either "Ă–stersund.txt" (if the file name was encoded in bytewise ISO-Latin-1 by the program @@ -752,7 +755,7 @@ Eshell V5.10.1 (abort with ^G) <section> <title>Notes About Raw File Names</title> - + <marker id="notes-about-raw-filenames"/> <p>Raw file names were introduced together with Unicode file name support in erts-5.8.2 (OTP R14B01). The reason "raw file names" was introduced in the system was to be able to @@ -1014,7 +1017,8 @@ ok allowed. This setting should correspond to the actual terminal you are using.</p> <p>The environment can also affect file name interpretation, if - Erlang is started with the <c>+fna</c> flag.</p> + Erlang is started with the <c>+fna</c> flag (which is default from + Erlang/OTP 17.0).</p> <p>You can check the setting of this by calling <c>io:getopts()</c>, which will give you an option list containing <c>{encoding,unicode}</c> or @@ -1046,8 +1050,7 @@ ok > 255.</p> <p><c>+fnl</c> means bytewise interpretation of file names, which was the usual way to represent ISO-Latin-1 file names before - UTF-8 file naming got widespread. This is the default on all - Unix-like operating systems except MacOS X.</p> + UTF-8 file naming got widespread.</p> <p><c>+fnu</c> means that file names are encoded in UTF-8, which is nowadays the common scheme (although not enforced).</p> <p><c>+fna</c> means that you automatically select between @@ -1055,8 +1058,8 @@ ok <c>LC_CTYPE</c> environment variables. This is optimistic heuristics indeed, nothing enforces a user to have a terminal with the same encoding as the file system, but usually, this is - the case. This might be the default behavior in a future - release.</p> + the case. This is the default on all Unix-like operating + systems except MacOS X.</p> <p>The file name translation mode can be read with the <c>file:native_name_encoding/0</c> function, which returns @@ -1068,7 +1071,7 @@ ok <p>This function returns the default encoding for Erlang source files (if no encoding comment is present) in the currently running release. For R16 this returns <c>latin1</c> (meaning - bytewise encoding). In R17 and forward it is expected to return + bytewise encoding). In 17.0 and forward it returns <c>utf8</c>.</p> <p>The encoding of each file can be specified using comments as described in diff --git a/lib/stdlib/test/stdlib_SUITE.erl b/lib/stdlib/test/stdlib_SUITE.erl index 8a2cb5ea6b..8fff5e2e05 100644 --- a/lib/stdlib/test/stdlib_SUITE.erl +++ b/lib/stdlib/test/stdlib_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2011. All Rights Reserved. +%% Copyright Ericsson AB 1997-2014. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -81,53 +81,59 @@ app_test(Config) when is_list(Config) -> %% Test that appup allows upgrade from/downgrade to a maximum of two %% major releases back. appup_test(_Config) -> + do_appup_tests(create_test_vsns()). + +do_appup_tests({[],[]}) -> + {skip,"no previous releases available"}; +do_appup_tests({OkVsns,NokVsns}) -> application:load(stdlib), {_,_,Vsn} = lists:keyfind(stdlib,1,application:loaded_applications()), AppupFile = filename:join([code:lib_dir(stdlib),ebin,"stdlib.appup"]), {ok,[{Vsn,UpFrom,DownTo}=AppupScript]} = file:consult(AppupFile), ct:log("~p~n",[AppupScript]), - {OkVsns,NokVsns} = create_test_vsns(Vsn), + ct:log("Testing ok versions: ~p~n",[OkVsns]), check_appup(OkVsns,UpFrom,{ok,[restart_new_emulator]}), check_appup(OkVsns,DownTo,{ok,[restart_new_emulator]}), + ct:log("Testing not ok versions: ~p~n",[NokVsns]), check_appup(NokVsns,UpFrom,error), check_appup(NokVsns,DownTo,error), ok. -create_test_vsns(Current) -> - [XStr,YStr|Rest] = string:tokens(Current,"."), - X = list_to_integer(XStr), - Y = list_to_integer(YStr), - SecondMajor = vsn(X,Y-2), - SecondMinor = SecondMajor ++ ".1.3", - FirstMajor = vsn(X,Y-1), - FirstMinor = FirstMajor ++ ".57", - ThisMajor = vsn(X,Y), - This = - case Rest of - [] -> - []; - ["1"] -> - [ThisMajor]; - _ -> - ThisMinor = ThisMajor ++ ".1", - [ThisMajor,ThisMinor] - end, - OkVsns = This ++ [FirstMajor, FirstMinor, SecondMajor, SecondMinor], - - ThirdMajor = vsn(X,Y-3), - ThirdMinor = ThirdMajor ++ ".10.12", - Illegal = ThisMajor ++ ",1", - Newer1Major = vsn(X,Y+1), - Newer1Minor = Newer1Major ++ ".1", - Newer2Major = ThisMajor ++ "1", - NokVsns = [ThirdMajor,ThirdMinor, - Illegal, - Newer1Major,Newer1Minor, - Newer2Major], - {OkVsns,NokVsns}. - -vsn(X,Y) -> - integer_to_list(X) ++ "." ++ integer_to_list(Y). +create_test_vsns() -> + This = erlang:system_info(otp_release), + FirstMajor = previous_major(This), + SecondMajor = previous_major(FirstMajor), + ThirdMajor = previous_major(SecondMajor), + Ok = stdlib_vsn([FirstMajor,SecondMajor]), + Nok0 = stdlib_vsn([ThirdMajor]), + Nok = case Ok of + [Ok1|_] -> + [Ok1 ++ ",1" | Nok0]; % illegal + _ -> + Nok0 + end, + {Ok,Nok}. + +previous_major("17") -> + "r16"; +previous_major("r"++Rel) -> + "r"++previous_major(Rel); +previous_major(Rel) -> + integer_to_list(list_to_integer(Rel)-1). + +stdlib_vsn([R|Rs]) -> + case test_server:is_release_available(R) of + true -> + {ok,N} = test_server:start_node(prevrel,peer,[{erl,[{release,R}]}]), + As = rpc:call(N,application,which_applications,[]), + {_,_,KV} = lists:keyfind(stdlib,1,As), + test_server:stop_node(N), + [KV|stdlib_vsn(Rs)]; + false -> + stdlib_vsn(Rs) + end; +stdlib_vsn([]) -> + []. check_appup([Vsn|Vsns],Instrs,Expected) -> case systools_relup:appup_search_for_version(Vsn, Instrs) of diff --git a/system/doc/reference_manual/distributed.xml b/system/doc/reference_manual/distributed.xml index d337920a64..88f98bc106 100644 --- a/system/doc/reference_manual/distributed.xml +++ b/system/doc/reference_manual/distributed.xml @@ -199,7 +199,7 @@ dilbert@uab</pre> <cell align="left" valign="middle">Depending on <c>Arg</c>, this function can return a list not only of visible nodes, but also hidden nodes and previously known nodes, etc.</cell> </row> <row> - <cell align="left" valign="middle"><c>set_cookie(Node, Cookie)</c></cell> + <cell align="left" valign="middle"><c>erlang:set_cookie(Node, Cookie)</c></cell> <cell align="left" valign="middle">Sets the magic cookie used when connecting to <c>Node</c>. If <c>Node</c> is the current node, <c>Cookie</c> will be used when connecting to all new nodes.</cell> </row> <row> diff --git a/xcomp/erl-xcomp-TileraMDE2.0-tilepro.conf b/xcomp/erl-xcomp-TileraMDE2.0-tilepro.conf index 84bf735ff2..fe0886ac8a 100644 --- a/xcomp/erl-xcomp-TileraMDE2.0-tilepro.conf +++ b/xcomp/erl-xcomp-TileraMDE2.0-tilepro.conf @@ -19,6 +19,7 @@ ## ## File: erl-xcomp-TileraMDE2.0-tilepro.conf ## Author: Rickard Green +## Tested on: TileraMDE-2.0, TileraMDE-3.0.1.125620 ## ## ----------------------------------------------------------------------------- ## When cross compiling Erlang/OTP using `otp_build', copy this file and set |