Commit 716bca6b authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+refined handling of test configurations, connections, and interactions


for handling multiple connections to the same gate
+do not generate function definitions, start instructions, and
communications operations for SUT components when simulateSUT is false
-removed get test description (identical operation in common)
+other minor refinements and white space (no more tabs)

Change-Id: I4574366a9c581c703d93a54edbf1d537d8f35906
Signed-off-by: default avatarmakedonski <makedonski@informatik.uni-goettingen.de>
parent bbc90f3a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ operation String size() : Integer {
//Supporting operations
operation Any getTestDescription() : Any {
	if (self.eContainer.isDefined()) {
		if (not self.eContainer.isKindOf(TestDescription)) {
		if (not self.eContainer.isKindOf(TDL!TestDescription)) {
			return self.eContainer.getTestDescription();
		} else {
			return self.eContainer;
+613 −568
Original line number Diff line number Diff line
@@ -343,7 +343,7 @@ rule TC2FD
    transform tc : TDL!TestConfiguration
    to fd : TTCN!FunctionDef {
    
    fd.name = tc.TTCNname();
    fd.name = "setupTestConfiguration_"+tc.TTCNname();
    
    var md = new TTCN!ModuleDefinition();
    md.def = fd;
@@ -405,6 +405,19 @@ rule TC2FD
        }
    }
    
    //handle multiple connections to the same gate
    for (c in tc.connection) {
        if (//c.endPoint.get(0).component.role.name = "SUT" and 
            c.endPoint.get(1).component.role.name = "Tester" ) {
            c.endPoint.get(1).createConnectionPort();               
        }
        if (//c.endPoint.get(1).component.role.name = "SUT" and 
           c.endPoint.get(0).component.role.name = "Tester" ) {
            c.endPoint.get(0).createConnectionPort();               
        }
    }
    
    
    //create connections
    for (c in tc.connection) { 
        if (simulateSUT or 
@@ -470,7 +483,7 @@ rule TD2FD
    }
    

	for (ci in td.testConfiguration.componentInstance) {
    for (ci in td.testConfiguration.componentInstance.select(c|simulateSUT or c.role.name = "Tester")) {
        var cf = new TTCN!FunctionDef();
        cf.name = td.TTCNname()+"_"+ci.TTCNname()+"_main";
    
@@ -1266,6 +1279,33 @@ operation TDL!GateReference mergeIntoSUT(sut : TTCN!TypeDefBody) {
    self.equivalent().port = pe;
}

//TODO: remove parameter?
operation TDL!GateReference createConnectionPort() {
    if (self.eContainer.isKindOf(TDL!Connection)) {
        var opposite = self.eContainer.endPoint.select(e|e <> self).first();

        var pe = new TTCN!PortElement();
    
        pe.name = self.gate.TTCNname()+"_to_"+opposite.component.TTCNname()+"_"+opposite.gate.TTCNname();
    
        var d = new TTCN!ComponentDefList();
        self.component.type.equivalent().defs.add(d);
    
        d.sc = ";";
        d.element = new TTCN!ComponentElementDef();
        d.element.port = new TTCN!PortInstance();
    
        d.element.port.ref = self.gate.type.equivalent();
        d.element.port.instances.add(pe);
        
        //TODO: check this has no side effects
        self.equivalent().port = pe;
    } else {
        //TODO: handle?
    }
}


operation TDL!DataInstanceUse getTemplateBody() : TTCN!TemplateBody {
    var tb = new TTCN!TemplateBody();
    tb.simple = new TTCN!SimpleSpec();
@@ -1289,24 +1329,14 @@ operation TDL!DataInstanceUse getTemplateBody() : TTCN!TemplateBody {
    return tb;
}

operation Any getTestDescription() : Any {
	if (self.eContainer.isDefined()) {
		if (not self.eContainer.isKindOf(TestDescription)) {
			return self.eContainer.getTestDescription();
		} else {
			return self.eContainer;
		}
	} 
}


operation TDL!Interaction executeSource() : TTCN!FunctionStatementList {
    var ssl = new TTCN!FunctionStatementList();
    
    var sfs = new TTCN!FunctionStatement();
    sfs.communication = new TTCN!CommunicationStatements();
    sfs.communication.send = new TTCN!SendStatement();
	sfs.communication.send.port = self.sourceGate.gate.equivalent();
    //sfs.communication.send.port = self.sourceGate.gate.equivalent();
    sfs.communication.send.port = self.sourceGate.equivalent().port;
    sfs.communication.send.send = new TTCN!PortSendOp();
    sfs.communication.send.send.template = new TTCN!InLineTemplate();
    sfs.communication.send.send.template.template = self.argument.getTemplateBody();
@@ -1323,7 +1353,8 @@ operation TDL!Interaction executeTarget(t : TDL!Target) : TTCN!FunctionStatement
    tfs.communication = new TTCN!CommunicationStatements();
    tfs.communication.receive = new TTCN!ReceiveStatement();
    tfs.communication.receive.any = new TTCN!PortOrAny();
	tfs.communication.receive.any.ref = t.targetGate.gate.equivalent();
    //tfs.communication.receive.any.ref = t.targetGate.gate.equivalent();
    tfs.communication.receive.any.ref = t.targetGate.equivalent().port;
    tfs.communication.receive.receive = new TTCN!PortReceiveOp();
    tfs.communication.receive.receive.template = new TTCN!InLineTemplate();
    tfs.communication.receive.receive.template.template = self.argument.getTemplateBody();
@@ -1336,21 +1367,31 @@ operation TDL!Interaction executeTarget(t : TDL!Target) : TTCN!FunctionStatement
operation TDL!Interaction execute() {
    //TODO: needs adapting to context
    //      add a statement block stack for each component during transformation?
	var td = self.getTestDescription();

	//var sfd = (td.name+"_"+self.sourceGate.component.name+"_main").getFunction();
	//var sb = sfd.statement;
    //TODO: simplify
    
    //source behaviour
    if (simulateSUT or self.sourceGate.component.role.name = "Tester") {
        var sc = self.getMainContext(self.sourceGate.component);
        var sb = stack.get(sc).last();
        var ssl = self.executeSource();
        sb.stat.add(ssl);
    }

	//var tfd = (td.name+"_"+self.target.first().targetGate.component.name+"_main").getFunction();
	//var tb = tfd.statement;
    //TODO: handle multicast?
    //target behaviour
    if (simulateSUT or self.target.first().targetGate.component.role.name = "Tester") {
        var tc = self.getMainContext(self.target.first().targetGate.component);
        var tb = stack.get(tc).last();

	self.execute(sb, tb);
        var t = self.target.first();
        var tsl = self.executeTarget(t);
        tb.stat.add(tsl);
    }
    //inlined above
    //self.execute(sb, tb);
}

//TODO: remove? (inlined above)
operation TDL!Interaction execute(sourceContext : TTCN!StatementBlock, targetContext : TTCN!StatementBlock) {
    //source behaviour
    var ssl = self.executeSource();
@@ -1360,7 +1401,6 @@ operation TDL!Interaction execute(sourceContext : TTCN!StatementBlock, targetCon
    var t = self.target.first();
    var tsl = self.executeTarget(t);
    targetContext.stat.add(tsl);

}

operation TDL!Behaviour getMainContext(component : TDL!ComponentInstance) : String {
@@ -1373,14 +1413,18 @@ operation TDL!AlternativeBehaviour execute() {
    //TODO: naive simplified assumption
    var fb = self.block.first().behaviour.first();
    if (fb.isKindOf(TDL!Interaction)) {
        if (simulateSUT or fb.sourceGate.component.role.name = "Tester") {
            var sc = self.getMainContext(fb.sourceGate.component);
            var sb = stack.get(sc).last();
            self.executeSource(sb);
        }

        if (simulateSUT or fb.target.first().targetGate.component.role.name = "Tester") {
            var tc = self.getMainContext(fb.target.first().targetGate.component);
            var tb = stack.get(tc).last();
            self.executeTarget(tb);
        }
    }
    
}

@@ -1479,7 +1523,8 @@ operation TDL!Interaction getGuardOp() : TTCN!GuardOp {
    op.receive = new TTCN!ReceiveStatement();
    op.receive.any = new TTCN!PortOrAny();
    //TODO: handle broadcast?
	op.receive.any.ref = self.target.first().targetGate.gate.equivalent();
    //op.receive.any.ref = self.target.first().targetGate.gate.equivalent();
    op.receive.any.ref = self.target.first().targetGate.equivalent().port;
    op.receive.receive = new TTCN!PortReceiveOp();
    op.receive.receive.template = new TTCN!InLineTemplate();
    op.receive.receive.template.template = self.argument.getTemplateBody();