diff options
author | Anton N Ryabkov <[email protected]> | 2017-04-25 18:27:15 +0700 |
---|---|---|
committer | Anton N Ryabkov <[email protected]> | 2017-05-02 08:34:17 +0700 |
commit | bf3ead6cdb3a5c7556831b9684574845101f4f36 (patch) | |
tree | cc1bf097f0feadc24f9bc04d51ca9dafc6e3bff0 /lib/stdlib/test | |
parent | 38294da512781e44b44b9331bf613003397d529b (diff) | |
download | otp-bf3ead6cdb3a5c7556831b9684574845101f4f36.tar.gz otp-bf3ead6cdb3a5c7556831b9684574845101f4f36.tar.bz2 otp-bf3ead6cdb3a5c7556831b9684574845101f4f36.zip |
Rolled back loop_receive function. HibernateAfterTimeout timeout used even in case of active timers exists.
Added unit tests for hibernate_after functionality combined with gen_statem timers.
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r-- | lib/stdlib/test/gen_statem_SUITE.erl | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/stdlib/test/gen_statem_SUITE.erl b/lib/stdlib/test/gen_statem_SUITE.erl index 33441c75e0..5b9daecfd3 100644 --- a/lib/stdlib/test/gen_statem_SUITE.erl +++ b/lib/stdlib/test/gen_statem_SUITE.erl @@ -1323,7 +1323,36 @@ auto_hibernate(Config) -> is_not_in_erlang_hibernate(Pid), timer:sleep(HibernateAfterTimeout), is_in_erlang_hibernate(Pid), - + %% Timer test 1 + TimerTimeout1 = 50, + ok = gen_statem:call(Pid, {arm_htimer, self(), TimerTimeout1}), + is_not_in_erlang_hibernate(Pid), + timer:sleep(TimerTimeout1), + is_not_in_erlang_hibernate(Pid), + receive + {Pid, htimer_armed} -> + ok + after 1000 -> + ct:fail(timer1) + end, + is_not_in_erlang_hibernate(Pid), + timer:sleep(HibernateAfterTimeout), + is_in_erlang_hibernate(Pid), + %% Timer test 2 + TimerTimeout2 = 150, + ok = gen_statem:call(Pid, {arm_htimer, self(), TimerTimeout2}), + is_not_in_erlang_hibernate(Pid), + timer:sleep(HibernateAfterTimeout), + is_in_erlang_hibernate(Pid), + receive + {Pid, htimer_armed} -> + ok + after 1000 -> + ct:fail(timer2) + end, + is_not_in_erlang_hibernate(Pid), + timer:sleep(HibernateAfterTimeout), + is_in_erlang_hibernate(Pid), stop_it(Pid), process_flag(trap_exit, OldFl), receive @@ -1761,6 +1790,11 @@ idle(cast, {hping,Pid}, Data) -> {keep_state, Data}; idle({call, From}, hping, _Data) -> {keep_state_and_data, [{reply, From, hpong}]}; +idle({call, From}, {arm_htimer, Pid, Timeout}, _Data) -> + {keep_state_and_data, [{reply, From, ok}, {timeout, Timeout, {arm_htimer, Pid}}]}; +idle(timeout, {arm_htimer, Pid}, _Data) -> + Pid ! {self(), htimer_armed}, + keep_state_and_data; idle(cast, {connect,Pid}, Data) -> Pid ! accept, {next_state,wfor_conf,Data,infinity}; % NoOp timeout just to test API |