Made requesting instance's allocation count for resource available via the service...
[keystone-rtos/rm-lld.git] / test / src / rm_test.c
index a24954e46f1c14245e007b1d4cc031bf1e236dd4..afb25a865f7a5d0e6bb67f92215e0364545db255 100644 (file)
         System_printf ("\n");                                                                       \
     } while(0);    
 
-#define STATUS_PASS_CHECK(title, core, instName, resName, resStart, resLen, refCnt, state, check, expectRefCnt) \
+#define STATUS_PASS_CHECK(title, core, instName, resName, resStart, resLen, refCnt, allocCnt, state, check, expectRefCnt, expectAllocCnt) \
     do {                                                                                                        \
         int32_t start = resStart;                                                                               \
         char    titleMsg[] = title;                                                                             \
                        core, expectRefCnt);                                                                     \
         System_printf ("Core %d : - Returned Owner Count: %-16d                -\n",                            \
                        core, refCnt);                                                                           \
+        System_printf ("Core %d : - Expected Inst Allocation Count: %-16d      -\n",                            \
+                       core, expectAllocCnt);                                                                   \
+        System_printf ("Core %d : - Returned Inst Allocation Count: %-16d      -\n",                            \
+                       core, allocCnt);                                                                         \
         System_printf ("Core %d : -                                                       -\n", core);          \
-        if ((state == check) && (refCnt == expectRefCnt)) {                                                     \
+        if ((state == check) && (refCnt == expectRefCnt) && (allocCnt == expectAllocCnt)) {                     \
             System_printf ("Core %d : - PASSED                                                -\n", core);      \
         }                                                                                                       \
         else {                                                                                                  \
                 System_printf ("Core %d : - FAILED - Owner Count Mismatch                         -\n",         \
                                core);                                                                           \
             }                                                                                                   \
+            else if (allocCnt != expectAllocCnt) {                                                              \
+                System_printf ("Core %d : - FAILED - Instance Allocation Count Mismatch           -\n",         \
+                               core);                                                                           \
+            }                                                                                                   \
             else {                                                                                              \
                 System_printf ("Core %d : - FAILED - Denial: %-6d                               -\n",           \
                                core, state);                                                                    \
@@ -821,6 +829,16 @@ void rmServerTsk(UArg arg0, UArg arg1)
                         requestInfo.resourceBase, requestInfo.resourceLength, 
                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
     
+    /* Get the status of a resource from Server */
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
+                 6543, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
+    rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
+                      coreNum, rmServerName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount, responseInfo.serviceState,
+                      RM_SERVICE_APPROVED, 1, 2); 
+    
     /* Should take two frees to free both references */
     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
                  6543, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);      
@@ -830,13 +848,33 @@ void rmServerTsk(UArg arg0, UArg arg1)
                         requestInfo.resourceBase, requestInfo.resourceLength, 
                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
 
+    /* Get the status of a resource from Server */
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
+                 6543, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
+    rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
+                      coreNum, rmServerName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount, responseInfo.serviceState,
+                      RM_SERVICE_APPROVED, 1, 1); 
+
     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
                  6543, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
     POSITIVE_PASS_CHECK("------- Free of Resource from Same Inst (2nd Ref) -------", 
                         coreNum, rmServerName, resourceNameGpQ,
                         requestInfo.resourceBase, requestInfo.resourceLength, 
-                        requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
+                        requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
+
+    /* Get the status of a resource from Server */
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
+                 6543, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
+    rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
+                      coreNum, rmServerName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount, responseInfo.serviceState,
+                      RM_SERVICE_APPROVED, 0, 0);     
 
     /* Allocate infrastructure queue taken by Linux kernel and shared with Rm_Client.  Expect error or denial. */
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
@@ -853,7 +891,8 @@ void rmServerTsk(UArg arg0, UArg arg1)
     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
                       coreNum, rmServerName, responseInfo.resourceName,
                       responseInfo.resourceBase, responseInfo.resourceLength, 
-                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2); 
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount, responseInfo.serviceState,
+                      RM_SERVICE_APPROVED, 2, 1); 
 
     /* Get the status of a resource from Server */
     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameQosCluster, 
@@ -862,7 +901,8 @@ void rmServerTsk(UArg arg0, UArg arg1)
     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
                       coreNum, rmServerName, responseInfo.resourceName,
                       responseInfo.resourceBase, responseInfo.resourceLength, 
