Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1 | #include "led-test-map.hpp" |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 2 | #include "manager.hpp" |
| 3 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> |
George Liu | a6c18f8 | 2020-06-22 10:50:04 +0800 | [diff] [blame] | 5 | |
| 6 | #include <algorithm> |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 7 | #include <set> |
| 8 | |
| 9 | #include <gtest/gtest.h> |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 10 | using namespace phosphor::led; |
| 11 | class LedTest : public ::testing::Test |
| 12 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 13 | public: |
Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 14 | sdbusplus::bus_t bus; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 15 | LedTest() : bus(sdbusplus::bus::new_default()) |
| 16 | { |
| 17 | // Nothing here |
| 18 | } |
George Liu | cc1de72 | 2024-08-22 16:47:14 +0800 | [diff] [blame] | 19 | ~LedTest() = default; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 20 | }; |
| 21 | |
| 22 | /** @brief Assert Single LED to On */ |
| 23 | TEST_F(LedTest, assertSingleLedOn) |
| 24 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 25 | Manager manager(bus, singleLedOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 26 | { |
| 27 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 28 | ActionSet ledsAssert{}; |
| 29 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 30 | |
| 31 | auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 32 | auto result = |
| 33 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 34 | EXPECT_EQ(true, result); |
| 35 | |
| 36 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 37 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 38 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 39 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 40 | }; |
| 41 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 42 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 43 | |
| 44 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 45 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 46 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 47 | refAssert.begin(), refAssert.end(), |
| 48 | std::inserter(temp, temp.begin())); |
| 49 | EXPECT_EQ(0, temp.size()); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /** @brief Assert Single LED to Blink */ |
| 54 | TEST_F(LedTest, assertSingleLedBlink) |
| 55 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 56 | Manager manager(bus, singleLedBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 57 | { |
| 58 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 59 | ActionSet ledsAssert{}; |
| 60 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 61 | |
| 62 | auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 63 | auto result = |
| 64 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 65 | EXPECT_EQ(true, result); |
| 66 | |
| 67 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 68 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 69 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 70 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 71 | }; |
| 72 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 73 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 74 | |
| 75 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 76 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 77 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 78 | refAssert.begin(), refAssert.end(), |
| 79 | std::inserter(temp, temp.begin())); |
| 80 | EXPECT_EQ(0, temp.size()); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /** @brief Assert Single LED to On and Try Assert Again */ |
| 85 | TEST_F(LedTest, assertSingleLedOnAndreAssert) |
| 86 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 87 | Manager manager(bus, singleLedOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 88 | { |
| 89 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 90 | ActionSet ledsAssert{}; |
| 91 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 92 | |
| 93 | auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 94 | auto result = |
| 95 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 96 | EXPECT_EQ(true, result); |
| 97 | |
| 98 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 99 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 100 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 101 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 102 | }; |
| 103 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 104 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 105 | |
| 106 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 107 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 108 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 109 | refAssert.begin(), refAssert.end(), |
| 110 | std::inserter(temp, temp.begin())); |
| 111 | EXPECT_EQ(0, temp.size()); |
| 112 | } |
| 113 | { |
| 114 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 115 | ActionSet ledsAssert{}; |
| 116 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 117 | |
| 118 | auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 119 | auto result = |
| 120 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 121 | EXPECT_EQ(true, result); |
| 122 | |
| 123 | EXPECT_EQ(0, ledsAssert.size()); |
| 124 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 125 | } |
| 126 | } |
| 127 | |
| 128 | /** @brief Assert Multiple LEDs to On */ |
| 129 | TEST_F(LedTest, assertMultipleLedOn) |
| 130 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 131 | Manager manager(bus, multipleLedsOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 132 | { |
| 133 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 134 | ActionSet ledsAssert{}; |
| 135 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 136 | |
| 137 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 138 | auto result = |
| 139 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 140 | EXPECT_EQ(true, result); |
| 141 | |
| 142 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 143 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 144 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 145 | phosphor::led::Layout::Action::On}, |
| 146 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 147 | phosphor::led::Layout::Action::On}, |
| 148 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 149 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 150 | }; |
| 151 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 152 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 153 | |
| 154 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 155 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 156 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 157 | refAssert.begin(), refAssert.end(), |
| 158 | std::inserter(temp, temp.begin())); |
| 159 | EXPECT_EQ(0, temp.size()); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** @brief Assert Multiple LEDs to Blink */ |
| 164 | TEST_F(LedTest, assertMultipleLedBlink) |
| 165 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 166 | Manager manager(bus, multipleLedsBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 167 | { |
| 168 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 169 | ActionSet ledsAssert{}; |
| 170 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 171 | |
| 172 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 173 | auto result = |
| 174 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 175 | EXPECT_EQ(true, result); |
| 176 | |
| 177 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 178 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 179 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 180 | phosphor::led::Layout::Action::Blink}, |
| 181 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 182 | phosphor::led::Layout::Action::Blink}, |
| 183 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 184 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 185 | }; |
| 186 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 187 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 188 | |
| 189 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 190 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 191 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 192 | refAssert.begin(), refAssert.end(), |
| 193 | std::inserter(temp, temp.begin())); |
| 194 | EXPECT_EQ(0, temp.size()); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | /** @brief Assert Multiple LEDs to Blink, DeAssert */ |
| 199 | TEST_F(LedTest, assertMultipleLedBlinkAndDeAssert) |
| 200 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 201 | Manager manager(bus, multipleLedsBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 202 | { |
| 203 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 204 | ActionSet ledsAssert{}; |
| 205 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 206 | |
| 207 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 208 | auto result = |
| 209 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 210 | EXPECT_EQ(true, result); |
| 211 | |
| 212 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 213 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 214 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 215 | phosphor::led::Layout::Action::Blink}, |
| 216 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 217 | phosphor::led::Layout::Action::Blink}, |
| 218 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 219 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 220 | }; |
| 221 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 222 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 223 | |
| 224 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 225 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 226 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 227 | refAssert.begin(), refAssert.end(), |
| 228 | std::inserter(temp, temp.begin())); |
| 229 | EXPECT_EQ(0, temp.size()); |
| 230 | } |
| 231 | { |
| 232 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 233 | ActionSet ledsAssert{}; |
| 234 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 235 | |
| 236 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 237 | auto result = |
| 238 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 239 | EXPECT_EQ(false, result); |
| 240 | |
| 241 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 242 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 243 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 244 | phosphor::led::Layout::Action::Blink}, |
| 245 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 246 | phosphor::led::Layout::Action::Blink}, |
| 247 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 248 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 249 | }; |
| 250 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 251 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 252 | |
| 253 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 254 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 255 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 256 | refDeAssert.begin(), refDeAssert.end(), |
| 257 | std::inserter(temp, temp.begin())); |
| 258 | EXPECT_EQ(0, temp.size()); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /** @brief Assert Multiple LEDs to Blink, DeAssert Twice */ |
| 263 | TEST_F(LedTest, assertMultipleLedBlinkAndDeAssertTwice) |
| 264 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 265 | Manager manager(bus, multipleLedsBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 266 | { |
| 267 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 268 | ActionSet ledsAssert{}; |
| 269 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 270 | |
| 271 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 272 | auto result = |
| 273 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 274 | EXPECT_EQ(true, result); |
| 275 | |
| 276 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 277 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 278 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 279 | phosphor::led::Layout::Action::Blink}, |
| 280 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 281 | phosphor::led::Layout::Action::Blink}, |
| 282 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 283 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 284 | }; |
| 285 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 286 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 287 | |
| 288 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 289 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 290 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 291 | refAssert.begin(), refAssert.end(), |
| 292 | std::inserter(temp, temp.begin())); |
| 293 | EXPECT_EQ(0, temp.size()); |
| 294 | } |
| 295 | { |
| 296 | // DeAssert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 297 | ActionSet ledsAssert{}; |
| 298 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 299 | |
| 300 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 301 | auto result = |
| 302 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 303 | EXPECT_EQ(false, result); |
| 304 | |
| 305 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 306 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 307 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 308 | phosphor::led::Layout::Action::Blink}, |
| 309 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 310 | phosphor::led::Layout::Action::Blink}, |
| 311 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 312 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 313 | }; |
| 314 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 315 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 316 | |
| 317 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 318 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 319 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 320 | refDeAssert.begin(), refDeAssert.end(), |
| 321 | std::inserter(temp, temp.begin())); |
| 322 | EXPECT_EQ(0, temp.size()); |
| 323 | } |
| 324 | { |
| 325 | // DeAssert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 326 | ActionSet ledsAssert{}; |
| 327 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 328 | |
| 329 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 330 | auto result = |
| 331 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 332 | EXPECT_EQ(false, result); |
| 333 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 334 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 335 | } |
| 336 | } |
| 337 | |
| 338 | /** @brief Assert Multiple LEDs to mix of On and Blink */ |
| 339 | TEST_F(LedTest, assertMultipleLedOnAndBlink) |
| 340 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 341 | Manager manager(bus, multipleLedsOnAndBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 342 | { |
| 343 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 344 | ActionSet ledsAssert{}; |
| 345 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 346 | |
| 347 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsMix"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 348 | auto result = |
| 349 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 350 | EXPECT_EQ(true, result); |
| 351 | |
| 352 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 353 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 354 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 355 | phosphor::led::Layout::Action::Blink}, |
| 356 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 357 | phosphor::led::Layout::Action::Blink}, |
| 358 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 359 | phosphor::led::Layout::Action::On}, |
| 360 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 361 | phosphor::led::Layout::Action::Blink}, |
| 362 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 363 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 364 | }; |
| 365 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 366 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 367 | |
| 368 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 369 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 370 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 371 | refAssert.begin(), refAssert.end(), |
| 372 | std::inserter(temp, temp.begin())); |
| 373 | EXPECT_EQ(0, temp.size()); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | /** @brief Assert 2 groups having distinct LEDs */ |
| 378 | TEST_F(LedTest, assertTwoGroupsOnWithDistinctLEDOn) |
| 379 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 380 | Manager manager(bus, twoGroupsWithDistinctLEDsOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 381 | { |
| 382 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 383 | ActionSet ledsAssert{}; |
| 384 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 385 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 386 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 387 | auto result = |
| 388 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 389 | EXPECT_EQ(true, result); |
| 390 | |
| 391 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 392 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 393 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 394 | phosphor::led::Layout::Action::Blink}, |
| 395 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 396 | phosphor::led::Layout::Action::On}, |
| 397 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 398 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 399 | }; |
| 400 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 401 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 402 | |
| 403 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 404 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 405 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 406 | refAssert.begin(), refAssert.end(), |
| 407 | std::inserter(temp, temp.begin())); |
| 408 | EXPECT_EQ(0, temp.size()); |
| 409 | } |
| 410 | { |
| 411 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 412 | ActionSet ledsAssert{}; |
| 413 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 414 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 415 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 416 | auto result = |
| 417 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 418 | EXPECT_EQ(true, result); |
| 419 | |
| 420 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 421 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 422 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 423 | phosphor::led::Layout::Action::Blink}, |
| 424 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 425 | phosphor::led::Layout::Action::Blink}, |
| 426 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 427 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 428 | }; |
| 429 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 430 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 431 | |
| 432 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 433 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 434 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 435 | refAssert.begin(), refAssert.end(), |
| 436 | std::inserter(temp, temp.begin())); |
| 437 | EXPECT_EQ(0, temp.size()); |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | /** @brief Assert 2 groups having one of the LEDs common */ |
| 442 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOn) |
| 443 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 444 | Manager manager(bus, twoGroupsWithOneComonLEDOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 445 | { |
| 446 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 447 | ActionSet ledsAssert{}; |
| 448 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 449 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 450 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 451 | auto result = |
| 452 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 453 | EXPECT_EQ(true, result); |
| 454 | |
| 455 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 456 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 457 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 458 | phosphor::led::Layout::Action::On}, |
| 459 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 460 | phosphor::led::Layout::Action::On}, |
| 461 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 462 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 463 | }; |
| 464 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 465 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 466 | |
| 467 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 468 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 469 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 470 | refAssert.begin(), refAssert.end(), |
| 471 | std::inserter(temp, temp.begin())); |
| 472 | EXPECT_EQ(0, temp.size()); |
| 473 | } |
| 474 | { |
| 475 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 476 | ActionSet ledsAssert{}; |
| 477 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 478 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 479 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 480 | auto result = |
| 481 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 482 | EXPECT_EQ(true, result); |
| 483 | |
| 484 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 485 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 486 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 487 | phosphor::led::Layout::Action::On}, |
| 488 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 489 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 490 | }; |
| 491 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 492 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 493 | |
| 494 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 495 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 496 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 497 | refAssert.begin(), refAssert.end(), |
| 498 | std::inserter(temp, temp.begin())); |
| 499 | EXPECT_EQ(0, temp.size()); |
| 500 | } |
| 501 | } |
| 502 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 503 | /** @brief Assert 2 groups having one of the LEDs common but having Blink as |
| 504 | * priority and Deassert*/ |
| 505 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertB) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 506 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 507 | Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 508 | { |
| 509 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 510 | ActionSet ledsAssert{}; |
| 511 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 512 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 513 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 514 | auto result = |
| 515 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 516 | EXPECT_EQ(true, result); |
| 517 | |
| 518 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 519 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 520 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 521 | phosphor::led::Layout::Action::On}, |
| 522 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 523 | phosphor::led::Layout::Action::On}, |
| 524 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 525 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 526 | }; |
| 527 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 528 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 529 | |
| 530 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 531 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 532 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 533 | refAssert.begin(), refAssert.end(), |
| 534 | std::inserter(temp, temp.begin())); |
| 535 | EXPECT_EQ(0, temp.size()); |
| 536 | } |
| 537 | { |
| 538 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 539 | ActionSet ledsAssert{}; |
| 540 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 541 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 542 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 543 | auto result = |
| 544 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 545 | EXPECT_EQ(true, result); |
| 546 | |
| 547 | // Need just the ledsAssserted populated with these. |
| 548 | // Does not action on [Three] since priority is [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 549 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 550 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 551 | phosphor::led::Layout::Action::On}, |
| 552 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 553 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 554 | }; |
| 555 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 556 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 557 | |
| 558 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 559 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 560 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 561 | refAssert.begin(), refAssert.end(), |
| 562 | std::inserter(temp, temp.begin())); |
| 563 | EXPECT_EQ(0, temp.size()); |
| 564 | } |
| 565 | { |
| 566 | // De-Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 567 | ActionSet ledsAssert{}; |
| 568 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 569 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 570 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 571 | auto result = |
| 572 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 573 | EXPECT_EQ(false, result); |
| 574 | |
| 575 | // Need just the ledsDeAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 576 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 577 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 578 | phosphor::led::Layout::Action::On}, |
| 579 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 580 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 581 | }; |
| 582 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 583 | EXPECT_EQ(0, ledsAssert.size()); |
| 584 | |
| 585 | // difference of refDeAssert and ledsDeAssert must be null. |
| 586 | // [Three] is not touched since its already [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 587 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 588 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 589 | refDeAssert.begin(), refDeAssert.end(), |
| 590 | std::inserter(temp, temp.begin())); |
| 591 | EXPECT_EQ(0, temp.size()); |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | /** @brief Assert 2 groups having one of the LEDs common but having Blink as |
| 596 | * priority and Deassert A */ |
| 597 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertA) |
| 598 | { |
| 599 | Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority); |
| 600 | { |
| 601 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 602 | ActionSet ledsAssert{}; |
| 603 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 604 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 605 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 606 | auto result = |
| 607 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 608 | EXPECT_EQ(true, result); |
| 609 | |
| 610 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 611 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 612 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 613 | phosphor::led::Layout::Action::On}, |
| 614 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 615 | phosphor::led::Layout::Action::On}, |
| 616 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 617 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 618 | }; |
| 619 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 620 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 621 | |
| 622 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 623 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 624 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 625 | refAssert.begin(), refAssert.end(), |
| 626 | std::inserter(temp, temp.begin())); |
| 627 | EXPECT_EQ(0, temp.size()); |
| 628 | } |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 629 | { |
| 630 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 631 | ActionSet ledsAssert{}; |
| 632 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 633 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 634 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 635 | auto result = |
| 636 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 637 | EXPECT_EQ(true, result); |
| 638 | |
| 639 | // Need just the ledsAssserted populated with these. |
| 640 | // [Three] does not get actioned since it has Blink priority |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 641 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 642 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 643 | phosphor::led::Layout::Action::On}, |
| 644 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 645 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 646 | }; |
| 647 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 648 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 649 | |
| 650 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 651 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 652 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 653 | refAssert.begin(), refAssert.end(), |
| 654 | std::inserter(temp, temp.begin())); |
| 655 | EXPECT_EQ(0, temp.size()); |
| 656 | } |
| 657 | { |
| 658 | // De-Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 659 | ActionSet ledsAssert{}; |
| 660 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 661 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 662 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 663 | auto result = |
| 664 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 665 | EXPECT_EQ(false, result); |
| 666 | |
| 667 | // Need just the ledsDeAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 668 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 669 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 670 | phosphor::led::Layout::Action::On}, |
| 671 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 672 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 673 | }; |
| 674 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 675 | |
| 676 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 677 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 678 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 679 | refDeAssert.begin(), refDeAssert.end(), |
| 680 | std::inserter(temp, temp.begin())); |
| 681 | EXPECT_EQ(0, temp.size()); |
| 682 | |
| 683 | // Need just the ledsAssert populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 684 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 685 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 686 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 687 | }; |
| 688 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 689 | |
| 690 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 691 | ActionSet temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 692 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 693 | refAssert.begin(), refAssert.end(), |
| 694 | std::inserter(temp1, temp1.begin())); |
| 695 | EXPECT_EQ(0, temp1.size()); |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | /** @brief Assert 2 groups having one of the LEDs common but having ON as |
| 700 | * priority And Deassert A */ |
| 701 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertA) |
| 702 | { |
| 703 | Manager manager(bus, twoGroupsWithOneComonLEDOnPriority); |
| 704 | { |
| 705 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 706 | ActionSet ledsAssert{}; |
| 707 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 708 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 709 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 710 | auto result = |
| 711 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 712 | EXPECT_EQ(true, result); |
| 713 | |
| 714 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 715 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 716 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 717 | phosphor::led::Layout::Action::On}, |
| 718 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 719 | phosphor::led::Layout::Action::On}, |
| 720 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 721 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 722 | }; |
| 723 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 724 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 725 | |
| 726 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 727 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 728 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 729 | refAssert.begin(), refAssert.end(), |
| 730 | std::inserter(temp, temp.begin())); |
| 731 | EXPECT_EQ(0, temp.size()); |
| 732 | } |
| 733 | { |
| 734 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 735 | ActionSet ledsAssert{}; |
| 736 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 737 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 738 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 739 | auto result = |
| 740 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 741 | EXPECT_EQ(true, result); |
| 742 | |
| 743 | // Need just the ledsAssserted populated with these. |
| 744 | // Three is set to ON due to ON priority. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 745 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 746 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 747 | phosphor::led::Layout::Action::On}, |
| 748 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 749 | phosphor::led::Layout::Action::On}, |
| 750 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 751 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 752 | }; |
| 753 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 754 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 755 | |
| 756 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 757 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 758 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 759 | refAssert.begin(), refAssert.end(), |
| 760 | std::inserter(temp, temp.begin())); |
| 761 | } |
| 762 | { |
| 763 | // De-Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 764 | ActionSet ledsAssert{}; |
| 765 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 766 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 767 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 768 | auto result = |
| 769 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 770 | EXPECT_EQ(false, result); |
| 771 | |
| 772 | // Need just the ledsDeAssserted populated with these. |
| 773 | // [Three] stays in [On] since [B] has it [On] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 774 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 775 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 776 | phosphor::led::Layout::Action::On}, |
| 777 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 778 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 779 | }; |
| 780 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 781 | EXPECT_EQ(0, ledsAssert.size()); |
| 782 | |
| 783 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 784 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 785 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 786 | refDeAssert.begin(), refDeAssert.end(), |
| 787 | std::inserter(temp, temp.begin())); |
| 788 | EXPECT_EQ(0, temp.size()); |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | /** @brief Assert 2 groups having one of the LEDs common but having ON as |
| 793 | * priority And Deassert B */ |
| 794 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertB) |
| 795 | { |
| 796 | Manager manager(bus, twoGroupsWithOneComonLEDOnPriority); |
| 797 | { |
| 798 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 799 | ActionSet ledsAssert{}; |
| 800 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 801 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 802 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 803 | auto result = |
| 804 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 805 | EXPECT_EQ(true, result); |
| 806 | |
| 807 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 808 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 809 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 810 | phosphor::led::Layout::Action::On}, |
| 811 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 812 | phosphor::led::Layout::Action::On}, |
| 813 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 814 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 815 | }; |
| 816 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 817 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 818 | |
| 819 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 820 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 821 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 822 | refAssert.begin(), refAssert.end(), |
| 823 | std::inserter(temp, temp.begin())); |
| 824 | EXPECT_EQ(0, temp.size()); |
| 825 | } |
| 826 | { |
| 827 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 828 | ActionSet ledsAssert{}; |
| 829 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 830 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 831 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 832 | auto result = |
| 833 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 834 | EXPECT_EQ(true, result); |
| 835 | |
| 836 | // Need just the ledsAssserted populated with these. |
| 837 | // Three is set to ON due to ON priority. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 838 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 839 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 840 | phosphor::led::Layout::Action::On}, |
| 841 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 842 | phosphor::led::Layout::Action::On}, |
| 843 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 844 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 845 | }; |
| 846 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 847 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 848 | |
| 849 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 850 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 851 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 852 | refAssert.begin(), refAssert.end(), |
| 853 | std::inserter(temp, temp.begin())); |
| 854 | } |
| 855 | { |
| 856 | // De-Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 857 | ActionSet ledsAssert{}; |
| 858 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 859 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 860 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 861 | auto result = |
| 862 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 863 | EXPECT_EQ(false, result); |
| 864 | |
| 865 | // Need just the ledsDeAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 866 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 867 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 868 | phosphor::led::Layout::Action::On}, |
| 869 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 870 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 871 | }; |
| 872 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 873 | |
| 874 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 875 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 876 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 877 | refDeAssert.begin(), refDeAssert.end(), |
| 878 | std::inserter(temp, temp.begin())); |
| 879 | EXPECT_EQ(0, temp.size()); |
| 880 | |
| 881 | // Need just the ledsAssert populated with these. |
| 882 | // Since [Three] stood [On], need to go back to [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 883 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 884 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 885 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 886 | }; |
| 887 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 888 | |
| 889 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 890 | ActionSet temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 891 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 892 | refAssert.begin(), refAssert.end(), |
| 893 | std::inserter(temp, temp.begin())); |
| 894 | EXPECT_EQ(0, temp.size()); |
| 895 | } |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | /** @brief Assert 2 groups having multiple common LEDs in Same State */ |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 899 | TEST_F(LedTest, assertTwoGroupsWithMultiplComonLEDOnAndDeAssert) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 900 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 901 | Manager manager(bus, twoGroupsWithMultiplComonLEDOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 902 | { |
| 903 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 904 | ActionSet ledsAssert{}; |
| 905 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 906 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 907 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 908 | auto result = |
| 909 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 910 | EXPECT_EQ(true, result); |
| 911 | |
| 912 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 913 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 914 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 915 | phosphor::led::Layout::Action::On}, |
| 916 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 917 | phosphor::led::Layout::Action::On}, |
| 918 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 919 | phosphor::led::Layout::Action::On}, |
| 920 | {"Seven", phosphor::led::Layout::Action::On, 0, 0, |
| 921 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 922 | }; |
| 923 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 924 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 925 | |
| 926 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 927 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 928 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 929 | refAssert.begin(), refAssert.end(), |
| 930 | std::inserter(temp, temp.begin())); |
| 931 | EXPECT_EQ(0, temp.size()); |
| 932 | } |
| 933 | { |
| 934 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 935 | ActionSet ledsAssert{}; |
| 936 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 937 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 938 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 939 | auto result = |
| 940 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 941 | EXPECT_EQ(true, result); |
| 942 | |
| 943 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 944 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 945 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 946 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 947 | }; |
| 948 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 949 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 950 | |
| 951 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 952 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 953 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 954 | refAssert.begin(), refAssert.end(), |
| 955 | std::inserter(temp, temp.begin())); |
| 956 | EXPECT_EQ(0, temp.size()); |
| 957 | } |
| 958 | { |
| 959 | // De-Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 960 | ActionSet ledsAssert{}; |
| 961 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 962 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 963 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 964 | auto result = |
| 965 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 966 | EXPECT_EQ(false, result); |
| 967 | |
| 968 | // Need just the ledsDeAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 969 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 970 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 971 | phosphor::led::Layout::Action::On}, |
| 972 | {"Seven", phosphor::led::Layout::Action::On, 0, 0, |
| 973 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 974 | }; |
| 975 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 976 | EXPECT_EQ(0, ledsAssert.size()); |
| 977 | |
| 978 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 979 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 980 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 981 | refDeAssert.begin(), refDeAssert.end(), |
| 982 | std::inserter(temp, temp.begin())); |
| 983 | EXPECT_EQ(0, temp.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 984 | } |
| 985 | } |
| 986 | |
| 987 | /** @brief Assert 2 groups having multiple LEDs common in different state */ |
| 988 | TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateBandA) |
| 989 | { |
| 990 | Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState); |
| 991 | { |
| 992 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 993 | ActionSet ledsAssert{}; |
| 994 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 995 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 996 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 997 | auto result = |
| 998 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 999 | EXPECT_EQ(true, result); |
| 1000 | |
| 1001 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1002 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1003 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1004 | phosphor::led::Layout::Action::On}, |
| 1005 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1006 | phosphor::led::Layout::Action::On}, |
| 1007 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1008 | phosphor::led::Layout::Action::On}, |
| 1009 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1010 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1011 | }; |
| 1012 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1013 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1014 | |
| 1015 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1016 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1017 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1018 | refAssert.begin(), refAssert.end(), |
| 1019 | std::inserter(temp, temp.begin())); |
| 1020 | EXPECT_EQ(0, temp.size()); |
| 1021 | } |
| 1022 | { |
| 1023 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1024 | ActionSet ledsAssert{}; |
| 1025 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1026 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1027 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1028 | auto result = |
| 1029 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1030 | EXPECT_EQ(true, result); |
| 1031 | |
| 1032 | // Need just the ledsAssserted populated with these |
| 1033 | // [Two] remains [On] due to higher priority. |
| 1034 | // [Three] remains [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1035 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1036 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1037 | phosphor::led::Layout::Action::On}, |
| 1038 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1039 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1040 | }; |
| 1041 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1042 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1043 | |
| 1044 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1045 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1046 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1047 | refAssert.begin(), refAssert.end(), |
| 1048 | std::inserter(temp, temp.begin())); |
| 1049 | EXPECT_EQ(0, temp.size()); |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | /** @brief Assert 2 groups having multiple LEDs common in different state */ |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1054 | TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoB) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1055 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 1056 | Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1057 | { |
| 1058 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1059 | ActionSet ledsAssert{}; |
| 1060 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1061 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1062 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1063 | auto result = |
| 1064 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1065 | EXPECT_EQ(true, result); |
| 1066 | |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1067 | // Need just the ledsAssserted populated with these.'Two' gets to Blink |
| 1068 | // due to higher priority. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1069 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1070 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1071 | phosphor::led::Layout::Action::On}, |
| 1072 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1073 | phosphor::led::Layout::Action::On}, |
| 1074 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1075 | phosphor::led::Layout::Action::On}, |
| 1076 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1077 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1078 | }; |
| 1079 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1080 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1081 | |
| 1082 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1083 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1084 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1085 | refAssert.begin(), refAssert.end(), |
| 1086 | std::inserter(temp, temp.begin())); |
| 1087 | EXPECT_EQ(0, temp.size()); |
| 1088 | } |
| 1089 | { |
| 1090 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1091 | ActionSet ledsAssert{}; |
| 1092 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1093 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1094 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1095 | auto result = |
| 1096 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1097 | EXPECT_EQ(true, result); |
| 1098 | |
| 1099 | // Need just the ledsAssserted populated with these. |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1100 | // [Three] remains [Blink] from previous |
| 1101 | // [Two] moves to [On] from [Blink] due to [On] priority |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1102 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1103 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1104 | phosphor::led::Layout::Action::On}, |
| 1105 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1106 | phosphor::led::Layout::Action::On}, |
| 1107 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1108 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1109 | }; |
| 1110 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1111 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1112 | |
| 1113 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1114 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1115 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1116 | refAssert.begin(), refAssert.end(), |
| 1117 | std::inserter(temp, temp.begin())); |
| 1118 | EXPECT_EQ(0, temp.size()); |
| 1119 | } |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1120 | } |
| 1121 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1122 | /** @brief Assert 2 groups having multiple LEDs common in different state |
| 1123 | * DeAssert twice |
| 1124 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1125 | TEST_F(LedTest, |
| 1126 | assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoBDeAssertTwice) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1127 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 1128 | Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1129 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1130 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1131 | ActionSet ledsAssert{}; |
| 1132 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1133 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1134 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1135 | auto result = |
| 1136 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1137 | EXPECT_EQ(true, result); |
| 1138 | |
| 1139 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1140 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1141 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1142 | phosphor::led::Layout::Action::On}, |
| 1143 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1144 | phosphor::led::Layout::Action::On}, |
| 1145 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1146 | phosphor::led::Layout::Action::On}, |
| 1147 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1148 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1149 | }; |
| 1150 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1151 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1152 | |
| 1153 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1154 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1155 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1156 | refAssert.begin(), refAssert.end(), |
| 1157 | std::inserter(temp, temp.begin())); |
| 1158 | EXPECT_EQ(0, temp.size()); |
| 1159 | } |
| 1160 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1161 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1162 | ActionSet ledsAssert{}; |
| 1163 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1164 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1165 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1166 | auto result = |
| 1167 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1168 | EXPECT_EQ(true, result); |
| 1169 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1170 | // Need just the ledsAssserted populated with these. |
| 1171 | // [Two] turns [On] due to priority |
| 1172 | // [Three] remains [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1173 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1174 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1175 | phosphor::led::Layout::Action::On}, |
| 1176 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1177 | phosphor::led::Layout::Action::On}, |
| 1178 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1179 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1180 | }; |
| 1181 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1182 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1183 | |
| 1184 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1185 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1186 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1187 | refAssert.begin(), refAssert.end(), |
| 1188 | std::inserter(temp, temp.begin())); |
| 1189 | EXPECT_EQ(0, temp.size()); |
| 1190 | } |
| 1191 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1192 | // DeAssert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1193 | ActionSet ledsAssert{}; |
| 1194 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1195 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1196 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1197 | auto result = |
| 1198 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1199 | EXPECT_EQ(false, result); |
| 1200 | |
| 1201 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1202 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1203 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1204 | phosphor::led::Layout::Action::On}, |
| 1205 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1206 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1207 | }; |
| 1208 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1209 | |
| 1210 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1211 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1212 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 1213 | refDeAssert.begin(), refDeAssert.end(), |
| 1214 | std::inserter(temp, temp.begin())); |
| 1215 | EXPECT_EQ(0, temp.size()); |
| 1216 | |
| 1217 | // Need just the ledsAssert populated with these. |
| 1218 | // [Two] will go back to [Blink] from [On] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1219 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1220 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1221 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1222 | }; |
| 1223 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1224 | |
| 1225 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1226 | ActionSet temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1227 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1228 | refAssert.begin(), refAssert.end(), |
| 1229 | std::inserter(temp1, temp1.begin())); |
| 1230 | EXPECT_EQ(0, temp1.size()); |
| 1231 | } |
| 1232 | { |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1233 | // DeAssert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1234 | ActionSet ledsAssert{}; |
| 1235 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1236 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1237 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1238 | auto result = |
| 1239 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1240 | EXPECT_EQ(false, result); |
| 1241 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1242 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1243 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1244 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1245 | phosphor::led::Layout::Action::On}, |
| 1246 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1247 | phosphor::led::Layout::Action::On}, |
| 1248 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1249 | phosphor::led::Layout::Action::On}, |
| 1250 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1251 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1252 | }; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1253 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1254 | EXPECT_EQ(0, ledsAssert.size()); |
| 1255 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1256 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1257 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1258 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 1259 | refDeAssert.begin(), refDeAssert.end(), |
| 1260 | std::inserter(temp, temp.begin())); |
| 1261 | EXPECT_EQ(0, temp.size()); |
| 1262 | } |
| 1263 | { |
| 1264 | // DeAssert Set-A again and make sure we get all empty |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1265 | ActionSet ledsAssert{}; |
| 1266 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1267 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1268 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1269 | auto result = |
| 1270 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1271 | EXPECT_EQ(false, result); |
| 1272 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1273 | EXPECT_EQ(0, ledsAssert.size()); |
| 1274 | } |
| 1275 | } |
| 1276 | |
| 1277 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1278 | * mixed priority. DeAssert-A |
| 1279 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1280 | TEST_F(LedTest, |
| 1281 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandB) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1282 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1283 | Manager manager(bus, |
| 1284 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1285 | { |
| 1286 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1287 | ActionSet ledsAssert{}; |
| 1288 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1289 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1290 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1291 | auto result = |
| 1292 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1293 | EXPECT_EQ(true, result); |
| 1294 | |
| 1295 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1296 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1297 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1298 | phosphor::led::Layout::Action::On}, |
| 1299 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1300 | phosphor::led::Layout::Action::On}, |
| 1301 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1302 | phosphor::led::Layout::Action::Blink}, |
| 1303 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1304 | phosphor::led::Layout::Action::On}, |
| 1305 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1306 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1307 | }; |
| 1308 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1309 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1310 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1311 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1312 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1313 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1314 | refAssert.begin(), refAssert.end(), |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1315 | std::inserter(temp, temp.begin())); |
| 1316 | EXPECT_EQ(0, temp.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1317 | } |
| 1318 | { |
| 1319 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1320 | ActionSet ledsAssert{}; |
| 1321 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1322 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1323 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1324 | auto result = |
| 1325 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1326 | EXPECT_EQ(true, result); |
| 1327 | |
| 1328 | // Need just the ledsAssserted populated with these. |
| 1329 | // [Two] gets to [ON] due to higher priority. |
| 1330 | // [Three] remains on since it never was in [Blink] before |
| 1331 | // [Ten] remains [Blink] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1332 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1333 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1334 | phosphor::led::Layout::Action::On}, |
| 1335 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1336 | phosphor::led::Layout::Action::On}, |
| 1337 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1338 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1339 | }; |
| 1340 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1341 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1342 | |
| 1343 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1344 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1345 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1346 | refAssert.begin(), refAssert.end(), |
| 1347 | std::inserter(temp, temp.begin())); |
| 1348 | EXPECT_EQ(0, temp.size()); |
| 1349 | } |
| 1350 | { |
| 1351 | // De-Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1352 | ActionSet ledsAssert{}; |
| 1353 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1354 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1355 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1356 | auto result = |
| 1357 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1358 | EXPECT_EQ(false, result); |
| 1359 | |
| 1360 | // Need just the ledsDeAsssert populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1361 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1362 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1363 | phosphor::led::Layout::Action::On}, |
| 1364 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1365 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1366 | }; |
| 1367 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1368 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1369 | // Need just the ledsAsssert populated with these. |
| 1370 | // [Ten] Moves to [On] since there is no prior [Blink] |
| 1371 | // [Three] remains [On] since it never changed state. |
| 1372 | // [Two] remains [On] since it did not go back |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1373 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1374 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1375 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1376 | }; |
| 1377 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1378 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1379 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1380 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1381 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1382 | refAssert.begin(), refAssert.end(), |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1383 | std::inserter(temp, temp.begin())); |
| 1384 | EXPECT_EQ(0, temp.size()); |
| 1385 | } |
| 1386 | } |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1387 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1388 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1389 | * mixed priority. DeAssert-B |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1390 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1391 | TEST_F( |
| 1392 | LedTest, |
| 1393 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandBDeAssertB) |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1394 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1395 | Manager manager(bus, |
| 1396 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1397 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1398 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1399 | ActionSet ledsAssert{}; |
| 1400 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1401 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1402 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1403 | auto result = |
| 1404 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1405 | EXPECT_EQ(true, result); |
| 1406 | |
| 1407 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1408 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1409 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1410 | phosphor::led::Layout::Action::On}, |
| 1411 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1412 | phosphor::led::Layout::Action::On}, |
| 1413 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1414 | phosphor::led::Layout::Action::Blink}, |
| 1415 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1416 | phosphor::led::Layout::Action::On}, |
| 1417 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1418 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1419 | }; |
| 1420 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1421 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1422 | |
| 1423 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1424 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1425 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1426 | refAssert.begin(), refAssert.end(), |
| 1427 | std::inserter(temp, temp.begin())); |
| 1428 | EXPECT_EQ(0, temp.size()); |
| 1429 | } |
| 1430 | { |
| 1431 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1432 | ActionSet ledsAssert{}; |
| 1433 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1434 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1435 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1436 | auto result = |
| 1437 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1438 | EXPECT_EQ(true, result); |
| 1439 | |
| 1440 | // Need just the ledsAssserted populated with these. |
| 1441 | // [Two] gets to [ON] due to higher priority. |
| 1442 | // [Three] remains on since it never was in [Blink] before |
| 1443 | // [Ten] remains [Blink] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1444 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1445 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1446 | phosphor::led::Layout::Action::On}, |
| 1447 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1448 | phosphor::led::Layout::Action::On}, |
| 1449 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1450 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1451 | }; |
| 1452 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1453 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1454 | |
| 1455 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1456 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1457 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1458 | refAssert.begin(), refAssert.end(), |
| 1459 | std::inserter(temp, temp.begin())); |
| 1460 | EXPECT_EQ(0, temp.size()); |
| 1461 | } |
| 1462 | { |
| 1463 | // De-Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1464 | ActionSet ledsAssert{}; |
| 1465 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1466 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1467 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1468 | auto result = |
| 1469 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1470 | EXPECT_EQ(false, result); |
| 1471 | |
| 1472 | // Need just the ledsDeAsssert populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1473 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1474 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1475 | phosphor::led::Layout::Action::On}, |
| 1476 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1477 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1478 | }; |
| 1479 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1480 | |
| 1481 | // Need just the ledsAsssert populated with these. |
| 1482 | // [Ten] remains [Blink] since it did not move to [On] |
| 1483 | // [Three] remains [On] since it never changed state. |
| 1484 | // [Two] moves to [Blink] since there is no prior [On] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1485 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1486 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1487 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1488 | }; |
| 1489 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1490 | |
| 1491 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1492 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1493 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1494 | refAssert.begin(), refAssert.end(), |
| 1495 | std::inserter(temp, temp.begin())); |
| 1496 | EXPECT_EQ(0, temp.size()); |
| 1497 | } |
| 1498 | } |
| 1499 | |
| 1500 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1501 | * mixed priority. |
| 1502 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1503 | TEST_F(LedTest, |
| 1504 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandA) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1505 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1506 | Manager manager(bus, |
| 1507 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1508 | { |
| 1509 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1510 | ActionSet ledsAssert{}; |
| 1511 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1512 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1513 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1514 | auto result = |
| 1515 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1516 | EXPECT_EQ(true, result); |
| 1517 | |
| 1518 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1519 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1520 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1521 | phosphor::led::Layout::Action::On}, |
| 1522 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1523 | phosphor::led::Layout::Action::Blink}, |
| 1524 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1525 | phosphor::led::Layout::Action::On}, |
| 1526 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1527 | phosphor::led::Layout::Action::On}, |
| 1528 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1529 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1530 | }; |
| 1531 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1532 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1533 | |
| 1534 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1535 | ActionSet temp{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1536 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1537 | refAssert.begin(), refAssert.end(), |
| 1538 | std::inserter(temp, temp.begin())); |
| 1539 | EXPECT_EQ(0, temp.size()); |
| 1540 | } |
| 1541 | { |
| 1542 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1543 | ActionSet ledsAssert{}; |
| 1544 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1545 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1546 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1547 | auto result = |
| 1548 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1549 | EXPECT_EQ(true, result); |
| 1550 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1551 | // Need just the ledsAssserted populated with these. |
| 1552 | // [Two] remains [ON] due to higher priority. |
| 1553 | // [Three] remains on since it never was in [Blink] before |
| 1554 | // [Ten] moves to [Blink] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1555 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1556 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1557 | phosphor::led::Layout::Action::On}, |
| 1558 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1559 | phosphor::led::Layout::Action::On}, |
| 1560 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1561 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1562 | }; |
| 1563 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1564 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1565 | |
| 1566 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1567 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1568 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1569 | refAssert.begin(), refAssert.end(), |
| 1570 | std::inserter(temp, temp.begin())); |
| 1571 | EXPECT_EQ(0, temp.size()); |
| 1572 | } |
| 1573 | } |
| 1574 | |
| 1575 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1576 | * mixed priority and De-Assert-A |
| 1577 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1578 | TEST_F( |
| 1579 | LedTest, |
| 1580 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandADeAssertA) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1581 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1582 | Manager manager(bus, |
| 1583 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1584 | { |
| 1585 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1586 | ActionSet ledsAssert{}; |
| 1587 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1588 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1589 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1590 | auto result = |
| 1591 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1592 | EXPECT_EQ(true, result); |
| 1593 | |
| 1594 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1595 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1596 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1597 | phosphor::led::Layout::Action::On}, |
| 1598 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1599 | phosphor::led::Layout::Action::Blink}, |
| 1600 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1601 | phosphor::led::Layout::Action::On}, |
| 1602 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1603 | phosphor::led::Layout::Action::On}, |
| 1604 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1605 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1606 | }; |
| 1607 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1608 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1609 | |
| 1610 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1611 | ActionSet temp{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1612 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1613 | refAssert.begin(), refAssert.end(), |
| 1614 | std::inserter(temp, temp.begin())); |
| 1615 | EXPECT_EQ(0, temp.size()); |
| 1616 | } |
| 1617 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1618 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1619 | ActionSet ledsAssert{}; |
| 1620 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1621 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1622 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1623 | auto result = |
| 1624 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1625 | EXPECT_EQ(true, result); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1626 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1627 | // Need just the ledsAssserted populated with these. |
| 1628 | // [Two] remains [ON] due to higher priority. |
| 1629 | // [Three] remains on since it never was in [Blink] before |
| 1630 | // [Ten] moves to [Blink] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1631 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1632 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1633 | phosphor::led::Layout::Action::On}, |
| 1634 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1635 | phosphor::led::Layout::Action::On}, |
| 1636 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1637 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1638 | }; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1639 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1640 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1641 | |
| 1642 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1643 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1644 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1645 | refAssert.begin(), refAssert.end(), |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1646 | std::inserter(temp, temp.begin())); |
| 1647 | EXPECT_EQ(0, temp.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1648 | } |
| 1649 | { |
| 1650 | // De-Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1651 | ActionSet ledsAssert{}; |
| 1652 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1653 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1654 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1655 | auto result = |
| 1656 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1657 | EXPECT_EQ(false, result); |
| 1658 | |
| 1659 | // Need just the ledsAssserted populated with these. |
| 1660 | // [Ten] remains [Blink] due to priority. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1661 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1662 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1663 | phosphor::led::Layout::Action::On}, |
| 1664 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1665 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1666 | }; |
| 1667 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1668 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1669 | // Need just the ledsAssserted populated with these. |
| 1670 | // [Two] remains [ON] due to higher priority. |
| 1671 | // [Three] remains [On] since it never was in [Blink] before |
| 1672 | // [Ten] moves to [On] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1673 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1674 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1675 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1676 | }; |
| 1677 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1678 | |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1679 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1680 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1681 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1682 | refAssert.begin(), refAssert.end(), |
| 1683 | std::inserter(temp, temp.begin())); |
| 1684 | EXPECT_EQ(0, temp.size()); |
| 1685 | } |
| 1686 | } |
| 1687 | |
| 1688 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1689 | * mixed priority and then DeAssert twice. |
| 1690 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1691 | TEST_F(LedTest, |
| 1692 | assertTwoGroupsWithMultipleComonLEDInDifferentStateOnBlinkPriorityBandA) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1693 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1694 | Manager manager(bus, |
| 1695 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1696 | { |
| 1697 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1698 | ActionSet ledsAssert{}; |
| 1699 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1700 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1701 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1702 | auto result = |
| 1703 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1704 | EXPECT_EQ(true, result); |
| 1705 | |
| 1706 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1707 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1708 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1709 | phosphor::led::Layout::Action::On}, |
| 1710 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1711 | phosphor::led::Layout::Action::Blink}, |
| 1712 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1713 | phosphor::led::Layout::Action::On}, |
| 1714 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1715 | phosphor::led::Layout::Action::On}, |
| 1716 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1717 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1718 | }; |
| 1719 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1720 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1721 | |
| 1722 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1723 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1724 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1725 | refAssert.begin(), refAssert.end(), |
| 1726 | std::inserter(temp, temp.begin())); |
| 1727 | EXPECT_EQ(0, temp.size()); |
| 1728 | } |
| 1729 | { |
| 1730 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1731 | ActionSet ledsAssert{}; |
| 1732 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1733 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1734 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1735 | auto result = |
| 1736 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1737 | EXPECT_EQ(true, result); |
| 1738 | |
| 1739 | // Need just the ledsAssserted populated with these. |
| 1740 | // [Two] remains [ON] due to higher priority. |
| 1741 | // [Three] remains on since it never was in [Blink] before |
| 1742 | // [Ten] moves to [Blink] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1743 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1744 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1745 | phosphor::led::Layout::Action::On}, |
| 1746 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1747 | phosphor::led::Layout::Action::On}, |
| 1748 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1749 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1750 | }; |
| 1751 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1752 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1753 | |
| 1754 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1755 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1756 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1757 | refAssert.begin(), refAssert.end(), |
| 1758 | std::inserter(temp, temp.begin())); |
| 1759 | EXPECT_EQ(0, temp.size()); |
| 1760 | } |
| 1761 | { |
| 1762 | // DeAssert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1763 | ActionSet ledsAssert{}; |
| 1764 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1765 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1766 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1767 | auto result = |
| 1768 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1769 | EXPECT_EQ(false, result); |
| 1770 | |
| 1771 | // Need just the ledsAssserted populated with these. |
| 1772 | // [Ten] remains [Blink] due to priority. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1773 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1774 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1775 | phosphor::led::Layout::Action::On}, |
| 1776 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1777 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1778 | }; |
| 1779 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1780 | |
| 1781 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1782 | ActionSet temp{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1783 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 1784 | refDeAssert.begin(), refDeAssert.end(), |
| 1785 | std::inserter(temp, temp.begin())); |
| 1786 | EXPECT_EQ(0, temp.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1787 | |
| 1788 | // Need just the ledsAssert populated with these. |
| 1789 | // [Two] will move to [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1790 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1791 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1792 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1793 | }; |
| 1794 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1795 | |
| 1796 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1797 | ActionSet temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1798 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1799 | refAssert.begin(), refAssert.end(), |
| 1800 | std::inserter(temp1, temp1.begin())); |
| 1801 | EXPECT_EQ(0, temp1.size()); |
| 1802 | } |
| 1803 | { |
| 1804 | // DeAssert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1805 | ActionSet ledsAssert{}; |
| 1806 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1807 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1808 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1809 | auto result = |
| 1810 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1811 | EXPECT_EQ(false, result); |
| 1812 | |
| 1813 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1814 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1815 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1816 | phosphor::led::Layout::Action::On}, |
| 1817 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1818 | phosphor::led::Layout::Action::On}, |
| 1819 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1820 | phosphor::led::Layout::Action::Blink}, |
| 1821 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1822 | phosphor::led::Layout::Action::On}, |
| 1823 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1824 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1825 | }; |
| 1826 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1827 | EXPECT_EQ(0, ledsAssert.size()); |
| 1828 | |
| 1829 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1830 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1831 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 1832 | refDeAssert.begin(), refDeAssert.end(), |
| 1833 | std::inserter(temp, temp.begin())); |
| 1834 | EXPECT_EQ(0, temp.size()); |
| 1835 | } |
| 1836 | { |
| 1837 | // DeAssert Set-B again and make sure we get all empty |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1838 | ActionSet ledsAssert{}; |
| 1839 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1840 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1841 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1842 | auto result = |
| 1843 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1844 | EXPECT_EQ(false, result); |
| 1845 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1846 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1847 | } |
| 1848 | } |