aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test/ssh_eqc_event_handler.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2016-10-13 16:17:04 +0200
committerErlang/OTP <[email protected]>2016-10-13 16:17:04 +0200
commitad56ed3c3ce10f50b1943a5827c516fc0ff98f4d (patch)
tree97a5ac8baaf7ab220fab2d88a2986b3b5e8c8440 /lib/ssh/test/ssh_eqc_event_handler.erl
parenta59807ef9a6a8af6eb6f13976eb405ddb9baad6c (diff)
parentf6c9b5caaa1ba6c22248ff22cc678b30d89cdd36 (diff)
downloadotp-ad56ed3c3ce10f50b1943a5827c516fc0ff98f4d.tar.gz
otp-ad56ed3c3ce10f50b1943a5827c516fc0ff98f4d.tar.bz2
otp-ad56ed3c3ce10f50b1943a5827c516fc0ff98f4d.zip
Merge branch 'hans/ssh/harmful_badmatch/OTP-13966' into maint-19
* hans/ssh/harmful_badmatch/OTP-13966: ssh: Removed matching of 'ok' after send which could cause error reports ssh: ssh_protocol_SUITE test for handling of illegal info_lines 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}.