blob: 73baa1ab4c2c6fba69fba363bca0749223222998 [file] [log] [blame]
Gilbert Chende2a1322022-05-24 15:35:21 +01001#include "common/instance_id.hpp"
2#include "mock_terminus_manager.hpp"
3#include "platform-mc/platform_manager.hpp"
4#include "test/test_instance_id.hpp"
5
6#include <sdeventplus/event.hpp>
7
8#include <bitset>
9
10#include <gtest/gtest.h>
11
12class PlatformManagerTest : public testing::Test
13{
14 protected:
15 PlatformManagerTest() :
16 bus(pldm::utils::DBusHandler::getBus()),
17 event(sdeventplus::Event::get_default()), instanceIdDb(),
18 reqHandler(pldmTransport, event, instanceIdDb, false,
19 std::chrono::seconds(1), 2, std::chrono::milliseconds(100)),
20 mockTerminusManager(event, reqHandler, instanceIdDb, termini, nullptr),
21 platformManager(mockTerminusManager, termini)
22 {}
23
24 PldmTransport* pldmTransport = nullptr;
25 sdbusplus::bus_t& bus;
26 sdeventplus::Event event;
27 TestInstanceIdDb instanceIdDb;
28 pldm::requester::Handler<pldm::requester::Request> reqHandler;
29 pldm::platform_mc::MockTerminusManager mockTerminusManager;
30 pldm::platform_mc::PlatformManager platformManager;
31 std::map<pldm_tid_t, std::shared_ptr<pldm::platform_mc::Terminus>> termini;
32};
33
34TEST_F(PlatformManagerTest, initTerminusTest)
35{
36 // Add terminus
37 auto mappedTid = mockTerminusManager.mapTid(pldm::MctpInfo(10, "", "", 1));
38 auto tid = mappedTid.value();
39 termini[tid] = std::make_shared<pldm::platform_mc::Terminus>(
40 tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
41 auto terminus = termini[tid];
42
43 /* Set supported command by terminus */
44 auto size = PLDM_MAX_TYPES * (PLDM_MAX_CMDS_PER_TYPE / 8);
45 std::vector<uint8_t> pldmCmds(size);
46 uint8_t type = PLDM_PLATFORM;
47 uint8_t cmd = PLDM_GET_PDR;
48 auto idx = type * (PLDM_MAX_CMDS_PER_TYPE / 8) + (cmd / 8);
49 pldmCmds[idx] = pldmCmds[idx] | (1 << (cmd % 8));
50 cmd = PLDM_GET_PDR_REPOSITORY_INFO;
51 idx = type * (PLDM_MAX_CMDS_PER_TYPE / 8) + (cmd / 8);
52 pldmCmds[idx] = pldmCmds[idx] | (1 << (cmd % 8));
53 termini[tid]->setSupportedCommands(pldmCmds);
54
55 // queue getPDRRepositoryInfo response
56 const size_t getPDRRepositoryInfoLen =
57 PLDM_GET_PDR_REPOSITORY_INFO_RESP_BYTES;
58 std::array<uint8_t, sizeof(pldm_msg_hdr) + getPDRRepositoryInfoLen>
59 getPDRRepositoryInfoResp{
60 0x0, 0x02, 0x50, PLDM_SUCCESS,
61 0x0, // repositoryState
62 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
63 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // updateTime
64 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
65 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // OEMUpdateTime
Gilbert Cheneac61a42022-02-23 20:56:19 +000066 2, 0x0, 0x0, 0x0, // recordCount
Gilbert Chende2a1322022-05-24 15:35:21 +010067 0x0, 0x1, 0x0, 0x0, // repositorySize
68 59, 0x0, 0x0, 0x0, // largestRecordSize
69 0x0 // dataTransferHandleTimeout
70 };
71 auto rc = mockTerminusManager.enqueueResponse(
Thu Nguyen98831af2024-07-30 09:51:00 +000072 reinterpret_cast<pldm_msg*>(getPDRRepositoryInfoResp.data()),
Gilbert Chende2a1322022-05-24 15:35:21 +010073 sizeof(getPDRRepositoryInfoResp));
74 EXPECT_EQ(rc, PLDM_SUCCESS);
75
76 // queue getPDR responses
77 const size_t getPdrRespLen = 81;
78 std::array<uint8_t, sizeof(pldm_msg_hdr) + getPdrRespLen> getPdrResp{
Gilbert Cheneac61a42022-02-23 20:56:19 +000079 0x0, 0x02, 0x51, PLDM_SUCCESS, 0x1, 0x0, 0x0, 0x0, // nextRecordHandle
Gilbert Chende2a1322022-05-24 15:35:21 +010080 0x0, 0x0, 0x0, 0x0, // nextDataTransferHandle
81 0x5, // transferFlag
82 69, 0x0, // responseCount
83 // numeric Sensor PDR
Gilbert Cheneac61a42022-02-23 20:56:19 +000084 0x0, 0x0, 0x0,
Gilbert Chende2a1322022-05-24 15:35:21 +010085 0x0, // record handle
86 0x1, // PDRHeaderVersion
87 PLDM_NUMERIC_SENSOR_PDR, // PDRType
88 0x0,
89 0x0, // recordChangeNumber
90 PLDM_PDR_NUMERIC_SENSOR_PDR_FIXED_LENGTH +
91 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_SENSOR_DATA_SIZE_MIN_LENGTH +
92 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_RANGE_FIELD_MIN_LENGTH,
93 0, // dataLength
94 0,
95 0, // PLDMTerminusHandle
96 0x1,
97 0x0, // sensorID=1
98 120,
99 0, // entityType=Power Supply(120)
100 1,
101 0, // entityInstanceNumber
102 0x1,
103 0x0, // containerID=1
104 PLDM_NO_INIT, // sensorInit
105 false, // sensorAuxiliaryNamesPDR
106 PLDM_SENSOR_UNIT_DEGRESS_C, // baseUint(2)=degrees C
107 1, // unitModifier = 1
108 0, // rateUnit
109 0, // baseOEMUnitHandle
110 0, // auxUnit
111 0, // auxUnitModifier
112 0, // auxRateUnit
113 0, // rel
114 0, // auxOEMUnitHandle
115 true, // isLinear
116 PLDM_SENSOR_DATA_SIZE_UINT8, // sensorDataSize
117 0, 0, 0xc0,
118 0x3f, // resolution=1.5
119 0, 0, 0x80,
120 0x3f, // offset=1.0
121 0,
122 0, // accuracy
123 0, // plusTolerance
124 0, // minusTolerance
125 2, // hysteresis
126 0, // supportedThresholds
127 0, // thresholdAndHysteresisVolatility
128 0, 0, 0x80,
129 0x3f, // stateTransistionInterval=1.0
130 0, 0, 0x80,
131 0x3f, // updateInverval=1.0
132 255, // maxReadable
133 0, // minReadable
134 PLDM_RANGE_FIELD_FORMAT_UINT8, // rangeFieldFormat
135 0, // rangeFieldsupport
136 0, // nominalValue
137 0, // normalMax
138 0, // normalMin
139 0, // warningHigh
140 0, // warningLow
141 0, // criticalHigh
142 0, // criticalLow
143 0, // fatalHigh
144 0 // fatalLow
145 };
Thu Nguyen98831af2024-07-30 09:51:00 +0000146 rc = mockTerminusManager.enqueueResponse(
147 reinterpret_cast<pldm_msg*>(getPdrResp.data()), sizeof(getPdrResp));
Gilbert Chende2a1322022-05-24 15:35:21 +0100148 EXPECT_EQ(rc, PLDM_SUCCESS);
149
Gilbert Cheneac61a42022-02-23 20:56:19 +0000150 const size_t getPdrAuxNameRespLen = 39;
151 std::array<uint8_t, sizeof(pldm_msg_hdr) + getPdrAuxNameRespLen>
152 getPdrAuxNameResp{
153 0x0, 0x02, 0x51, PLDM_SUCCESS, 0x0, 0x0, 0x0,
154 0x0, // nextRecordHandle
155 0x0, 0x0, 0x0, 0x0, // nextDataTransferHandle
156 0x5, // transferFlag
157 0x1b, 0x0, // responseCount
158 // Common PDR Header
159 0x1, 0x0, 0x0,
160 0x0, // record handle
161 0x1, // PDRHeaderVersion
162 PLDM_ENTITY_AUXILIARY_NAMES_PDR, // PDRType
163 0x1,
164 0x0, // recordChangeNumber
165 0x11,
166 0, // dataLength
167 /* Entity Auxiliary Names PDR Data*/
168 3,
169 0x80, // entityType system software
170 0x1,
171 0x0, // Entity instance number =1
172 0,
173 0, // Overal system
174 0, // shared Name Count one name only
175 01, // nameStringCount
176 0x65, 0x6e, 0x00,
177 0x00, // Language Tag "en"
178 0x53, 0x00, 0x30, 0x00,
179 0x00 // Entity Name "S0"
180 };
181 rc = mockTerminusManager.enqueueResponse(
182 reinterpret_cast<pldm_msg*>(getPdrAuxNameResp.data()),
183 sizeof(getPdrAuxNameResp));
184 EXPECT_EQ(rc, PLDM_SUCCESS);
185
Gilbert Chende2a1322022-05-24 15:35:21 +0100186 stdexec::sync_wait(platformManager.initTerminus());
187 EXPECT_EQ(true, terminus->initialized);
Gilbert Cheneac61a42022-02-23 20:56:19 +0000188 EXPECT_EQ(2, terminus->pdrs.size());
189 EXPECT_EQ(1, terminus->numericSensors.size());
190 EXPECT_EQ("S0", terminus->getTerminusName());
Gilbert Chende2a1322022-05-24 15:35:21 +0100191}
192
Thu Nguyenb8cf46b2024-06-15 02:44:35 +0000193TEST_F(PlatformManagerTest, parseTerminusNameTest)
194{
195 // Add terminus
196 auto mappedTid = mockTerminusManager.mapTid(pldm::MctpInfo(10, "", "", 1));
197 auto tid = mappedTid.value();
198 termini[tid] = std::make_shared<pldm::platform_mc::Terminus>(
199 tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
200 auto terminus = termini[tid];
201
202 /* Set supported command by terminus */
203 auto size = PLDM_MAX_TYPES * (PLDM_MAX_CMDS_PER_TYPE / 8);
204 std::vector<uint8_t> pldmCmds(size);
205 uint8_t type = PLDM_PLATFORM;
206 uint8_t cmd = PLDM_GET_PDR;
207 auto idx = type * (PLDM_MAX_CMDS_PER_TYPE / 8) + (cmd / 8);
208 pldmCmds[idx] = pldmCmds[idx] | (1 << (cmd % 8));
209 cmd = PLDM_GET_PDR_REPOSITORY_INFO;
210 idx = type * (PLDM_MAX_CMDS_PER_TYPE / 8) + (cmd / 8);
211 pldmCmds[idx] = pldmCmds[idx] | (1 << (cmd % 8));
212 termini[tid]->setSupportedCommands(pldmCmds);
213
214 // queue getPDRRepositoryInfo response
215 const size_t getPDRRepositoryInfoLen =
216 PLDM_GET_PDR_REPOSITORY_INFO_RESP_BYTES;
217 std::array<uint8_t, sizeof(pldm_msg_hdr) + getPDRRepositoryInfoLen>
218 getPDRRepositoryInfoResp{
219 0x0, 0x02, 0x50, PLDM_SUCCESS,
220 0x0, // repositoryState
221 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
222 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // updateTime
223 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
224 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // OEMUpdateTime
225 2, 0x0, 0x0, 0x0, // recordCount
226 0x0, 0x1, 0x0, 0x0, // repositorySize
227 59, 0x0, 0x0, 0x0, // largestRecordSize
228 0x0 // dataTransferHandleTimeout
229 };
230 auto rc = mockTerminusManager.enqueueResponse(
231 reinterpret_cast<pldm_msg*>(getPDRRepositoryInfoResp.data()),
232 sizeof(getPDRRepositoryInfoResp));
233 EXPECT_EQ(rc, PLDM_SUCCESS);
234
235 // queue getPDR responses
236 const size_t getPdrRespLen = 81;
237 std::array<uint8_t, sizeof(pldm_msg_hdr) + getPdrRespLen> getPdrResp{
238 0x0, 0x02, 0x51, PLDM_SUCCESS, 0x1, 0x0, 0x0, 0x0, // nextRecordHandle
239 0x0, 0x0, 0x0, 0x0, // nextDataTransferHandle
240 0x5, // transferFlag
241 69, 0x0, // responseCount
242 // numeric Sensor PDR
243 0x0, 0x0, 0x0,
244 0x0, // record handle
245 0x1, // PDRHeaderVersion
246 PLDM_NUMERIC_SENSOR_PDR, // PDRType
247 0x0,
248 0x0, // recordChangeNumber
249 PLDM_PDR_NUMERIC_SENSOR_PDR_FIXED_LENGTH +
250 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_SENSOR_DATA_SIZE_MIN_LENGTH +
251 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_RANGE_FIELD_MIN_LENGTH,
252 0, // dataLength
253 0,
254 0, // PLDMTerminusHandle
255 0x1,
256 0x0, // sensorID=1
257 120,
258 0, // entityType=Power Supply(120)
259 1,
260 0, // entityInstanceNumber
261 0x1,
262 0x0, // containerID=1
263 PLDM_NO_INIT, // sensorInit
264 false, // sensorAuxiliaryNamesPDR
265 PLDM_SENSOR_UNIT_DEGRESS_C, // baseUint(2)=degrees C
266 1, // unitModifier = 1
267 0, // rateUnit
268 0, // baseOEMUnitHandle
269 0, // auxUnit
270 0, // auxUnitModifier
271 0, // auxRateUnit
272 0, // rel
273 0, // auxOEMUnitHandle
274 true, // isLinear
275 PLDM_SENSOR_DATA_SIZE_UINT8, // sensorDataSize
276 0, 0, 0xc0,
277 0x3f, // resolution=1.5
278 0, 0, 0x80,
279 0x3f, // offset=1.0
280 0,
281 0, // accuracy
282 0, // plusTolerance
283 0, // minusTolerance
284 2, // hysteresis
285 0, // supportedThresholds
286 0, // thresholdAndHysteresisVolatility
287 0, 0, 0x80,
288 0x3f, // stateTransistionInterval=1.0
289 0, 0, 0x80,
290 0x3f, // updateInverval=1.0
291 255, // maxReadable
292 0, // minReadable
293 PLDM_RANGE_FIELD_FORMAT_UINT8, // rangeFieldFormat
294 0, // rangeFieldsupport
295 0, // nominalValue
296 0, // normalMax
297 0, // normalMin
298 0, // warningHigh
299 0, // warningLow
300 0, // criticalHigh
301 0, // criticalLow
302 0, // fatalHigh
303 0 // fatalLow
304 };
305 rc = mockTerminusManager.enqueueResponse(
306 reinterpret_cast<pldm_msg*>(getPdrResp.data()), sizeof(getPdrResp));
307 EXPECT_EQ(rc, PLDM_SUCCESS);
308
309 const size_t getPdrAuxNameRespLen = 39;
310 std::array<uint8_t, sizeof(pldm_msg_hdr) + getPdrAuxNameRespLen>
311 getPdrAuxNameResp{
312 0x0, 0x02, 0x51, PLDM_SUCCESS, 0x0, 0x0, 0x0,
313 0x0, // nextRecordHandle
314 0x0, 0x0, 0x0, 0x0, // nextDataTransferHandle
315 0x5, // transferFlag
316 0x1b, 0x0, // responseCount
317 // Common PDR Header
318 0x1, 0x0, 0x0,
319 0x0, // record handle
320 0x1, // PDRHeaderVersion
321 PLDM_ENTITY_AUXILIARY_NAMES_PDR, // PDRType
322 0x1,
323 0x0, // recordChangeNumber
324 0x11,
325 0, // dataLength
326 /* Entity Auxiliary Names PDR Data*/
327 3,
328 0x80, // entityType system software
329 0x1,
330 0x0, // Entity instance number =1
331 0,
332 0, // Overal system
333 0, // shared Name Count one name only
334 01, // nameStringCount
335 0x65, 0x6e, 0x00,
336 0x00, // Language Tag "en"
337 0x53, 0x00, 0x30, 0x00,
338 0x00 // Entity Name "S0"
339 };
340 rc = mockTerminusManager.enqueueResponse(
341 reinterpret_cast<pldm_msg*>(getPdrAuxNameResp.data()),
342 sizeof(getPdrAuxNameResp));
343 EXPECT_EQ(rc, PLDM_SUCCESS);
344
345 stdexec::sync_wait(platformManager.initTerminus());
346 EXPECT_EQ(true, terminus->initialized);
347 EXPECT_EQ(2, terminus->pdrs.size());
348 EXPECT_EQ("S0", terminus->getTerminusName());
349}
350
Gilbert Chende2a1322022-05-24 15:35:21 +0100351TEST_F(PlatformManagerTest, initTerminusDontSupportGetPDRTest)
352{
353 // Add terminus
354 auto mappedTid = mockTerminusManager.mapTid(pldm::MctpInfo(10, "", "", 1));
355 auto tid = mappedTid.value();
356 termini[tid] = std::make_shared<pldm::platform_mc::Terminus>(
357 tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
358 auto terminus = termini[tid];
359
360 /* Set supported command by terminus */
361 auto size = PLDM_MAX_TYPES * (PLDM_MAX_CMDS_PER_TYPE / 8);
362 std::vector<uint8_t> pldmCmds(size);
363 uint8_t type = PLDM_PLATFORM;
364 uint8_t cmd = PLDM_GET_PDR_REPOSITORY_INFO;
365 auto idx = type * (PLDM_MAX_CMDS_PER_TYPE / 8) + (cmd / 8);
366 pldmCmds[idx] = pldmCmds[idx] | (1 << (cmd % 8));
367 termini[tid]->setSupportedCommands(pldmCmds);
368
369 // queue getPDRRepositoryInfo response
370 const size_t getPDRRepositoryInfoLen =
371 PLDM_GET_PDR_REPOSITORY_INFO_RESP_BYTES;
372 std::array<uint8_t, sizeof(pldm_msg_hdr) + getPDRRepositoryInfoLen>
373 getPDRRepositoryInfoResp{
374 0x0, 0x02, 0x50, PLDM_SUCCESS,
375 0x0, // repositoryState
376 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
377 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // updateTime
378 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
379 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // OEMUpdateTime
380 1, 0x0, 0x0, 0x0, // recordCount
381 0x0, 0x1, 0x0, 0x0, // repositorySize
382 59, 0x0, 0x0, 0x0, // largestRecordSize
383 0x0 // dataTransferHandleTimeout
384 };
385 auto rc = mockTerminusManager.enqueueResponse(
Thu Nguyen98831af2024-07-30 09:51:00 +0000386 reinterpret_cast<pldm_msg*>(getPDRRepositoryInfoResp.data()),
Gilbert Chende2a1322022-05-24 15:35:21 +0100387 sizeof(getPDRRepositoryInfoResp));
388 EXPECT_EQ(rc, PLDM_SUCCESS);
389
390 // queue getPDR responses
391 const size_t getPdrRespLen = 81;
392 std::array<uint8_t, sizeof(pldm_msg_hdr) + getPdrRespLen> getPdrResp{
393 0x0, 0x02, 0x51, PLDM_SUCCESS, 0x0, 0x0, 0x0, 0x0, // nextRecordHandle
394 0x0, 0x0, 0x0, 0x0, // nextDataTransferHandle
395 0x5, // transferFlag
396 69, 0x0, // responseCount
397 // numeric Sensor PDR
398 0x1, 0x0, 0x0,
399 0x0, // record handle
400 0x1, // PDRHeaderVersion
401 PLDM_NUMERIC_SENSOR_PDR, // PDRType
402 0x0,
403 0x0, // recordChangeNumber
404 PLDM_PDR_NUMERIC_SENSOR_PDR_FIXED_LENGTH +
405 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_SENSOR_DATA_SIZE_MIN_LENGTH +
406 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_RANGE_FIELD_MIN_LENGTH,
407 0, // dataLength
408 0,
409 0, // PLDMTerminusHandle
410 0x1,
411 0x0, // sensorID=1
412 120,
413 0, // entityType=Power Supply(120)
414 1,
415 0, // entityInstanceNumber
416 0x1,
417 0x0, // containerID=1
418 PLDM_NO_INIT, // sensorInit
419 false, // sensorAuxiliaryNamesPDR
420 PLDM_SENSOR_UNIT_DEGRESS_C, // baseUint(2)=degrees C
421 1, // unitModifier = 1
422 0, // rateUnit
423 0, // baseOEMUnitHandle
424 0, // auxUnit
425 0, // auxUnitModifier
426 0, // auxRateUnit
427 0, // rel
428 0, // auxOEMUnitHandle
429 true, // isLinear
430 PLDM_SENSOR_DATA_SIZE_UINT8, // sensorDataSize
431 0, 0, 0xc0,
432 0x3f, // resolution=1.5
433 0, 0, 0x80,
434 0x3f, // offset=1.0
435 0,
436 0, // accuracy
437 0, // plusTolerance
438 0, // minusTolerance
439 2, // hysteresis
440 0, // supportedThresholds
441 0, // thresholdAndHysteresisVolatility
442 0, 0, 0x80,
443 0x3f, // stateTransistionInterval=1.0
444 0, 0, 0x80,
445 0x3f, // updateInverval=1.0
446 255, // maxReadable
447 0, // minReadable
448 PLDM_RANGE_FIELD_FORMAT_UINT8, // rangeFieldFormat
449 0, // rangeFieldsupport
450 0, // nominalValue
451 0, // normalMax
452 0, // normalMin
453 0, // warningHigh
454 0, // warningLow
455 0, // criticalHigh
456 0, // criticalLow
457 0, // fatalHigh
458 0 // fatalLow
459 };
Thu Nguyen98831af2024-07-30 09:51:00 +0000460 rc = mockTerminusManager.enqueueResponse(
461 reinterpret_cast<pldm_msg*>(getPdrResp.data()), sizeof(getPdrResp));
Gilbert Chende2a1322022-05-24 15:35:21 +0100462 EXPECT_EQ(rc, PLDM_SUCCESS);
463
464 stdexec::sync_wait(platformManager.initTerminus());
465 EXPECT_EQ(true, terminus->initialized);
466 EXPECT_EQ(0, terminus->pdrs.size());
467}
468
469TEST_F(PlatformManagerTest, negativeInitTerminusTest1)
470{
471 // terminus doesn't Type2 support
472 auto mappedTid = mockTerminusManager.mapTid(pldm::MctpInfo(10, "", "", 1));
473 auto tid = mappedTid.value();
474 termini[tid] =
475 std::make_shared<pldm::platform_mc::Terminus>(tid, 1 << PLDM_BASE);
476 auto terminus = termini[tid];
477
478 stdexec::sync_wait(platformManager.initTerminus());
479 EXPECT_EQ(true, terminus->initialized);
480 EXPECT_EQ(0, terminus->pdrs.size());
Gilbert Cheneac61a42022-02-23 20:56:19 +0000481 EXPECT_EQ(0, terminus->numericSensors.size());
Gilbert Chende2a1322022-05-24 15:35:21 +0100482}
483
484TEST_F(PlatformManagerTest, negativeInitTerminusTest2)
485{
486 // terminus responses error
487 auto mappedTid = mockTerminusManager.mapTid(pldm::MctpInfo(10, "", "", 1));
488 auto tid = mappedTid.value();
489 termini[tid] = std::make_shared<pldm::platform_mc::Terminus>(
490 tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
491 auto terminus = termini[tid];
492
493 // queue getPDRRepositoryInfo response cc=PLDM_ERROR
494 const size_t getPDRRepositoryInfoLen = 1;
495 std::array<uint8_t, sizeof(pldm_msg_hdr) + getPDRRepositoryInfoLen>
496 getPDRRepositoryInfoResp{0x0, 0x02, 0x50, PLDM_ERROR};
497 auto rc = mockTerminusManager.enqueueResponse(
Thu Nguyen98831af2024-07-30 09:51:00 +0000498 reinterpret_cast<pldm_msg*>(getPDRRepositoryInfoResp.data()),
Gilbert Chende2a1322022-05-24 15:35:21 +0100499 sizeof(getPDRRepositoryInfoResp));
500 EXPECT_EQ(rc, PLDM_SUCCESS);
501
502 // queue getPDR responses cc=PLDM_ERROR
503 const size_t getPdrRespLen = 1;
504 std::array<uint8_t, sizeof(pldm_msg_hdr) + getPdrRespLen> getPdrResp{
505 0x0, 0x02, 0x51, PLDM_ERROR};
Thu Nguyen98831af2024-07-30 09:51:00 +0000506 rc = mockTerminusManager.enqueueResponse(
507 reinterpret_cast<pldm_msg*>(getPdrResp.data()), sizeof(getPdrResp));
Gilbert Chende2a1322022-05-24 15:35:21 +0100508 EXPECT_EQ(rc, PLDM_SUCCESS);
509
510 stdexec::sync_wait(platformManager.initTerminus());
511 EXPECT_EQ(true, terminus->initialized);
512 EXPECT_EQ(0, terminus->pdrs.size());
Gilbert Cheneac61a42022-02-23 20:56:19 +0000513 EXPECT_EQ(0, terminus->numericSensors.size());
Gilbert Chende2a1322022-05-24 15:35:21 +0100514}