aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-09-06 15:21:05 +0200
committerBjörn Gustavsson <[email protected]>2013-09-18 10:22:30 +0200
commita37aee55dccc5ea35ef9b5568cff4bd0364f4b1c (patch)
tree0821f16a726f609e62d4cc6053957318e401c08c /lib
parent905036dccbf7150e26d2db8e8ba04cf779e26fb0 (diff)
downloadotp-a37aee55dccc5ea35ef9b5568cff4bd0364f4b1c.tar.gz
otp-a37aee55dccc5ea35ef9b5568cff4bd0364f4b1c.tar.bz2
otp-a37aee55dccc5ea35ef9b5568cff4bd0364f4b1c.zip
asn1_test_lib: Remove unnecessary loading of a compiled ASN.1 spec
asn1ct:compile/2 calls c:c/2 to invoke the compiler and to load the compiled code. That means that there is no need load the module after having invoked the ASN.1 compiler. To make sure that we'll notice if that behavior changes in the future, extend the rtUI/1 test case to verify that the loaded module has the correct encoding rule (if asn1ct:compile/2 would fail to reload the module, the previous encoding rule would be returned). While at it, it also makes sense to test calling M:bit_string_format/0 to ensure that it continues working.
Diffstat (limited to 'lib')
-rw-r--r--lib/asn1/test/asn1_SUITE.erl5
-rw-r--r--lib/asn1/test/asn1_test_lib.erl28
2 files changed, 5 insertions, 28 deletions
diff --git a/lib/asn1/test/asn1_SUITE.erl b/lib/asn1/test/asn1_SUITE.erl
index cb000713cf..0d4f6ddb32 100644
--- a/lib/asn1/test/asn1_SUITE.erl
+++ b/lib/asn1/test/asn1_SUITE.erl
@@ -850,7 +850,10 @@ duplicate_tags(Config) ->
rtUI(Config) -> test(Config, fun rtUI/3).
rtUI(Config, Rule, Opts) ->
asn1_test_lib:compile("Prim", Config, [Rule|Opts]),
- {ok, _} = asn1rt:info('Prim').
+ {ok, _} = asn1rt:info('Prim'),
+ Rule = 'Prim':encoding_rule(),
+ io:format("Default BIT STRING format: ~p\n",
+ ['Prim':bit_string_format()]).
testROSE(Config) -> test(Config, fun testROSE/3).
testROSE(Config, Rule, Opts) ->
diff --git a/lib/asn1/test/asn1_test_lib.erl b/lib/asn1/test/asn1_test_lib.erl
index 60b2b2b42e..5bdd0a4637 100644
--- a/lib/asn1/test/asn1_test_lib.erl
+++ b/lib/asn1/test/asn1_test_lib.erl
@@ -40,15 +40,7 @@ compile_all(Files, Config, Options) ->
compile_file(File, Options) ->
try
- ok = asn1ct:compile(File, [warnings_as_errors|Options]),
- case should_load(File, Options) of
- false ->
- ok;
- {module, Module} ->
- code:purge(Module),
- {module, Module} = code:load_file(Module),
- code:purge(Module)
- end
+ ok = asn1ct:compile(File, [warnings_as_errors|Options])
catch
Class:Reason ->
ct:print("Failed to compile ~s\n", [File]),
@@ -69,24 +61,6 @@ hex_to_bin(S) ->
%%% Internal functions.
%%%
-should_load(File, Options) ->
- case lists:member(abs, Options) of
- true ->
- false;
- false ->
- {module,list_to_atom(strip_extension(filename:basename(File)))}
- end.
-
-strip_extension(File) ->
- strip_extension(File, filename:extension(File)).
-
-strip_extension(File, "") ->
- File;
-strip_extension(File, Ext) when Ext == ".asn"; Ext == ".set"; Ext == ".asn1"->
- strip_extension(filename:rootname(File));
-strip_extension(File, _Ext) ->
- File.
-
hex2num(C) when $0 =< C, C =< $9 -> C - $0;
hex2num(C) when $A =< C, C =< $F -> C - $A + 10;
hex2num(C) when $a =< C, C =< $f -> C - $a + 10.