Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ITS - Intelligent Transport Systems
ITS
Commits
016a834b
Commit
016a834b
authored
Jul 05, 2017
by
garciay
Browse files
Layers ongoing
parent
ff4f594d
Changes
1
Hide whitespace changes
Inline
Side-by-side
ttcn/TestCodec/TestCodec_DENM.ttcn
0 → 100644
View file @
016a834b
module
TestCodec_DENM
{
// LibIts
import
from
ITS_Container
language
"ASN.1:1997"
all
;
import
from
DENM_PDU_Descriptions
language
"ASN.1:1997"
all
;
// LibItsCommon
import
from
LibItsCommon_Functions
all
;
import
from
LibItsCommon_ASN1_NamedNumbers
all
;
// LibItsDenm
import
from
LibItsDenm_TestSystem
all
;
import
from
LibItsDenm_Templates
all
;
// TestCodec
import
from
TestCodec_TestAndSystem
all
;
group
LibItsDenm_testCases
{
group
testDenmPrimitiveMessages
{
testcase
tc_DenmReq
()
runs
on
TCType
system
TCType
{
var
template
(
value
)
SituationContainer
v_situation
:=
m_situation
(
CauseCodeType_vehicleBreakdown_
,
VehicleBreakdownSubCauseCode_unavailable_
);
TestDenmReq
(
m_denmReq
(
m_denmPdu
(
m_denm
(
m_denmMgmtCon
(
m_tsActionId
),
v_situation
,
m_denmLocation_zeroDelta
)
)
),
true
,
oct2bit
(
'
01020001
B20788B80059F48D95CDEFC8C5E0020020002461A83C000004805A100C4528399D4C387FFF80
'
O
)
);
}
}
// End of group testDenmPrimitiveMessages
group
testDenmPort
{
/**
* @desc validate DenmReq
* @verdict Pass on success, Fail otherwise
*/
testcase
tc_Denm_Port
()
runs
on
ItsDenm
system
ItsDenmSystem
{
var
DenmReq
v_denmReq
;
var
template
(
value
)
SituationContainer
v_situation
:=
m_situation
(
CauseCodeType_vehicleBreakdown_
,
VehicleBreakdownSubCauseCode_unavailable_
);
map
(
self
:
denmPort
,
system
:
denmPort
);
v_denmReq
:=
valueof
(
m_denmReq
(
m_denmPdu
(
m_denm
(
m_denmMgmtCon
(
m_tsActionId
),
v_situation
,
m_denmLocation_zeroDelta
))
)
);
denmPort
.
send
(
v_denmReq
);
tc_ac
.
start
;
alt
{
[]
denmPort
.
receive
(
DenmInd
:
?
)
{
setverdict
(
pass
);
}
[]
tc_ac
.
timeout
{
setverdict
(
fail
,
"Expected message not received1"
);
}
}
unmap
(
self
:
denmPort
,
system
:
denmPort
);
}
}
// End of group testDenmPort
}
// End of group LibItsDenm_testCases
group
encdec_functions
{
function
TestDenmReq
(
in
template
(
value
)
DenmReq
p_denmReq
,
in
boolean
p_decode
:=
true
,
in
template
(
omit
)
bitstring
p_expEncMsg
:=
omit
)
runs
on
TCType
{
var
bitstring
v_encMsg
;
var
template
(
omit
)
TestRecord
v_tr
:=
{
bs
:=
p_expEncMsg
};
var
DenmReq
v_decMsg
;
var
integer
v_res
:=
0
;
// Encode template
log
(
"Encode template "
,
valueof
(
p_denmReq
));
v_encMsg
:=
encvalue
(
p_denmReq
);
log
(
"Encoded message: "
,
bit2oct
(
v_encMsg
));
// Check result
if
(
not
isbound
(
v_encMsg
))
{
setverdict
(
fail
,
"Encoding failed!"
);
stop
;
}
if
(
ispresent
(
v_tr
.
bs
))
{
if
(
not
match
(
v_encMsg
,
p_expEncMsg
))
{
log
(
"Expected message: "
,
bit2oct
(
valueof
(
p_expEncMsg
)));
setverdict
(
fail
,
"Encoding failed, not the expected result!"
);
stop
;
}
}
setverdict
(
pass
,
"Encoding passed."
);
// Check decoding
if
(
p_decode
==
true
)
{
v_res
:=
decvalue
(
v_encMsg
,
v_decMsg
);
log
(
"Decoded message: "
,
v_decMsg
);
select
(
v_res
)
{
case
(
0
)
{
if
(
match
(
v_decMsg
,
p_denmReq
))
{
setverdict
(
pass
);
}
else
{
setverdict
(
fail
);
}
}
case
(
1
)
{
setverdict
(
fail
,
"Decoding failed."
);
}
case
(
2
)
{
setverdict
(
fail
,
"Not enough bits."
);
}
}
}
}
// End of function TestDenmReq
}
// End of group encdec_functions
}
// End of module TestCodec_DENM
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment