Skip to content

Commit

Permalink
Remove "brightness" from bluePath and yellowPath
Browse files Browse the repository at this point in the history
Summary: Removing brightness from the path that we store in BSP mapping will allow us to use that variable as a base path. Later in the diff stack, i will add blinking of led. The path for controlling blinking will have the same base path

Reviewed By: rajank7

Differential Revision: D56506142

fbshipit-source-id: 5aa1aa40b8fc35be4e01bfef112bf4f10c8e62f8
  • Loading branch information
Harshit Gulati authored and facebook-github-bot committed Apr 26, 2024
1 parent 90cdd78 commit 45fed4e
Show file tree
Hide file tree
Showing 8 changed files with 1,514 additions and 1,505 deletions.
360 changes: 180 additions & 180 deletions fboss/lib/bsp/janga800bic/Janga800bicBspPlatformMapping.cpp

Large diffs are not rendered by default.

1,024 changes: 512 additions & 512 deletions fboss/lib/bsp/meru800bfa/Meru800bfaBspPlatformMapping.cpp

Large diffs are not rendered by default.

320 changes: 160 additions & 160 deletions fboss/lib/bsp/meru800bia/Meru800biaBspPlatformMapping.cpp

Large diffs are not rendered by default.

512 changes: 256 additions & 256 deletions fboss/lib/bsp/montblanc/MontblancBspPlatformMapping.cpp

Large diffs are not rendered by default.

512 changes: 256 additions & 256 deletions fboss/lib/bsp/morgan800cc/Morgan800ccBspPlatformMapping.cpp

Large diffs are not rendered by default.

264 changes: 132 additions & 132 deletions fboss/lib/bsp/tahan800bc/Tahan800bcBspPlatformMapping.cpp

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion fboss/lib/led/LedIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace {
constexpr auto kLedOn = "1";
constexpr auto kLedOff = "0";
constexpr auto kLedBrightnessPath = "/brightness";
} // namespace

namespace facebook::fboss {
Expand Down Expand Up @@ -107,7 +108,8 @@ void LedIO::yellowOff() {
setLed(*yellowPath_, kLedOff);
}

void LedIO::setLed(const std::string& ledPath, const std::string& ledOp) {
void LedIO::setLed(const std::string& ledBasePath, const std::string& ledOp) {
std::string ledPath = ledBasePath + kLedBrightnessPath;
std::fstream fs;
fs.open(ledPath, std::fstream::out);

Expand Down
23 changes: 15 additions & 8 deletions fboss/lib/led/tests/LedTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@ class LedTests : public ::testing::Test {
}

void testFakeLed() {
mkdir(blueBasePath_.c_str(), 0777);
blueFd_ = open(bluePath_.c_str(), O_RDWR | O_CREAT, 0777);
EXPECT_GE(blueFd_, 0);

mkdir(yellowBasePath_.c_str(), 0777);
yellowFd_ = open(yellowPath_.c_str(), O_RDWR | O_CREAT, 0777);
EXPECT_GE(yellowFd_, 0);

LedMapping ledMapping;
ledMapping.id() = 0;
ledMapping.bluePath() = bluePath_;
ledMapping.yellowPath() = yellowPath_;
ledMapping.bluePath() = blueBasePath_;
ledMapping.yellowPath() = yellowBasePath_;
// Instantiating Led object will write 0 to both blue and yellow LED
// files and set current color to Off
led_ = std::make_unique<LedIO>(ledMapping);
blueFd_ = open(bluePath_.c_str(), O_RDWR);
EXPECT_GE(blueFd_, 0);
yellowFd_ = open(yellowPath_.c_str(), O_RDWR);
EXPECT_GE(yellowFd_, 0);

VerifyLedOff();

// Since current color is Off, setting it to Off again will be noop
Expand Down Expand Up @@ -115,8 +120,10 @@ class LedTests : public ::testing::Test {
}

folly::test::TemporaryDirectory tmpDir_;
std::string bluePath_ = tmpDir_.path().string() + "/invalidBlueLed";
std::string yellowPath_ = tmpDir_.path().string() + "/invalidYellowLed";
std::string blueBasePath_ = tmpDir_.path().string() + "/invalidBlueLed";
std::string yellowBasePath_ = tmpDir_.path().string() + "/invalidYellowLed";
std::string bluePath_ = blueBasePath_ + "/brightness";
std::string yellowPath_ = yellowBasePath_ + "/brightness";
int blueFd_;
int yellowFd_;
std::unique_ptr<LedIO> led_;
Expand Down

0 comments on commit 45fed4e

Please sign in to comment.