aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test/ssh_eqc_event_handler.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2016-10-13 13:09:42 +0200
committerHans Nilsson <[email protected]>2016-10-13 15:43:25 +0200
commitd53bd4936297f6310e59f88191014bb5dd0d8b2c (patch)
treee9626c254f8f39787b0d4ce30cb4a11389209d37 /lib/ssh/test/ssh_eqc_event_handler.erl
parenta59807ef9a6a8af6eb6f13976eb405ddb9baad6c (diff)
downloadotp-d53bd4936297f6310e59f88191014bb5dd0d8b2c.tar.gz
otp-d53bd4936297f6310e59f88191014bb5dd0d8b2c.tar.bz2
otp-d53bd4936297f6310e59f88191014bb5dd0d8b2c.zip
ssh: property test case for illegal infoline and close
This tests an illegal client that sends an info line and closes 'immediatly'.
Diffstat (limited to 'lib/ssh/test/ssh_eqc_event_handler.erl')
-rw-r--r--lib/ssh/test/ssh_eqc_event_handler.erl43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/ssh/test/ssh_eqc_event_handler.erl b/lib/ssh/test/ssh_eqc_event_handler.erl
new file mode 100644
index 0000000000..233965012a
--- /dev/null
+++ b/lib/ssh/test/ssh_eqc_event_handler.erl
@@ -0,0 +1,43 @@
+-module(ssh_eqc_event_handler).
+
+-compile(export_all).
+
+-behaviour(gen_event).
+
+add_report_handler() ->
+ error_logger:add_report_handler(?MODULE, [self(),Ref=make_ref()]),
+ receive
+ {event_handler_started,HandlerPid,Ref} ->
+ {ok,HandlerPid}
+ end.
+
+get_reports(Pid) ->
+ Pid ! {get_reports,self(),Ref=make_ref()},
+ receive
+ {reports,Reports,Ref} ->
+ {ok,Reports}
+ end.
+
+%%%================================================================
+
+-record(state, {
+ reports = []
+ }).
+
+%% error_logger:add_report_handler(ssh_eqc_event_handler, [self()]).
+
+init([CallerPid,Ref]) ->
+ CallerPid ! {event_handler_started,self(),Ref},
+ {ok, #state{}}.
+
+handle_event(Event, State) ->
+ {ok, State#state{reports = [Event|State#state.reports]}}.
+
+handle_info({get_reports,From,Ref}, State) ->
+ From ! {reports, lists:reverse(State#state.reports), Ref},
+ {ok, State#state{reports=[]}}.
+
+handle_call(_Request, State) -> {ok,reply,State}.
+terminate(_Arg, _State) -> stop.
+
+code_change(_OldVsn, State, _Extra) -> {ok, State}.