691e60e43cd7ff4ccc801ed03c90e2ec98a4ebc5
1 /*
2 * rm_arm_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-2013, 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[] = "/tmp/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 = rm_pkt->pktLenBytes;
315 int32_t status;
317 if (rm_pkt) {
318 free (rm_pkt);
319 }
320 }
322 int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
323 {
324 sock_name_t *server_sock_name = (sock_name_t *)appTransport;
325 Rm_Packet *rm_pkt = (Rm_Packet *)pktHandle;
327 if (sock_send(rmClientSocket, (char *)rm_pkt, (int) rm_pkt->pktLenBytes, server_sock_name)) {
328 error_msg("send data failed\n");
329 }
331 return (0);
332 }
334 void transportReceive (void)
335 {
336 int32_t rm_result;
337 int retval;
338 int length = 0;
339 sock_name_t serv_sock_name;
340 sock_name_t server_sock_addr;
341 Rm_Packet *rm_pkt = NULL;
342 struct timeval tv = {0, CLIENT_SOCK_TIMEOUT_USEC};
343 struct sockaddr_un server_addr;
345 retval = sock_wait(rmClientSocket, &length, &tv, -1);
346 if (retval == -2) {
347 /* Timeout */
348 return;
349 }
350 else if (retval < 0) {
351 error_msg("Error in reading from socket, error %d\n", retval);
352 return;
353 }
355 if (length < sizeof(*rm_pkt)) {
356 error_msg("invalid RM message length %d\n", length);
357 return;
358 }
359 rm_pkt = calloc(1, length);
360 if (!rm_pkt) {
361 error_msg("can't malloc for recv'd RM message (err: %s)\n",
362 strerror(errno));
363 return;
364 }
366 server_sock_addr.type = sock_addr_e;
367 server_sock_addr.s.addr = &server_addr;
368 retval = sock_recv(rmClientSocket, (char *)rm_pkt, length, &server_sock_addr);
369 if (retval != length) {
370 error_msg("recv RM pkt failed from socket, received = %d, expected = %d\n",
371 retval, length);
372 return;
373 }
375 info_msg("received RM pkt of size %d bytes from %s\n", length, server_sock_addr.s.addr->sun_path);
377 /* Provide packet to RM Server for processing */
378 if (rm_result = Rm_receivePacket(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle, rm_pkt)) {
379 printf("RM failed to process received packet: %d\n", rm_result);
380 }
382 transportFree(rm_pkt);
383 }
386 void serviceCallback(Rm_ServiceRespInfo *serviceResponse)
387 {
388 uint32_t qIndex = 0;
390 /* Populate next free entry in the responseInfoQueue */
391 while (responseInfoQueue[qIndex].serviceId != 0) {
392 qIndex++;
393 if (qIndex == MAX_QUEUED_SERVICE_RESPONSES) {
394 qIndex = 0;
395 }
396 }
398 /* Save the response in the response queue for the test task to pick up */
399 memcpy((void *)&responseInfoQueue[qIndex], (void *)serviceResponse, sizeof(Rm_ServiceRespInfo));
400 }
402 void waitForResponse(Rm_ServiceRespInfo *respInfo)
403 {
404 uint32_t qIndex = 0;
406 if ((respInfo->serviceState == RM_SERVICE_PROCESSING) ||
407 (respInfo->serviceState == RM_SERVICE_PENDING_SERVER_RESPONSE)) {
408 /* Scan responseInfoQueue for the response received via the callback function */
409 while((responseInfoQueue[qIndex].serviceId != respInfo->serviceId) ||
410 (responseInfoQueue[qIndex].rmHandle != respInfo->rmHandle)) {
411 /* Check socket for response packets */
412 transportReceive();
414 qIndex++;
415 if (qIndex == MAX_QUEUED_SERVICE_RESPONSES) {
416 qIndex = 0;
417 }
418 }
420 memcpy((void *)respInfo, (void *)&responseInfoQueue[qIndex], sizeof(Rm_ServiceRespInfo));
421 memset((void *)&responseInfoQueue[qIndex], 0, sizeof(Rm_ServiceRespInfo));
422 }
423 }
425 void setRmRequest(Rm_ServiceReqInfo *reqInfo, Rm_ServiceType type, const char *resName, int32_t resBase,
426 uint32_t resLen, int32_t resAlign, const char *nsName, int setCallback, Rm_ServiceRespInfo *respInfo)
427 {
428 memset((void *)reqInfo, 0, sizeof(Rm_ServiceReqInfo));
429 reqInfo->type = type;
430 reqInfo->resourceName = resName;
431 reqInfo->resourceBase = resBase;
432 reqInfo->resourceLength = resLen;
433 reqInfo->resourceAlignment = resAlign;
434 reqInfo->resourceNsName = nsName;
435 if (setCallback) {
436 reqInfo->callback.serviceCallback = serviceCallback;
437 }
438 memset((void *)respInfo, 0, sizeof(Rm_ServiceRespInfo));
439 }
441 void cleanup(void)
442 {
443 Rm_ServiceReqInfo requestInfo;
444 Rm_ServiceRespInfo responseInfo;
445 int32_t result;
446 int32_t finalMallocFree;
448 /* Free all allocated resources */
449 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAccumCh,
450 0, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);
451 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
452 waitForResponse(&responseInfo);
453 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
454 coreNum, rmClientName, responseInfo.resourceName,
455 responseInfo.resourceBase, responseInfo.resourceLength,
456 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
457 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAccumCh,
458 40, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);
459 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
460 waitForResponse(&responseInfo);
461 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
462 coreNum, rmClientName, responseInfo.resourceName,
463 responseInfo.resourceBase, responseInfo.resourceLength,
464 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
466 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameQosCluster,
467 0, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
468 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
469 waitForResponse(&responseInfo);
470 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
471 coreNum, rmClientName, responseInfo.resourceName,
472 responseInfo.resourceBase, responseInfo.resourceLength,
473 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
474 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameQosCluster,
475 2, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
476 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
477 waitForResponse(&responseInfo);
478 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
479 coreNum, rmClientName, responseInfo.resourceName,
480 responseInfo.resourceBase, responseInfo.resourceLength,
481 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
483 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifQ,
484 525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
485 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
486 waitForResponse(&responseInfo);
487 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
488 coreNum, rmClientName, responseInfo.resourceName,
489 responseInfo.resourceBase, responseInfo.resourceLength,
490 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
492 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifQ,
493 525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
494 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
495 waitForResponse(&responseInfo);
496 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
497 coreNum, rmClientName, responseInfo.resourceName,
498 responseInfo.resourceBase, responseInfo.resourceLength,
499 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
501 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameInfraQ,
502 800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
503 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
504 waitForResponse(&responseInfo);
505 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
506 coreNum, rmClientName, responseInfo.resourceName,
507 responseInfo.resourceBase, responseInfo.resourceLength,
508 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
510 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ,
511 7000, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
512 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
513 waitForResponse(&responseInfo);
514 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
515 coreNum, rmClientName, responseInfo.resourceName,
516 responseInfo.resourceBase, responseInfo.resourceLength,
517 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
519 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ,
520 7011, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
521 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
522 waitForResponse(&responseInfo);
523 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
524 coreNum, rmClientName, responseInfo.resourceName,
525 responseInfo.resourceBase, responseInfo.resourceLength,
526 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
528 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ,
529 7010, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);
530 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
531 waitForResponse(&responseInfo);
532 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
533 coreNum, rmClientName, responseInfo.resourceName,
534 responseInfo.resourceBase, responseInfo.resourceLength,
535 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
537 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ,
538 7005, 25, 0, NULL, RM_TEST_TRUE, &responseInfo);
539 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
540 waitForResponse(&responseInfo);
541 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
542 coreNum, rmClientName, responseInfo.resourceName,
543 responseInfo.resourceBase, responseInfo.resourceLength,
544 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
546 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh,
547 0, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);
548 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
549 waitForResponse(&responseInfo);
550 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
551 coreNum, rmClientName, responseInfo.resourceName,
552 responseInfo.resourceBase, responseInfo.resourceLength,
553 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
554 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh,
555 50, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);
556 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
557 waitForResponse(&responseInfo);
558 POSITIVE_PASS_CHECK("-------------------- Resource Cleanup -------------------",
559 coreNum, rmClientName, responseInfo.resourceName,
560 responseInfo.resourceBase, responseInfo.resourceLength,
561 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
563 /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
564 result = Rm_serviceCloseHandle(rmClientServiceHandle);
565 ERROR_CHECK(RM_OK, result, rmClientName, "Service handle close failed");
567 result = Rm_transportUnregister(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle);
568 ERROR_CHECK(RM_OK, result, rmClientName, "Unregister of Server transport failed");
570 sock_close(rmClientSocket);
572 result = Rm_delete(rmClientHandle, RM_TEST_TRUE);
573 ERROR_CHECK(RM_OK, result, rmClientName, "Instance delete failed");
575 printf ("Core %d : ---------------------------------------------------------\n", coreNum);
576 printf ("Core %d : ------------------ Memory Leak Check --------------------\n", coreNum);
577 printf ("Core %d : - : malloc count | free count -\n", coreNum);
578 printf ("Core %d : - Example Completion : %6d | %6d -\n", coreNum,
579 rmMallocCounter, rmFreeCounter);
580 finalMallocFree = rmMallocCounter - rmFreeCounter;
581 if (finalMallocFree > 0) {
582 printf ("Core %d : - FAILED - %6d unfreed mallocs -\n",
583 coreNum, finalMallocFree);
584 testErrors++;
585 }
586 else if (finalMallocFree < 0) {
587 printf ("Core %d : - FAILED - %6d more frees than mallocs -\n",
588 coreNum, -finalMallocFree);
589 testErrors++;
590 }
591 else {
592 printf ("Core %d : - PASSED -\n",
593 coreNum);
594 }
595 printf ("Core %d : ---------------------------------------------------------\n", coreNum);
596 printf ("\n");
598 printf ("Core %d : ---------------------------------------------------------\n", coreNum);
599 printf ("Core %d : ------------------ Example Completion -------------------\n", coreNum);
600 if (testErrors) {
601 printf ("Core %d : - Test Errors: %-32d -\n", coreNum, testErrors);
602 }
603 printf ("Core %d : ---------------------------------------------------------\n", coreNum);
604 printf ("\n");
605 }
607 void client_test(void)
608 {
609 Rm_ServiceReqInfo requestInfo;
610 Rm_ServiceRespInfo responseInfo;
611 uint32_t i, j;
613 /* Create new NameServer object */
614 setRmRequest(&requestInfo, Rm_service_RESOURCE_MAP_TO_NAME, resourceNameGpQ,
615 1002, 1, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
616 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
617 waitForResponse(&responseInfo);
618 POSITIVE_PASS_CHECK("--------------- Create NameServer Object ----------------",
619 coreNum, rmClientName, resourceNameGpQ,
620 requestInfo.resourceBase, responseInfo.resourceLength,
621 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
623 /* Retrieve a resource via a NameServer name */
624 setRmRequest(&requestInfo, Rm_service_RESOURCE_GET_BY_NAME, NULL,
625 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
626 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
627 waitForResponse(&responseInfo);
628 POSITIVE_PASS_CHECK("------- Retrieve Resource Via NameServer Object ---------",
629 coreNum, rmClientName, responseInfo.resourceName,
630 responseInfo.resourceBase, responseInfo.resourceLength,
631 0, responseInfo.serviceState, RM_SERVICE_APPROVED);
633 /* Allocate the resource returned from the NameServer request */
634 memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
635 requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
636 requestInfo.resourceName = responseInfo.resourceName;
637 requestInfo.resourceBase = responseInfo.resourceBase;
638 requestInfo.resourceLength = responseInfo.resourceLength;
639 requestInfo.resourceNsName = NULL;
640 requestInfo.callback.serviceCallback = serviceCallback;
641 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
642 waitForResponse(&responseInfo);
643 POSITIVE_PASS_CHECK("-------- Init Allocate Using Retrieved Resource ---------",
644 coreNum, rmClientName, responseInfo.resourceName,
645 requestInfo.resourceBase, requestInfo.resourceLength,
646 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
648 /* Retrieve the resource status via the NameServer name */
649 setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, NULL,
650 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
651 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
652 waitForResponse(&responseInfo);
653 STATUS_PASS_CHECK("---- Retrieve Resource Status Via NameServer Object -----",
654 coreNum, rmClientName, responseInfo.resourceName,
655 responseInfo.resourceBase, responseInfo.resourceLength,
656 responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);
658 /* Free resource via a NameServer name */
659 setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL,
660 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
661 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
662 waitForResponse(&responseInfo);
663 POSITIVE_PASS_CHECK("--- Free of Retrieved Resource Using NameServer Name ----",
664 coreNum, rmClientName, nameServerNameFavQ,
665 0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);
667 /* Delete the NameServer name */
668 setRmRequest(&requestInfo, Rm_service_RESOURCE_UNMAP_NAME, NULL,
669 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
670 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
671 waitForResponse(&responseInfo);
672 POSITIVE_PASS_CHECK("--------------- Delete NameServer Object ----------------",
673 coreNum, rmClientName, nameServerNameFavQ,
674 0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);
676 /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
677 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh,
678 0, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);
679 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
680 waitForResponse(&responseInfo);
681 POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --",
682 coreNum, rmClientName, resourceNameAifRxCh,
683 requestInfo.resourceBase, requestInfo.resourceLength,
684 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
686 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifRxCh,
687 50, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);
688 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
689 waitForResponse(&responseInfo);
690 POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Init Allocate) -",
691 coreNum, rmClientName, resourceNameAifRxCh,
692 requestInfo.resourceBase, requestInfo.resourceLength,
693 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
694 /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */
696 /* BEGIN testing allocations with UNSPECIFIED base and alignment values */
697 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh,
698 RM_RESOURCE_BASE_UNSPECIFIED, 5, 4, NULL, RM_TEST_TRUE, &responseInfo);
699 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
700 waitForResponse(&responseInfo);
701 POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------",
702 coreNum, rmClientName, resourceNameAccumCh,
703 RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength,
704 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
706 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh,
707 RM_RESOURCE_BASE_UNSPECIFIED, 2, 1, NULL, RM_TEST_TRUE, &responseInfo);
708 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
709 waitForResponse(&responseInfo);
710 POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------",
711 coreNum, rmClientName, resourceNameAccumCh,
712 RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength,
713 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
715 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh,
716 RM_RESOURCE_BASE_UNSPECIFIED, 2, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);
717 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
718 waitForResponse(&responseInfo);
719 POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----",
720 coreNum, rmClientName, resourceNameAccumCh,
721 RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength,
722 RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);
723 /* END testing allocations with UNSPECIFIED base and alignment values */
725 /* Allocate infrastructure queue shared between Linux kernel and Client */
726 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ,
727 800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
728 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
729 waitForResponse(&responseInfo);
730 POSITIVE_PASS_CHECK("-- Init Allocation of Shared Linux and Client Resource --",
731 coreNum, rmClientName, resourceNameInfraQ,
732 requestInfo.resourceBase, requestInfo.resourceLength,
733 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
735 /* BEGIN Allocating some resources without providing a callback function. RM should block and not return until the result
736 * is returned by the server. */
737 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
738 7000, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
739 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
740 waitForResponse(&responseInfo);
741 POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --",
742 coreNum, rmClientName, resourceNameGpQ,
743 requestInfo.resourceBase, requestInfo.resourceLength,
744 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
746 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
747 7005, 25, 0, NULL, RM_TEST_TRUE, &responseInfo);
748 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
749 waitForResponse(&responseInfo);
750 POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --",
751 coreNum, rmClientName, resourceNameGpQ,
752 requestInfo.resourceBase, requestInfo.resourceLength,
753 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
755 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
756 7010, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);
757 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
758 waitForResponse(&responseInfo);
759 POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --",
760 coreNum, rmClientName, resourceNameGpQ,
761 requestInfo.resourceBase, requestInfo.resourceLength,
762 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
764 /* Init allocation of resource already owned by Client should return approved and there should only
765 * be one instance of Client in resource's owner list. */
766 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
767 7011, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
768 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
769 waitForResponse(&responseInfo);
770 POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----",
771 coreNum, rmClientName, resourceNameGpQ,
772 requestInfo.resourceBase, requestInfo.resourceLength,
773 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
774 /* END Allocating some resources without providing a callback function. RM should block and not return
775 * until the result is returned by the Server. */
777 /* BEGIN Getting the status of resources from Client and CD */
778 setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ,
779 7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);
780 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
781 waitForResponse(&responseInfo);
782 STATUS_PASS_CHECK("-- Status Check of Resources from Client (Non-Blocking) -",
783 coreNum, rmClientName, responseInfo.resourceName,
784 responseInfo.resourceBase, responseInfo.resourceLength,
785 responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);
787 setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ,
788 4025, 20, 0, NULL, RM_TEST_TRUE, &responseInfo);
789 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
790 waitForResponse(&responseInfo);
791 STATUS_PASS_CHECK("---- Status Check of Resources from Client (Blocking) ---",
792 coreNum, rmClientName, responseInfo.resourceName,
793 responseInfo.resourceBase, responseInfo.resourceLength,
794 responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);
795 /* END Getting the status of resources from Client and CD */
797 /* Verify static allocations were validated. Validation responses should have been received after the
798 * first service requests were made on the Client and CD post transport path registration. */
799 while (numStaticResponses > 0) {
800 /* Loop until all static request validations have been received */
801 for (i = 0; i < MAX_STATIC_ALLOCATION_RESPS; i++) {
802 if (staticResponseQueue[i].serviceId != 0) {
803 for (j = 0; j < MAX_QUEUED_SERVICE_RESPONSES; j++) {
804 if ((staticResponseQueue[i].serviceId == responseInfoQueue[j].serviceId) &&
805 (staticResponseQueue[i].rmHandle == responseInfoQueue[j].rmHandle)) {
806 POSITIVE_PASS_CHECK("------------- Static Allocation Validation --------------",
807 coreNum, rmClientName, responseInfoQueue[j].resourceName,
808 responseInfoQueue[j].resourceBase, responseInfoQueue[j].resourceLength,
809 0, responseInfoQueue[j].serviceState,
810 RM_SERVICE_APPROVED);
811 memset((void *)&staticResponseQueue[i], 0, sizeof(Rm_ServiceRespInfo));
812 memset((void *)&responseInfoQueue[j], 0, sizeof(Rm_ServiceRespInfo));
813 numStaticResponses--;
814 break;
815 }
816 }
817 }
818 }
819 }
821 #if PRINT_USED_RESOURCES
822 Rm_resourceStatus(rmCdHandle, RM_TEST_TRUE);
823 #endif
824 }
826 void connection_setup(void)
827 {
828 Rm_TransportCfg rmTransCfg;
829 int32_t rm_result;
830 int i;
831 sock_name_t sock_name;
832 int32_t result = 0;
833 char server_sock_name[] = RM_SERVER_SOCKET_NAME;
835 /* Initialize the transport map */
836 for (i = 0; i < MAX_MAPPING_ENTRIES; i++) {
837 rmTransportMap[i].transportHandle = NULL;
838 }
840 sock_name.type = sock_name_e;
841 sock_name.s.name = rmClientSockName;
843 rmClientSocket = sock_open(&sock_name);
844 if (!rmClientSocket) {
845 error_msg("Client socket open failed\n");
846 exit(EXIT_FAILURE);
847 }
849 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock = calloc(1, sizeof(sock_name_t));
850 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock->type = sock_name_e;
851 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock->s.name = calloc(1, strlen(server_sock_name)+1);
852 strncpy(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock->s.name, server_sock_name, strlen(server_sock_name)+1);
854 /* Register the Server with the Client instance */
855 rmTransCfg.rmHandle = rmClientHandle;
856 rmTransCfg.appTransportHandle = (Rm_AppTransportHandle) rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock;
857 rmTransCfg.remoteInstType = Rm_instType_SERVER;
858 rmTransCfg.transportCallouts.rmAllocPkt = transportAlloc;
859 rmTransCfg.transportCallouts.rmSendPkt = transportSend;
860 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle = Rm_transportRegister(&rmTransCfg, &rm_result);
861 }
863 int main(int argc, char *argv[])
864 {
865 int fd;
866 struct stat file_stat;
867 char *static_policy_addr = NULL;
868 Rm_InitCfg rmInitCfg;
869 int status;
870 Rm_ServiceReqInfo requestInfo;
871 Rm_ServiceRespInfo responseInfo;
872 int32_t result;
874 printf ("*********************************************************\n");
875 printf ("*************** RM Linux Client Testing *****************\n");
876 printf ("*********************************************************\n");
878 printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
880 coreNum = 0;
881 testErrors = 0;
883 if (argc > 2)
884 {
885 error_msg("Invalid number of input arguments\n");
886 exit(EXIT_FAILURE);
887 }
889 if (argc == 2){
890 /* mmap static policy */
891 fd = open(argv[1], O_RDONLY);
892 if (fd == -1) {
893 error_msg("Error opening static policy\n");
894 exit(EXIT_FAILURE);
895 }
896 /* Obtain file size */
897 if (fstat(fd, &file_stat) == -1) {
898 error_msg("Error getting static policy size\n");
899 exit(EXIT_FAILURE);
900 }
901 static_policy_addr = mmap(NULL, file_stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
902 if (static_policy_addr == MAP_FAILED) {
903 error_msg("mmap of static failed\n");
904 exit(EXIT_FAILURE);
905 }
906 }
908 /* Initialize the RM Client - RM must be initialized before anything else in the system */
909 memset(&rmInitCfg, 0, sizeof(rmInitCfg));
910 rmInitCfg.instName = rmClientName;
911 rmInitCfg.instType = Rm_instType_CLIENT;
912 if (static_policy_addr) {
913 rmInitCfg.instCfg.clientCfg.staticPolicy = (void *)static_policy_addr;
914 }
915 rmClientHandle = Rm_init(&rmInitCfg, &result);
916 ERROR_CHECK(RM_OK, result, rmClientName, "Initialization failed");
918 printf("\n\nInitialized %s\n\n", rmClientName);
920 /* Open Client service handle */
921 rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);
922 ERROR_CHECK(RM_OK, result, rmClientName, "Service handle open failed");
924 /* Initialize the static allocation response queue */
925 for (numStaticResponses = 0; numStaticResponses < MAX_STATIC_ALLOCATION_RESPS; numStaticResponses++) {
926 memset((void *)&staticResponseQueue[numStaticResponses], 0, sizeof(Rm_ServiceRespInfo));
927 }
928 numStaticResponses = 0;
930 /* Static allocation tests */
931 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster,
932 0, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
933 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
934 POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------",
935 coreNum, rmClientName, resourceNameQosCluster,
936 requestInfo.resourceBase, requestInfo.resourceLength,
937 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);
938 if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
939 memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
940 }
942 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster,
943 2, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
944 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
945 POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------",
946 coreNum, rmClientName, resourceNameQosCluster,
947 requestInfo.resourceBase, requestInfo.resourceLength,
948 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);
949 if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
950 memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
951 }
953 /* Request resource from Client that can only be allocated to CD according to static policy */
954 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster,
955 1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
956 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
957 NEGATIVE_PASS_CHECK("---------------- Static Init Allocation -----------------",
958 coreNum, rmClientName, resourceNameQosCluster,
959 requestInfo.resourceBase, requestInfo.resourceLength,
960 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);
962 /* Request resource from both Client and CD that is shared according to static policy */
963 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifQ,
964 525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
965 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
966 POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------",
967 coreNum, rmClientName, resourceNameAifQ,
968 requestInfo.resourceBase, requestInfo.resourceLength,
969 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);
970 if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
971 memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
972 }
974 setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifQ,
975 525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
976 rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
977 POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------",
978 coreNum, rmClientName, resourceNameAifQ,
979 requestInfo.resourceBase, requestInfo.resourceLength,
980 requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);
981 if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
982 memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
983 }
985 connection_setup();
986 client_test();
987 cleanup();
989 return (0);
990 }