Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Dynamic test case errors with template after replacing a BIT3 with enum
Dynamic test case errors with template after replacing a BIT3 with enum [message #1809656] Fri, 19 July 2019 10:57 Go to next message
Oliver Smith is currently offline Oliver SmithFriend
Messages: 2
Registered: July 2019
Junior Member
Hello Eclipse Titan community,

I'm fairly new to Titan and TTCN3, and came across a problem while working on the osmo-ttcn3-hacks repository. (This is my first post, so I can't post an external link.)

There was a template that looked like this:
template PDU_ML3_NW_MS tr_ML3_MT_MM_ID_Req(template BIT3 id_type := ?) := {
	discriminator := '0101'B,
	tiOrSkip := {
		skipIndicator := '0000'B
	},
	msgs := {
		mm := {
			identityRequest := {
				messageType := '011000'B,
				nsd := '00'B,
				identityType := id_type,
				spare1_5 := ?
			}
		}
	}
}


I have created a new type enumerated CmIdentityType:
type enumerated CmIdentityType {
	CM_ID_TYPE_IMSI			('001'B),
	CM_ID_TYPE_IMEI			('010'B),
	CM_ID_TYPE_IMEISV		('011'B),
	CM_ID_TYPE_TMSI			('100'B),
	CM_ID_TYPE_PTMSI_RAI_PTMSI_SIG	('101'B)
}


And used it in the template as id_type instead of BIT3:
template PDU_ML3_NW_MS tr_ML3_MT_MM_ID_Req(template CmIdentityType id_type := ?) := {
	discriminator := '0101'B,
	tiOrSkip := {
		skipIndicator := '0000'B
	},
	msgs := {
		mm := {
			identityRequest := {
				messageType := '011000'B,
				nsd := '00'B,
				identityType := int2bit(enum2int(valueof(id_type)), 3),
				spare1_5 := ?
			}
		}
	}
}


This compiles, and works as expected when supplying an enum key like this:
BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI)));


However, when omitting the id_type, it still compiled, but generates a runtime error (but it worked with the old template):
	/* wait for LU reject, ignore any ID REQ */
	alt {
	[] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { }
	[] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; }
	}

TC_lu_by_imei0(12)@gsmdevel: Dynamic test case error: Performing a valueof or send operation on a non-specific template of enumerated type @L3_Templates.CmIdentityType.

So this is the problem I am trying to solve, to get the above code snippet working with the new template, just like it used to work with the old one.

I have tried to modify the template further, by create a conversion function instead of using valueof. The idea was to let it handle the omitted value. But while it is also compiling, it throws another runtime error:
private function magic_convert_func(template (omit) CmIdentityType id_type) return template (omit) bitstring {
	if (istemplatekind(id_type, "omit")) {
		return omit;
	} else {
		return int2bit(enum2int(valueof(id_type)), 3);
	}
}

template PDU_ML3_NW_MS tr_ML3_MT_MM_ID_Req(template CmIdentityType id_type := ?) := {
	discriminator := '0101'B,
	tiOrSkip := {
		skipIndicator := '0000'B
	},
	msgs := {
		mm := {
			identityRequest := {
				messageType := '011000'B,
				nsd := '00'B,
				identityType := magic_convert_func(id_type),
				spare1_5 := ?
			}
		}
	}
}

TC_lu_by_imei0(12)@gsmdevel: Dynamic test case error: Restriction `omit' on template of type @L3_Templates.CmIdentityType violated.


It would be great if somebody could help me understand what is going wrong here.
Thanks for reading!
Re: Dynamic test case errors with template after replacing a BIT3 with enum [message #1809720 is a reply to message #1809656] Mon, 22 July 2019 07:06 Go to previous messageGo to next message
roland gecse is currently offline roland gecseFriend
Messages: 20
Registered: December 2015
Junior Member
Let me give you some pointers!

FYI, only integer expressions are allowed in the parentheses of enum items.

type enumerated CmIdentityType {
	CM_ID_TYPE_IMSI			('001'B),  // 0
	CM_ID_TYPE_IMEI			('010'B),  // 1
	CM_ID_TYPE_IMEISV		('011'B),  // 2
	CM_ID_TYPE_TMSI			('100'B),  // 3
	CM_ID_TYPE_PTMSI_RAI_PTMSI_SIG	('101'B)   // 4
}


(If the above code slips through the compiler then I suspect TITAN is ignoring those bitstring literals and uses the default enum item numbering scheme instead that is shown in the comments above. Even if this is not the case...)

CM_ID_TYPE_IMSI resolves to a specific value, hence:

BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI)));


works because CM_ID_TYPE_IMSI actual parameter value is a specific value, which overrides the default any value (?) in tr_ML3_MT_MM_ID_Req hence yielding a specific value template.

However, the template tr_ML3_MT_MM_ID_Req in

BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req))


uses the default any value as actual parameter of id_type and its run time evaluation fails because of the valueof therein:

identityType := int2bit(enum2int(valueof(id_type)), 3),


which resolves to valueof(?) that clearly makes no sense.

I believe your next attempt with magic_convert_func fails for the same reason; the actual parameter being passed is any value (?) instead of omit that you suspect.

You can help yourself to track such issues by putting some extra log() statements before the problematic line or enable TTCN_MATCHING in LogMask/ConsoleMask in the Logging section of your configuration file.

Also, feel free to study TTCN-3 Core Language section 6.2.4 for additional info!
Re: Dynamic test case errors with template after replacing a BIT3 with enum [message #1809727 is a reply to message #1809720] Mon, 22 July 2019 07:41 Go to previous messageGo to next message
Kristof Szabados is currently offline Kristof SzabadosFriend
Messages: 60
Registered: July 2015
Member
Hi,

Just a minor note: in newer versions of the standard it is allowed to give the enumeration's value with bitstrings/hexstrings/etc... that can be statically evaluated to an integer.
Titan does provide support for this feature.
Re: Dynamic test case errors with template after replacing a BIT3 with enum [message #1809741 is a reply to message #1809720] Mon, 22 July 2019 09:16 Go to previous messageGo to next message
Oliver Smith is currently offline Oliver SmithFriend
Messages: 2
Registered: July 2019
Junior Member
I've added log statements inside magic_convert_func, and it turned out that it did not get executed at all. Now I understand the runtime error message:
Dynamic test case error: Restriction `omit' on template of type @L3_Templates.CmIdentityType violated.


This comes from the (omit) in the following line, and it means that "?" cannot be passed as parameter to that function.
private function magic_convert_func(template (omit) CmIdentityType id_type)


In fact, I was a bit confused by "?" (AnyElement) and "omit", and looking at the spec helped clear it up. Now I have the following function, and it works as expected:
private function magic_convert_func(template CmIdentityType id_type) return template bitstring {
	if (istemplatekind(id_type, "?")) {
		return ?;
	} else {
		return int2bit(enum2int(valueof(id_type)), 3);
	}
}

template PDU_ML3_NW_MS tr_ML3_MT_MM_ID_Req(template CmIdentityType id_type := ?) := {
	discriminator := '0101'B,
	tiOrSkip := {
		skipIndicator := '0000'B
	},
	msgs := {
		mm := {
			identityRequest := {
				messageType := '011000'B,
				nsd := '00'B,
				identityType := magic_convert_func(id_type),
				spare1_5 := ?
			}
		}
	}
}


Thank you very much for the replies, Roland and Kristof!
Re: Dynamic test case errors with template after replacing a BIT3 with enum [message #1809770 is a reply to message #1809727] Tue, 23 July 2019 06:38 Go to previous message
Kristof Szabados is currently offline Kristof SzabadosFriend
Messages: 60
Registered: July 2015
Member
Hi,

Just a minor correction.
It is a Titan extension, that the enum values can be directly assigned with a bitstring/hexstring/etc...
According to the standard, these values have to be converted explicitly.
for example (from section 6.2.4):
typeenumerated MyEnum {
e_num (1),
e_expr (2+2), // same as e_expr (4)
e_bin_conv (bit2int('0111'B)), // same as e_bin_conv(7)
e_oct_conv (oct2int('34'O)), // same as e_oct_conv(52)
e_hex_conv (hex2int('AC'H)) // same as e_hex_conv(172)
}
Previous Topic:Q: TTCN3 and templates / lists of templates
Next Topic:Result after running Executable
Goto Forum:
  


Current Time: Fri Apr 19 09:38:42 GMT 2024

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

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

Back to the top