Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
f_selfSync(p_syncId,p_ret);
}
/**
* @desc This function synchronizes a MTC with itself. In case
* of a non successful execution status it sends a STOP
* message to itself and invokes that way the
* shutdown default (if activated).
* This function will set the server verdict to INCONC (and
* stop the test case) if no shutdown default is activated.
* Otherwise no verdict is set.
* @remark Sync ports should be connected prior to the invocation
* of this function!
* @param p_syncId Synchronization point name/id
* @param p_ret Current behavior execution status
* @return Updated execution status
* @see LibCommon_Sync.f_connect4SelfSync
* @see LibCommon_Sync.a_dummyShutDown
*/
function f_selfSync( in charstring p_syncId ,
in FncRetCode p_ret )
runs on SelfSyncComp
return FncRetCode{
if (p_ret != e_success){
f_selfSyncStop() ; // function will not return!
}
if ( p_syncId == c_prDone ) {
log("**** f_selfSync: Successfully passed PREAMBLE synchronization point. ****") ;
} else if ( p_syncId == c_tbDone ) {
log("**** f_selfSync: Successfully passed TEST BODY synchronization point. ****") ;
} else {
log("**** f_selfSync: Successfully passed synchronization point. ****") ;
}
return e_success ;
}// end function f_selfSync
/**
* @desc This function can be used to shut down a test case _prior_
* to reaching a synchronization point. it sends a STOP
* message to itself and invokes that way the
* shutdown default (if activated).
* This function will set the server verdict to INCONC (and
* stop the test case) if no shutdown default is activated.
* Otherwise no verdict is set.
* @remark Sync ports should be connected prior to the invocation
* of this function!
* @see LibCommon_Sync.f_connect4SelfSync
*/
function f_selfSyncStop()
runs on SelfSyncComp {
log("**** f_selfSyncStop: MTC requests to stop test case (itself). ****") ;
syncSendPort.send(m_syncServerStop) ; // this MUST be _server_ for the default to catch!
tc_sync.start(PX_TSYNC_TIME_LIMIT);
alt{
[] tc_sync.timeout{
log("**** f_selfSyncStop: Stopping MTC without shutdown - either no shutdown default active or missing syncPort connection ****") ;
setverdict(inconc);
stop ;
}
}//end alt
tc_sync.stop;
stop; // if shutdown default is not activated or if it does not stop
} // end function f_selfSyncStop
} // end group otherSelfSyncRelatedDefinitions
/**
*
* @desc The sychronization protocol is conceptually based on
* named synchronization. Each synchronization point
* has it own specific synchronization message. This
* makes each synchronization unique, and allows, e.g., to
* ensure that a server synchronizes only clients which have
* reached the same synchronization point.
*/
group syncProtocolDefinition {
type union SyncCmd {
ClientReady clientReady,
ServerReady serverReady,
ClientStop clientStop,
ServerStop serverStop
}
type record ClientReady {
charstring syncPointId
}
type record ServerReady {
charstring syncPointId
}
type record ClientStop {}
type record ServerStop {}
} // end group syncProtocolDefinition
group syncMessages {
template SyncCmd m_syncClientReady( template charstring p_syncId ) := {
clientReady := { p_syncId }
}
template SyncCmd m_syncServerReady( template charstring p_syncId ) := {
serverReady := { p_syncId }
}
template SyncCmd m_syncClientStop := {
clientStop := {}
}
template SyncCmd m_syncServerStop := {
serverStop := {}
}
} // end group syncMessages
group otherSyncFunctions {
/**
* @desc Makes server send a sync message to all known clients
* @param p_clientRefs List of client references to which the message is to be send
* @param p_syncCmd The actual synchronization message to be sent out
*/
function f_serverSendToAllClients( in ClientSyncCompList p_clientRefs,
in template SyncCmd p_syncCmd)
runs on ServerSyncComp {
var integer i:=0;
for (i:=0; i< sizeof(p_clientRefs); i:=i+1 ){
syncPort.send(p_syncCmd) to p_clientRefs[i];
}
} // end function f_serverSendToAllClients
/**
* @desc This function is intended only for use on server in concurrent
* TTCN-3 test cases. It waits for all components to shut down
* within the PX_TSHUT_DOWN_TIME_LIMIT. If a timeout occurs
* it aborts the test case (no matter how far clients got with their
* shutdown).
* This function sets the server verdict.
*/
function f_serverWaitForAllClientsToShutDown()
runs on ServerSyncComp {
tc_shutDown.start(PX_TSHUT_DOWN_TIME_LIMIT);
alt {
[] all component.done {
tc_shutDown.stop;
log("**** f_serverWaitForAllClientsToShutDown: All components have properly shut down. Sync server will now terminate the test case. ****") ;
}
[] tc_shutDown.timeout {
log("**** f_serverWaitForAllClientsToShutDown: Not all clients have properly shutdown within the shut down time limit. Sync server will now terminate test case! ****") ;
}
} // end alt
// cover case that shut down default is NOT activated
setverdict(inconc);
mtc.stop;
} // end function f_serverWaitForAllClientsToShutDown
} // end group otherSyncFunctions
} // end group otherSyncDefinitions
} // end module LibCommon_Sync