|
31 | 31 |
|
32 | 32 | #include "OCS_string.h"
|
33 | 33 |
|
| 34 | +#define maxRecords \ |
| 35 | + (OS_MAX_TASKS + OS_MAX_QUEUES + OS_MAX_BIN_SEMAPHORES + OS_MAX_COUNT_SEMAPHORES + OS_MAX_MUTEXES + \ |
| 36 | + OS_MAX_NUM_OPEN_FILES + OS_MAX_NUM_OPEN_DIRS + OS_MAX_TIMEBASES + OS_MAX_TIMERS + OS_MAX_MODULES + \ |
| 37 | + OS_MAX_FILE_SYSTEMS + OS_MAX_CONSOLES) |
| 38 | + |
34 | 39 | typedef struct
|
35 | 40 | {
|
36 | 41 | uint32 TaskCount;
|
@@ -1065,6 +1070,78 @@ void Test_OS_ObjectIdIterator(void)
|
1065 | 1070 | UtAssert_STUB_COUNT(OS_Unlock_Global_Impl, 2);
|
1066 | 1071 | }
|
1067 | 1072 |
|
| 1073 | +void Test_OS_ObjectIDInteger(void) |
| 1074 | +{ |
| 1075 | + /* |
| 1076 | + * Test Case For: |
| 1077 | + * OS_ObjectIdToInteger, OS_ObjectIdFromInteger, OS_ObjectIdEqual, OS_ObjectIdDefined |
| 1078 | + */ |
| 1079 | + int32 actual; |
| 1080 | + OS_object_token_t token; |
| 1081 | + osal_id_t typesI[maxRecords]; |
| 1082 | + osal_id_t typesJ[maxRecords]; |
| 1083 | + uint32 intID; |
| 1084 | + int32 recordscount = 0; |
| 1085 | + uint32 maxType = 0; |
| 1086 | + uint32 typeReturn = 0; |
| 1087 | + osal_objtype_t idtype; |
| 1088 | + char str[maxRecords]; |
| 1089 | + |
| 1090 | + for (idtype = 0; idtype < OS_OBJECT_TYPE_USER; ++idtype) |
| 1091 | + { |
| 1092 | + typeReturn = OS_GetMaxForObjectType(idtype); |
| 1093 | + maxType += typeReturn; |
| 1094 | + } |
| 1095 | + |
| 1096 | + if (maxType == maxRecords) |
| 1097 | + { |
| 1098 | + for (idtype = 0; idtype < OS_OBJECT_TYPE_USER; ++idtype) |
| 1099 | + { |
| 1100 | + actual = OS_SUCCESS; |
| 1101 | + do |
| 1102 | + { |
| 1103 | + snprintf(str, sizeof(str), "%d", recordscount); |
| 1104 | + |
| 1105 | + actual = OS_ObjectIdAllocateNew(idtype, str, &token); |
| 1106 | + |
| 1107 | + if (actual == OS_SUCCESS) |
| 1108 | + { |
| 1109 | + typesI[recordscount] = token.obj_id; |
| 1110 | + intID = OS_ObjectIdToInteger(typesI[recordscount]); |
| 1111 | + typesJ[recordscount] = OS_ObjectIdFromInteger(intID); |
| 1112 | + |
| 1113 | + recordscount++; |
| 1114 | + } |
| 1115 | + |
| 1116 | + } while (actual == OS_SUCCESS); |
| 1117 | + } |
| 1118 | + |
| 1119 | + for (int i = 0; i < recordscount; i++) |
| 1120 | + { |
| 1121 | + UtAssert_True(OS_ObjectIdDefined(typesI[i]), "%lu Is defined", OS_ObjectIdToInteger(typesI[i])); |
| 1122 | + |
| 1123 | + for (int j = 0; j < recordscount; j++) |
| 1124 | + { |
| 1125 | + if (i == j) |
| 1126 | + { |
| 1127 | + UtAssert_True(OS_ObjectIdEqual(typesI[i], typesJ[j]), "%lu equals %lu", |
| 1128 | + OS_ObjectIdToInteger(typesI[i]), OS_ObjectIdToInteger(typesJ[j])); |
| 1129 | + } |
| 1130 | + else |
| 1131 | + { |
| 1132 | + UtAssert_True(!OS_ObjectIdEqual(typesI[i], typesJ[j]), "%lu does not equal %lu", |
| 1133 | + OS_ObjectIdToInteger(typesI[i]), OS_ObjectIdToInteger(typesJ[j])); |
| 1134 | + } |
| 1135 | + } |
| 1136 | + } |
| 1137 | + } |
| 1138 | + else |
| 1139 | + { |
| 1140 | + UtAssert_Failed("Max records calculated by unit test does not match flight software. Confirm calculation in " |
| 1141 | + "test is correct"); |
| 1142 | + } |
| 1143 | +} |
| 1144 | + |
1068 | 1145 | /* Osapi_Test_Setup
|
1069 | 1146 | *
|
1070 | 1147 | * Purpose:
|
@@ -1115,4 +1192,5 @@ void UtTest_Setup(void)
|
1115 | 1192 | ADD_TEST(OS_GetBaseForObjectType);
|
1116 | 1193 | ADD_TEST(OS_GetResourceName);
|
1117 | 1194 | ADD_TEST(OS_ObjectIdIterator);
|
| 1195 | + ADD_TEST(OS_ObjectIDInteger); |
1118 | 1196 | }
|
0 commit comments