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