From b430fa479c26cceb1408d0bb92da76637c4a1e5a Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Mon, 17 Feb 2014 01:27:02 +0900 Subject: [PATCH] PULSE condition checking is only 98% embarassing --- prototype/corfurl/rebar.config.script | 12 +++++------ prototype/corfurl/test/corfurl_pulse.erl | 27 ++++++++++++++++++------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/prototype/corfurl/rebar.config.script b/prototype/corfurl/rebar.config.script index 2155bb5..ae29cb2 100644 --- a/prototype/corfurl/rebar.config.script +++ b/prototype/corfurl/rebar.config.script @@ -11,12 +11,12 @@ case PulseBuild of [{erlang,display,1} ]}, {pulse_side_effect, - [ {corfurl_sequencer, get, 0} - , {corfurl_flu, write, 4} - , {corfurl_flu, read, 3} - , {corfurl_flu, seal, 2} - , {corfurl_flu, trim, 3} - , {corfurl_flu, fill, 3} + [ {corfurl_sequencer, get, '_'} + , {corfurl_flu, write, '_'} + , {corfurl_flu, read, '_'} + , {corfurl_flu, seal, '_'} + , {corfurl_flu, trim, '_'} + , {corfurl_flu, fill, '_'} , {event_logger, event, '_'} diff --git a/prototype/corfurl/test/corfurl_pulse.erl b/prototype/corfurl/test/corfurl_pulse.erl index 7e8ba55..57f5e6e 100644 --- a/prototype/corfurl/test/corfurl_pulse.erl +++ b/prototype/corfurl/test/corfurl_pulse.erl @@ -185,10 +185,23 @@ prop_pulse_test_() -> ?assert(eqc:quickcheck(eqc:testing_time(Timeout,?QC_OUT(prop_pulse())))) end}. -check_trace(Trace, _Cmds, _Seed) -> - %% TODO: yeah +check_trace(Trace, Cmds, _Seed) -> + %% TODO: yeah!!!!!!!!!! + Results = [X || {_TS, {result, _Pid, X}} <- Trace], - lists:sort(Results) == lists:usort(Results). + {CmdsSeq, CmdsPars} = Cmds, + NaiveCmds = CmdsSeq ++ lists:flatten(CmdsPars), + NaiveCommands = [{Sym, Args} || {set,_,{call,_,Sym,Args}} <- NaiveCmds], + NaiveAppends = [X || {append, _} = X <- NaiveCommands], + + %% If you want to see PULSE causing crazy scheduling, then + %% use this commented conjunction() instead of the real one: + %% conjunction( + %% [{bogus_order_check_do_not_use_me, equals(Results, lists:usort(Results))}]). + + conjunction( + [{hackkkkk_NumResults_match_NumAppends, equals(length(NaiveAppends), length(Results))}, + {no_duplicate_results, equals(lists:sort(Results), lists:usort(Results))}]). %% Presenting command data statistics in a nicer way command_data({set, _, {call, _, Fun, _}}, {_S, _V}) -> @@ -260,10 +273,10 @@ setup(NumChains, ChainLen, PageSize) -> #run{seq=Seq, proj=Proj, flus=FLUs}. -define(LOG(Tag, MkCall), - event_logger:event({call, self(), Tag}), - __Result = MkCall, - event_logger:event({result, self(), __Result}), - __Result). + event_logger:event({call, self(), Tag}), + LOG__Result = MkCall, + event_logger:event({result, self(), LOG__Result}), + LOG__Result). append(#run{seq=Seq,proj=Proj}, Page) -> ?LOG({append, Page},