diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2014-06-02 13:01:58 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2014-06-02 13:01:58 +0100 |
| commit | d5ecd1810c1eec0b70cd9d2915b3e0c87efc2e75 (patch) | |
| tree | 423bb346b7189fd5ddd54c2f461641339183c963 | |
| parent | 1be9ca92828ef68581a999a563832e49cde84afc (diff) | |
| download | rabbitmq-server-git-d5ecd1810c1eec0b70cd9d2915b3e0c87efc2e75.tar.gz | |
Do "randomness" properly, trap exits.
| -rwxr-xr-x | quickcheck | 6 | ||||
| -rw-r--r-- | src/gm_qc.erl | 23 |
2 files changed, 13 insertions, 16 deletions
diff --git a/quickcheck b/quickcheck index 565b19304c..8b1736bb6e 100755 --- a/quickcheck +++ b/quickcheck @@ -15,10 +15,8 @@ main([NodeStr, ModStr, TrialsStr]) -> case rpc:call(Node, code, ensure_loaded, [proper]) of {module, proper} -> case rpc:call(Node, proper, module, - [Mod] ++ [[{numtests, Trials}, - {constraint_tries, 200}, - {start_size, 5}, - long_result]]) of + [Mod] ++ [[{numtests, Trials}, + {constraint_tries, 200}]]) of [] -> ok; R -> io:format("~p.~n", [R]), quit(1) diff --git a/src/gm_qc.erl b/src/gm_qc.erl index 782bde9d26..234e8b1651 100644 --- a/src/gm_qc.erl +++ b/src/gm_qc.erl @@ -45,14 +45,11 @@ prop_gm_test() -> ?MODULE -> ok; _ -> exit(compile_with_INSTRUMENT_FOR_QC) end, + process_flag(trap_exit, true), erlang:register(?MODULE, self()), ?FORALL(Cmds, commands(?MODULE), gm_test(Cmds)). gm_test(Cmds) -> - %% Give some feedback on how long our sequences are, since it - %% seems easy to end up with lots of tiny sequences and think - %% you're doing something. - io:format("~p", [length(Cmds)]), {_H, State, Res} = run_commands(?MODULE, Cmds), cleanup(State), ?WHENFAIL( @@ -90,13 +87,10 @@ command(S = #state{outstanding = Outstanding}) -> end. qc_join(_S) -> {call,?MODULE,do_join, []}. -qc_leave(S) -> {call,?MODULE,do_leave,[random(gms(S))]}. -qc_send(S = #state{seq = N}) -> {call,?MODULE,do_send, [N, random(gms(S))]}. -qc_proceed(S) -> {call,?MODULE,do_proceed, [random(gms(S)), - random(gms(S))]}. - -random([]) -> will_fail_precondition; -random(L) -> lists:nth(random:uniform(length(L)), L). +qc_leave(S) -> {call,?MODULE,do_leave,[oneof(gms(S))]}. +qc_send(S = #state{seq = N}) -> {call,?MODULE,do_send, [N, oneof(gms(S))]}. +qc_proceed(S) -> {call,?MODULE,do_proceed, [oneof(gms(S)), + oneof(gms(S))]}. precondition(S, {call, ?MODULE, do_join, []}) -> length(gms(S)) < ?MAX_SIZE; @@ -256,7 +250,12 @@ handle_msg({instrumented, From, To, Thing}, S = #state{instrumented = Msgs}) -> {ok, Q} -> queue:in(Thing, Q); error -> queue:from_list([Thing]) end, - S#state{instrumented = dict:store({From, To}, Q1, Msgs)}. + S#state{instrumented = dict:store({From, To}, Q1, Msgs)}; +handle_msg({'EXIT', _From, normal}, S) -> + S; +handle_msg({'EXIT', _From, Reason}, S) -> + %% We just trapped exits to get nicer SASL logging. + exit(Reason). process_msg(From, _To, {call, Ref}) -> From ! {proceed, Ref}; process_msg(_From, To, {cast, Msg}) -> gen_server2:cast(To, Msg). |
