Commit e3cc4e6d authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Merge branch 'STF531-REG-TCs' into Release1

parents 1ce83c0f 8beda19d
......@@ -1424,29 +1424,62 @@ module OneM2M_Functions {
} //end f_check_notificationContent
}// end of group NotificationFunctions
}// end of group NotificationFunctions
/**
* @desc Check that a resource is present in the IUT (resourceId is known)
* @param p_resourceIndex Resource index
* @return boolean
*/
function f_cse_isResourcePresent (integer p_resourceIndex) runs on CseSimu return boolean {
//Check to see if the resource is present or not
mccPort.send(m_request(m_retrieveResource(f_getResourceAddress(p_resourceIndex), f_getOriginator(p_resourceIndex))));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitive(int2000))) {
tc_ac.stop;
setverdict(pass, testcasename() & ": Resource present: " & f_getResourceAddress(p_resourceIndex));
return true;
}
[] mccPort.receive(mw_response(mw_responsePrimitive(?, -))) {
tc_ac.stop;
setverdict(inconc, testcasename() & ": Wrong response status code in the response");
return false;
}
[] tc_ac.timeout {
setverdict(inconc, testcasename() & ": No answer while retrieving resource");
return false;
}
}
return false;
}
/**
* @desc Registration of Test System (simulating a CSE) to the CSE IUT (creation of remoteCSE)
* @param p_requestPrimitive Template request primitive
* @return Internal resource index of the created resource
*/
function f_cse_registerRemoteCse(in template RequestPrimitive p_requestPrimitive) runs on CseSimu return integer {
function f_cse_registerRemoteCse(in template RequestPrimitive p_requestPrimitive, in template PrimitiveContent p_contentResponse := ?) runs on CseSimu return integer {
var MsgIn v_response;
var RequestPrimitive v_request;
var integer v_resourceIndex := -1;
var integer v_localResourceIndex := -1;
var PrimitiveContent v_remoteCSEResource;
v_request := f_getCreateRequestPrimitive(int16, p_requestPrimitive, -1);
mccPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
[] mccPort.receive(mw_response(mw_responsePrimitiveOK(p_contentResponse))) -> value v_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource type RemoteCSE created successfuly");
f_checkAttributesToBeSaved(int16, v_request, v_response.primitive.responsePrimitive);
v_resourceIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int16, -1);
v_remoteCSEResource := f_cse_generateLocalResource(v_response.primitive.responsePrimitive.primitiveContent, 1, int16);
v_localResourceIndex := f_setLocalResource(v_remoteCSEResource, int16, -1);
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
......@@ -1477,6 +1510,7 @@ module OneM2M_Functions {
var MsgIn v_request;
var ResponsePrimitive v_response;
var PrimitiveContent v_remoteCSEResource;
var integer v_localResourceIndex := -1;
var integer v_resourceIndex := -1;
tc_ac.start;
......@@ -1484,7 +1518,18 @@ module OneM2M_Functions {
[] mccPortIn.receive(mw_request(p_requestPrimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource type RemoteCSE created successfuly");
v_resourceIndex := f_cse_createLocalResource(v_request.primitive.requestPrimitive.primitiveContent, 1, int16, v_remoteCSEResource);//TODO Get index from v_request.primitive.requestPrimitive.to_
v_remoteCSEResource := f_cse_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, 1, int16);//TODO Get index from v_request.primitive.requestPrimitive.to_
v_localResourceIndex := f_setLocalResource(v_remoteCSEResource, int16, -1);
v_response := m_responsePrimitive(int2001,v_request.primitive.requestPrimitive.requestIdentifier);
v_response.from_ := PX_CSE1_ID;
v_response.to_ := v_request.primitive.requestPrimitive.from_;
v_response.primitiveContent.remoteCSE := vc_localResourcesList[v_localResourceIndex].resource.remoteCSE;
mccPort.send(m_response(v_response));
v_resourceIndex := f_setResource(v_request.primitive.responsePrimitive.primitiveContent, int16, -1);
}
[] mccPortIn.receive {
tc_ac.stop;
......@@ -1555,44 +1600,43 @@ module OneM2M_Functions {
* @param p_modifiedResource Assigned and/or modified fields
* @return Internal resource index of the saved resource or -1
*/
function f_cse_createLocalResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType, out PrimitiveContent p_myResource) runs on CseSimu return integer {
function f_cse_generateLocalResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType) runs on CseSimu return PrimitiveContent {
var integer v_resourceIndex := lengthof(vc_resourcesList);
var integer v_resourceIndex := lengthof(vc_localResourcesList);
var PrimitiveContent v_myResource;
// TODO To review the code (use of indexes, generation of value for certain attributes, etc..)
if(p_resourceType == int16 and ispresent(p_resource)) {
if(ischosen(p_resource.remoteCSE)){
p_myResource.remoteCSE := p_resource.remoteCSE;
v_myResource.remoteCSE := p_resource.remoteCSE;
if(not(ispresent(p_resource.remoteCSE.resourceName))) {
p_myResource.remoteCSE.resourceName := "remoteCSE" & int2char(v_resourceIndex);
v_myResource.remoteCSE.resourceName := "remoteCSE" & int2char(v_resourceIndex);
}
p_myResource.remoteCSE.resourceType := p_resourceType;
p_myResource.remoteCSE.resourceID := "remoteCSE" & int2char(v_resourceIndex);
p_myResource.remoteCSE.parentID := f_getResourceId(vc_resourcesList[p_parentIndex].resource);
p_myResource.remoteCSE.creationTime := fx_generateTimestamp();
v_myResource.remoteCSE.resourceType := p_resourceType;
v_myResource.remoteCSE.resourceID := "remoteCSE" & int2char(v_resourceIndex);
v_myResource.remoteCSE.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.remoteCSE.creationTime := fx_generateTimestamp();
if(not(ispresent(p_resource.remoteCSE.expirationTime))) {
p_myResource.remoteCSE.expirationTime := "20301231T012345";
v_myResource.remoteCSE.expirationTime := "20301231T012345";
}
p_myResource.remoteCSE.lastModifiedTime := p_myResource.remoteCSE. creationTime;
p_myResource.remoteCSE.announceTo := omit;
p_myResource.remoteCSE.announcedAttribute := omit;
v_myResource.remoteCSE.lastModifiedTime := v_myResource.remoteCSE. creationTime;
v_myResource.remoteCSE.announceTo := omit;
v_myResource.remoteCSE.announcedAttribute := omit;
if(not(ispresent(p_resource.remoteCSE.pointOfAccess))) {
//TODO Create a pollingChannel resource
p_myResource.remoteCSE.pointOfAccess := omit;
v_myResource.remoteCSE.pointOfAccess := omit;
}
if(vc_resourcesList[v_resourceIndex].resourceType == int5) {
p_myResource.remoteCSE.m2M_Ext_ID := omit;
p_myResource.remoteCSE.trigger_Recipient_ID:= omit;
if(vc_localResourcesList[v_resourceIndex].resourceType == int5) {
v_myResource.remoteCSE.m2M_Ext_ID := omit;
v_myResource.remoteCSE.trigger_Recipient_ID:= omit;
}
p_myResource.remoteCSE.nodeLink := omit;
return f_setResource(p_myResource, p_resourceType, p_parentIndex, false);
v_myResource.remoteCSE.nodeLink := omit;
}
}
return v_resourceIndex;
return v_myResource;
}//End of function
......@@ -2309,6 +2353,71 @@ module OneM2M_Functions {
}
}
/**
* @desc Resolution of the resource address field (to) for a given resource depending on addressing and hierarchical format
* @param p_targetResourceIndex Internal resource index of the given resource
* @return Resource address for the given resource
* @verdict
*/
function f_getLocalResourceAddress(integer p_targetResourceIndex := -1, AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on CseSimu return XSD.ID {
var XSD.ID v_resourceAddress;
if(p_primitiveScope == e_cseRelative) {
if(p_addressingMethod == e_nonHierarchical) {
if(p_targetResourceIndex == -1) {
return PX_CSE1_RESOURCE_ID;
} else {
return f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
}
} else {
if(p_targetResourceIndex == -1) {
return PX_CSE1_NAME;
} else {
v_resourceAddress := f_getResourceAddress(vc_localResourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
}
} else if (p_primitiveScope == e_spRelative) {
if(p_addressingMethod == e_nonHierarchical) {
if(p_targetResourceIndex == -1) {
return PX_CSE1_ID & "/" & PX_CSE1_RESOURCE_ID;
} else {
v_resourceAddress := PX_CSE_ID & "/" & f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else {
if(p_targetResourceIndex == -1) {
return PX_CSE1_ID & "/" & PX_CSE1_NAME;
} else {
v_resourceAddress := f_getResourceAddress(vc_localResourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
}
} else if (p_primitiveScope == e_absolute) {
if(p_addressingMethod == e_nonHierarchical) {
if(p_targetResourceIndex == -1) {
return PX_SP1_ID & PX_CSE1_ID;
} else {
v_resourceAddress := f_getResourceAddress(-, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else {
if(p_targetResourceIndex == -1) {
return PX_SP1_ID & PX_CSE1_ID & "/" & PX_CSE1_NAME;
} else {
v_resourceAddress := f_getResourceAddress(vc_localResourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
}
} else {
return "";
}
}
/**
* @desc Saving of a resource and its parent index in the internal resource list
* @param p_resource Resource to be saved
......@@ -2335,6 +2444,27 @@ module OneM2M_Functions {
}
/**
* @desc Saving of a local resource and its parent index in the internal resource list
* @param p_resource Resource to be saved
* @param p_parentIndex Parent index of resource to be saved
* @return Internal resource index of the saved resource
* @verdict
*/
function f_setLocalResource(PrimitiveContent p_resource, ResourceType p_resourceType, integer p_parentIndex := -1) runs on CseSimu return integer {
var integer v_newIndex := -1;
if(isbound(vc_localResourcesList)) {
vc_localResourcesList[lengthof(vc_localResourcesList)] := {p_parentIndex, p_resourceType, p_resource};
} else {
vc_localResourcesList[0] := {p_parentIndex, p_resourceType, p_resource};
}
v_newIndex := lengthof(vc_localResourcesList)-1;
return v_newIndex;
}
/**
* @desc Set Acpid into the requestPrimitive
* @param p_requestPrimitive RequestPrimitive to be modified
......
......@@ -18,7 +18,8 @@ module OneM2M_Pics {
* @see oneM2M TS-0017 A.5.5.1/1
*/
modulepar boolean PICS_ACP_SUPPORT := true;
modulepar boolean PICS_IN_CSE := true;
modulepar boolean PICS_IN_CSE := true;
modulepar boolean PICS_MN_CSE := true;
modulepar boolean PICS_UNSTRUCTURED_CSE_RELATIVE_RESOURCE_ID_FORMAT := true;
modulepar boolean PICS_STRUCTURED_CSE_RELATIVE_RESOURCE_ID_FORMAT := true;
......
......@@ -78,10 +78,26 @@ module OneM2M_Pixits {
modulepar charstring PX_CSE1_ADDRESS := "127.0.0.1:3141";
/**
* @desc Test System CSE1 Name
*/
modulepar XSD.ID PX_CSE1_NAME := "CSE1_NAME";
/**
* @desc Test System CSE1-ID with SP-relative-CSE-ID format (relative) according to TS-0001-7.2-1
*/
modulepar XSD.ID PX_CSE1_ID := "/MyCSEId";
modulepar XSD.ID PX_CSE1_ID := "/CSE1_ID";
/**
* @desc Test System CSE1 resource ID with Unstructured-CSE-relative-Resource-ID (relative) format according to TS-0001-7.2-1
*/
modulepar XSD.ID PX_CSE1_RESOURCE_ID := "CSE1_RESOURCE_ID";
/**
* @desc Test System M2M-SP1-ID with M2M-SP-ID format (absolute) according to TS-0001-7.2-1 Unstructured-CSE-relative -Resource-ID
*/
modulepar XSD.ID PX_SP1_ID := "//onem2m.org";
/**
* @desc Test System AE1-ID with AE-ID-Stem format (relative) according to TS-0001-7.2-1
......
......@@ -1051,10 +1051,10 @@ module OneM2M_Templates {
discoveryResultType := omit
};
template RequestPrimitive mw_deleteRequest(template XSD.ID p_resourceAddress := ?) := {
template RequestPrimitive mw_deleteRequest(template XSD.ID p_resourceAddress := ?, template XSD.ID p_from := *) := {
operation := int4,
to_ := p_resourceAddress,
from_ := ?,
from_ := p_from,
requestIdentifier := ?,
resourceType := *,
primitiveContent := *,
......@@ -1209,6 +1209,10 @@ module OneM2M_Templates {
cSEBase := p_cSEBase
}
template PrimitiveContent m_primitiveContentRemoteCSE(template RemoteCSE_optional p_remoteCSE) := {
remoteCSE := p_remoteCSE
}
template PrimitiveContent mw_primitiveContent := ?;
/**
......@@ -3715,6 +3719,11 @@ module OneM2M_Templates {
primitiveContent := {subscription := m_contentSubscription}
}
template (value) UtTriggerPrimitive m_utCreateRemoteCSE modifies m_utCreate := {
requestIdentifier := testcasename() & "-m_utCreateRemoteCSE" & f_rnd(1, 1000000),
resourceType := int16
}
template (value) UtTriggerPrimitive m_utRetrieveResource(XSD.ID p_targetResourceAddress, in XSD.ID p_originator) := {
operation := int2,
to_ := p_targetResourceAddress,
......
......@@ -62,6 +62,7 @@ module OneM2M_TestSystem {
port OneM2MPort mccPortIn;
//global variables
var MyResourcesList vc_localResourcesList;
var AeSimu vc_aeSimu;//For CF02 when CseSimu is master
var integer vc_remoteCseIndex;
var MsgIn vc_request;
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment