Commit ce6baf91 authored by stancakapost's avatar stancakapost
Browse files

added add component.done to avoid racing condition between mtc

termination and ptc termination

also changed the behavior so that it is actually dependent on components
having different seeds. The way it was before, it would also have worked
if the components used the same seed, as only the rnd(seed) - function,
which does not use the internal seed (just updates it), was used.
parent 1bdd1cd0
...@@ -7,44 +7,46 @@ ...@@ -7,44 +7,46 @@
/* The following requirements are tested: /* The following requirements are tested:
* check that rnd() uses seeds per component * check that rnd() uses seeds per component
* *
* */ */
module Sem_160102_predefined_functions_091 { module Sem_160102_predefined_functions_091 {
type component GeneralComp {} type component GeneralComp {}
//function to generate random number with seed given as input //function to generate random number with seed given as input
function frnd(float seed) runs on GeneralComp { function frnd(float seed) runs on GeneralComp {
var float v_random1 := rnd(seed); var float v_random1 := rnd(seed);
var float v_random2 := rnd();
if(match(rnd(seed),v_random1) and not match(rnd(1.0), v_random1) ) { if(match(v_random2, rnd(v_random1)) and not match(seed, v_random1) ) {
setverdict(pass); setverdict(pass);
} else { } else {
setverdict(fail,v_random1); setverdict(fail,v_random1);
}
} }
}
testcase TC_Sem_160102_predefined_functions_091 (float General_Comp_seed) runs on GeneralComp system GeneralComp { testcase TC_Sem_160102_predefined_functions_091 (float General_Comp_seed) runs on GeneralComp system GeneralComp {
var float v_random1,v_random2; var float v_random1,v_random2;
//Generate components with different seeds //Generate components with different seeds
var GeneralComp v_ptc1,v_ptc2; var GeneralComp v_ptc1,v_ptc2;
v_ptc1:= GeneralComp.create alive; v_ptc1:= GeneralComp.create alive;
v_ptc2:= GeneralComp.create alive; v_ptc2:= GeneralComp.create alive;
//different seeds given to components: //different seeds given to components:
v_ptc1.start(frnd(General_Comp_seed)); v_ptc1.start(frnd(General_Comp_seed));
v_ptc2.start(frnd(General_Comp_seed+0.5)); v_ptc2.start(frnd(General_Comp_seed+0.5));
} all component.done;
}
control{ control{
const float General_Comp_seed := 0.0; const float General_Comp_seed := 0.0;
execute(TC_Sem_160102_predefined_functions_091(General_Comp_seed)); execute(TC_Sem_160102_predefined_functions_091(General_Comp_seed));
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment