aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test/diameter_app_SUITE.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2014-03-31 10:18:24 +0200
committerAnders Svensson <[email protected]>2014-03-31 16:43:10 +0200
commit81eefc9958e9bb3e64eebccc87b38acd56cb62df (patch)
tree79b81255cbdad4ae4b74d9ec6395bae527891d9e /lib/diameter/test/diameter_app_SUITE.erl
parentd360e898d93502d1d27d4552688476a629fdd52e (diff)
downloadotp-81eefc9958e9bb3e64eebccc87b38acd56cb62df.tar.gz
otp-81eefc9958e9bb3e64eebccc87b38acd56cb62df.tar.bz2
otp-81eefc9958e9bb3e64eebccc87b38acd56cb62df.zip
Simplify xref tests in app suite
By examining which modules *use* runtime and compiler modules instead of which modules compiler modules call. Note that the semantics are changed somewhat: we will now fail if diameter modules are called from an application which diameter.app lists as a start dependency, which wasn't the case previously.
Diffstat (limited to 'lib/diameter/test/diameter_app_SUITE.erl')
-rw-r--r--lib/diameter/test/diameter_app_SUITE.erl40
1 files changed, 17 insertions, 23 deletions
diff --git a/lib/diameter/test/diameter_app_SUITE.erl b/lib/diameter/test/diameter_app_SUITE.erl
index 891147b7d1..f68a18b5c2 100644
--- a/lib/diameter/test/diameter_app_SUITE.erl
+++ b/lib/diameter/test/diameter_app_SUITE.erl
@@ -50,7 +50,7 @@
diameter_exprecs,
diameter_make]).
--define(HELP_MODULES, [diameter_dbg,
+-define(INFO_MODULES, [diameter_dbg,
diameter_info]).
%% ===========================================================================
@@ -99,13 +99,13 @@ vsn(Config) ->
%% # modules/1
%%
%% Ensure that the app file modules and installed modules differ by
-%% compiler/help modules.
+%% compiler/info modules.
%% ===========================================================================
modules(Config) ->
Mods = fetch(modules, fetch(app, Config)),
Installed = code_mods(),
- Help = lists:sort(?HELP_MODULES ++ ?COMPILER_MODULES),
+ Help = lists:sort(?INFO_MODULES ++ ?COMPILER_MODULES),
{[], Help} = {Mods -- Installed, lists:sort(Installed -- Mods)}.
@@ -181,7 +181,8 @@ xref(Config) ->
[?APP, erts | fetch(applications, App)]),
{ok, Undefs} = xref:analyze(XRef, undefined_function_calls),
- {ok, CTdeps} = xref:analyze(XRef, {module_call, ?COMPILER_MODULES}),
+ {ok, RTmods} = xref:analyze(XRef, {module_use, Mods}),
+ {ok, CTmods} = xref:analyze(XRef, {module_use, ?COMPILER_MODULES}),
{ok, RTdeps} = xref:analyze(XRef, {module_call, Mods}),
xref:stop(XRef),
@@ -194,18 +195,24 @@ xref(Config) ->
Undefs),
%% diameter_tcp does call ssl despite the latter not being listed
%% as a dependency in the app file since ssl is only required for
- %% TLS security: it's up to a client who wants TLS it to start
- %% ssl.
+ %% TLS security: it's up to a client who wants TLS to start ssl.
- %% Ensure that compiler modules don't call runtime modules.
- [] = lists:filter(fun nok_compiler_dependency/1, CTdeps),
+ %% Ensure that only runtime or info modules call runtime modules.
+ %% It's not strictly necessary that diameter compiler modules not
+ %% depend on other diameter modules but it's a simple source of
+ %% build errors if not properly encoded in the makefile so guard
+ %% against it.
+ [] = (RTmods -- Mods) -- ?INFO_MODULES,
+
+ %% Ensure that runtime modules don't call compiler modules.
+ CTmods = CTmods -- Mods,
%% Ensure that runtime modules only call other runtime modules, or
%% applications declared as in runtime_dependencies in the app
%% file. Note that the declared application versions are ignored
%% since we only know what we can see now.
- [] = lists:filter(fun(M) -> not ok_runtime_dependency(M, Mods, Deps) end,
- RTdeps).
+ [] = lists:filter(fun(M) -> not lists:member(app(M), Deps) end,
+ RTdeps -- Mods).
unversion(App) ->
T = lists:dropwhile(fun is_vsn_ch/1, lists:reverse(App)),
@@ -214,19 +221,6 @@ unversion(App) ->
is_vsn_ch(C) ->
$0 =< C andalso C =< $9 orelse $. == C.
-%% It's not strictly necessary that diameter compiler modules not
-%% depend on other diameter modules but it's a simple source of build
-%% errors if not properly encoded in the makefile so guard against it.
-nok_compiler_dependency(Mod) ->
- is_diameter(Mod) andalso not lists:member(Mod, ?COMPILER_MODULES).
-
-ok_runtime_dependency(Mod, Mods, Apps) ->
- lists:member(app(Mod), Apps)
- orelse (is_diameter(Mod) andalso lists:member(Mod, Mods)).
-
-is_diameter(Mod) ->
- lists:prefix("diameter", atom_to_list(Mod)).
-
app('$M_EXPR') -> %% could be anything but assume it's ok
"erts";
app(Mod) ->