1%%
2%% %CopyrightBegin%
3%%
4%% Copyright Ericsson AB 2010-2015. All Rights Reserved.
5%%
6%% Licensed under the Apache License, Version 2.0 (the "License");
7%% you may not use this file except in compliance with the License.
8%% You may obtain a copy of the License at
9%%
10%%     http://www.apache.org/licenses/LICENSE-2.0
11%%
12%% Unless required by applicable law or agreed to in writing, software
13%% distributed under the License is distributed on an "AS IS" BASIS,
14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15%% See the License for the specific language governing permissions and
16%% limitations under the License.
17%%
18%% %CopyrightEnd%
19%%
20
21-module(diameter_ct).
22
23%%
24%% Module used to run suites from Makefile.
25%%
26
27-export([run/1,
28         cover/0]).
29
30%% The makefile looks for signs of failure so ignore the ct:run_test/1
31%% return value.
32
33run(Suites) ->
34    ct_run([{suite, Suites}]).
35
36cover() ->
37    ct_run([{spec, "./testspec"}]).
38
39ct_run(Opts) ->
40    Start = info(),
41    ct:run_test([{logdir, "./log"},
42                 {auto_compile, false}
43                 | Opts]),
44    info(Start , info()).
45
46info() ->
47    [{time, diameter_lib:now()},
48     {process_count, erlang:system_info(process_count)}
49     | erlang:memory()].
50
51info(L0, L1) ->
52    [T, C | M]
53        = lists:zipwith(fun({T,N0}, {T,N1}) -> {T, N1, diff(T, N0, N1)} end,
54                        L0,
55                        L1),
56    Diff = [T, C, {memory, M}],
57    io:format("INFO: ~p~n", [Diff]).
58
59diff(time, T0, T1) ->
60    diameter_lib:micro_diff(T1, T0);
61diff(_, N0, N1) ->
62    N1 - N0.
63