-                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount,
+                      responseInfo.serviceState, RM_SERVICE_APPROVED, 0, 0);
 
     /* BEGIN Testing CD local allocation feature from Server */
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
@@ -930,7 +970,8 @@ void rmClientTsk(UArg arg0, UArg arg1)
     STATUS_PASS_CHECK("---- Retrieve Resource Status Via NameServer Object -----", 
                       coreNum, rmClientName, responseInfo.resourceName,
                       responseInfo.resourceBase, responseInfo.resourceLength, 
-                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);  
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount,
+                      responseInfo.serviceState, RM_SERVICE_APPROVED, 1, 1);  
 
     /* Free resource via a NameServer name */
     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL, 
@@ -1066,7 +1107,8 @@ void rmClientTsk(UArg arg0, UArg arg1)
     STATUS_PASS_CHECK("-- Status Check of Resources from Client (Non-Blocking) -", 
                       coreNum, rmClientName, responseInfo.resourceName,
                       responseInfo.resourceBase, responseInfo.resourceLength, 
-                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);   
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount,
+                      responseInfo.serviceState, RM_SERVICE_APPROVED, 2, 1);   
     
     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
                  4025, 20, 0, NULL, RM_TEST_FALSE, &responseInfo);     
@@ -1074,7 +1116,8 @@ void rmClientTsk(UArg arg0, UArg arg1)
     STATUS_PASS_CHECK("---- Status Check of Resources from Client (Blocking) ---", 
                       coreNum, rmClientName, responseInfo.resourceName,
                       responseInfo.resourceBase, responseInfo.resourceLength, 
-                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);      
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount,
+                      responseInfo.serviceState, RM_SERVICE_APPROVED, 1, 0);      
 
     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ, 
                  800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
@@ -1083,7 +1126,8 @@ void rmClientTsk(UArg arg0, UArg arg1)
     STATUS_PASS_CHECK("---- Status Check of Resources from CD (Non-Blocking) ---", 
                       coreNum, rmCdName, responseInfo.resourceName,
                       responseInfo.resourceBase, responseInfo.resourceLength, 
-                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2); 
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount,
+                      responseInfo.serviceState, RM_SERVICE_APPROVED, 2, 0); 
 
     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ, 
                  805, 6, 0, NULL, RM_TEST_FALSE, &responseInfo);     
@@ -1091,7 +1135,8 @@ void rmClientTsk(UArg arg0, UArg arg1)
     STATUS_PASS_CHECK("------ Status Check of Resources from CD (Blocking) -----", 
                       coreNum, rmCdName, responseInfo.resourceName,
                       responseInfo.resourceBase, responseInfo.resourceLength, 
-                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);   
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount, 
+                      responseInfo.serviceState, RM_SERVICE_APPROVED, 1, 0);   
     /* END Getting the status of resources from Client and CD */    
 
     /* BEGIN Testing CD local allocation feature */
@@ -1177,7 +1222,8 @@ void rmClientTsk(UArg arg0, UArg arg1)
     STATUS_PASS_CHECK("----- Status Check of Resource Alloc'd Locally to CD ----", 
                       coreNum, rmCdName, responseInfo.resourceName,
                       responseInfo.resourceBase, responseInfo.resourceLength, 
-                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1); 
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount,
+                      responseInfo.serviceState, RM_SERVICE_APPROVED, 1, 0); 
 
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameLowPrioQ, 
                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_TRUE, &responseInfo);     
@@ -1194,7 +1240,8 @@ void rmClientTsk(UArg arg0, UArg arg1)
     STATUS_PASS_CHECK("- Status Check of Res Alloc'd Locally to CD After Share -", 
                       coreNum, rmClientName, responseInfo.resourceName,
                       responseInfo.resourceBase, responseInfo.resourceLength, 
-                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount,
+                      responseInfo.serviceState, RM_SERVICE_APPROVED, 2, 1);
 
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
                  900, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
@@ -1229,7 +1276,8 @@ void rmClientTsk(UArg arg0, UArg arg1)
     STATUS_PASS_CHECK("-- Status Check After Free of Locally Shared Resource ---", 
                       coreNum, rmClientName, responseInfo.resourceName,
                       responseInfo.resourceBase, responseInfo.resourceLength, 
-                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);   
+                      responseInfo.resourceNumOwners, responseInfo.instAllocCount,
+                      responseInfo.serviceState, RM_SERVICE_APPROVED, 0, 0);   
 
     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
                  965, 2, 0, NULL, RM_TEST_FALSE, &responseInfo);