diff --git a/src/chronos.erl b/src/chronos.erl index d1a2f0f..f3500bd 100644 --- a/src/chronos.erl +++ b/src/chronos.erl @@ -53,7 +53,7 @@ -spec start_link(server_name()) -> {'ok', pid()} | 'ignore' | {'error', term()}. start_link(ServerName) -> - gen_server:start_link({local, ServerName}, _Args = [], _Opts = []). + gen_server:start_link({local, ServerName}, ?MODULE, _Args = [], _Opts = []). %% -start_link() -> {'ok',pid()} | 'ignore' | {'error',term()}. %% start_link() -> diff --git a/test/chronos_eqc.erl b/test/chronos_eqc.erl index b090d11..c65e569 100644 --- a/test/chronos_eqc.erl +++ b/test/chronos_eqc.erl @@ -32,11 +32,11 @@ initial_state() -> command(S) -> frequency ([ {100, {call, timer_expiry, start_server, [server_name()]}} ] - ++ [ {1000, {call, timer_expiry, start_timer, start_timer_args(S)}} + ++ [ {1000, {call, timer_expiry, start_timer, args(start_timer, S)}} || S#state.servers /= [] ] - ++ [ {200, {call, timer_expiry, stop_timer, stop_timer_args(S)}} + ++ [ {200, {call, timer_expiry, stop_timer, args(stop_timer, S)}} || S#state.servers /= [] ] - ++ [ {1000, {call, ?MODULE, advance_time, advance_time_args(S)}} + ++ [ {1000, {call, ?MODULE, advance_time, args(advance_time, S)}} || S#state.servers /= [] andalso possible_to_advance_time(S) ] ). @@ -169,15 +169,16 @@ timer_name() -> {timer, nat()}. timer_duration() -> choose(10, 100). -start_timer_args(S) -> +args(start_timer, S) -> + ?LET(Server, oneof(S#state.servers), - [Server, timer_name(), timer_duration()]). + [Server, timer_name(), timer_duration()]); -stop_timer_args(S) -> +args(stop_timer, S) -> ?LET({Server, Timer}, oneof( S#state.running ++ [{hd(S#state.servers), bogus}]), - [Server, Timer]). + [Server, Timer]); -advance_time_args(_S) -> +args(advance_time, _S) -> [choose(5, 50)]. %%---------------------- OPERATIONS ----------------------