Commit 2e08fa3d authored by urbant's avatar urbant
Browse files

Tests for sections 21.3.3, 21.3.4, 21.3.5, 21.3.6., 21.3.7, 21.3.8, 23.5, 23.6

parent 967b925e
Loading
Loading
Loading
Loading
+37 −0
Original line number Original line Diff line number Diff line
/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:21.3.3, restarting explicitly stopped non-alive component
 ** @verdict  pass reject
 *****************************************************************/

// The following requirements are tested:
// Stopping a non-alive-type test component (implicitly or explicitly) shall destroy 
// it and all resources associated with the test component shall be released.

module NegSem_210303_Stop_test_component_001 {

    type port P message {
        inout integer;
    }
    
    type component GeneralComp {
        port P p;
    }
    
	function f() runs on GeneralComp {
        p.receive(integer:?);
	}
	
    testcase TC_NegSem_210303_Stop_test_component_001() runs on GeneralComp system GeneralComp {
        var GeneralComp ptc := GeneralComp.create;
		ptc.start(f());
        ptc.stop;
        ptc.start(f());
		setverdict(pass);
    }

    control {
        execute(TC_NegSem_210303_Stop_test_component_001());
    }
}
 No newline at end of file
+36 −0
Original line number Original line Diff line number Diff line
/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:21.3.3, stopping all PTCs from a PTC
 ** @verdict  pass reject
 *****************************************************************/

// The following requirements are tested:
// The all keyword can be used by the MTC only in order to stop all running PTCs but 
// the MTC itself.

module NegSem_210303_Stop_test_component_002 {

    type port P message {
        inout integer;
    }
    
    type component GeneralComp {
        port P p;
    }
    
	function f() runs on GeneralComp {
        all component.stop;
	}
	
    testcase TC_NegSem_210303_Stop_test_component_002() runs on GeneralComp system GeneralComp {
        var GeneralComp ptc := GeneralComp.create;
		ptc.start(f()); 
        ptc.done;
        setverdict(pass);
    }

    control {
        execute(TC_NegSem_210303_Stop_test_component_002());
    }
}
 No newline at end of file
+40 −0
Original line number Original line Diff line number Diff line
/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:21.3.3, applying stop operation to a variable of a different than component type
 ** @verdict  pass reject
 *****************************************************************/

// The following requirements are tested:
// The variable associated with VariableRef (being a component type variable, a component
// type parameter, etc.) or the return type associated with FunctionInstance shall be of
// component type.

module NegSem_210303_Stop_test_component_003 {

    type port P message {
        inout integer;
    }
    
    type component GeneralComp {
        port P p;
    }
    
	function f_behaviour() runs on GeneralComp {
        p.receive(integer:?); // infinite blocking
	}
	
    testcase TC_NegSem_210303_Stop_test_component_003() runs on GeneralComp system GeneralComp {
        var GeneralComp v_ptc[2];
        v_ptc[0] := GeneralComp.create;
        v_ptc[1] := GeneralComp.create;
        v_ptc[0].start(f_behaviour());
        v_ptc[1].start(f_behaviour());
		v_ptc.stop;
        setverdict(pass);
    }

    control {
        execute(TC_NegSem_210303_Stop_test_component_003());
    }
}
 No newline at end of file
+46 −0
Original line number Original line Diff line number Diff line
/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:21.3.3, applying stop operation to a function call result of a different than component type
 ** @verdict  pass reject
 *****************************************************************/

// The following requirements are tested:
// The variable associated with VariableRef (being a component type variable, a component
// type parameter, etc.) or the return type associated with FunctionInstance shall be of
// component type.

module NegSem_210303_Stop_test_component_004 {

    type port P message {
        inout integer;
    }
    
    type component GeneralComp {
        port P p;
    }
    
    type GeneralComp CompArray[2];
    
	function f_behaviour() runs on GeneralComp {
        p.receive(integer:?); // infinite blocking
	}
       
    function f_createComponents() return CompArray {
        var CompArray v_ptc;
        v_ptc[0] := GeneralComp.create;
        v_ptc[1] := GeneralComp.create;
        v_ptc[0].start(f_behaviour());
        v_ptc[1].start(f_behaviour());
        return v_ptc;
    }
	
    testcase TC_NegSem_210303_Stop_test_component_004() runs on GeneralComp system GeneralComp {
        f_createComponents().stop;
        setverdict(pass);
    }

    control {
        execute(TC_NegSem_210303_Stop_test_component_004());
    }
}
 No newline at end of file
+34 −55
Original line number Original line Diff line number Diff line
/*****************************************************************
/*****************************************************************
 ** @author   STF 451
 ** @author   STF 451, updated by STF 487
 ** @version  0.0.1
 ** @version  0.0.1
 ** @purpose  1:21.3.3, Ensure that self.stop stops current component 
 ** @purpose  1:21.3.3, Ensure that self.stop stops current component 
 ** @verdict  pass accept, ttcn3verdict:pass
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/
 *****************************************************************/

// The following requirements are tested:
// A component can stop its own behaviour by using a simple stop execution statement
// (see clause 19.9) or by addressing itself in the stop operation, e.g. by using 
// the self operation.

module Sem_210303_Stop_test_component_002 {
module Sem_210303_Stop_test_component_002 {


	type port PSync message {
	    inout all;
	}
    type component GeneralComp {
    type component GeneralComp {
    	timer t;
    	port PSync p_sync;
    }
    }
	function f() runs on GeneralComp {
	function f() runs on GeneralComp {
	 p_sync.send("Started PTC");
        var boolean v_cond := true;
	 self.stop; //stops the ptc
        if (v_cond) {
	    
	    // wait 2 seconds to catch the self.stop not working
	    t.start(2.0);
	    t.timeout;
	}
	
    testcase TC_Sem_210303_Stop_test_component_002() runs on GeneralComp system GeneralComp {
        var GeneralComp ptc;
		
		ptc:=GeneralComp.create;
		connect(mtc:p_sync, ptc:p_sync);

		
		ptc.start(f()); 
		t.start(2.0);
		alt {
            [] p_sync.receive {
                t.stop;
                // wait to be sure that self.stop was called
                t.start(0.5);
                t.timeout;
                if (ptc.running) {
                    setverdict(fail);
                } else {
            setverdict(pass);
            setverdict(pass);
            self.stop; //stops the ptc
        }
        }
            }
        setverdict(fail); // in case the stop operation doesn't work
		    [] t.timeout {
		        setverdict(fail);
		    }
	}
	}
	
	
    testcase TC_Sem_210303_Stop_test_component_002() runs on GeneralComp system GeneralComp {
        var GeneralComp v_ptc := GeneralComp.create;
		v_ptc.start(f()); 
		v_ptc.done;     
    }
    }


    control {
    control {
Loading