Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » more strict 'ifpresent' handling in titan 6.6.x compared to previous versions
more strict 'ifpresent' handling in titan 6.6.x compared to previous versions [message #1826175] Mon, 20 April 2020 15:44 Go to next message
Harald Welte is currently offline Harald WelteFriend
Messages: 140
Registered: July 2017
Location: Berlin, Germany
Senior Member

I just wanted to upgrade the Osmocom test suites from TITAN 6.5.0 to 6.6.1 yesterday, and it seems code that was compiled by 6.5.0 is no longer compiling with 6.6.1

specifically, there are code sequences like the following:
function tr_CBSP_WRITE_CBS_COMPL(template uint16_t msg_id, template uint16_t new_ser_nr,
                                 template BSSMAP_FIELD_CellIdentificationList cell_list,
                                 template uint8_t channel_ind)
return template CBSP_PDU {
        var template CBSP_IEs ies := {
                tr_CbspMsgId(msg_id),
                tr_NewSerNo(new_ser_nr)
        };
        if (istemplatekind(cell_list, "*")) {
                ies[lengthof(ies)] := tr_CbspCellList ifpresent;
        } else if (istemplatekind(cell_list, "?")) {
                ies[lengthof(ies)] := tr_CbspCellList(?);
        } else if (not istemplatekind(cell_list, "omit")) {
                ies[lengthof(ies)] := tr_CbspCellList(cell_list);
        }
        if (not istemplatekind(channel_ind, "omit")) {
                ies[lengthof(ies)] := tr_CbspChannelInd(channel_ind);
        }
        return tr_CBSP(CBSP_MSGT_WRITE_REPLACE_COMPL, ies);
}


where 6.6.1 now fails compilation with:
    CBSP_Templates.ttcn:371.25-39: error: `ifpresent' is not allowed here


The full source file is at https://git.osmocom.org/osmo-ttcn3-hacks/tree/library/CBSP_Templates.ttcn

unfortunately it gives no explanation as to why it's not allowed. The same code compiles just fine under earlier versions. I think up to 6.5.0 are fine. Right now I only have a system with 6.3.0 for testing, and 6.3.0 definitely compiles the same code just fine.

Can somebody help me clarify

a) if the above is a valid TTCN-3 language construct. If not, why?
b) was it intentional to remove this functionality from TITAN?

Thanks!
Re: more strict 'ifpresent' handling in titan 6.6.x compared to previous versions [message #1826223 is a reply to message #1826175] Tue, 21 April 2020 11:52 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Harald,


the bug report that triggered the change is this one:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=559422
and the connected commit:
https://github.com/eclipse/titan.core/commit/1629c2787a5dbd03805f2883bc98771fb5f3186b

The essence of the change is that on the right hand side of a template value assignment one only can have omit (or ifpresent which is handled in the same manner) if an optional field appears
on the left hand side.


In
ies[lengthof(ies)] := tr_CbspCellList ifpresent;


the left hand side is either a set of , or record of , or array , which cannot be assigned an omit as value.

Indeed, before 6.6.1 Titan was less restrictive, hence not fully aligned with the standard.
I apologize for any inconvenience this may have caused.

Best regards
Elemer

Re: more strict 'ifpresent' handling in titan 6.6.x compared to previous versions [message #1826228 is a reply to message #1826223] Tue, 21 April 2020 14:30 Go to previous messageGo to next message
Harald Welte is currently offline Harald WelteFriend
Messages: 140
Registered: July 2017
Location: Berlin, Germany
Senior Member

Thanks for the feedback.

So this means the new behavior is in-line with the language specification, and the previous behavior was a violation of the language spec?

I guess I have to find some time to understand how to express something functionally equivalent. It seems again like one of those situations where one would hope the power of TTCN3 can offer an easy solution, but in reality it's hard to find a way to solve it. But there obviously must be a way?

How do I construct a match/receive template for a set of / record of / array, were some elements can 'either be missing or present'?

Something like
ies[lengthof(ies)] := (omit, tr_CbspCellList);

also doesn't work, but renders:

> CBSP_Templates.ttcn:372.26-29: error: `omit' value is not allowed in this context


Regards,
Harald
Re: more strict 'ifpresent' handling in titan 6.6.x compared to previous versions [message #1826255 is a reply to message #1826228] Wed, 22 April 2020 08:50 Go to previous message
Gyorgy Rethy is currently offline Gyorgy RethyFriend
Messages: 31
Registered: April 2015
Member
Hi Harald,

I don't think the template list will work at a set element level, but at the set level, like this:
    if (istemplatekind(cell_list, "*")) {
        var template CBSP_IEs ies0 := ies;
	ies[lengthof(ies)] := tr_CbspCellList;
	ies := (ies0, ies);
}


However, it has a consequence that no further ie-s can be added later. Therefore, the check and addition of channel_ind should be moved before the checking of cell_list.
function tr_CBSP_WRITE_CBS_COMPL(template integer msg_id, template integer new_ser_nr,
				 template BSSMAP_FIELD_CellIdentificationList cell_list,
				 template integer channel_ind)
return template CBSP_PDU {
	var template CBSP_IEs ies := {
		tr_CbspMsgId(msg_id),
		tr_NewSerNo(new_ser_nr)
	};
//GyRethy: this check is moved forward, in front of the cell_list check
	if (not istemplatekind(channel_ind, "omit")) {
		ies[lengthof(ies)] := tr_CbspChannelInd(channel_ind);
	};

	if (istemplatekind(cell_list, "*")) {
               var template CBSP_IEs ies0 := ies;
		ies[lengthof(ies)] := tr_CbspCellList;
		ies := (ies0, ies);
	} else if (istemplatekind(cell_list, "?")) {
		ies[lengthof(ies)] := tr_CbspCellList(?);
	} else if (not istemplatekind(cell_list, "omit")) {
		ies[lengthof(ies)] := tr_CbspCellList(cell_list);
	}
	return tr_CBSP(CBSP_MSGT_WRITE_REPLACE_COMPL, ies);
}

[Updated on: Wed, 22 April 2020 09:01]

Report message to a moderator

Previous Topic:IPsec over UDP
Next Topic:Problem executing STF525 CAM Test
Goto Forum:
  


Current Time: Thu Apr 18 19:20:54 GMT 2024

Powered by FUDForum. Page generated in 0.01496 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top