aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/system_profile_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/test/system_profile_SUITE.erl')
-rw-r--r--erts/emulator/test/system_profile_SUITE.erl114
1 files changed, 47 insertions, 67 deletions
diff --git a/erts/emulator/test/system_profile_SUITE.erl b/erts/emulator/test/system_profile_SUITE.erl
index 2ecb4a28a7..2e359b11ce 100644
--- a/erts/emulator/test/system_profile_SUITE.erl
+++ b/erts/emulator/test/system_profile_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2007-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2007-2016. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -23,61 +23,29 @@
-module(system_profile_SUITE).
--export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
- init_per_group/2,end_per_group/2,
+-export([all/0, suite/0,
system_profile_on_and_off/1,
- runnable_procs/1,
- runnable_ports/1,
+ runnable_procs/1, runnable_ports/1,
dont_profile_profiler/1,
- scheduler/1
- ]).
-
--export([init_per_testcase/2, end_per_testcase/2]).
+ scheduler/1, sane_location/1]).
-export([profiler_process/1, ring_loop/1, port_echo_start/0,
list_load/0, run_load/2]).
--include_lib("test_server/include/test_server.hrl").
-
--define(default_timeout, ?t:minutes(1)).
+-include_lib("common_test/include/ct.hrl").
-init_per_testcase(_Case, Config) ->
- Dog=?t:timetrap(?default_timeout),
- [{watchdog, Dog}|Config].
-end_per_testcase(_Case, Config) ->
- Dog=?config(watchdog, Config),
- ?t:timetrap_cancel(Dog),
- ok.
-
-suite() -> [{ct_hooks,[ts_install_cth]}].
+suite() ->
+ [{ct_hooks,[ts_install_cth]},
+ {timetrap, {minutes, 1}}].
all() ->
[system_profile_on_and_off, runnable_procs,
- runnable_ports, scheduler, dont_profile_profiler].
-
-groups() ->
- [].
-
-init_per_suite(Config) ->
- Config.
-
-end_per_suite(_Config) ->
- ok.
-
-init_per_group(_GroupName, Config) ->
- Config.
-
-end_per_group(_GroupName, Config) ->
- Config.
-
+ runnable_ports, scheduler, dont_profile_profiler,
+ sane_location].
%% No specification clause needed for an init function in a conf case!!!
%% Test switching system_profiling on and off.
-system_profile_on_and_off(suite) ->
- [];
-system_profile_on_and_off(doc) ->
- ["Tests switching system_profiling on and off."];
system_profile_on_and_off(Config) when is_list(Config) ->
Pid = start_profiler_process(),
@@ -106,12 +74,7 @@ system_profile_on_and_off(Config) when is_list(Config) ->
exit(Pid,kill),
ok.
-%% Test runnable_procs
-
-runnable_procs(suite) ->
- [];
-runnable_procs(doc) ->
- ["Tests system_profiling with runnable_procs."];
+%% Tests system_profiling with runnable_procs.
runnable_procs(Config) when is_list(Config) ->
lists:foreach(fun (TsType) ->
Arg = case TsType of
@@ -148,10 +111,7 @@ do_runnable_procs({TsType, TsTypeFlag}) ->
exit(Pid,kill),
ok.
-runnable_ports(suite) ->
- [];
-runnable_ports(doc) ->
- ["Tests system_profiling with runnable_port."];
+%% Tests system_profiling with runnable_port.
runnable_ports(Config) when is_list(Config) ->
lists:foreach(fun (TsType) ->
Arg = case TsType of
@@ -184,10 +144,7 @@ do_runnable_ports({TsType, TsTypeFlag}, Config) ->
exit(Pid,kill),
ok.
-scheduler(suite) ->
- [];
-scheduler(doc) ->
- ["Tests system_profiling with scheduler."];
+%% Tests system_profiling with scheduler.
scheduler(Config) when is_list(Config) ->
case {erlang:system_info(smp_support), erlang:system_info(schedulers_online)} of
{false,_} -> {skipped, "No need for scheduler test when smp support is disabled."};
@@ -209,11 +166,7 @@ scheduler(Config) when is_list(Config) ->
strict_monotonic_timestamp])
end.
-% the profiler pid should not be profiled
-dont_profile_profiler(suite) ->
- [];
-dont_profile_profiler(doc) ->
- ["Ensure system profiler process is not profiled."];
+%% Ensure system profiler process is not profiled.
dont_profile_profiler(Config) when is_list(Config) ->
Pid = start_profiler_process(),
@@ -231,6 +184,33 @@ dont_profile_profiler(Config) when is_list(Config) ->
exit(Pid,kill),
ok.
+%% Check sane location (of exits)
+sane_location(Config) when is_list(Config) ->
+ Check = spawn_link(fun() -> flush_sane_location() end),
+ erlang:system_profile(Check, [runnable_procs]),
+ Me = self(),
+ Pids = [spawn_link(fun() -> wat(Me) end) || _ <- lists:seq(1,100)],
+ [receive {Pid,ok} -> ok end || Pid <- Pids],
+ Check ! {Me, done},
+ receive {Check,ok} -> ok end,
+ ok.
+
+wat(Pid) ->
+ Pid ! {self(), ok}.
+
+flush_sane_location() ->
+ receive
+ {profile,_,_,{M,F,A},_} when is_atom(M), is_atom(F),
+ is_integer(A) ->
+ flush_sane_location();
+ {profile,_,_,0,_} ->
+ flush_sane_location();
+ {Pid,done} when is_pid(Pid) ->
+ Pid ! {self(), ok};
+ M ->
+ ct:fail({badness,M})
+ end.
+
%%% Check scheduler profiling
@@ -421,7 +401,7 @@ ring_loop(RelayTo) ->
%% API
echo(Config) ->
- Path = ?config(data_dir, Config),
+ Path = proplists:get_value(data_dir, Config),
erl_ddll:load_driver(Path, echo_drv),
Pid = spawn_link(?MODULE, port_echo_start, []),
Pid ! {self(), get_ports},
@@ -481,7 +461,7 @@ check_ts(no_timestamp, Ts) ->
no_timestamp = Ts
catch
_ : _ ->
- ?t:fail({unexpected_timestamp, Ts})
+ ct:fail({unexpected_timestamp, Ts})
end,
ok;
check_ts(timestamp, Ts) ->
@@ -492,7 +472,7 @@ check_ts(timestamp, Ts) ->
true = is_integer(Us)
catch
_ : _ ->
- ?t:fail({unexpected_timestamp, Ts})
+ ct:fail({unexpected_timestamp, Ts})
end,
ok;
check_ts(monotonic_timestamp, Ts) ->
@@ -500,7 +480,7 @@ check_ts(monotonic_timestamp, Ts) ->
true = is_integer(Ts)
catch
_ : _ ->
- ?t:fail({unexpected_timestamp, Ts})
+ ct:fail({unexpected_timestamp, Ts})
end,
ok;
check_ts(strict_monotonic_timestamp, Ts) ->
@@ -510,7 +490,7 @@ check_ts(strict_monotonic_timestamp, Ts) ->
true = is_integer(UMI)
catch
_ : _ ->
- ?t:fail({unexpected_timestamp, Ts})
+ ct:fail({unexpected_timestamp, Ts})
end,
ok.
@@ -534,7 +514,7 @@ run_load(N, Pids) ->
run_load(N - 1, [Pid | Pids]).
list_load() ->
- ok = case math:sin(random:uniform(32451)) of
+ ok = case math:sin(rand:uniform(32451)) of
A when is_float(A) -> ok;
_ -> ok
end,