From cda603880cac4a686d88e0bbb940a790525c9c5d Mon Sep 17 00:00:00 2001 From: Jesper Louis Andersen Date: Thu, 25 Jun 2015 14:52:47 +0200 Subject: [PATCH] Hello Travis CI! --- .travis.yml | 2 +- eqc_test/fuse_time.erl | 98 -------------------------------------- eqc_test/fuse_time_eqc.erl | 61 ------------------------ rebar.config | 11 ++++- test/fuse_SUITE.erl | 4 +- test/fuse_time_eqc.erl | 30 ++++++------ test/fuse_time_mock.erl | 42 +++------------- 7 files changed, 34 insertions(+), 214 deletions(-) delete mode 100644 eqc_test/fuse_time.erl delete mode 100644 eqc_test/fuse_time_eqc.erl diff --git a/.travis.yml b/.travis.yml index 8d9f296..c250ad9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: erlang -script: "make all; make tests" +script: "rebar3 ct" otp_release: - R16B03-1 - 17.0 diff --git a/eqc_test/fuse_time.erl b/eqc_test/fuse_time.erl deleted file mode 100644 index 47f1a77..0000000 --- a/eqc_test/fuse_time.erl +++ /dev/null @@ -1,98 +0,0 @@ -%%%------------------------------------------------------------------- -%%% @author Thomas Arts <> -%%% @copyright (C) 2014, Thomas Arts -%%% @doc -%%% -%%% @end -%%% Created : 26 Mar 2014 by Thomas Arts <> -%%%------------------------------------------------------------------- --module(fuse_time). - --include_lib("eqc/include/eqc.hrl"). --include_lib("pulse_otp/include/pulse_otp.hrl"). - --export([start/1, init/2]). --export([timestamp/0,elapse_time/1]). --export([send_after/3, cancel_timer/1]). --export([inc/2]). - --export([prop_inc/0]). - --define(UNIT,1000*1000). - -send_after(_When, _Target, _Msg) -> make_ref(). -cancel_timer(_Ref) -> 0. - -timestamp() -> - ?MODULE ! {timestamp, self()}, - receive - {timestamp, Time} -> Time - after 1000 -> - exit(timeout) - end. - -elapse_time(N) -> - ?MODULE ! {elapse, self(), N}, - receive - {timestamp, Time} -> Time - after 1000 -> - exit(timeout) - end. - -start(Time) -> - case whereis(?MODULE) of - Pid when is_pid(Pid) -> - Pid ! {reset, self(), Time}, - receive - ok -> ok - end; - undefined -> - spawn_link(fuse_time, init, [self(), Time]), - receive - ok -> ?MODULE - end - end. - -init(From, Time) -> - register(?MODULE, self()), - From ! ok, - loop(Time). - -loop(Time) -> - receive - {timestamp, From} -> - From ! {timestamp, Time}, - loop(inc(Time,0)); - {elapse, From, N} -> - NewTime = inc(Time,N), - From ! {timestamp, NewTime}, - loop(NewTime); - {reset, From, RTime} -> - From ! ok, - loop(RTime); - stop -> - Time - end. - -inc({Mega,One,Mili},N) -> - inc({Mega,One,Mili},N,?UNIT). - -inc({Mega,One,Micro}, N, Unit) -> - NewTime = Mega*Unit*Unit + One*Unit + Micro + N, - NMega = NewTime div (Unit*Unit), - NOne = (NewTime rem (Unit*Unit)) div Unit, - NMicro = NewTime rem Unit, - {NMega, NOne, NMicro}. - -prop_inc() -> - ?FORALL(Base, choose(2,10), - ?FORALL({Time,N}, {{choose(0,Base-1),choose(0,Base-1),choose(0,Base-1)},choose(0,Base*Base+1)}, - begin - {Me,One,Mi} = inc(Time,N,Base), - ?WHENFAIL(io:format("Computed: ~p\n",[{Me,One,Mi}]), - Me - --module(fuse_time_eqc). - - --include_lib("eqc/include/eqc.hrl"). --include_lib("eqc/include/eqc_statem.hrl"). - --compile(export_all). - -initial_state() -> - {0,0,0}. - -timestamp_command(_S) -> - {call, fuse_time, timestamp, []}. - -timestamp_next(_S, NewTime, []) -> - NewTime. - -timestamp_post(S, [], NewTime) -> - S =< NewTime. - -time_inc() -> - ?LET(N, choose(0, 1000*1000), - N+1). - -elapse_time_command(_S) -> - {call, fuse_time, elapse_time, [time_inc()]}. - -elapse_time_post(S, [_], NewTime) -> - less(S,NewTime). - - -less(X,Y) when X= - true; -less(X,Y) -> - {X,'>=',Y}. - - -prop_os() -> - ?FORALL(Cmds, commands(?MODULE), - begin - fuse_time:start({0,0,0}), - {H, S, Res} = run_commands(?MODULE,Cmds), - pretty_commands(?MODULE, Cmds, {H, S, Res}, - Res == ok) - end). - -prop_os_par() -> - ?FORALL(Cmds, parallel_commands(?MODULE), - begin - fuse_time:start({0,0,0}), - {H, S, Res} = run_parallel_commands(?MODULE,Cmds), - pretty_commands(?MODULE, Cmds, {H, S, Res}, - Res == ok) - end). diff --git a/rebar.config b/rebar.config index 7f552bd..8bfdb05 100644 --- a/rebar.config +++ b/rebar.config @@ -1,4 +1,11 @@ {erl_opts, [ - debug_info, warn_export_all, warn_export_vars, warn_shadow_vars, warn_obsolete_guard - %% warn_missing_spec + debug_info, + warn_export_all, + warn_export_vars, + warn_shadow_vars, + warn_obsolete_guard ]}. + +{profiles, [ + {eqc, [{erl_opts, [{d, 'EQC'}, debug_info]} ]} +] }. diff --git a/test/fuse_SUITE.erl b/test/fuse_SUITE.erl index 0eafcd9..e35e540 100644 --- a/test/fuse_SUITE.erl +++ b/test/fuse_SUITE.erl @@ -70,12 +70,12 @@ simple_test(_Config) -> receive {?FUSE_SIMPLE, blown} -> ok after 1000 -> - ct:fail(timeout_eh) + ct:fail(timeout_eh) end, receive {set_alarm, {?FUSE_SIMPLE, fuse_blown}} -> ok after 61 * 1000 -> - ct:fail(timeout_ah) + ct:fail(timeout_ah) end, ct:sleep(600), ok = fuse:ask(?FUSE_SIMPLE, sync), diff --git a/test/fuse_time_eqc.erl b/test/fuse_time_eqc.erl index fda048a..973b047 100644 --- a/test/fuse_time_eqc.erl +++ b/test/fuse_time_eqc.erl @@ -1,6 +1,6 @@ %%% @author Thomas Arts %%% @copyright (C) 2014, Quviq AB -%%% @doc Showing that the fuse_time module behaves as expected +%%% @doc Showing that the fuse_time_mock module behaves as expected %%% %%% @end %%% Created : 26 Mar 2014 by Thomas Arts @@ -13,23 +13,24 @@ -include_lib("eqc/include/eqc_statem.hrl"). initial_state() -> - {0,0,0}. + -10000. -timestamp_command(_S) -> - {call, fuse_time_mock, timestamp, []}. +monotonic_time() -> + fuse_time_mock:monotonic_time(). + +monotonic_time_args(_S) -> []. -timestamp_next(_S, NewTime, []) -> +monotonic_time_next(_S, NewTime, []) -> NewTime. -timestamp_post(S, [], NewTime) -> +monotonic_time_post(S, [], NewTime) -> S =< NewTime. -time_inc() -> - ?LET(N, choose(0, 1000*1000), - N+1). - -elapse_time_command(_S) -> - {call, fuse_time_mock, elapse_time, [time_inc()]}. +elapse_time(Inc) -> + fuse_time_mock:elapse_time(Inc). + +elapse_time_args(_S) -> + [?LET(N, choose(0, 1000*1000*1000), N+1)]. elapse_time_post(S, [_], NewTime) -> less(S,NewTime). @@ -37,11 +38,10 @@ elapse_time_post(S, [_], NewTime) -> less(X,Y) when X= true; less(X,Y) -> {X,'>=',Y}. - prop_seq() -> ?FORALL(Cmds, commands(?MODULE), begin - fuse_time_mock:start({0,0,0}), + fuse_time_mock:start(0), {H, S, Res} = run_commands(?MODULE,Cmds), pretty_commands(?MODULE, Cmds, {H, S, Res}, Res == ok) @@ -50,7 +50,7 @@ prop_seq() -> prop_par() -> ?FORALL(Cmds, parallel_commands(?MODULE), begin - fuse_time_mock:start({0,0,0}), + fuse_time_mock:start(-10000), {H, S, Res} = run_parallel_commands(?MODULE,Cmds), pretty_commands(?MODULE, Cmds, {H, S, Res}, Res == ok) diff --git a/test/fuse_time_mock.erl b/test/fuse_time_mock.erl index 819ebf3..c7333b6 100644 --- a/test/fuse_time_mock.erl +++ b/test/fuse_time_mock.erl @@ -12,25 +12,20 @@ -include_lib("pulse_otp/include/pulse_otp.hrl"). -export([start/1, init/2]). --export([timestamp/0,elapse_time/1]). +-export([monotonic_time/0,elapse_time/1]). -export([send_after/3, cancel_timer/1]). --export([inc/2]). - --export([prop_inc/0]). - --define(UNIT,1000*1000). send_after(_When, _Target, _Msg) -> make_ref(). cancel_timer(_Ref) -> 0. -timestamp() -> - ?MODULE ! {timestamp, self()}, +monotonic_time() -> + ?MODULE ! {monotonic_time, self()}, receive {timestamp, Time} -> Time after 1000 -> exit(timeout) end. - + elapse_time(N) -> ?MODULE ! {elapse, self(), N}, receive @@ -60,11 +55,11 @@ init(From, Time) -> loop(Time) -> receive - {timestamp, From} -> + {monotonic_time, From} -> From ! {timestamp, Time}, - loop(inc(Time,0)); + loop(Time); {elapse, From, N} -> - NewTime = inc(Time,N), + NewTime = Time + N, From ! {timestamp, NewTime}, loop(NewTime); {reset, From, RTime} -> @@ -73,26 +68,3 @@ loop(Time) -> stop -> Time end. - -inc({Mega,One,Mili},N) -> - inc({Mega,One,Mili},N,?UNIT). - -inc({Mega,One,Micro}, N, Unit) -> - NewTime = Mega*Unit*Unit + One*Unit + Micro + N, - NMega = NewTime div (Unit*Unit), - NOne = (NewTime rem (Unit*Unit)) div Unit, - NMicro = NewTime rem Unit, - {NMega, NOne, NMicro}. - -prop_inc() -> - ?FORALL(Base, choose(2,10), - ?FORALL({Time,N}, {{choose(0,Base-1),choose(0,Base-1),choose(0,Base-1)},choose(0,Base*Base+1)}, - begin - {Me,One,Mi} = inc(Time,N,Base), - ?WHENFAIL(io:format("Computed: ~p\n",[{Me,One,Mi}]), - Me