aboutsummaryrefslogtreecommitdiffstats
path: root/test/tracer_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-11-10 14:59:11 +0000
committerLoïc Hoguin <[email protected]>2017-11-10 14:59:11 +0000
commit6cc162583df2e476db6464a58c96318e3063bd19 (patch)
treeb3b7afee0b50069de01f75f013cc29b264ffbedf /test/tracer_SUITE.erl
parent32d9d494c70f1f48a9194fce8eb550cd3f88df54 (diff)
downloadcowboy-6cc162583df2e476db6464a58c96318e3063bd19.tar.gz
cowboy-6cc162583df2e476db6464a58c96318e3063bd19.tar.bz2
cowboy-6cc162583df2e476db6464a58c96318e3063bd19.zip
Keep the state returned by the tracer callback
It was mistakenly discarded.
Diffstat (limited to 'test/tracer_SUITE.erl')
-rw-r--r--test/tracer_SUITE.erl24
1 files changed, 21 insertions, 3 deletions
diff --git a/test/tracer_SUITE.erl b/test/tracer_SUITE.erl
index 6f83fd3..0f7fc5f 100644
--- a/test/tracer_SUITE.erl
+++ b/test/tracer_SUITE.erl
@@ -98,12 +98,13 @@ do_tracer_callback(Pid) ->
fun
(Event, _) when Event =:= init; Event =:= terminate ->
Pid ! Event,
- undefined;
+ 0;
(Event={trace_ts, _, call, {cowboy_req, reply, _}, _}, State) ->
Pid ! Event,
- State;
+ Pid ! {state, State},
+ State + 1;
(_, State) ->
- State
+ State + 1
end.
%% Tests.
@@ -140,6 +141,23 @@ terminate(Config) ->
error(timeout)
end.
+state(Config) ->
+ doc("Ensure the returned state is used."),
+ Ref = config(ref, Config),
+ Opts = ranch:get_protocol_options(Ref),
+ ranch:set_protocol_options(Ref, Opts#{
+ tracer_callback => do_tracer_callback(self()),
+ tracer_match_specs => [fun(_,_,_) -> true end]
+ }),
+ do_get("/", Config),
+ receive
+ {state, St} ->
+ true = St > 0,
+ ok
+ after 100 ->
+ error(timeout)
+ end.
+
empty(Config) ->
doc("Empty match specs unconditionally enable tracing."),
Ref = config(ref, Config),