-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move out utility functions from platform_manager to helpers
Summary: Move out `createDirectories` and `getStringFileContent` from `fboss::platform::platform_manager::Utils` to `fboss::platform::PlatformUtils` (under `platform/helpers/` directory) This allows re-use outside of Platform Manager; these utility functions are not tied to PM-specific logic. In particular this is used by following diff which adds a caching feature to `PlatformNameLib` that saves the results of `dmidecode` to a file. Without this refactor, there would be a circular dependency since `Utils::getConfig` calls `PlatformNameLib`, while `PlatformNameLib` would call `Utils::createDirectories`/`Utils::getStringFileContent`. Reviewed By: Scott8440 Differential Revision: D61427074 fbshipit-source-id: 8ecda71c18e64d6c26c94e0046a19c8bf87f394f
- Loading branch information
1 parent
ffd58cc
commit 7573e99
Showing
15 changed files
with
107 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. | ||
|
||
#include <filesystem> | ||
|
||
#include <folly/testing/TestUtil.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include "fboss/platform/helpers/PlatformUtils.h" | ||
|
||
namespace fs = std::filesystem; | ||
using namespace ::testing; | ||
using namespace facebook::fboss::platform; | ||
|
||
namespace facebook::fboss::platform { | ||
|
||
TEST(PlatformUtilsTest, CreateParentDirectories) { | ||
auto tmpPath = folly::test::TemporaryDirectory().path(); | ||
EXPECT_TRUE(PlatformUtils().createDirectories(tmpPath.string())); | ||
EXPECT_TRUE(fs::exists(tmpPath.string())); | ||
tmpPath = tmpPath / "a"; | ||
EXPECT_TRUE(PlatformUtils().createDirectories(tmpPath.string())); | ||
EXPECT_TRUE(fs::exists(tmpPath.string())); | ||
tmpPath = tmpPath / "b" / "c"; | ||
EXPECT_TRUE(PlatformUtils().createDirectories(tmpPath.string())); | ||
EXPECT_TRUE(fs::exists(tmpPath.string())); | ||
EXPECT_TRUE(PlatformUtils().createDirectories("/")); | ||
EXPECT_FALSE(PlatformUtils().createDirectories("")); | ||
} | ||
|
||
} // namespace facebook::fboss::platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.