Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 1 | #include <array> |
| 2 | |
| 3 | #include "libpldm/pdr.h" |
| 4 | #include "libpldm/platform.h" |
| 5 | |
| 6 | #include <gtest/gtest.h> |
| 7 | |
| 8 | TEST(PDRAccess, testInit) |
| 9 | { |
| 10 | auto repo = pldm_pdr_init(); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 11 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 0u); |
| 12 | EXPECT_EQ(pldm_pdr_get_repo_size(repo), 0u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 13 | pldm_pdr_destroy(repo); |
| 14 | } |
| 15 | |
| 16 | TEST(PDRUpdate, testAdd) |
| 17 | { |
| 18 | auto repo = pldm_pdr_init(); |
| 19 | |
| 20 | std::array<uint8_t, 10> data{}; |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 21 | auto handle = pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 22 | EXPECT_EQ(handle, 1u); |
| 23 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 24 | EXPECT_EQ(pldm_pdr_get_repo_size(repo), data.size()); |
| 25 | |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 26 | handle = pldm_pdr_add(repo, data.data(), data.size(), 0u, false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 27 | EXPECT_EQ(handle, 2u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 28 | handle = pldm_pdr_add(repo, data.data(), data.size(), 0u, false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 29 | EXPECT_EQ(handle, 3u); |
| 30 | handle = pldm_pdr_add(repo, data.data(), data.size(), htole32(0xdeeddeedu), |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 31 | false, 1); |
Lei YU | 90ff3ed | 2020-03-02 11:16:51 +0800 | [diff] [blame] | 32 | EXPECT_EQ(handle, htole32(0xdeeddeed)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 33 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 4u); |
| 34 | EXPECT_EQ(pldm_pdr_get_repo_size(repo), data.size() * 4u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 35 | |
| 36 | pldm_pdr_destroy(repo); |
| 37 | } |
| 38 | |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 39 | TEST(PDRRemoveByTerminus, testRemoveByTerminus) |
| 40 | { |
| 41 | std::array<uint8_t, 10> data{}; |
| 42 | |
| 43 | auto repo = pldm_pdr_init(); |
| 44 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 45 | pldm_pdr_remove_pdrs_by_terminus_handle(repo, 1); |
| 46 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 0u); |
| 47 | pldm_pdr_destroy(repo); |
| 48 | |
| 49 | repo = pldm_pdr_init(); |
| 50 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 2); |
| 51 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 52 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 2u); |
| 53 | pldm_pdr_remove_pdrs_by_terminus_handle(repo, 1); |
| 54 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
| 55 | pldm_pdr_destroy(repo); |
| 56 | |
| 57 | repo = pldm_pdr_init(); |
| 58 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 59 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 2); |
| 60 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 2); |
| 61 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 3u); |
| 62 | pldm_pdr_remove_pdrs_by_terminus_handle(repo, 2); |
| 63 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
| 64 | pldm_pdr_destroy(repo); |
| 65 | |
| 66 | repo = pldm_pdr_init(); |
| 67 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 68 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 2); |
| 69 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 70 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 3u); |
| 71 | pldm_pdr_remove_remote_pdrs(repo); |
| 72 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
| 73 | pldm_pdr_remove_pdrs_by_terminus_handle(repo, 1); |
| 74 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
| 75 | pldm_pdr_remove_pdrs_by_terminus_handle(repo, 2); |
| 76 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 0u); |
| 77 | pldm_pdr_destroy(repo); |
| 78 | } |
| 79 | |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 80 | TEST(PDRUpdate, testRemove) |
| 81 | { |
| 82 | std::array<uint8_t, 10> data{}; |
| 83 | |
| 84 | auto repo = pldm_pdr_init(); |
| 85 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 86 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 0u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 87 | pldm_pdr_destroy(repo); |
| 88 | |
| 89 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 90 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 91 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 92 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 0u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 93 | pldm_pdr_destroy(repo); |
| 94 | |
| 95 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 96 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 97 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 98 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 99 | pldm_pdr_destroy(repo); |
| 100 | |
| 101 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 102 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 103 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 104 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 105 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 106 | pldm_pdr_destroy(repo); |
| 107 | |
| 108 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 109 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 110 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 111 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 112 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 113 | pldm_pdr_destroy(repo); |
| 114 | |
| 115 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 116 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 117 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 118 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 119 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 120 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 121 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 0u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 122 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 123 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 124 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 2u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 125 | pldm_pdr_destroy(repo); |
| 126 | |
| 127 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 128 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 129 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 130 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 131 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 132 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 133 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 4u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 134 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 135 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 136 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 6u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 137 | pldm_pdr_destroy(repo); |
| 138 | |
| 139 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 140 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 141 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 142 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 143 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 144 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 145 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 3u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 146 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 147 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 148 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 5u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 149 | pldm_pdr_destroy(repo); |
| 150 | |
| 151 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 152 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 153 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 154 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 155 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 156 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 157 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 3u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 158 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 159 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 160 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 5u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 161 | pldm_pdr_destroy(repo); |
| 162 | |
| 163 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 164 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 165 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 166 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 167 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 168 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 169 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 2u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 170 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 171 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 172 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 4u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 173 | pldm_pdr_destroy(repo); |
| 174 | |
| 175 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 176 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 177 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 178 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 179 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 180 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 181 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 3u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 182 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 183 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 184 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 5u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 185 | pldm_pdr_destroy(repo); |
| 186 | |
| 187 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 188 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 189 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 190 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 191 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 192 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 193 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 2u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 194 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 195 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 196 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 4u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 197 | pldm_pdr_destroy(repo); |
| 198 | |
| 199 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 200 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 201 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 202 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 203 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 204 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 205 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 206 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 207 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 208 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 3u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 209 | pldm_pdr_destroy(repo); |
| 210 | |
| 211 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 212 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 213 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 214 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 215 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 216 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 217 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 218 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 219 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 220 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 3u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 221 | pldm_pdr_destroy(repo); |
| 222 | |
| 223 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 224 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 225 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 226 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 227 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 228 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 229 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 2u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 230 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 231 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 232 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 4u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 233 | pldm_pdr_destroy(repo); |
| 234 | |
| 235 | repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 236 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
| 237 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 238 | pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
| 239 | pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 240 | pldm_pdr_remove_remote_pdrs(repo); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 241 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 2u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 242 | auto handle = pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 243 | EXPECT_EQ(handle, 3u); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 244 | handle = pldm_pdr_add(repo, data.data(), data.size(), 0, true, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 245 | EXPECT_EQ(handle, 4u); |
| 246 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 4u); |
Deepak Kodihalli | 4a68093 | 2020-04-22 03:31:17 -0500 | [diff] [blame] | 247 | pldm_pdr_destroy(repo); |
| 248 | } |
| 249 | |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 250 | TEST(PDRAccess, testGet) |
| 251 | { |
| 252 | auto repo = pldm_pdr_init(); |
| 253 | |
| 254 | std::array<uint32_t, 10> in{100, 345, 3, 6, 89, 0, 11, 45, 23434, 123123}; |
Deepak Kodihalli | 87514cc | 2020-04-16 09:08:38 -0500 | [diff] [blame] | 255 | pldm_pdr_add(repo, reinterpret_cast<uint8_t*>(in.data()), sizeof(in), 1, |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 256 | false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 257 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 258 | EXPECT_EQ(pldm_pdr_get_repo_size(repo), sizeof(in)); |
| 259 | uint32_t size{}; |
| 260 | uint32_t nextRecHdl{}; |
| 261 | uint8_t* outData = nullptr; |
| 262 | auto hdl = pldm_pdr_find_record(repo, 0, &outData, &size, &nextRecHdl); |
| 263 | EXPECT_NE(hdl, nullptr); |
| 264 | EXPECT_EQ(size, sizeof(in)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 265 | EXPECT_EQ(nextRecHdl, 0u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 266 | EXPECT_EQ(memcmp(outData, in.data(), sizeof(in)), 0); |
| 267 | outData = nullptr; |
| 268 | |
| 269 | auto hdl2 = pldm_pdr_find_record(repo, 1, &outData, &size, &nextRecHdl); |
| 270 | EXPECT_EQ(hdl, hdl2); |
| 271 | EXPECT_NE(hdl, nullptr); |
| 272 | EXPECT_EQ(size, sizeof(in)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 273 | EXPECT_EQ(nextRecHdl, 0u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 274 | EXPECT_EQ(memcmp(outData, in.data(), sizeof(in)), 0); |
| 275 | outData = nullptr; |
| 276 | |
Lei YU | 7cfeb8e | 2020-02-27 18:24:18 +0800 | [diff] [blame] | 277 | hdl = pldm_pdr_find_record(repo, htole32(0xdeaddead), &outData, &size, |
| 278 | &nextRecHdl); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 279 | EXPECT_EQ(hdl, nullptr); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 280 | EXPECT_EQ(size, 0u); |
| 281 | EXPECT_EQ(nextRecHdl, 0u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 282 | EXPECT_EQ(outData, nullptr); |
| 283 | outData = nullptr; |
| 284 | |
| 285 | std::array<uint32_t, 10> in2{1000, 3450, 30, 60, 890, |
| 286 | 0, 110, 450, 234034, 123123}; |
Deepak Kodihalli | 87514cc | 2020-04-16 09:08:38 -0500 | [diff] [blame] | 287 | pldm_pdr_add(repo, reinterpret_cast<uint8_t*>(in2.data()), sizeof(in2), 2, |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 288 | false, 1); |
Deepak Kodihalli | 87514cc | 2020-04-16 09:08:38 -0500 | [diff] [blame] | 289 | pldm_pdr_add(repo, reinterpret_cast<uint8_t*>(in2.data()), sizeof(in2), 3, |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 290 | false, 1); |
Deepak Kodihalli | 87514cc | 2020-04-16 09:08:38 -0500 | [diff] [blame] | 291 | pldm_pdr_add(repo, reinterpret_cast<uint8_t*>(in2.data()), sizeof(in2), 4, |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 292 | true, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 293 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 4u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 294 | EXPECT_EQ(pldm_pdr_get_repo_size(repo), sizeof(in2) * 4); |
| 295 | hdl = pldm_pdr_find_record(repo, 0, &outData, &size, &nextRecHdl); |
| 296 | EXPECT_NE(hdl, nullptr); |
| 297 | EXPECT_EQ(size, sizeof(in)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 298 | EXPECT_EQ(nextRecHdl, 2u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 299 | EXPECT_EQ(memcmp(outData, in.data(), sizeof(in)), 0); |
| 300 | outData = nullptr; |
| 301 | hdl2 = pldm_pdr_find_record(repo, 1, &outData, &size, &nextRecHdl); |
| 302 | EXPECT_EQ(hdl, hdl2); |
| 303 | EXPECT_NE(hdl, nullptr); |
| 304 | EXPECT_EQ(size, sizeof(in)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 305 | EXPECT_EQ(nextRecHdl, 2u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 306 | EXPECT_EQ(memcmp(outData, in.data(), sizeof(in)), 0); |
| 307 | outData = nullptr; |
| 308 | hdl = pldm_pdr_find_record(repo, 2, &outData, &size, &nextRecHdl); |
| 309 | EXPECT_NE(hdl, nullptr); |
| 310 | EXPECT_EQ(size, sizeof(in2)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 311 | EXPECT_EQ(nextRecHdl, 3u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 312 | EXPECT_EQ(memcmp(outData, in2.data(), sizeof(in2)), 0); |
| 313 | outData = nullptr; |
| 314 | hdl = pldm_pdr_find_record(repo, 3, &outData, &size, &nextRecHdl); |
| 315 | EXPECT_NE(hdl, nullptr); |
Deepak Kodihalli | 87514cc | 2020-04-16 09:08:38 -0500 | [diff] [blame] | 316 | EXPECT_EQ(pldm_pdr_record_is_remote(hdl), false); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 317 | EXPECT_EQ(size, sizeof(in2)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 318 | EXPECT_EQ(nextRecHdl, 4u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 319 | EXPECT_EQ(memcmp(outData, in2.data(), sizeof(in2)), 0); |
| 320 | outData = nullptr; |
| 321 | hdl = pldm_pdr_find_record(repo, 4, &outData, &size, &nextRecHdl); |
| 322 | EXPECT_NE(hdl, nullptr); |
Deepak Kodihalli | 87514cc | 2020-04-16 09:08:38 -0500 | [diff] [blame] | 323 | EXPECT_EQ(pldm_pdr_record_is_remote(hdl), true); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 324 | EXPECT_EQ(size, sizeof(in2)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 325 | EXPECT_EQ(nextRecHdl, 0u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 326 | EXPECT_EQ(memcmp(outData, in2.data(), sizeof(in2)), 0); |
| 327 | outData = nullptr; |
| 328 | |
| 329 | pldm_pdr_destroy(repo); |
| 330 | } |
| 331 | |
| 332 | TEST(PDRAccess, testGetNext) |
| 333 | { |
| 334 | auto repo = pldm_pdr_init(); |
| 335 | |
| 336 | std::array<uint32_t, 10> in{100, 345, 3, 6, 89, 0, 11, 45, 23434, 123123}; |
Deepak Kodihalli | 87514cc | 2020-04-16 09:08:38 -0500 | [diff] [blame] | 337 | pldm_pdr_add(repo, reinterpret_cast<uint8_t*>(in.data()), sizeof(in), 1, |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 338 | false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 339 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 340 | EXPECT_EQ(pldm_pdr_get_repo_size(repo), sizeof(in)); |
| 341 | uint32_t size{}; |
| 342 | uint32_t nextRecHdl{}; |
| 343 | uint8_t* outData = nullptr; |
| 344 | auto hdl = pldm_pdr_find_record(repo, 0, &outData, &size, &nextRecHdl); |
| 345 | EXPECT_NE(hdl, nullptr); |
| 346 | EXPECT_EQ(size, sizeof(in)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 347 | EXPECT_EQ(nextRecHdl, 0u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 348 | EXPECT_EQ(memcmp(outData, in.data(), sizeof(in)), 0); |
| 349 | outData = nullptr; |
| 350 | |
| 351 | std::array<uint32_t, 10> in2{1000, 3450, 30, 60, 890, |
| 352 | 0, 110, 450, 234034, 123123}; |
Deepak Kodihalli | 87514cc | 2020-04-16 09:08:38 -0500 | [diff] [blame] | 353 | pldm_pdr_add(repo, reinterpret_cast<uint8_t*>(in2.data()), sizeof(in2), 2, |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 354 | false, 1); |
Deepak Kodihalli | 87514cc | 2020-04-16 09:08:38 -0500 | [diff] [blame] | 355 | pldm_pdr_add(repo, reinterpret_cast<uint8_t*>(in2.data()), sizeof(in2), 3, |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 356 | false, 1); |
Deepak Kodihalli | 87514cc | 2020-04-16 09:08:38 -0500 | [diff] [blame] | 357 | pldm_pdr_add(repo, reinterpret_cast<uint8_t*>(in2.data()), sizeof(in2), 4, |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 358 | false, 1); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 359 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 4u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 360 | EXPECT_EQ(pldm_pdr_get_repo_size(repo), sizeof(in2) * 4); |
| 361 | hdl = pldm_pdr_get_next_record(repo, hdl, &outData, &size, &nextRecHdl); |
| 362 | EXPECT_NE(hdl, nullptr); |
| 363 | EXPECT_EQ(size, sizeof(in2)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 364 | EXPECT_EQ(nextRecHdl, 3u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 365 | EXPECT_EQ(memcmp(outData, in2.data(), sizeof(in2)), 0); |
| 366 | outData = nullptr; |
| 367 | hdl = pldm_pdr_get_next_record(repo, hdl, &outData, &size, &nextRecHdl); |
| 368 | EXPECT_NE(hdl, nullptr); |
| 369 | EXPECT_EQ(size, sizeof(in2)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 370 | EXPECT_EQ(nextRecHdl, 4u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 371 | EXPECT_EQ(memcmp(outData, in2.data(), sizeof(in2)), 0); |
| 372 | outData = nullptr; |
| 373 | hdl = pldm_pdr_get_next_record(repo, hdl, &outData, &size, &nextRecHdl); |
| 374 | EXPECT_NE(hdl, nullptr); |
| 375 | EXPECT_EQ(size, sizeof(in2)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 376 | EXPECT_EQ(nextRecHdl, 0u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 377 | EXPECT_EQ(memcmp(outData, in2.data(), sizeof(in2)), 0); |
| 378 | outData = nullptr; |
| 379 | |
| 380 | pldm_pdr_destroy(repo); |
| 381 | } |
| 382 | |
| 383 | TEST(PDRAccess, testFindByType) |
| 384 | { |
| 385 | auto repo = pldm_pdr_init(); |
| 386 | |
| 387 | std::array<uint8_t, sizeof(pldm_pdr_hdr)> data{}; |
| 388 | pldm_pdr_hdr* hdr = reinterpret_cast<pldm_pdr_hdr*>(data.data()); |
| 389 | hdr->type = 1; |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 390 | auto first = pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 391 | hdr->type = 2; |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 392 | auto second = pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 393 | hdr->type = 3; |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 394 | auto third = pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 395 | hdr->type = 4; |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 396 | auto fourth = pldm_pdr_add(repo, data.data(), data.size(), 0, false, 1); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 397 | |
| 398 | uint8_t* outData = nullptr; |
| 399 | uint32_t size{}; |
| 400 | auto firstRec = |
| 401 | pldm_pdr_find_record_by_type(repo, 1, nullptr, &outData, &size); |
| 402 | EXPECT_EQ(pldm_pdr_get_record_handle(repo, firstRec), first); |
| 403 | outData = nullptr; |
| 404 | auto secondRec = |
| 405 | pldm_pdr_find_record_by_type(repo, 2, nullptr, &outData, &size); |
| 406 | EXPECT_EQ(pldm_pdr_get_record_handle(repo, secondRec), second); |
| 407 | outData = nullptr; |
| 408 | auto thirdRec = |
| 409 | pldm_pdr_find_record_by_type(repo, 3, nullptr, &outData, &size); |
| 410 | EXPECT_EQ(pldm_pdr_get_record_handle(repo, thirdRec), third); |
| 411 | outData = nullptr; |
| 412 | auto fourthRec = |
| 413 | pldm_pdr_find_record_by_type(repo, 4, nullptr, &outData, &size); |
| 414 | EXPECT_EQ(pldm_pdr_get_record_handle(repo, fourthRec), fourth); |
| 415 | outData = nullptr; |
| 416 | auto fifthRec = |
| 417 | pldm_pdr_find_record_by_type(repo, 5, nullptr, &outData, &size); |
| 418 | EXPECT_EQ(fifthRec, nullptr); |
| 419 | EXPECT_EQ(outData, nullptr); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 420 | EXPECT_EQ(size, 0u); |
Deepak Kodihalli | 3b02ed8 | 2020-02-06 01:18:25 -0600 | [diff] [blame] | 421 | |
| 422 | auto rec = |
| 423 | pldm_pdr_find_record_by_type(repo, 3, secondRec, &outData, &size); |
| 424 | EXPECT_EQ(pldm_pdr_get_record_handle(repo, rec), third); |
| 425 | outData = nullptr; |
| 426 | rec = pldm_pdr_find_record_by_type(repo, 4, secondRec, &outData, &size); |
| 427 | EXPECT_EQ(pldm_pdr_get_record_handle(repo, rec), fourth); |
| 428 | outData = nullptr; |
| 429 | rec = pldm_pdr_find_record_by_type(repo, 2, firstRec, &outData, &size); |
| 430 | EXPECT_EQ(pldm_pdr_get_record_handle(repo, rec), second); |
| 431 | outData = nullptr; |
| 432 | |
| 433 | pldm_pdr_destroy(repo); |
| 434 | } |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 435 | |
| 436 | TEST(PDRUpdate, testAddFruRecordSet) |
| 437 | { |
| 438 | auto repo = pldm_pdr_init(); |
| 439 | |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 440 | auto handle = pldm_pdr_add_fru_record_set(repo, 1, 10, 1, 0, 100, 0); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 441 | EXPECT_EQ(handle, 1u); |
| 442 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 1u); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 443 | EXPECT_EQ(pldm_pdr_get_repo_size(repo), |
| 444 | sizeof(pldm_pdr_hdr) + sizeof(pldm_pdr_fru_record_set)); |
| 445 | uint32_t size{}; |
| 446 | uint32_t nextRecHdl{}; |
| 447 | uint8_t* outData = nullptr; |
| 448 | auto hdl = pldm_pdr_find_record(repo, 0, &outData, &size, &nextRecHdl); |
| 449 | EXPECT_NE(hdl, nullptr); |
| 450 | EXPECT_EQ(size, sizeof(pldm_pdr_hdr) + sizeof(pldm_pdr_fru_record_set)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 451 | EXPECT_EQ(nextRecHdl, 0u); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 452 | pldm_pdr_hdr* hdr = reinterpret_cast<pldm_pdr_hdr*>(outData); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 453 | EXPECT_EQ(hdr->version, 1u); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 454 | EXPECT_EQ(hdr->type, PLDM_PDR_FRU_RECORD_SET); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 455 | EXPECT_EQ(hdr->length, htole16(sizeof(pldm_pdr_fru_record_set))); |
| 456 | EXPECT_EQ(hdr->record_handle, htole32(1)); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 457 | pldm_pdr_fru_record_set* fru = reinterpret_cast<pldm_pdr_fru_record_set*>( |
| 458 | outData + sizeof(pldm_pdr_hdr)); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 459 | EXPECT_EQ(fru->terminus_handle, htole16(1)); |
| 460 | EXPECT_EQ(fru->fru_rsi, htole16(10)); |
| 461 | EXPECT_EQ(fru->entity_type, htole16(1)); |
| 462 | EXPECT_EQ(fru->entity_instance_num, htole16(0)); |
| 463 | EXPECT_EQ(fru->container_id, htole16(100)); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 464 | outData = nullptr; |
| 465 | |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 466 | handle = pldm_pdr_add_fru_record_set(repo, 2, 11, 2, 1, 101, 0); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 467 | EXPECT_EQ(handle, 2u); |
| 468 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 2u); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 469 | EXPECT_EQ(pldm_pdr_get_repo_size(repo), |
| 470 | 2 * (sizeof(pldm_pdr_hdr) + sizeof(pldm_pdr_fru_record_set))); |
| 471 | hdl = pldm_pdr_find_record(repo, 2, &outData, &size, &nextRecHdl); |
| 472 | EXPECT_NE(hdl, nullptr); |
| 473 | EXPECT_EQ(size, sizeof(pldm_pdr_hdr) + sizeof(pldm_pdr_fru_record_set)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 474 | EXPECT_EQ(nextRecHdl, 0u); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 475 | hdr = reinterpret_cast<pldm_pdr_hdr*>(outData); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 476 | EXPECT_EQ(hdr->version, 1u); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 477 | EXPECT_EQ(hdr->type, PLDM_PDR_FRU_RECORD_SET); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 478 | EXPECT_EQ(hdr->length, htole16(sizeof(pldm_pdr_fru_record_set))); |
| 479 | EXPECT_EQ(hdr->record_handle, htole32(2)); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 480 | fru = reinterpret_cast<pldm_pdr_fru_record_set*>(outData + |
| 481 | sizeof(pldm_pdr_hdr)); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 482 | EXPECT_EQ(fru->terminus_handle, htole16(2)); |
| 483 | EXPECT_EQ(fru->fru_rsi, htole16(11)); |
| 484 | EXPECT_EQ(fru->entity_type, htole16(2)); |
| 485 | EXPECT_EQ(fru->entity_instance_num, htole16(1)); |
| 486 | EXPECT_EQ(fru->container_id, htole16(101)); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 487 | outData = nullptr; |
| 488 | |
| 489 | hdl = pldm_pdr_find_record(repo, 1, &outData, &size, &nextRecHdl); |
| 490 | EXPECT_NE(hdl, nullptr); |
| 491 | EXPECT_EQ(size, sizeof(pldm_pdr_hdr) + sizeof(pldm_pdr_fru_record_set)); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 492 | EXPECT_EQ(nextRecHdl, 2u); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 493 | hdr = reinterpret_cast<pldm_pdr_hdr*>(outData); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 494 | EXPECT_EQ(hdr->version, 1u); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 495 | EXPECT_EQ(hdr->type, PLDM_PDR_FRU_RECORD_SET); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 496 | EXPECT_EQ(hdr->length, htole16(sizeof(pldm_pdr_fru_record_set))); |
| 497 | EXPECT_EQ(hdr->record_handle, htole32(1)); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 498 | fru = reinterpret_cast<pldm_pdr_fru_record_set*>(outData + |
| 499 | sizeof(pldm_pdr_hdr)); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 500 | EXPECT_EQ(fru->terminus_handle, htole16(1)); |
| 501 | EXPECT_EQ(fru->fru_rsi, htole16(10)); |
| 502 | EXPECT_EQ(fru->entity_type, htole16(1)); |
| 503 | EXPECT_EQ(fru->entity_instance_num, htole16(0)); |
| 504 | EXPECT_EQ(fru->container_id, htole16(100)); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 505 | outData = nullptr; |
| 506 | |
| 507 | pldm_pdr_destroy(repo); |
| 508 | } |
| 509 | |
| 510 | TEST(PDRUpdate, tesFindtFruRecordSet) |
| 511 | { |
| 512 | auto repo = pldm_pdr_init(); |
| 513 | |
| 514 | uint16_t terminusHdl{}; |
| 515 | uint16_t entityType{}; |
| 516 | uint16_t entityInstanceNum{}; |
| 517 | uint16_t containerId{}; |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 518 | auto first = pldm_pdr_add_fru_record_set(repo, 1, 1, 1, 0, 100, 1); |
| 519 | auto second = pldm_pdr_add_fru_record_set(repo, 1, 2, 1, 1, 100, 2); |
| 520 | auto third = pldm_pdr_add_fru_record_set(repo, 1, 3, 1, 2, 100, 3); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 521 | EXPECT_EQ(first, pldm_pdr_get_record_handle( |
| 522 | repo, pldm_pdr_fru_record_set_find_by_rsi( |
| 523 | repo, 1, &terminusHdl, &entityType, |
| 524 | &entityInstanceNum, &containerId))); |
| 525 | EXPECT_EQ(second, pldm_pdr_get_record_handle( |
| 526 | repo, pldm_pdr_fru_record_set_find_by_rsi( |
| 527 | repo, 2, &terminusHdl, &entityType, |
| 528 | &entityInstanceNum, &containerId))); |
| 529 | EXPECT_EQ(third, pldm_pdr_get_record_handle( |
| 530 | repo, pldm_pdr_fru_record_set_find_by_rsi( |
| 531 | repo, 3, &terminusHdl, &entityType, |
| 532 | &entityInstanceNum, &containerId))); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 533 | EXPECT_EQ(terminusHdl, 1u); |
| 534 | EXPECT_EQ(entityType, 1u); |
| 535 | EXPECT_EQ(entityInstanceNum, 2u); |
| 536 | EXPECT_EQ(containerId, 100u); |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 537 | EXPECT_EQ(nullptr, pldm_pdr_fru_record_set_find_by_rsi( |
| 538 | repo, 4, &terminusHdl, &entityType, |
| 539 | &entityInstanceNum, &containerId)); |
| 540 | |
| 541 | pldm_pdr_destroy(repo); |
| 542 | } |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 543 | |
| 544 | TEST(EntityAssociationPDR, testInit) |
| 545 | { |
| 546 | auto tree = pldm_entity_association_tree_init(); |
| 547 | EXPECT_NE(tree, nullptr); |
| 548 | pldm_entity_association_tree_destroy(tree); |
| 549 | } |
| 550 | |
| 551 | TEST(EntityAssociationPDR, testBuild) |
| 552 | { |
| 553 | // 1 |
| 554 | // | |
| 555 | // 2--3--4 |
| 556 | // | |
| 557 | // 5--6--7 |
| 558 | // | | |
| 559 | // 9 8 |
| 560 | |
| 561 | pldm_entity entities[9]{}; |
| 562 | |
| 563 | entities[0].entity_type = 1; |
| 564 | entities[1].entity_type = 2; |
| 565 | entities[2].entity_type = 2; |
| 566 | entities[3].entity_type = 3; |
| 567 | entities[4].entity_type = 4; |
| 568 | entities[5].entity_type = 5; |
| 569 | entities[6].entity_type = 5; |
| 570 | entities[7].entity_type = 6; |
| 571 | entities[8].entity_type = 7; |
| 572 | |
| 573 | auto tree = pldm_entity_association_tree_init(); |
| 574 | |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 575 | auto l1 = pldm_entity_association_tree_add( |
| 576 | tree, &entities[0], 0xFFFF, nullptr, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 577 | EXPECT_NE(l1, nullptr); |
| 578 | auto l2a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 579 | tree, &entities[1], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 580 | EXPECT_NE(l2a, nullptr); |
| 581 | auto l2b = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 582 | tree, &entities[2], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 583 | EXPECT_NE(l2b, nullptr); |
| 584 | auto l2c = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 585 | tree, &entities[3], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 586 | EXPECT_NE(l2c, nullptr); |
| 587 | auto l3a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 588 | tree, &entities[4], 0xFFFF, l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 589 | EXPECT_NE(l3a, nullptr); |
| 590 | auto l3b = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 591 | tree, &entities[5], 0xFFFF, l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 592 | EXPECT_NE(l3b, nullptr); |
| 593 | auto l3c = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 594 | tree, &entities[6], 0xFFFF, l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 595 | EXPECT_NE(l3b, nullptr); |
| 596 | auto l4a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 597 | tree, &entities[7], 0xFFFF, l3a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 598 | EXPECT_NE(l4a, nullptr); |
| 599 | auto l4b = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 600 | tree, &entities[8], 0xFFFF, l3b, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 601 | EXPECT_NE(l4b, nullptr); |
| 602 | |
| 603 | EXPECT_EQ(pldm_entity_is_node_parent(l1), true); |
| 604 | EXPECT_EQ(pldm_entity_is_node_parent(l2a), true); |
| 605 | EXPECT_EQ(pldm_entity_is_node_parent(l3a), true); |
| 606 | EXPECT_EQ(pldm_entity_is_node_parent(l3b), true); |
| 607 | |
| 608 | EXPECT_EQ(pldm_entity_is_node_parent(l2b), false); |
| 609 | EXPECT_EQ(pldm_entity_is_node_parent(l2c), false); |
| 610 | EXPECT_EQ(pldm_entity_is_node_parent(l3c), false); |
| 611 | EXPECT_EQ(pldm_entity_is_node_parent(l4a), false); |
| 612 | EXPECT_EQ(pldm_entity_is_node_parent(l4b), false); |
| 613 | |
George Liu | b6b3cf3 | 2021-06-07 16:30:59 +0800 | [diff] [blame] | 614 | EXPECT_EQ(pldm_entity_is_exist_parent(l1), false); |
George Liu | fe77eea | 2021-04-28 15:08:07 +0800 | [diff] [blame] | 615 | |
George Liu | b6b3cf3 | 2021-06-07 16:30:59 +0800 | [diff] [blame] | 616 | pldm_entity nodeL1 = pldm_entity_extract(l1); |
| 617 | pldm_entity parentL2a = pldm_entity_get_parent(l2a); |
| 618 | pldm_entity parentL2b = pldm_entity_get_parent(l2b); |
| 619 | pldm_entity parentL2c = pldm_entity_get_parent(l2c); |
| 620 | EXPECT_EQ(pldm_entity_is_exist_parent(l2a), true); |
| 621 | EXPECT_EQ(pldm_entity_is_exist_parent(l2b), true); |
| 622 | EXPECT_EQ(pldm_entity_is_exist_parent(l2c), true); |
| 623 | EXPECT_EQ(parentL2a.entity_type, nodeL1.entity_type); |
| 624 | EXPECT_EQ(parentL2a.entity_instance_num, nodeL1.entity_instance_num); |
| 625 | EXPECT_EQ(parentL2a.entity_container_id, nodeL1.entity_container_id); |
| 626 | EXPECT_EQ(parentL2b.entity_type, nodeL1.entity_type); |
| 627 | EXPECT_EQ(parentL2b.entity_instance_num, nodeL1.entity_instance_num); |
| 628 | EXPECT_EQ(parentL2b.entity_container_id, nodeL1.entity_container_id); |
| 629 | EXPECT_EQ(parentL2c.entity_type, nodeL1.entity_type); |
| 630 | EXPECT_EQ(parentL2c.entity_instance_num, nodeL1.entity_instance_num); |
| 631 | EXPECT_EQ(parentL2c.entity_container_id, nodeL1.entity_container_id); |
George Liu | fe77eea | 2021-04-28 15:08:07 +0800 | [diff] [blame] | 632 | |
George Liu | b6b3cf3 | 2021-06-07 16:30:59 +0800 | [diff] [blame] | 633 | pldm_entity nodeL2a = pldm_entity_extract(l2a); |
| 634 | pldm_entity parentL3a = pldm_entity_get_parent(l3a); |
| 635 | pldm_entity parentL3b = pldm_entity_get_parent(l3b); |
| 636 | pldm_entity parentL3c = pldm_entity_get_parent(l3c); |
| 637 | EXPECT_EQ(pldm_entity_is_exist_parent(l3a), true); |
| 638 | EXPECT_EQ(pldm_entity_is_exist_parent(l3b), true); |
| 639 | EXPECT_EQ(pldm_entity_is_exist_parent(l3c), true); |
| 640 | EXPECT_EQ(parentL3a.entity_type, nodeL2a.entity_type); |
| 641 | EXPECT_EQ(parentL3a.entity_instance_num, nodeL2a.entity_instance_num); |
| 642 | EXPECT_EQ(parentL3a.entity_container_id, nodeL2a.entity_container_id); |
| 643 | EXPECT_EQ(parentL3b.entity_type, nodeL2a.entity_type); |
| 644 | EXPECT_EQ(parentL3b.entity_instance_num, nodeL2a.entity_instance_num); |
| 645 | EXPECT_EQ(parentL3b.entity_container_id, nodeL2a.entity_container_id); |
| 646 | EXPECT_EQ(parentL3c.entity_type, nodeL2a.entity_type); |
| 647 | EXPECT_EQ(parentL3c.entity_instance_num, nodeL2a.entity_instance_num); |
| 648 | EXPECT_EQ(parentL3c.entity_container_id, nodeL2a.entity_container_id); |
George Liu | fe77eea | 2021-04-28 15:08:07 +0800 | [diff] [blame] | 649 | |
George Liu | b6b3cf3 | 2021-06-07 16:30:59 +0800 | [diff] [blame] | 650 | pldm_entity nodeL3a = pldm_entity_extract(l3a); |
| 651 | pldm_entity parentL4a = pldm_entity_get_parent(l4a); |
| 652 | EXPECT_EQ(pldm_entity_is_exist_parent(l4a), true); |
| 653 | EXPECT_EQ(parentL4a.entity_type, nodeL3a.entity_type); |
| 654 | EXPECT_EQ(parentL4a.entity_instance_num, nodeL3a.entity_instance_num); |
| 655 | EXPECT_EQ(parentL4a.entity_container_id, nodeL3a.entity_container_id); |
George Liu | fe77eea | 2021-04-28 15:08:07 +0800 | [diff] [blame] | 656 | |
George Liu | b6b3cf3 | 2021-06-07 16:30:59 +0800 | [diff] [blame] | 657 | pldm_entity nodeL3b = pldm_entity_extract(l3b); |
| 658 | pldm_entity parentL4b = pldm_entity_get_parent(l4b); |
| 659 | EXPECT_EQ(pldm_entity_is_exist_parent(l4b), true); |
| 660 | EXPECT_EQ(parentL4b.entity_type, nodeL3b.entity_type); |
| 661 | EXPECT_EQ(parentL4b.entity_instance_num, nodeL3b.entity_instance_num); |
| 662 | EXPECT_EQ(parentL4b.entity_container_id, nodeL3b.entity_container_id); |
George Liu | fe77eea | 2021-04-28 15:08:07 +0800 | [diff] [blame] | 663 | |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 664 | size_t num{}; |
| 665 | pldm_entity* out = nullptr; |
| 666 | pldm_entity_association_tree_visit(tree, &out, &num); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 667 | EXPECT_EQ(num, 9u); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 668 | |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 669 | EXPECT_EQ(out[0].entity_type, 1u); |
| 670 | EXPECT_EQ(out[0].entity_instance_num, 1u); |
| 671 | EXPECT_EQ(out[0].entity_container_id, 0u); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 672 | |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 673 | EXPECT_EQ(out[1].entity_type, 2u); |
| 674 | EXPECT_EQ(out[1].entity_instance_num, 1u); |
| 675 | EXPECT_EQ(out[1].entity_container_id, 1u); |
| 676 | EXPECT_EQ(out[2].entity_type, 2u); |
| 677 | EXPECT_EQ(out[2].entity_instance_num, 2u); |
| 678 | EXPECT_EQ(out[2].entity_container_id, 1u); |
| 679 | EXPECT_EQ(out[3].entity_type, 3u); |
| 680 | EXPECT_EQ(out[3].entity_instance_num, 1u); |
| 681 | EXPECT_EQ(out[3].entity_container_id, 1u); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 682 | |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 683 | EXPECT_EQ(out[4].entity_type, 4u); |
| 684 | EXPECT_EQ(out[4].entity_instance_num, 1u); |
| 685 | EXPECT_EQ(out[4].entity_container_id, 2u); |
| 686 | EXPECT_EQ(out[5].entity_type, 5u); |
| 687 | EXPECT_EQ(out[5].entity_instance_num, 1u); |
| 688 | EXPECT_EQ(out[5].entity_container_id, 2u); |
| 689 | EXPECT_EQ(out[6].entity_type, 5u); |
| 690 | EXPECT_EQ(out[6].entity_instance_num, 2u); |
| 691 | EXPECT_EQ(out[6].entity_container_id, 2u); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 692 | |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 693 | EXPECT_EQ(out[7].entity_type, 7u); |
| 694 | EXPECT_EQ(out[7].entity_instance_num, 1u); |
| 695 | EXPECT_EQ(out[7].entity_container_id, 4u); |
| 696 | EXPECT_EQ(out[8].entity_type, 6u); |
| 697 | EXPECT_EQ(out[8].entity_instance_num, 1u); |
| 698 | EXPECT_EQ(out[8].entity_container_id, 3u); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 699 | |
| 700 | free(out); |
George Liu | d9855ab | 2021-05-13 09:41:31 +0800 | [diff] [blame] | 701 | |
| 702 | pldm_entity p1 = pldm_entity_extract(l1); |
| 703 | EXPECT_EQ(p1.entity_type, 1u); |
| 704 | EXPECT_EQ(p1.entity_instance_num, 1u); |
| 705 | EXPECT_EQ(p1.entity_container_id, 0u); |
| 706 | |
| 707 | pldm_entity p2a = pldm_entity_extract(l2a); |
| 708 | EXPECT_EQ(p2a.entity_type, 2u); |
| 709 | EXPECT_EQ(p2a.entity_instance_num, 1u); |
| 710 | EXPECT_EQ(p2a.entity_container_id, 1u); |
| 711 | pldm_entity p2b = pldm_entity_extract(l2b); |
| 712 | EXPECT_EQ(p2b.entity_type, 2u); |
| 713 | EXPECT_EQ(p2b.entity_instance_num, 2u); |
| 714 | EXPECT_EQ(p2b.entity_container_id, 1u); |
| 715 | pldm_entity p2c = pldm_entity_extract(l2c); |
| 716 | EXPECT_EQ(p2c.entity_type, 3u); |
| 717 | EXPECT_EQ(p2c.entity_instance_num, 1u); |
| 718 | EXPECT_EQ(p2c.entity_container_id, 1u); |
| 719 | |
| 720 | pldm_entity p3a = pldm_entity_extract(l3a); |
| 721 | EXPECT_EQ(p3a.entity_type, 4u); |
| 722 | EXPECT_EQ(p3a.entity_instance_num, 1u); |
| 723 | EXPECT_EQ(p3a.entity_container_id, 2u); |
| 724 | pldm_entity p3b = pldm_entity_extract(l3b); |
| 725 | EXPECT_EQ(p3b.entity_type, 5u); |
| 726 | EXPECT_EQ(p3b.entity_instance_num, 1u); |
| 727 | EXPECT_EQ(p3b.entity_container_id, 2u); |
| 728 | pldm_entity p3c = pldm_entity_extract(l3c); |
| 729 | EXPECT_EQ(p3c.entity_type, 5u); |
| 730 | EXPECT_EQ(p3c.entity_instance_num, 2u); |
| 731 | EXPECT_EQ(p3c.entity_container_id, 2u); |
| 732 | |
| 733 | pldm_entity p4a = pldm_entity_extract(l4a); |
| 734 | EXPECT_EQ(p4a.entity_type, 6u); |
| 735 | EXPECT_EQ(p4a.entity_instance_num, 1u); |
| 736 | EXPECT_EQ(p4a.entity_container_id, 3u); |
| 737 | pldm_entity p4b = pldm_entity_extract(l4b); |
| 738 | EXPECT_EQ(p4b.entity_type, 7u); |
| 739 | EXPECT_EQ(p4b.entity_instance_num, 1u); |
| 740 | EXPECT_EQ(p4b.entity_container_id, 4u); |
| 741 | |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 742 | pldm_entity_association_tree_destroy(tree); |
| 743 | } |
| 744 | |
| 745 | TEST(EntityAssociationPDR, testSpecialTrees) |
| 746 | { |
| 747 | pldm_entity entities[3]{}; |
| 748 | |
| 749 | entities[0].entity_type = 1; |
| 750 | entities[1].entity_type = 2; |
| 751 | entities[2].entity_type = 1; |
| 752 | |
| 753 | // A |
| 754 | auto tree = pldm_entity_association_tree_init(); |
| 755 | auto node = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 756 | tree, &entities[0], 0xFFFF, nullptr, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 757 | EXPECT_NE(node, nullptr); |
| 758 | size_t num{}; |
| 759 | pldm_entity* out = nullptr; |
| 760 | pldm_entity_association_tree_visit(tree, &out, &num); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 761 | EXPECT_EQ(num, 1u); |
| 762 | EXPECT_EQ(out[0].entity_type, 1u); |
| 763 | EXPECT_EQ(out[0].entity_instance_num, 1u); |
| 764 | EXPECT_EQ(out[0].entity_container_id, 0u); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 765 | free(out); |
| 766 | pldm_entity_association_tree_destroy(tree); |
| 767 | |
| 768 | // A-A-A |
| 769 | tree = pldm_entity_association_tree_init(); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 770 | node = pldm_entity_association_tree_add(tree, &entities[0], 0xFFFF, nullptr, |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 771 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 772 | EXPECT_NE(node, nullptr); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 773 | node = pldm_entity_association_tree_add(tree, &entities[1], 0xFFFF, nullptr, |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 774 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 775 | EXPECT_NE(node, nullptr); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 776 | node = pldm_entity_association_tree_add(tree, &entities[2], 0xFFFF, nullptr, |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 777 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 778 | EXPECT_NE(node, nullptr); |
| 779 | pldm_entity_association_tree_visit(tree, &out, &num); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 780 | EXPECT_EQ(num, 3u); |
| 781 | EXPECT_EQ(out[0].entity_type, 1u); |
| 782 | EXPECT_EQ(out[0].entity_instance_num, 1u); |
| 783 | EXPECT_EQ(out[0].entity_container_id, 0u); |
| 784 | EXPECT_EQ(out[1].entity_type, 1u); |
| 785 | EXPECT_EQ(out[1].entity_instance_num, 2u); |
| 786 | EXPECT_EQ(out[1].entity_container_id, 0u); |
| 787 | EXPECT_EQ(out[2].entity_type, 2u); |
| 788 | EXPECT_EQ(out[2].entity_instance_num, 1u); |
| 789 | EXPECT_EQ(out[2].entity_container_id, 0u); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 790 | free(out); |
| 791 | pldm_entity_association_tree_destroy(tree); |
| 792 | |
| 793 | // A |
| 794 | // | |
| 795 | // A |
| 796 | // | |
| 797 | // A |
| 798 | tree = pldm_entity_association_tree_init(); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 799 | node = pldm_entity_association_tree_add(tree, &entities[0], 0xFFFF, nullptr, |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 800 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 801 | EXPECT_NE(node, nullptr); |
| 802 | auto node1 = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 803 | tree, &entities[1], 0xFFFF, node, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 804 | EXPECT_NE(node1, nullptr); |
| 805 | auto node2 = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 806 | tree, &entities[2], 0xFFFF, node1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 807 | EXPECT_NE(node2, nullptr); |
| 808 | pldm_entity_association_tree_visit(tree, &out, &num); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 809 | EXPECT_EQ(num, 3u); |
| 810 | EXPECT_EQ(out[0].entity_type, 1u); |
| 811 | EXPECT_EQ(out[0].entity_instance_num, 1u); |
| 812 | EXPECT_EQ(out[0].entity_container_id, 0u); |
| 813 | EXPECT_EQ(out[1].entity_type, 2u); |
| 814 | EXPECT_EQ(out[1].entity_instance_num, 1u); |
| 815 | EXPECT_EQ(out[1].entity_container_id, 1u); |
| 816 | EXPECT_EQ(out[2].entity_type, 1u); |
| 817 | EXPECT_EQ(out[2].entity_instance_num, 1u); |
| 818 | EXPECT_EQ(out[2].entity_container_id, 2u); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 819 | free(out); |
| 820 | pldm_entity_association_tree_destroy(tree); |
| 821 | |
| 822 | // A-A |
| 823 | // | |
| 824 | // A-A |
| 825 | tree = pldm_entity_association_tree_init(); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 826 | node = pldm_entity_association_tree_add(tree, &entities[0], 0xFFFF, nullptr, |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 827 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 828 | EXPECT_NE(node, nullptr); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 829 | node = pldm_entity_association_tree_add(tree, &entities[0], 0xFFFF, nullptr, |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 830 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 831 | EXPECT_NE(node, nullptr); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 832 | node1 = pldm_entity_association_tree_add(tree, &entities[1], 0xFFFF, node, |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 833 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 834 | EXPECT_NE(node1, nullptr); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 835 | node2 = pldm_entity_association_tree_add(tree, &entities[2], 0xFFFF, node, |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 836 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 837 | EXPECT_NE(node2, nullptr); |
| 838 | pldm_entity_association_tree_visit(tree, &out, &num); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 839 | EXPECT_EQ(num, 4u); |
| 840 | EXPECT_EQ(out[0].entity_type, 1u); |
| 841 | EXPECT_EQ(out[0].entity_instance_num, 1u); |
| 842 | EXPECT_EQ(out[0].entity_container_id, 0u); |
| 843 | EXPECT_EQ(out[1].entity_type, 1u); |
| 844 | EXPECT_EQ(out[1].entity_instance_num, 2u); |
| 845 | EXPECT_EQ(out[1].entity_container_id, 0u); |
| 846 | EXPECT_EQ(out[2].entity_type, 2u); |
| 847 | EXPECT_EQ(out[2].entity_instance_num, 1u); |
| 848 | EXPECT_EQ(out[2].entity_container_id, 1u); |
| 849 | EXPECT_EQ(out[3].entity_type, 1u); |
| 850 | EXPECT_EQ(out[3].entity_instance_num, 1u); |
| 851 | EXPECT_EQ(out[3].entity_container_id, 1u); |
Deepak Kodihalli | 0578705 | 2020-03-10 01:54:08 -0500 | [diff] [blame] | 852 | free(out); |
| 853 | pldm_entity_association_tree_destroy(tree); |
| 854 | } |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 855 | |
| 856 | TEST(EntityAssociationPDR, testPDR) |
| 857 | { |
| 858 | // e = entity type, c = container id, i = instance num |
| 859 | |
| 860 | // INPUT |
| 861 | // 1(e=1)--1a(e=2) |
| 862 | // | |
| 863 | // 2(e=2)--3(e=2)--4(e=2)--5(e=3) |
| 864 | // | |
| 865 | // 6(e=4)--7(e=5)--8(e=5)--9(e=5) |
| 866 | // | | |
| 867 | // 11(e=6) 10(e=7) |
| 868 | |
| 869 | // Expected OUTPUT |
| 870 | // 1(e=1,c=0,i=1) |
| 871 | // | |
| 872 | // 2(e=2,c=1,i=1)--3(e=2,c=1,i=2)--4(e=3,c=1,i=1)--5(e=3,c=1,i=2) |
| 873 | // | |
| 874 | // 6(e=4,c=2,i=1)--7(e=5,c=2,i=1)--8(e=5,c=2,i=2)--9(e=5,c=2,i=3) |
| 875 | // | | |
| 876 | // 10(e=6,c=3,i=1) 11(e=7,c=4,i=1) |
| 877 | pldm_entity entities[11]{}; |
| 878 | |
| 879 | entities[0].entity_type = 1; |
| 880 | entities[1].entity_type = 2; |
| 881 | entities[2].entity_type = 3; |
| 882 | entities[3].entity_type = 2; |
| 883 | entities[4].entity_type = 3; |
| 884 | entities[5].entity_type = 4; |
| 885 | entities[6].entity_type = 5; |
| 886 | entities[7].entity_type = 5; |
| 887 | entities[8].entity_type = 5; |
| 888 | entities[9].entity_type = 6; |
| 889 | entities[10].entity_type = 7; |
| 890 | |
| 891 | auto tree = pldm_entity_association_tree_init(); |
| 892 | |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 893 | auto l1 = pldm_entity_association_tree_add( |
| 894 | tree, &entities[0], 0xFFFF, nullptr, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 895 | EXPECT_NE(l1, nullptr); |
| 896 | auto l1a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 897 | tree, &entities[1], 0xFFFF, nullptr, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 898 | EXPECT_NE(l1a, nullptr); |
| 899 | |
| 900 | auto l2a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 901 | tree, &entities[1], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 902 | EXPECT_NE(l2a, nullptr); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 903 | auto l2b = pldm_entity_association_tree_add(tree, &entities[2], 0xFFFF, l1, |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 904 | PLDM_ENTITY_ASSOCIAION_LOGICAL); |
| 905 | EXPECT_NE(l2b, nullptr); |
| 906 | auto l2c = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 907 | tree, &entities[3], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 908 | EXPECT_NE(l2c, nullptr); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 909 | auto l2d = pldm_entity_association_tree_add(tree, &entities[4], 0xFFFF, l1, |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 910 | PLDM_ENTITY_ASSOCIAION_LOGICAL); |
| 911 | EXPECT_NE(l2d, nullptr); |
| 912 | |
| 913 | auto l3a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 914 | tree, &entities[5], 0xFFFF, l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 915 | EXPECT_NE(l3a, nullptr); |
| 916 | auto l3b = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 917 | tree, &entities[6], 0xFFFF, l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 918 | EXPECT_NE(l3b, nullptr); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 919 | auto l3c = pldm_entity_association_tree_add(tree, &entities[7], 0xFFFF, l2a, |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 920 | PLDM_ENTITY_ASSOCIAION_LOGICAL); |
| 921 | EXPECT_NE(l3c, nullptr); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 922 | auto l3d = pldm_entity_association_tree_add(tree, &entities[8], 0xFFFF, l2a, |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 923 | PLDM_ENTITY_ASSOCIAION_LOGICAL); |
| 924 | EXPECT_NE(l3d, nullptr); |
| 925 | |
| 926 | auto l4a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 927 | tree, &entities[9], 0xFFFF, l3a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 928 | EXPECT_NE(l4a, nullptr); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 929 | auto l4b = pldm_entity_association_tree_add( |
| 930 | tree, &entities[10], 0xFFFF, l3b, PLDM_ENTITY_ASSOCIAION_LOGICAL); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 931 | EXPECT_NE(l4b, nullptr); |
| 932 | |
| 933 | EXPECT_EQ(pldm_entity_get_num_children(l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL), |
| 934 | 2); |
| 935 | EXPECT_EQ(pldm_entity_get_num_children(l1, PLDM_ENTITY_ASSOCIAION_LOGICAL), |
| 936 | 2); |
| 937 | EXPECT_EQ( |
| 938 | pldm_entity_get_num_children(l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL), 2); |
| 939 | EXPECT_EQ( |
| 940 | pldm_entity_get_num_children(l3b, PLDM_ENTITY_ASSOCIAION_PHYSICAL), 0); |
| 941 | EXPECT_EQ(pldm_entity_get_num_children(l3b, PLDM_ENTITY_ASSOCIAION_LOGICAL), |
| 942 | 1); |
| 943 | |
| 944 | auto repo = pldm_pdr_init(); |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 945 | pldm_entity_association_pdr_add(tree, repo, false, 1); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 946 | |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 947 | EXPECT_EQ(pldm_pdr_get_record_count(repo), 6u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 948 | |
| 949 | uint32_t currRecHandle{}; |
| 950 | uint32_t nextRecHandle{}; |
| 951 | uint8_t* data = nullptr; |
| 952 | uint32_t size{}; |
| 953 | uint32_t commonSize = sizeof(struct pldm_pdr_hdr) + sizeof(uint16_t) + |
| 954 | sizeof(uint8_t) + sizeof(pldm_entity) + |
| 955 | sizeof(uint8_t); |
| 956 | |
| 957 | pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle); |
| 958 | EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children( |
| 959 | l1, PLDM_ENTITY_ASSOCIAION_LOGICAL) * |
| 960 | sizeof(pldm_entity))); |
| 961 | uint8_t* start = data; |
| 962 | pldm_pdr_hdr* hdr = reinterpret_cast<pldm_pdr_hdr*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 963 | EXPECT_EQ(le32toh(hdr->record_handle), 1u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 964 | EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 965 | EXPECT_EQ(le16toh(hdr->length), size - sizeof(struct pldm_pdr_hdr)); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 966 | start += sizeof(pldm_pdr_hdr); |
| 967 | uint16_t* containerId = reinterpret_cast<uint16_t*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 968 | EXPECT_EQ(le16toh(*containerId), 1u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 969 | start += sizeof(uint16_t); |
| 970 | EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_LOGICAL); |
| 971 | start += sizeof(uint8_t); |
| 972 | pldm_entity* entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 973 | EXPECT_EQ(le16toh(entity->entity_type), 1u); |
| 974 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 975 | EXPECT_EQ(le16toh(entity->entity_container_id), 0u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 976 | start += sizeof(pldm_entity); |
| 977 | EXPECT_EQ(*start, |
| 978 | pldm_entity_get_num_children(l1, PLDM_ENTITY_ASSOCIAION_LOGICAL)); |
| 979 | start += sizeof(uint8_t); |
| 980 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 981 | EXPECT_EQ(le16toh(entity->entity_type), 3u); |
| 982 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 983 | EXPECT_EQ(le16toh(entity->entity_container_id), 1u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 984 | start += sizeof(pldm_entity); |
| 985 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 986 | EXPECT_EQ(le16toh(entity->entity_type), 3u); |
| 987 | EXPECT_EQ(le16toh(entity->entity_instance_num), 2u); |
| 988 | EXPECT_EQ(le16toh(entity->entity_container_id), 1u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 989 | start += sizeof(pldm_entity); |
| 990 | |
| 991 | currRecHandle = nextRecHandle; |
| 992 | |
| 993 | pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle); |
| 994 | EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children( |
| 995 | l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL) * |
| 996 | sizeof(pldm_entity))); |
| 997 | start = data; |
| 998 | hdr = reinterpret_cast<pldm_pdr_hdr*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 999 | EXPECT_EQ(le32toh(hdr->record_handle), 2u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1000 | EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 1001 | EXPECT_EQ(le16toh(hdr->length), size - sizeof(struct pldm_pdr_hdr)); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1002 | start += sizeof(pldm_pdr_hdr); |
| 1003 | containerId = reinterpret_cast<uint16_t*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1004 | EXPECT_EQ(le16toh(*containerId), 1u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1005 | start += sizeof(uint16_t); |
| 1006 | EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1007 | start += sizeof(uint8_t); |
| 1008 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1009 | EXPECT_EQ(le16toh(entity->entity_type), 1u); |
| 1010 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 1011 | EXPECT_EQ(le16toh(entity->entity_container_id), 0u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1012 | start += sizeof(pldm_entity); |
| 1013 | EXPECT_EQ(*start, pldm_entity_get_num_children( |
| 1014 | l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL)); |
| 1015 | start += sizeof(uint8_t); |
| 1016 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1017 | EXPECT_EQ(le16toh(entity->entity_type), 2u); |
| 1018 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 1019 | EXPECT_EQ(le16toh(entity->entity_container_id), 1u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1020 | start += sizeof(pldm_entity); |
| 1021 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1022 | EXPECT_EQ(le16toh(entity->entity_type), 2u); |
| 1023 | EXPECT_EQ(le16toh(entity->entity_instance_num), 2u); |
| 1024 | EXPECT_EQ(le16toh(entity->entity_container_id), 1u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1025 | start += sizeof(pldm_entity); |
| 1026 | |
| 1027 | currRecHandle = nextRecHandle; |
| 1028 | |
| 1029 | pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle); |
| 1030 | EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children( |
| 1031 | l2a, PLDM_ENTITY_ASSOCIAION_LOGICAL) * |
| 1032 | sizeof(pldm_entity))); |
| 1033 | start = data; |
| 1034 | hdr = reinterpret_cast<pldm_pdr_hdr*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1035 | EXPECT_EQ(le32toh(hdr->record_handle), 3u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1036 | EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 1037 | EXPECT_EQ(le16toh(hdr->length), size - sizeof(struct pldm_pdr_hdr)); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1038 | start += sizeof(pldm_pdr_hdr); |
| 1039 | containerId = reinterpret_cast<uint16_t*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1040 | EXPECT_EQ(le16toh(*containerId), 2u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1041 | start += sizeof(uint16_t); |
| 1042 | EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_LOGICAL); |
| 1043 | start += sizeof(uint8_t); |
| 1044 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1045 | EXPECT_EQ(le16toh(entity->entity_type), 2u); |
| 1046 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 1047 | EXPECT_EQ(le16toh(entity->entity_container_id), 1u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1048 | start += sizeof(pldm_entity); |
| 1049 | EXPECT_EQ(*start, pldm_entity_get_num_children( |
| 1050 | l2a, PLDM_ENTITY_ASSOCIAION_LOGICAL)); |
| 1051 | start += sizeof(uint8_t); |
| 1052 | entity = reinterpret_cast<pldm_entity*>(start); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 1053 | EXPECT_EQ(le16toh(entity->entity_type), 5); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1054 | EXPECT_EQ(le16toh(entity->entity_instance_num), 2u); |
| 1055 | EXPECT_EQ(le16toh(entity->entity_container_id), 2u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1056 | start += sizeof(pldm_entity); |
| 1057 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1058 | EXPECT_EQ(le16toh(entity->entity_type), 5u); |
| 1059 | EXPECT_EQ(le16toh(entity->entity_instance_num), 3u); |
| 1060 | EXPECT_EQ(le16toh(entity->entity_container_id), 2u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1061 | start += sizeof(pldm_entity); |
| 1062 | |
| 1063 | currRecHandle = nextRecHandle; |
| 1064 | |
| 1065 | pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle); |
| 1066 | EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children( |
| 1067 | l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL) * |
| 1068 | sizeof(pldm_entity))); |
| 1069 | start = data; |
| 1070 | hdr = reinterpret_cast<pldm_pdr_hdr*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1071 | EXPECT_EQ(le32toh(hdr->record_handle), 4u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1072 | EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 1073 | EXPECT_EQ(le16toh(hdr->length), size - sizeof(struct pldm_pdr_hdr)); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1074 | start += sizeof(pldm_pdr_hdr); |
| 1075 | containerId = reinterpret_cast<uint16_t*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1076 | EXPECT_EQ(le16toh(*containerId), 2u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1077 | start += sizeof(uint16_t); |
| 1078 | EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1079 | start += sizeof(uint8_t); |
| 1080 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1081 | EXPECT_EQ(le16toh(entity->entity_type), 2u); |
| 1082 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 1083 | EXPECT_EQ(le16toh(entity->entity_container_id), 1u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1084 | start += sizeof(pldm_entity); |
| 1085 | EXPECT_EQ(*start, pldm_entity_get_num_children( |
| 1086 | l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL)); |
| 1087 | start += sizeof(uint8_t); |
| 1088 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1089 | EXPECT_EQ(le16toh(entity->entity_type), 4u); |
| 1090 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 1091 | EXPECT_EQ(le16toh(entity->entity_container_id), 2u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1092 | start += sizeof(pldm_entity); |
| 1093 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1094 | EXPECT_EQ(le16toh(entity->entity_type), 5u); |
| 1095 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 1096 | EXPECT_EQ(le16toh(entity->entity_container_id), 2u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1097 | start += sizeof(pldm_entity); |
| 1098 | |
| 1099 | currRecHandle = nextRecHandle; |
| 1100 | |
| 1101 | pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle); |
| 1102 | EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children( |
| 1103 | l3a, PLDM_ENTITY_ASSOCIAION_PHYSICAL) * |
| 1104 | sizeof(pldm_entity))); |
| 1105 | start = data; |
| 1106 | hdr = reinterpret_cast<pldm_pdr_hdr*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1107 | EXPECT_EQ(le32toh(hdr->record_handle), 5u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1108 | EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 1109 | EXPECT_EQ(le16toh(hdr->length), size - sizeof(struct pldm_pdr_hdr)); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1110 | start += sizeof(pldm_pdr_hdr); |
| 1111 | containerId = reinterpret_cast<uint16_t*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1112 | EXPECT_EQ(le16toh(*containerId), 3u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1113 | start += sizeof(uint16_t); |
| 1114 | EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1115 | start += sizeof(uint8_t); |
| 1116 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1117 | EXPECT_EQ(le16toh(entity->entity_type), 4u); |
| 1118 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 1119 | EXPECT_EQ(le16toh(entity->entity_container_id), 2u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1120 | start += sizeof(pldm_entity); |
| 1121 | EXPECT_EQ(*start, pldm_entity_get_num_children( |
| 1122 | l3a, PLDM_ENTITY_ASSOCIAION_PHYSICAL)); |
| 1123 | start += sizeof(uint8_t); |
| 1124 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1125 | EXPECT_EQ(le16toh(entity->entity_type), 6u); |
| 1126 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 1127 | EXPECT_EQ(le16toh(entity->entity_container_id), 3u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1128 | start += sizeof(pldm_entity); |
| 1129 | |
| 1130 | currRecHandle = nextRecHandle; |
| 1131 | |
| 1132 | pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle); |
| 1133 | EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children( |
| 1134 | l3b, PLDM_ENTITY_ASSOCIAION_LOGICAL) * |
| 1135 | sizeof(pldm_entity))); |
| 1136 | start = data; |
| 1137 | hdr = reinterpret_cast<pldm_pdr_hdr*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1138 | EXPECT_EQ(le32toh(hdr->record_handle), 6u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1139 | EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION); |
Deepak Kodihalli | fb4dd7b | 2020-03-17 03:27:22 -0500 | [diff] [blame] | 1140 | EXPECT_EQ(le16toh(hdr->length), size - sizeof(struct pldm_pdr_hdr)); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1141 | start += sizeof(pldm_pdr_hdr); |
| 1142 | containerId = reinterpret_cast<uint16_t*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1143 | EXPECT_EQ(le16toh(*containerId), 4u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1144 | start += sizeof(uint16_t); |
| 1145 | EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_LOGICAL); |
| 1146 | start += sizeof(uint8_t); |
| 1147 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1148 | EXPECT_EQ(le16toh(entity->entity_type), 5u); |
| 1149 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 1150 | EXPECT_EQ(le16toh(entity->entity_container_id), 2u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1151 | start += sizeof(pldm_entity); |
| 1152 | EXPECT_EQ(*start, pldm_entity_get_num_children( |
| 1153 | l3b, PLDM_ENTITY_ASSOCIAION_LOGICAL)); |
| 1154 | start += sizeof(uint8_t); |
| 1155 | entity = reinterpret_cast<pldm_entity*>(start); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1156 | EXPECT_EQ(le16toh(entity->entity_type), 7u); |
| 1157 | EXPECT_EQ(le16toh(entity->entity_instance_num), 1u); |
| 1158 | EXPECT_EQ(le16toh(entity->entity_container_id), 4u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1159 | |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1160 | EXPECT_EQ(nextRecHandle, 0u); |
Deepak Kodihalli | 0a738f0 | 2020-03-10 01:56:21 -0500 | [diff] [blame] | 1161 | |
| 1162 | pldm_pdr_destroy(repo); |
| 1163 | pldm_entity_association_tree_destroy(tree); |
| 1164 | } |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1165 | |
| 1166 | TEST(EntityAssociationPDR, testFind) |
| 1167 | { |
| 1168 | // 1 |
| 1169 | // | |
| 1170 | // 2--3--4 |
| 1171 | // | |
| 1172 | // 5--6--7 |
| 1173 | // | | |
| 1174 | // 8 9 |
| 1175 | |
| 1176 | pldm_entity entities[9]{}; |
| 1177 | |
| 1178 | entities[0].entity_type = 1; |
| 1179 | entities[1].entity_type = 2; |
| 1180 | entities[2].entity_type = 2; |
| 1181 | entities[3].entity_type = 3; |
| 1182 | entities[4].entity_type = 4; |
| 1183 | entities[5].entity_type = 5; |
| 1184 | entities[6].entity_type = 5; |
| 1185 | entities[7].entity_type = 6; |
| 1186 | entities[8].entity_type = 7; |
| 1187 | |
| 1188 | auto tree = pldm_entity_association_tree_init(); |
| 1189 | |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1190 | auto l1 = pldm_entity_association_tree_add( |
| 1191 | tree, &entities[0], 0xFFFF, nullptr, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1192 | EXPECT_NE(l1, nullptr); |
| 1193 | auto l2a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1194 | tree, &entities[1], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1195 | EXPECT_NE(l2a, nullptr); |
| 1196 | auto l2b = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1197 | tree, &entities[2], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1198 | EXPECT_NE(l2b, nullptr); |
| 1199 | auto l2c = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1200 | tree, &entities[3], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1201 | EXPECT_NE(l2c, nullptr); |
| 1202 | auto l3a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1203 | tree, &entities[4], 0xFFFF, l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1204 | EXPECT_NE(l3a, nullptr); |
| 1205 | auto l3b = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1206 | tree, &entities[5], 0xFFFF, l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1207 | EXPECT_NE(l3b, nullptr); |
| 1208 | auto l3c = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1209 | tree, &entities[6], 0xFFFF, l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1210 | EXPECT_NE(l3c, nullptr); |
| 1211 | auto l4a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1212 | tree, &entities[7], 0xFFFF, l3a, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1213 | EXPECT_NE(l4a, nullptr); |
| 1214 | auto l4b = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1215 | tree, &entities[8], 0xFFFF, l3b, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1216 | EXPECT_NE(l4b, nullptr); |
| 1217 | |
| 1218 | pldm_entity entity{}; |
| 1219 | |
| 1220 | entity.entity_type = 1; |
| 1221 | entity.entity_instance_num = 1; |
| 1222 | auto result = pldm_entity_association_tree_find(tree, &entity); |
| 1223 | EXPECT_EQ(result, l1); |
| 1224 | EXPECT_EQ(entity.entity_container_id, 0); |
| 1225 | |
| 1226 | entity.entity_type = 2; |
| 1227 | entity.entity_instance_num = 1; |
| 1228 | result = pldm_entity_association_tree_find(tree, &entity); |
| 1229 | EXPECT_EQ(result, l2a); |
| 1230 | EXPECT_EQ(entity.entity_container_id, 1); |
| 1231 | entity.entity_type = 2; |
| 1232 | entity.entity_instance_num = 2; |
| 1233 | result = pldm_entity_association_tree_find(tree, &entity); |
| 1234 | EXPECT_EQ(result, l2b); |
| 1235 | EXPECT_EQ(entity.entity_container_id, 1); |
| 1236 | entity.entity_type = 3; |
| 1237 | entity.entity_instance_num = 1; |
| 1238 | result = pldm_entity_association_tree_find(tree, &entity); |
| 1239 | EXPECT_EQ(result, l2c); |
| 1240 | EXPECT_EQ(entity.entity_container_id, 1); |
| 1241 | |
| 1242 | entity.entity_type = 7; |
| 1243 | entity.entity_instance_num = 1; |
| 1244 | result = pldm_entity_association_tree_find(tree, &entity); |
| 1245 | EXPECT_EQ(result, l4b); |
| 1246 | EXPECT_EQ(entity.entity_container_id, 4); |
| 1247 | |
| 1248 | pldm_entity_association_tree_destroy(tree); |
| 1249 | } |
| 1250 | |
Sampa Misra | c073a20 | 2021-05-08 10:56:05 -0500 | [diff] [blame] | 1251 | TEST(EntityAssociationPDR, testCopyTree) |
| 1252 | { |
| 1253 | pldm_entity entities[4]{}; |
| 1254 | entities[0].entity_type = 1; |
| 1255 | entities[1].entity_type = 2; |
| 1256 | entities[2].entity_type = 2; |
| 1257 | entities[3].entity_type = 3; |
| 1258 | |
| 1259 | auto orgTree = pldm_entity_association_tree_init(); |
| 1260 | auto newTree = pldm_entity_association_tree_init(); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1261 | auto l1 = |
| 1262 | pldm_entity_association_tree_add(orgTree, &entities[0], 0xFFFF, nullptr, |
| 1263 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Sampa Misra | c073a20 | 2021-05-08 10:56:05 -0500 | [diff] [blame] | 1264 | EXPECT_NE(l1, nullptr); |
| 1265 | auto l2a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1266 | orgTree, &entities[1], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Sampa Misra | c073a20 | 2021-05-08 10:56:05 -0500 | [diff] [blame] | 1267 | EXPECT_NE(l2a, nullptr); |
| 1268 | auto l2b = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1269 | orgTree, &entities[2], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Sampa Misra | c073a20 | 2021-05-08 10:56:05 -0500 | [diff] [blame] | 1270 | EXPECT_NE(l2b, nullptr); |
| 1271 | auto l2c = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1272 | orgTree, &entities[3], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
Sampa Misra | c073a20 | 2021-05-08 10:56:05 -0500 | [diff] [blame] | 1273 | EXPECT_NE(l2c, nullptr); |
| 1274 | size_t orgNum{}; |
| 1275 | pldm_entity* orgOut = nullptr; |
| 1276 | pldm_entity_association_tree_visit(orgTree, &orgOut, &orgNum); |
| 1277 | EXPECT_EQ(orgNum, 4u); |
| 1278 | |
| 1279 | pldm_entity_association_tree_copy_root(orgTree, newTree); |
| 1280 | size_t newNum{}; |
| 1281 | pldm_entity* newOut = nullptr; |
| 1282 | pldm_entity_association_tree_visit(newTree, &newOut, &newNum); |
| 1283 | EXPECT_EQ(newNum, orgNum); |
| 1284 | EXPECT_EQ(newOut[0].entity_type, 1u); |
| 1285 | EXPECT_EQ(newOut[0].entity_instance_num, 1u); |
| 1286 | EXPECT_EQ(newOut[0].entity_container_id, 0u); |
| 1287 | free(orgOut); |
| 1288 | free(newOut); |
| 1289 | pldm_entity_association_tree_destroy(orgTree); |
| 1290 | pldm_entity_association_tree_destroy(newTree); |
| 1291 | } |
| 1292 | |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1293 | TEST(EntityAssociationPDR, testExtract) |
| 1294 | { |
| 1295 | std::vector<uint8_t> pdr{}; |
| 1296 | pdr.resize(sizeof(pldm_pdr_hdr) + sizeof(pldm_pdr_entity_association) + |
| 1297 | sizeof(pldm_entity) * 4); |
| 1298 | pldm_pdr_hdr* hdr = reinterpret_cast<pldm_pdr_hdr*>(pdr.data()); |
| 1299 | hdr->type = PLDM_PDR_ENTITY_ASSOCIATION; |
| 1300 | hdr->length = |
| 1301 | htole16(sizeof(pldm_pdr_entity_association) + sizeof(pldm_entity) * 4); |
| 1302 | |
| 1303 | pldm_pdr_entity_association* e = |
| 1304 | reinterpret_cast<pldm_pdr_entity_association*>(pdr.data() + |
| 1305 | sizeof(pldm_pdr_hdr)); |
| 1306 | e->container_id = htole16(1); |
| 1307 | e->num_children = 5; |
| 1308 | e->container.entity_type = htole16(1); |
| 1309 | e->container.entity_instance_num = htole16(1); |
| 1310 | e->container.entity_container_id = htole16(0); |
| 1311 | |
| 1312 | pldm_entity* entity = e->children; |
| 1313 | entity->entity_type = htole16(2); |
| 1314 | entity->entity_instance_num = htole16(1); |
| 1315 | entity->entity_container_id = htole16(1); |
| 1316 | ++entity; |
| 1317 | entity->entity_type = htole16(3); |
| 1318 | entity->entity_instance_num = htole16(1); |
| 1319 | entity->entity_container_id = htole16(1); |
| 1320 | ++entity; |
| 1321 | entity->entity_type = htole16(4); |
| 1322 | entity->entity_instance_num = htole16(1); |
| 1323 | entity->entity_container_id = htole16(1); |
| 1324 | ++entity; |
| 1325 | entity->entity_type = htole16(5); |
| 1326 | entity->entity_instance_num = htole16(1); |
| 1327 | entity->entity_container_id = htole16(1); |
| 1328 | ++entity; |
| 1329 | entity->entity_type = htole16(6); |
| 1330 | entity->entity_instance_num = htole16(1); |
| 1331 | entity->entity_container_id = htole16(1); |
| 1332 | |
| 1333 | size_t num{}; |
| 1334 | pldm_entity* out = nullptr; |
| 1335 | pldm_entity_association_pdr_extract(pdr.data(), pdr.size(), &num, &out); |
crgeddes | 2550cee | 2020-05-05 17:51:28 +0000 | [diff] [blame] | 1336 | EXPECT_EQ(num, (unsigned)e->num_children + 1); |
| 1337 | EXPECT_EQ(out[0].entity_type, 1u); |
| 1338 | EXPECT_EQ(out[0].entity_instance_num, 1u); |
| 1339 | EXPECT_EQ(out[0].entity_container_id, 0u); |
| 1340 | EXPECT_EQ(out[1].entity_type, 2u); |
| 1341 | EXPECT_EQ(out[1].entity_instance_num, 1u); |
| 1342 | EXPECT_EQ(out[1].entity_container_id, 1u); |
| 1343 | EXPECT_EQ(out[2].entity_type, 3u); |
| 1344 | EXPECT_EQ(out[2].entity_instance_num, 1u); |
| 1345 | EXPECT_EQ(out[2].entity_container_id, 1u); |
| 1346 | EXPECT_EQ(out[3].entity_type, 4u); |
| 1347 | EXPECT_EQ(out[3].entity_instance_num, 1u); |
| 1348 | EXPECT_EQ(out[3].entity_container_id, 1u); |
| 1349 | EXPECT_EQ(out[4].entity_type, 5u); |
| 1350 | EXPECT_EQ(out[4].entity_instance_num, 1u); |
| 1351 | EXPECT_EQ(out[4].entity_container_id, 1u); |
| 1352 | EXPECT_EQ(out[5].entity_type, 6u); |
| 1353 | EXPECT_EQ(out[5].entity_instance_num, 1u); |
| 1354 | EXPECT_EQ(out[5].entity_container_id, 1u); |
Deepak Kodihalli | 3b28ba8 | 2020-03-30 07:39:47 -0500 | [diff] [blame] | 1355 | |
| 1356 | free(out); |
| 1357 | } |
George Liu | 6a6c3ab | 2021-06-22 16:12:42 +0800 | [diff] [blame] | 1358 | |
| 1359 | TEST(EntityAssociationPDR, testGetChildren) |
| 1360 | { |
| 1361 | pldm_entity entities[4]{}; |
| 1362 | entities[0].entity_type = 1; |
| 1363 | entities[1].entity_type = 2; |
| 1364 | entities[2].entity_type = 2; |
| 1365 | entities[3].entity_type = 3; |
| 1366 | |
| 1367 | auto tree = pldm_entity_association_tree_init(); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1368 | auto l1 = pldm_entity_association_tree_add( |
| 1369 | tree, &entities[0], 0xFFFF, nullptr, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
George Liu | 6a6c3ab | 2021-06-22 16:12:42 +0800 | [diff] [blame] | 1370 | EXPECT_NE(l1, nullptr); |
| 1371 | auto l2a = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1372 | tree, &entities[1], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
George Liu | 6a6c3ab | 2021-06-22 16:12:42 +0800 | [diff] [blame] | 1373 | EXPECT_NE(l2a, nullptr); |
| 1374 | auto l2b = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1375 | tree, &entities[2], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
George Liu | 6a6c3ab | 2021-06-22 16:12:42 +0800 | [diff] [blame] | 1376 | EXPECT_NE(l2b, nullptr); |
| 1377 | auto l2c = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1378 | tree, &entities[3], 0xFFFF, l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
George Liu | 6a6c3ab | 2021-06-22 16:12:42 +0800 | [diff] [blame] | 1379 | EXPECT_NE(l2c, nullptr); |
| 1380 | |
| 1381 | pldm_entity et1; |
| 1382 | et1.entity_type = 2; |
| 1383 | et1.entity_instance_num = 1; |
| 1384 | EXPECT_EQ(true, pldm_is_current_parent_child(l1, &et1)); |
| 1385 | |
| 1386 | pldm_entity et2; |
| 1387 | et2.entity_type = 2; |
| 1388 | et2.entity_instance_num = 2; |
| 1389 | EXPECT_EQ(true, pldm_is_current_parent_child(l1, &et2)); |
| 1390 | |
| 1391 | pldm_entity et3; |
| 1392 | et3.entity_type = 2; |
| 1393 | et3.entity_instance_num = 3; |
| 1394 | EXPECT_EQ(false, pldm_is_current_parent_child(l1, &et3)); |
| 1395 | |
| 1396 | pldm_entity_association_tree_destroy(tree); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | TEST(EntityAssociationPDR, testEntityInstanceNumber) |
| 1400 | { |
| 1401 | pldm_entity entities[9]{}; |
| 1402 | |
| 1403 | entities[0].entity_type = 1; |
| 1404 | entities[1].entity_type = 2; |
| 1405 | entities[2].entity_type = 2; |
| 1406 | entities[3].entity_type = 2; |
| 1407 | entities[4].entity_type = 2; |
| 1408 | entities[5].entity_type = 2; |
| 1409 | entities[6].entity_type = 2; |
| 1410 | entities[7].entity_type = 3; |
| 1411 | entities[8].entity_type = 3; |
| 1412 | |
| 1413 | auto tree = pldm_entity_association_tree_init(); |
| 1414 | auto repo = pldm_pdr_init(); |
| 1415 | |
| 1416 | uint16_t terminusHdl{}; |
| 1417 | uint16_t entityType{}; |
| 1418 | uint16_t entityInstanceNum{}; |
| 1419 | uint16_t containerId{}; |
| 1420 | |
| 1421 | auto node = pldm_entity_association_tree_add( |
| 1422 | tree, &entities[0], 0xFFFF, nullptr, PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1423 | EXPECT_NE(node, nullptr); |
| 1424 | |
| 1425 | auto l1 = pldm_entity_association_tree_add(tree, &entities[1], 63, node, |
| 1426 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1427 | auto first = pldm_pdr_add_fru_record_set( |
| 1428 | repo, 1, 1, entities[1].entity_type, entities[1].entity_instance_num, |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 1429 | entities[1].entity_container_id, 1); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1430 | EXPECT_NE(l1, nullptr); |
| 1431 | EXPECT_EQ(entities[1].entity_instance_num, 63); |
| 1432 | EXPECT_EQ(first, pldm_pdr_get_record_handle( |
| 1433 | repo, pldm_pdr_fru_record_set_find_by_rsi( |
| 1434 | repo, 1, &terminusHdl, &entityType, |
| 1435 | &entityInstanceNum, &containerId))); |
| 1436 | EXPECT_EQ(entityType, 2); |
| 1437 | EXPECT_EQ(entityInstanceNum, 63); |
| 1438 | |
| 1439 | auto l2 = pldm_entity_association_tree_add(tree, &entities[2], 37, node, |
| 1440 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1441 | auto second = pldm_pdr_add_fru_record_set( |
| 1442 | repo, 1, 2, entities[2].entity_type, entities[2].entity_instance_num, |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 1443 | entities[2].entity_container_id, 2); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1444 | EXPECT_NE(l2, nullptr); |
| 1445 | EXPECT_EQ(entities[2].entity_instance_num, 37); |
| 1446 | EXPECT_EQ(second, pldm_pdr_get_record_handle( |
| 1447 | repo, pldm_pdr_fru_record_set_find_by_rsi( |
| 1448 | repo, 2, &terminusHdl, &entityType, |
| 1449 | &entityInstanceNum, &containerId))); |
| 1450 | EXPECT_EQ(entityType, 2); |
| 1451 | EXPECT_EQ(entityInstanceNum, 37); |
| 1452 | |
| 1453 | auto l3 = pldm_entity_association_tree_add(tree, &entities[3], 44, node, |
| 1454 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1455 | auto third = pldm_pdr_add_fru_record_set( |
| 1456 | repo, 1, 3, entities[3].entity_type, entities[3].entity_instance_num, |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 1457 | entities[3].entity_container_id, 3); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1458 | EXPECT_NE(l3, nullptr); |
| 1459 | EXPECT_EQ(entities[3].entity_instance_num, 44); |
| 1460 | EXPECT_EQ(third, pldm_pdr_get_record_handle( |
| 1461 | repo, pldm_pdr_fru_record_set_find_by_rsi( |
| 1462 | repo, 3, &terminusHdl, &entityType, |
| 1463 | &entityInstanceNum, &containerId))); |
| 1464 | EXPECT_EQ(entityType, 2); |
| 1465 | EXPECT_EQ(entityInstanceNum, 44); |
| 1466 | |
| 1467 | auto l4 = pldm_entity_association_tree_add(tree, &entities[4], 89, node, |
| 1468 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1469 | auto fourth = pldm_pdr_add_fru_record_set( |
| 1470 | repo, 1, 4, entities[4].entity_type, entities[4].entity_instance_num, |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 1471 | entities[4].entity_container_id, 4); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1472 | EXPECT_NE(l4, nullptr); |
| 1473 | EXPECT_EQ(entities[4].entity_instance_num, 89); |
| 1474 | EXPECT_EQ(fourth, pldm_pdr_get_record_handle( |
| 1475 | repo, pldm_pdr_fru_record_set_find_by_rsi( |
| 1476 | repo, 4, &terminusHdl, &entityType, |
| 1477 | &entityInstanceNum, &containerId))); |
| 1478 | EXPECT_EQ(entityType, 2); |
| 1479 | EXPECT_EQ(entityInstanceNum, 89); |
| 1480 | |
| 1481 | auto l5 = pldm_entity_association_tree_add(tree, &entities[5], 0xFFFF, node, |
| 1482 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1483 | auto fifth = pldm_pdr_add_fru_record_set( |
| 1484 | repo, 1, 5, entities[5].entity_type, entities[5].entity_instance_num, |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 1485 | entities[5].entity_container_id, 5); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1486 | EXPECT_NE(l5, nullptr); |
| 1487 | EXPECT_EQ(entities[5].entity_instance_num, 90); |
| 1488 | EXPECT_EQ(fifth, pldm_pdr_get_record_handle( |
| 1489 | repo, pldm_pdr_fru_record_set_find_by_rsi( |
| 1490 | repo, 5, &terminusHdl, &entityType, |
| 1491 | &entityInstanceNum, &containerId))); |
| 1492 | EXPECT_EQ(entityType, 2); |
| 1493 | EXPECT_EQ(entityInstanceNum, 90); |
| 1494 | |
| 1495 | auto l6 = pldm_entity_association_tree_add(tree, &entities[6], 90, node, |
| 1496 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1497 | EXPECT_EQ(l6, nullptr); |
| 1498 | |
| 1499 | auto l7 = pldm_entity_association_tree_add(tree, &entities[7], 100, l1, |
| 1500 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1501 | auto seventh = pldm_pdr_add_fru_record_set( |
| 1502 | repo, 1, 7, entities[7].entity_type, entities[7].entity_instance_num, |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 1503 | entities[7].entity_container_id, 7); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1504 | EXPECT_NE(l7, nullptr); |
| 1505 | EXPECT_EQ(entities[7].entity_instance_num, 100); |
| 1506 | EXPECT_EQ(seventh, pldm_pdr_get_record_handle( |
| 1507 | repo, pldm_pdr_fru_record_set_find_by_rsi( |
| 1508 | repo, 7, &terminusHdl, &entityType, |
| 1509 | &entityInstanceNum, &containerId))); |
| 1510 | EXPECT_EQ(entityType, 3); |
| 1511 | EXPECT_EQ(entityInstanceNum, 100); |
| 1512 | |
| 1513 | auto l8 = pldm_entity_association_tree_add(tree, &entities[8], 100, l2, |
| 1514 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 1515 | auto eighth = pldm_pdr_add_fru_record_set( |
| 1516 | repo, 1, 8, entities[8].entity_type, entities[8].entity_instance_num, |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 1517 | entities[8].entity_container_id, 8); |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 1518 | EXPECT_NE(l8, nullptr); |
| 1519 | EXPECT_EQ(entities[8].entity_instance_num, 100); |
| 1520 | EXPECT_EQ(eighth, pldm_pdr_get_record_handle( |
| 1521 | repo, pldm_pdr_fru_record_set_find_by_rsi( |
| 1522 | repo, 8, &terminusHdl, &entityType, |
| 1523 | &entityInstanceNum, &containerId))); |
| 1524 | EXPECT_EQ(entityType, 3); |
| 1525 | EXPECT_EQ(entityInstanceNum, 100); |
| 1526 | |
| 1527 | pldm_pdr_destroy(repo); |
| 1528 | pldm_entity_association_tree_destroy(tree); |
| 1529 | } |