1 /*
2 * rm_linux_client_test.c
3 *
4 * Multi-process Resource Manager test that uses sockets to allow a Linux
5 * User-space application to request RM services from a RM Server,
6 * Client Delegate, and Client.
7 *
8 * ============================================================================
9 *
10 * Copyright (c) 2012-2015, Texas Instruments Incorporated
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * * Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
32 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
35 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
37 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
38 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 */
42 /* Standard includes */
43 #include <stdio.h>
44 #include <errno.h>
45 #include <stdlib.h>
46 #include <string.h>
47 #include <sys/mman.h>
48 #include <sys/stat.h>
49 #include <fcntl.h>
51 /* Socket Includes */
52 #include "sockutils.h"
53 #include "sockrmmsg.h"
55 /* RM Includes */
56 #include <ti/drv/rm/rm.h>
57 #include <ti/drv/rm/rm_transport.h>
58 #include <ti/drv/rm/rm_services.h>
60 /**********************************************************************
61 ************************** RM Test Symbols ***************************
62 **********************************************************************/
64 #define error_msg printf
65 #define info_msg printf
67 /* Test FALSE */
68 #define RM_TEST_FALSE 0
69 /* Test TRUE */
70 #define RM_TEST_TRUE 1
72 /* Socket timeout */
73 #define CLIENT_SOCK_TIMEOUT_USEC (500)
75 /* Application's registered RM transport indices */
76 #define SERVER_TO_CLIENT_MAP_ENTRY 0
77 /* Maximum number of registered RM transports */
78 #define MAX_MAPPING_ENTRIES 1
80 /* Size of RM static allocation response queue. Must be greater than number of APPROVED
81 * static allocations */
82 #define MAX_STATIC_ALLOCATION_RESPS 5
84 /* Size of RM service response queue */
85 #define MAX_QUEUED_SERVICE_RESPONSES 10
87 /* Error checking macro */
88 #define ERROR_CHECK(checkVal, resultVal, rmInstName, printMsg) \
89 if (resultVal != checkVal) { \
90 char errorMsgToPrint[] = printMsg; \
91 printf("Error Core %d : %s : ", coreNum, rmInstName); \
92 printf("%s with error code : %d\n", errorMsgToPrint, resultVal); \
93 testErrors++; \
94 }
96 #define POSITIVE_PASS_CHECK(title, core, instName, resName, resStart, resLen, align, state, check) \
97 do { \
98 int32_t start = resStart; \
99 int32_t alignment = align; \
100 char titleMsg[] = title; \
101 printf ("Core %d : ---------------------------------------------------------\n", \
102 core); \
103 printf ("Core %d : %s\n", core, titleMsg); \
104 printf ("Core %d : - Instance Name: %-32s -\n", core, instName); \
105 printf ("Core %d : - Resource Name: %-32s -\n", core, resName); \
106 if (start == RM_RESOURCE_BASE_UNSPECIFIED) { \
107 printf ("Core %d : - Start: UNSPECIFIED -\n", \
108 core); \
109 printf ("Core %d : - Length: %-16d -\n", \
110 core, resLen); \
111 } \
112 else { \
113 printf ("Core %d : - Start: %-16d -\n", \
114 core, resStart); \
115 printf ("Core %d : - End: %-16d -\n", core, \
116 (start + resLen - 1)); \
117 } \
118 if (alignment == RM_RESOURCE_ALIGNMENT_UNSPECIFIED) { \
119 printf ("Core %d : - Alignment: UNSPECIFIED -\n", \
120 core); \
121 } \
122 else { \
123 printf ("Core %d : - Alignment: %-16d -\n", \
124 core, alignment); \
125 } \
126 printf ("Core %d : - -\n", \
127 core); \
128 if (state == check) { \
129 printf ("Core %d : - PASSED -\n", \
130 core); \
131 } \
132 else { \
133 printf ("Core %d : - FAILED - Denial: %-6d -\n", \
134 core, state); \
135 testErrors++; \
136 } \
137 printf ("Core %d : ---------------------------------------------------------\n", \
138 core); \
139 printf ("\n"); \
140 } while(0);
142 #define NEGATIVE_PASS_CHECK(title, core, instName, resName, resStart, resLen, align, state, check) \
143 do { \
144 int32_t start = resStart; \
145 int32_t alignment = align; \
146 char titleMsg[] = title; \
147 printf ("Core %d : ---------------------------------------------------------\n", \
148 core); \
149 printf ("Core %d : %s\n", core, titleMsg); \
150 printf ("Core %d : - Instance Name: %-32s -\n", core, instName); \
151 printf ("Core %d : - Resource Name: %-32s -\n", core, resName); \
152 if (start == RM_RESOURCE_BASE_UNSPECIFIED) { \
153 printf ("Core %d : - Start: UNSPECIFIED -\n", \
154 core); \
155 printf ("Core %d : - Length: %-16d -\n", \
156 core, resLen); \
157 } \
158 else { \
159 printf ("Core %d : - Start: %-16d -\n", \
160 core, resStart); \
161 printf ("Core %d : - End: %-16d -\n", core, \
162 (start + resLen - 1)); \
163 } \
164 if (alignment == RM_RESOURCE_ALIGNMENT_UNSPECIFIED) { \
165 printf ("Core %d : - Alignment: UNSPECIFIED -\n", \
166 core); \
167 } \
168 else { \
169 printf ("Core %d : - Alignment: %-16d -\n", \
170 core, alignment); \
171 } \
172 printf ("Core %d : - -\n", \
173 core); \
174 if (state != check) { \
175 printf ("Core %d : - PASSED - Denial: %-6d -\n", \
176 core, state); \
177 } \
178 else { \
179 printf ("Core %d : - FAILED - Expected Denial -\n", \
180 core); \
181 testErrors++; \
182 } \
183 printf ("Core %d : ---------------------------------------------------------\n", \
184 core); \
185 printf ("\n"); \
186 } while(0);
188 #define STATUS_PASS_CHECK(title, core, instName, resName, resStart, resLen, refCnt, state, check, expectRefCnt) \
189 do { \
190 int32_t start = resStart; \
191 char titleMsg[] = title; \
192 printf ("Core %d : ---------------------------------------------------------\n", \
193 core); \
194 printf ("Core %d : %s\n", core, titleMsg); \
195 printf ("Core %d : - Instance Name: %-32s -\n", core, instName); \
196 printf ("Core %d : - Resource Name: %-32s -\n", core, resName); \
197 printf ("Core %d : - Start: %-16d -\n", \
198 core, resStart); \
199 printf ("Core %d : - End: %-16d -\n", core, \
200 (start + resLen - 1)); \
201 printf ("Core %d : - Expected Owner Count: %-16d -\n", \
202 core, expectRefCnt); \
203 printf ("Core %d : - Returned Owner Count: %-16d -\n", \
204 core, refCnt); \
205 printf ("Core %d : - -\n", core); \
206 if ((state == check) && (refCnt == expectRefCnt)) { \
207 printf ("Core %d : - PASSED -\n", core); \
208 } \
209 else { \
210 if (refCnt != expectRefCnt) { \
211 printf ("Core %d : - FAILED - Owner Count Mismatch -\n", \
212 core); \
213 } \
214 else { \
215 printf ("Core %d : - FAILED - Denial: %-6d -\n", \
216 core, state); \
217 } \
218 testErrors++; \
219 } \
220 printf ("Core %d : ---------------------------------------------------------\n", \
221 core); \
222 printf ("\n"); \
223 } while(0);
225 /**********************************************************************
226 ********************** RM Test Data Structures ***********************
227 **********************************************************************/
229 /* RM registered transport mapping structure */
230 typedef struct trans_map_entry_s {
231 /* Registered RM transport handle */
232 Rm_TransportHandle transportHandle;
233 /* Remote socket tied to the transport handle */
234 sock_name_t *remote_sock;
235 } Transport_MapEntry;
237 /**********************************************************************
238 ********************** Extern Variables ******************************
239 **********************************************************************/
241 /* Alloc and free OSAL variables */
242 extern uint32_t rmMallocCounter;
243 extern uint32_t rmFreeCounter;
245 /**********************************************************************
246 ********************** Global Variables ******************************
247 **********************************************************************/
249 /* Core number */
250 uint16_t coreNum;
251 /* Number of errors that occurred during the test */
252 uint16_t testErrors;
254 /* Client instance name (must match with RM Global Resource List (GRL) and policies */
255 char rmClientName[RM_NAME_MAX_CHARS] = "RM_Client";
257 /* Client socket name */
258 char rmClientSockName[] = "/var/run/rm/rm_client";
260 /* Client socket handle */
261 sock_h rmClientSocket;
263 /* Client instance handles */
264 Rm_Handle rmClientHandle = NULL;
266 /* Client instance service handles */
267 Rm_ServiceHandle *rmClientServiceHandle = NULL;
269 /* Transport map stores the RM transport handle to IPC MessageQ queue mapping */
270 Transport_MapEntry rmTransportMap[MAX_MAPPING_ENTRIES];
272 /* Static allocation response queue */
273 Rm_ServiceRespInfo staticResponseQueue[MAX_STATIC_ALLOCATION_RESPS];
274 /* Static allocation response queue index */
275 uint32_t numStaticResponses;
277 /* RM response info queue used to store service responses received via the callback function */
278 Rm_ServiceRespInfo responseInfoQueue[MAX_QUEUED_SERVICE_RESPONSES];
280 /* RM resource names (must match resource node names in GRL and policies */
281 char resourceNameMemRegion[RM_NAME_MAX_CHARS] = "memory-regions";
282 char resourceNameAccumCh[RM_NAME_MAX_CHARS] = "accumulator-ch";
283 char resourceNameGpQ[RM_NAME_MAX_CHARS] = "gp-queue";
284 char resourceNameAifQ[RM_NAME_MAX_CHARS] = "aif-queue";
285 char resourceNameQosCluster[RM_NAME_MAX_CHARS] = "qos-cluster";
286 char resourceNameAifRxCh[RM_NAME_MAX_CHARS] = "aif-rx-ch";
287 char resourceNameInfraQ[RM_NAME_MAX_CHARS] = "infra-queue";
289 /* Test RM NameServer name */
290 char nameServerNameFavQ[RM_NAME_MAX_CHARS] = "My_Favorite_Queue";
292 /**********************************************************************
293 *************************** Test Functions ***************************
294 **********************************************************************/
296 Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle)
297 {
298 Rm_Packet *rm_pkt = NULL;
300 rm_pkt = calloc(1, sizeof(*rm_pkt));
301 if (!rm_pkt) {
302 error_msg("can't malloc for RM send message (err: %s)\n",
303 strerror(errno));
304 return (NULL);
305 }
306 rm_pkt->pktLenBytes = pktSize;
307 *pktHandle = rm_pkt;
309 return(rm_pkt);
310 }
312 void transportFree (Rm_Packet *rm_pkt)
313 {
314 uint32_t pkt_size;
315 int32_t status;
317 if (rm_pkt) {
318 pkt_size = rm_pkt->pktLenBytes;
319 free (rm_pkt);
320 }
321 }
323 int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
324 {
325 sock_name_t *server_sock_name = (sock_name_t *)appTransport;
326 Rm_Packet *rm_pkt = (Rm_Packet *)pktHandle;
328 if (sock_send(rmClientSocket, (char *)rm_pkt, (int) rm_pkt->pktLenBytes, server_sock_name)) {
329 error_msg("send data failed\n");
330 }
332 return (0);
333 }
335 void transportReceive (void)
336 {
337 int32_t rm_result;
338 int retval;
339 int length = 0;
340 sock_name_t serv_sock_name;
341 sock_name_t server_sock_addr;
342 Rm_Packet *rm_pkt = NULL;
343 struct timeval tv = {0, CLIENT_SOCK_TIMEOUT_USEC};
344 struct sockaddr_un server_addr;
346 retval = sock_wait(rmClientSocket, &length, &tv, -1);
347 if (retval == -2) {
348 /* Timeout */
349 return;
350 }
351 else if (retval < 0) {
352 error_msg("Error in reading from socket, error %d\n", retval);
353 return;
354 }
356 if (length < sizeof(*rm_pkt)) {
357 error_msg("invalid RM message length %d\n", length);
358 return;
359 }
360 rm_pkt = calloc(1, length);
361 if (!rm_pkt) {
362 error_msg("can't malloc for recv'd RM message (err: %s)\n",
363 strerror(errno));
364 return;
365 }
367 server_sock_addr.type = sock_addr_e;
368 server_sock_addr.s.addr = &server_addr;
369 retval = sock_recv(rmClientSocket, (char *)rm_pkt, length, &server_sock_addr);
370 if (retval != length) {
371 error_msg("recv RM pkt failed from socket, received = %d, expected = %d\n",
372 retval, length);
373 return;
374 }
376 info_msg("received RM pkt of size %d bytes from %s\n", length, server_sock_addr.s.addr->sun_path);
378 /* Provide packet to RM Server for processing */
379 if (rm_result = Rm_receivePacket(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle, rm_pkt)) {
380 printf("RM failed to process received packet: %d\n", rm_result);
381 }
383 transportFree(rm_pkt);
384 }
387 void serviceCallback(Rm_ServiceRespInfo *serviceResponse)
388 {
389 uint32_t qIndex = 0;
391 /* Populate next free entry in the responseInfoQueue */
392 while (responseInfoQueue[qIndex].serviceId != 0) {
393 qIndex++;
394 if (qIndex == MAX_QUEUED_SERVICE_RESPONSES) {
395 qIndex = 0;
396 }
397 }
399 /* Save the response in the response queue for the test task to pick up */
400 memcpy((void *)&responseInfoQueue[qIndex], (void *)serviceResponse, sizeof(Rm_ServiceRespInfo));
401 }
403 void waitForResponse(Rm_ServiceRespInfo *respInfo)
404 {
405 uint32_t qIndex = 0;
407 if ((respInfo->serviceState == RM_SERVICE_PROCESSING) ||
408 (respInfo->serviceState == RM_SERVICE_PENDING_SERVER_RESPONSE)) {
409 /* Scan responseInfoQueue for the response received via the callback function */
410 while((responseInfoQueue[qIndex].serviceId != respInfo->serviceId) ||
411 (responseInfoQueue[qIndex].rmHandle != respInfo->rmHandle)) {
412 /* Check socket for response packets */
413 transportReceive();
415 qIndex++;
416 if (qIndex == MAX_QUEUED_SERVICE_RESPONSES) {
417 qIndex = 0;
418 }
419 }
421 memcpy((void *)respInfo, (void *)&responseInfoQueue[qIndex], sizeof(Rm_ServiceRespInfo));
422 memset((void *)&responseInfoQueue[qIndex], 0, sizeof(Rm_ServiceRespInfo));
423 }
424 }
426 void setRmRequest(Rm_ServiceReqInfo *reqInfo, Rm_ServiceType type, const char *resName, int32_t resBase,
427 uint32_t resLen, int32_t resAlign, const char *nsName, int setCallback, Rm_ServiceRespInfo *respInfo)
428 {
429 memset((void *)reqInfo, 0, sizeof(Rm_ServiceReqInfo));
430 reqInfo->type = type;
431 reqInfo->resourceName = resName;
432 reqInfo->resourceBase = resBase;
433 reqInfo->resourceLength = resLen;
434 reqInfo->resourceAlignment = resAlign;
435 reqInfo->resourceNsName = nsName;
436 if (setCallback) {
437 reqInfo->callback.serviceCallback = serviceCallback;
438 }
439 memset((void *)respInfo, 0, sizeof(Rm_ServiceRespInfo));
440 }
442 void cleanup(void)
443 {
444 Rm_ServiceReqInfo requestInfo;
445 Rm_ServiceRespInfo responseInfo;
446 int32_t result;
447 int32_t finalMallocFree;
449 /* Free all allocated resources */
450 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAccumCh,
451 0, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);
452 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
453 waitForResponse(&responseInfo);
454 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
455 coreNum, rmClientName, responseInfo.resourceName,
456 responseInfo.resourceBase, responseInfo.resourceLength,
457 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
458 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAccumCh,
459 40, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);
460 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
461 waitForResponse(&responseInfo);
462 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
463 coreNum, rmClientName, responseInfo.resourceName,
464 responseInfo.resourceBase, responseInfo.resourceLength,
465 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
467 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameQosCluster,
468 0, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
469 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
470 waitForResponse(&responseInfo);
471 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
472 coreNum, rmClientName, responseInfo.resourceName,
473 responseInfo.resourceBase, responseInfo.resourceLength,
474 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
475 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameQosCluster,
476 2, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
477 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
478 waitForResponse(&responseInfo);
479 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
480 coreNum, rmClientName, responseInfo.resourceName,
481 responseInfo.resourceBase, responseInfo.resourceLength,
482 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
484 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifQ,
485 525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
486 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
487 waitForResponse(&responseInfo);
488 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
489 coreNum, rmClientName, responseInfo.resourceName,
490 responseInfo.resourceBase, responseInfo.resourceLength,
491 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
493 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifQ,
494 525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
495 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
496 waitForResponse(&responseInfo);
497 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
498 coreNum, rmClientName, responseInfo.resourceName,
499 responseInfo.resourceBase, responseInfo.resourceLength,
500 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
502 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameInfraQ,
503 800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
504 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
505 waitForResponse(&responseInfo);
506 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
507 coreNum, rmClientName, responseInfo.resourceName,
508 responseInfo.resourceBase, responseInfo.resourceLength,
509 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
511 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ,
512 7000, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
513 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
514 waitForResponse(&responseInfo);
515 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
516 coreNum, rmClientName, responseInfo.resourceName,
517 responseInfo.resourceBase, responseInfo.resourceLength,
518 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
520 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ,
521 7011, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
522 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
523 waitForResponse(&responseInfo);
524 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
525 coreNum, rmClientName, responseInfo.resourceName,
526 responseInfo.resourceBase, responseInfo.resourceLength,
527 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
529 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ,
530 7010, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);
531 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
532 waitForResponse(&responseInfo);
533 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
534 coreNum, rmClientName, responseInfo.resourceName,
535 responseInfo.resourceBase, responseInfo.resourceLength,
536 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
538 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ,
539 7005, 25, 0, NULL, RM_TEST_TRUE, &responseInfo);
540 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
541 waitForResponse(&responseInfo);
542 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
543 coreNum, rmClientName, responseInfo.resourceName,
544 responseInfo.resourceBase, responseInfo.resourceLength,
545 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
547 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh,
548 0, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);
549 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
550 waitForResponse(&responseInfo);
551 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
552 coreNum, rmClientName, responseInfo.resourceName,
553 responseInfo.resourceBase, responseInfo.resourceLength,
554 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
555 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh,
556 50, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);
557 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
558 waitForResponse(&responseInfo);
559 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
560 coreNum, rmClientName, responseInfo.resourceName,
561 responseInfo.resourceBase, responseInfo.resourceLength,
562 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
564 /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
565 result = Rm_serviceCloseHandle(rmClientServiceHandle);
566 ERROR_CHECK(RM_OK, result, rmClientName, "Service handle close failed");
568 result = Rm_transportUnregister(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle);
569 ERROR_CHECK(RM_OK, result, rmClientName, "Unregister of Server transport failed");
571 sock_close(rmClientSocket);
573 result = Rm_delete(rmClientHandle, RM_TEST_TRUE);
574 ERROR_CHECK(RM_OK, result, rmClientName, "Instance delete failed");
576 printf ("Core %d : ---------------------------------------------------------\n", coreNum);
577 printf ("Core %d : ------------------ Memory Leak Check --------------------\n", coreNum);
578 printf ("Core %d : - : malloc count | free count -\n", coreNum);
579 printf ("Core %d : - Example Completion : %6d | %6d -\n", coreNum,
580 rmMallocCounter, rmFreeCounter);
581 finalMallocFree = rmMallocCounter - rmFreeCounter;
582 if (finalMallocFree > 0) {
583 printf ("Core %d : - FAILED - %6d unfreed mallocs -\n",
584 coreNum, finalMallocFree);
585 testErrors++;
586 }
587 else if (finalMallocFree < 0) {
588 printf ("Core %d : - FAILED - %6d more frees than mallocs -\n",
589 coreNum, -finalMallocFree);
590 testErrors++;
591 }
592 else {
593 printf ("Core %d : - PASSED -\n",
594 coreNum);
595 }
596 printf ("Core %d : ---------------------------------------------------------\n", coreNum);
597 printf ("\n");
599 printf ("Core %d : ---------------------------------------------------------\n", coreNum);
600 printf ("Core %d : ------------------ Example Completion -------------------\n", coreNum);
601 if (testErrors) {
602 printf ("Core %d : - Test Errors: %-32d -\n", coreNum, testErrors);
603 }
604 printf ("Core %d : ---------------------------------------------------------\n", coreNum);
605 printf ("\n");
606 }
608 void client_test(void)
609 {
610 Rm_ServiceReqInfo requestInfo;
611 Rm_ServiceRespInfo responseInfo;
612 uint32_t i, j;
614 /* Create new NameServer object */
615 setRmRequest(&requestInfo, Rm_service_RESOURCE_MAP_TO_NAME, resourceNameGpQ,
616 1002, 1, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
617 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
618 waitForResponse(&responseInfo);
619 POSITIVE_PASS_CHECK("--------------- Create NameServer Object ----------------",
620 coreNum, rmClientName, resourceNameGpQ,
621 requestInfo.resourceBase, responseInfo.resourceLength,
622 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
624 /* Retrieve a resource via a NameServer name */
625 setRmRequest(&requestInfo, Rm_service_RESOURCE_GET_BY_NAME, NULL,
626 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
627 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
628 waitForResponse(&responseInfo);
629 POSITIVE_PASS_CHECK("------- Retrieve Resource Via NameServer Object ---------",
630 coreNum, rmClientName, responseInfo.resourceName,
631 responseInfo.resourceBase, responseInfo.resourceLength,
632 0, responseInfo.serviceState, RM_SERVICE_APPROVED);
634 /* Allocate the resource returned from the NameServer request */
635 memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
636 requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
637 requestInfo.resourceName = responseInfo.resourceName;
638 requestInfo.resourceBase = responseInfo.resourceBase;
639 requestInfo.resourceLength = responseInfo.resourceLength;
640 requestInfo.resourceNsName = NULL;
641 requestInfo.callback.serviceCallback = serviceCallback;
642 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
643 waitForResponse(&responseInfo);
644 POSITIVE_PASS_CHECK("-------- Init Allocate Using Retrieved Resource ---------",
645 coreNum, rmClientName, responseInfo.resourceName,
646 requestInfo.resourceBase, requestInfo.resourceLength,
647 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
649 /* Retrieve the resource status via the NameServer name */
650 setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, NULL,
651 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
652 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
653 waitForResponse(&responseInfo);
654 STATUS_PASS_CHECK("---- Retrieve Resource Status Via NameServer Object -----",
655 coreNum, rmClientName, responseInfo.resourceName,
656 responseInfo.resourceBase, responseInfo.resourceLength,
657 responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);
659 /* Free resource via a NameServer name */
660 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL,
661 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
662 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
663 waitForResponse(&responseInfo);
664 POSITIVE_PASS_CHECK("--- Free of Retrieved Resource Using NameServer Name ----",
665 coreNum, rmClientName, nameServerNameFavQ,
666 0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);
668 /* Delete the NameServer name */
669 setRmRequest(&requestInfo, Rm_service_RESOURCE_UNMAP_NAME, NULL,
670 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
671 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
672 waitForResponse(&responseInfo);
673 POSITIVE_PASS_CHECK("--------------- Delete NameServer Object ----------------",
674 coreNum, rmClientName, nameServerNameFavQ,
675 0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);
677 /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
678 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh,
679 0, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);
680 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
681 waitForResponse(&responseInfo);
682 POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --",
683 coreNum, rmClientName, resourceNameAifRxCh,
684 requestInfo.resourceBase, requestInfo.resourceLength,
685 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
687 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifRxCh,
688 50, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);
689 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
690 waitForResponse(&responseInfo);
691 POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Init Allocate) -",
692 coreNum, rmClientName, resourceNameAifRxCh,
693 requestInfo.resourceBase, requestInfo.resourceLength,
694 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
695 /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */
697 /* BEGIN testing allocations with UNSPECIFIED base and alignment values */
698 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh,
699 RM_RESOURCE_BASE_UNSPECIFIED, 5, 4, NULL, RM_TEST_TRUE, &responseInfo);
700 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
701 waitForResponse(&responseInfo);
702 POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------",
703 coreNum, rmClientName, resourceNameAccumCh,
704 RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength,
705 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
707 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh,
708 RM_RESOURCE_BASE_UNSPECIFIED, 2, 1, NULL, RM_TEST_TRUE, &responseInfo);
709 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
710 waitForResponse(&responseInfo);
711 POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------",
712 coreNum, rmClientName, resourceNameAccumCh,
713 RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength,
714 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
716 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh,
717 RM_RESOURCE_BASE_UNSPECIFIED, 2, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);
718 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
719 waitForResponse(&responseInfo);
720 POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----",
721 coreNum, rmClientName, resourceNameAccumCh,
722 RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength,
723 RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);
724 /* END testing allocations with UNSPECIFIED base and alignment values */
726 /* Allocate infrastructure queue shared between Linux kernel and Client */
727 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ,
728 800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
729 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
730 waitForResponse(&responseInfo);
731 POSITIVE_PASS_CHECK("-- Init Allocation of Shared Linux and Client Resource --",
732 coreNum, rmClientName, resourceNameInfraQ,
733 requestInfo.resourceBase, requestInfo.resourceLength,
734 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
736 /* BEGIN Allocating some resources without providing a callback function. RM should block and not return until the result
737 * is returned by the server. */
738 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
739 7000, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
740 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
741 waitForResponse(&responseInfo);
742 POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --",
743 coreNum, rmClientName, resourceNameGpQ,
744 requestInfo.resourceBase, requestInfo.resourceLength,
745 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
747 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
748 7005, 25, 0, NULL, RM_TEST_TRUE, &responseInfo);
749 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
750 waitForResponse(&responseInfo);
751 POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --",
752 coreNum, rmClientName, resourceNameGpQ,
753 requestInfo.resourceBase, requestInfo.resourceLength,
754 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
756 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
757 7010, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);
758 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
759 waitForResponse(&responseInfo);
760 POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --",
761 coreNum, rmClientName, resourceNameGpQ,
762 requestInfo.resourceBase, requestInfo.resourceLength,
763 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
765 /* Init allocation of resource already owned by Client should return approved and there should only
766 * be one instance of Client in resource's owner list. */
767 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
768 7011, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
769 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
770 waitForResponse(&responseInfo);
771 POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----",
772 coreNum, rmClientName, resourceNameGpQ,
773 requestInfo.resourceBase, requestInfo.resourceLength,
774 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
775 /* END Allocating some resources without providing a callback function. RM should block and not return
776 * until the result is returned by the Server. */
778 /* BEGIN Getting the status of resources from Client and CD */
779 setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ,
780 7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);
781 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
782 waitForResponse(&responseInfo);
783 STATUS_PASS_CHECK("-- Status Check of Resources from Client (Non-Blocking) -",
784 coreNum, rmClientName, responseInfo.resourceName,
785 responseInfo.resourceBase, responseInfo.resourceLength,
786 responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);
788 setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ,
789 4025, 20, 0, NULL, RM_TEST_TRUE, &responseInfo);
790 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
791 waitForResponse(&responseInfo);
792 STATUS_PASS_CHECK("---- Status Check of Resources from Client (Blocking) ---",
793 coreNum, rmClientName, responseInfo.resourceName,
794 responseInfo.resourceBase, responseInfo.resourceLength,
795 responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);
796 /* END Getting the status of resources from Client and CD */
798 /* Verify static allocations were validated. Validation responses should have been received after the
799 * first service requests were made on the Client and CD post transport path registration. */
800 while (numStaticResponses > 0) {
801 /* Loop until all static request validations have been received */
802 for (i = 0; i < MAX_STATIC_ALLOCATION_RESPS; i++) {
803 if (staticResponseQueue[i].serviceId != 0) {
804 for (j = 0; j < MAX_QUEUED_SERVICE_RESPONSES; j++) {
805 if ((staticResponseQueue[i].serviceId == responseInfoQueue[j].serviceId) &&
806 (staticResponseQueue[i].rmHandle == responseInfoQueue[j].rmHandle)) {
807 POSITIVE_PASS_CHECK("------------- Static Allocation Validation --------------",
808 coreNum, rmClientName, responseInfoQueue[j].resourceName,
809 responseInfoQueue[j].resourceBase, responseInfoQueue[j].resourceLength,
810 0, responseInfoQueue[j].serviceState,
811 RM_SERVICE_APPROVED);
812 memset((void *)&staticResponseQueue[i], 0, sizeof(Rm_ServiceRespInfo));
813 memset((void *)&responseInfoQueue[j], 0, sizeof(Rm_ServiceRespInfo));
814 numStaticResponses--;
815 break;
816 }
817 }
818 }
819 }
820 }
821 }
823 void connection_setup(void)
824 {
825 Rm_TransportCfg rmTransCfg;
826 int32_t rm_result;
827 int i;
828 sock_name_t sock_name;
829 int32_t result = 0;
830 char server_sock_name[] = RM_SERVER_SOCKET_NAME;
832 /* Initialize the transport map */
833 for (i = 0; i < MAX_MAPPING_ENTRIES; i++) {
834 rmTransportMap[i].transportHandle = NULL;
835 }
837 sock_name.type = sock_name_e;
838 sock_name.s.name = rmClientSockName;
840 rmClientSocket = sock_open(&sock_name);
841 if (!rmClientSocket) {
842 error_msg("Client socket open failed\n");
843 exit(EXIT_FAILURE);
844 }
846 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock = calloc(1, sizeof(sock_name_t));
847 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock->type = sock_name_e;
848 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock->s.name = calloc(1, strlen(server_sock_name)+1);
849 strncpy(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock->s.name, server_sock_name, strlen(server_sock_name)+1);
851 /* Register the Server with the Client instance */
852 rmTransCfg.rmHandle = rmClientHandle;
853 rmTransCfg.appTransportHandle = (Rm_AppTransportHandle) rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock;
854 rmTransCfg.remoteInstType = Rm_instType_SERVER;
855 rmTransCfg.transportCallouts.rmAllocPkt = transportAlloc;
856 rmTransCfg.transportCallouts.rmSendPkt = transportSend;
857 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle = Rm_transportRegister(&rmTransCfg, &rm_result);
858 }
860 int main(int argc, char *argv[])
861 {
862 int fd;
863 struct stat file_stat;
864 char *static_policy_addr = NULL;
865 Rm_InitCfg rmInitCfg;
866 int status;
867 Rm_ServiceReqInfo requestInfo;
868 Rm_ServiceRespInfo responseInfo;
869 int32_t result;
871 printf ("*********************************************************\n");
872 printf ("*************** RM Linux Client Testing *****************\n");
873 printf ("*********************************************************\n");
875 printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
877 coreNum = 0;
878 testErrors = 0;
880 if (argc > 2)
881 {
882 error_msg("Invalid number of input arguments\n");
883 exit(EXIT_FAILURE);
884 }
886 if (argc == 2){
887 /* mmap static policy */
888 fd = open(argv[1], O_RDONLY);
889 if (fd == -1) {
890 error_msg("Error opening static policy\n");
891 exit(EXIT_FAILURE);
892 }
893 /* Obtain file size */
894 if (fstat(fd, &file_stat) == -1) {
895 error_msg("Error getting static policy size\n");
896 exit(EXIT_FAILURE);
897 }
898 static_policy_addr = mmap(NULL, file_stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
899 if (static_policy_addr == MAP_FAILED) {
900 error_msg("mmap of static failed\n");
901 exit(EXIT_FAILURE);
902 }
903 }
905 /* Initialize the RM Client - RM must be initialized before anything else in the system */
906 memset(&rmInitCfg, 0, sizeof(rmInitCfg));
907 rmInitCfg.instName = rmClientName;
908 rmInitCfg.instType = Rm_instType_CLIENT;
909 if (static_policy_addr) {
910 rmInitCfg.instCfg.clientCfg.staticPolicy = (void *)static_policy_addr;
911 }
912 rmClientHandle = Rm_init(&rmInitCfg, &result);
913 ERROR_CHECK(RM_OK, result, rmClientName, "Initialization failed");
915 printf("\n\nInitialized %s\n\n", rmClientName);
917 /* Open Client service handle */
918 rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);
919 ERROR_CHECK(RM_OK, result, rmClientName, "Service handle open failed");
921 /* Initialize the static allocation response queue */
922 for (numStaticResponses = 0; numStaticResponses < MAX_STATIC_ALLOCATION_RESPS; numStaticResponses++) {
923 memset((void *)&staticResponseQueue[numStaticResponses], 0, sizeof(Rm_ServiceRespInfo));
924 }
925 numStaticResponses = 0;
927 /* Static allocation tests */
928 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster,
929 0, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
930 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
931 POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------",
932 coreNum, rmClientName, resourceNameQosCluster,
933 requestInfo.resourceBase, requestInfo.resourceLength,
934 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);
935 if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
936 memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
937 }
939 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster,
940 2, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
941 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
942 POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------",
943 coreNum, rmClientName, resourceNameQosCluster,
944 requestInfo.resourceBase, requestInfo.resourceLength,
945 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);
946 if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
947 memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
948 }
950 /* Request resource from Client that can only be allocated to CD according to static policy */
951 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster,
952 1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
953 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
954 NEGATIVE_PASS_CHECK("---------------- Static Init Allocation -----------------",
955 coreNum, rmClientName, resourceNameQosCluster,
956 requestInfo.resourceBase, requestInfo.resourceLength,
957 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);
959 /* Request resource from both Client and CD that is shared according to static policy */
960 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifQ,
961 525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
962 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
963 POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------",
964 coreNum, rmClientName, resourceNameAifQ,
965 requestInfo.resourceBase, requestInfo.resourceLength,
966 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);
967 if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
968 memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
969 }
971 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifQ,
972 525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
973 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
974 POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------",
975 coreNum, rmClientName, resourceNameAifQ,
976 requestInfo.resourceBase, requestInfo.resourceLength,
977 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);
978 if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
979 memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
980 }
982 connection_setup();
983 client_test();
984 cleanup();
986 return (0);
987 }