Skip to content

Commit

Permalink
Hello Travis CI!
Browse files Browse the repository at this point in the history
  • Loading branch information
jlouis committed Jun 25, 2015
1 parent a78258b commit cda6038
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 214 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: erlang

script: "make all; make tests"
script: "rebar3 ct"
otp_release:
- R16B03-1
- 17.0
Expand Down
98 changes: 0 additions & 98 deletions eqc_test/fuse_time.erl

This file was deleted.

61 changes: 0 additions & 61 deletions eqc_test/fuse_time_eqc.erl

This file was deleted.

11 changes: 9 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -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]} ]}
] }.
4 changes: 2 additions & 2 deletions test/fuse_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
30 changes: 15 additions & 15 deletions test/fuse_time_eqc.erl
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
Expand All @@ -13,35 +13,35 @@
-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).

less(X,Y) when X=<Y -> 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)
Expand All @@ -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)
Expand Down
42 changes: 7 additions & 35 deletions test/fuse_time_mock.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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} ->
Expand All @@ -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<Base*Base andalso One<Base andalso Mi<Base)
end)).




0 comments on commit cda6038

Please sign in to comment.