diff options
author | Lukas Larsson <[email protected]> | 2012-07-11 12:55:46 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2012-07-19 16:26:35 +0200 |
commit | 1afa5d69e5d42e8837f7fb975671487c6301b42f (patch) | |
tree | fa6be3549bca2558fec8a40727050191d3f07169 /lib/common_test | |
parent | f3528e0a5ecb2f655f9d2e5de996424defcdf1c9 (diff) | |
download | otp-1afa5d69e5d42e8837f7fb975671487c6301b42f.tar.gz otp-1afa5d69e5d42e8837f7fb975671487c6301b42f.tar.bz2 otp-1afa5d69e5d42e8837f7fb975671487c6301b42f.zip |
Add ct:notify and ct:sync_notify
Diffstat (limited to 'lib/common_test')
-rw-r--r-- | lib/common_test/src/ct.erl | 27 | ||||
-rw-r--r-- | lib/common_test/src/ct_event.erl | 16 |
2 files changed, 41 insertions, 2 deletions
diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl index 571d99029f..6373634812 100644 --- a/lib/common_test/src/ct.erl +++ b/lib/common_test/src/ct.erl @@ -66,7 +66,8 @@ capture_start/0, capture_stop/0, capture_get/0, capture_get/1, fail/1, fail/2, comment/1, comment/2, make_priv_dir/0, testcases/2, userdata/2, userdata/3, - timetrap/1, get_timetrap_info/0, sleep/1]). + timetrap/1, get_timetrap_info/0, sleep/1, + notify/2, sync_notify/2]). %% New API for manipulating with config handlers -export([add_config/2, remove_config/2]). @@ -1047,3 +1048,27 @@ sleep({seconds,Ss}) -> sleep(trunc(Ss * 1000)); sleep(Time) -> test_server:adjusted_sleep(Time). + +%%%----------------------------------------------------------------- +%%% @spec notify(Name,Data) -> ok +%%% Name = atom() +%%% Data = term() +%%% +%%% @doc <p>Sends a asynchronous notification of type <c>Name</c> with +%%% <c>Data</c>to the common_test event manager. This can later be +%%% caught by any installed event manager. </p> +%%% @see //stdlib/gen_event +notify(Name,Data) -> + ct_event:notify(Name, Data). + +%%%----------------------------------------------------------------- +%%% @spec sync_notify(Name,Data) -> ok +%%% Name = atom() +%%% Data = term() +%%% +%%% @doc <p>Sends a synchronous notification of type <c>Name</c> with +%%% <c>Data</c>to the common_test event manager. This can later be +%%% caught by any installed event manager. </p> +%%% @see //stdlib/gen_event +sync_notify(Name,Data) -> + ct_event:sync_notify(Name, Data). diff --git a/lib/common_test/src/ct_event.erl b/lib/common_test/src/ct_event.erl index 3e79898ad1..998be35fda 100644 --- a/lib/common_test/src/ct_event.erl +++ b/lib/common_test/src/ct_event.erl @@ -31,7 +31,7 @@ %% API -export([start_link/0, add_handler/0, add_handler/1, stop/0]). --export([notify/1, sync_notify/1]). +-export([notify/1, notify/2, sync_notify/1,sync_notify/2]). -export([is_alive/0]). %% gen_event callbacks @@ -90,6 +90,13 @@ notify(Event) -> end. %%-------------------------------------------------------------------- +%% Function: notify(Name,Data) -> ok +%% Description: Asynchronous notification to event manager. +%%-------------------------------------------------------------------- +notify(Name, Data) -> + notify(#event{ name = Name, data = Data}). + +%%-------------------------------------------------------------------- %% Function: sync_notify(Event) -> ok %% Description: Synchronous notification to event manager. %%-------------------------------------------------------------------- @@ -102,6 +109,13 @@ sync_notify(Event) -> end. %%-------------------------------------------------------------------- +%% Function: sync_notify(Name,Data) -> ok +%% Description: Synchronous notification to event manager. +%%-------------------------------------------------------------------- +sync_notify(Name,Data) -> + sync_notify(#event{ name = Name, data = Data}). + +%%-------------------------------------------------------------------- %% Function: is_alive() -> true | false %% Description: Check if Event Manager is alive. %%-------------------------------------------------------------------- |