Deprecate std::filesystem namespace include
Clang-tidy is complaining about our using fs = ... directives. These
were originally added to handle boost::filesystem vs
std::experimental::filesystem vs std::filesystem between the various
compilers. Now that we're all on std::filesystem, this redefinition can
be removed.
```
ChassisIntrusionSensor.hpp:11:11: error: namespace alias decl 'fs' is unused [misc-unused-alias-decls,-warnings-as-errors]
11 | namespace fs = std::filesystem;
```
Tested: code compiles
Change-Id: If4b968ff9cceb4038f526321d3c7c11563ffbce9
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/src/tests/test_Utils.cpp b/src/tests/test_Utils.cpp
index 8192475..3db6727 100644
--- a/src/tests/test_Utils.cpp
+++ b/src/tests/test_Utils.cpp
@@ -13,13 +13,12 @@
#include <gtest/gtest.h>
-namespace fs = std::filesystem;
class TestUtils : public testing::Test
{
public:
std::string testDir;
- fs::path hwmonDir;
- fs::path peciDir;
+ std::filesystem::path hwmonDir;
+ std::filesystem::path peciDir;
TestUtils()
{
// Create test environment
@@ -30,10 +29,10 @@
{
throw std::bad_alloc();
}
- hwmonDir = fs::path(testDir) / "hwmon";
- fs::create_directory(hwmonDir);
+ hwmonDir = std::filesystem::path(testDir) / "hwmon";
+ std::filesystem::create_directory(hwmonDir);
auto hwmon10 = hwmonDir / "hwmon10";
- fs::create_directory(hwmonDir / "hwmon10");
+ std::filesystem::create_directory(hwmonDir / "hwmon10");
{
std::ofstream temp1Input{hwmon10 / "temp1_input"};
std::ofstream temp1Min{hwmon10 / "temp1_min"};
@@ -45,7 +44,7 @@
~TestUtils() override
{
- fs::remove_all(testDir);
+ std::filesystem::remove_all(testDir);
}
TestUtils(const TestUtils&) = delete;
@@ -55,10 +54,10 @@
void createPECIDir()
{
- peciDir = fs::path(testDir) / "peci";
+ peciDir = std::filesystem::path(testDir) / "peci";
auto peci0 = peciDir /
"peci-0/device/0-30/peci-cputemp.0/hwmon/hwmon25";
- fs::create_directories(peci0);
+ std::filesystem::create_directories(peci0);
{
std::ofstream temp0Input{peci0 / "temp0_input"};
std::ofstream temp1Input{peci0 / "temp1_input"};
@@ -66,14 +65,17 @@
std::ofstream name{peci0 / "name"};
}
auto devDir = peciDir / "peci-0/peci_dev/peci-0";
- fs::create_directories(devDir);
- fs::create_directory_symlink("../../../peci-0", devDir / "device");
- fs::create_directory_symlink("device/0-30", peciDir / "peci-0/0-30");
+ std::filesystem::create_directories(devDir);
+ std::filesystem::create_directory_symlink("../../../peci-0",
+ devDir / "device");
+ std::filesystem::create_directory_symlink("device/0-30",
+ peciDir / "peci-0/0-30");
// Let's keep this for debugging purpose
- for (auto p = fs::recursive_directory_iterator(
- peciDir, fs::directory_options::follow_directory_symlink);
- p != fs::recursive_directory_iterator(); ++p)
+ for (auto p = std::filesystem::recursive_directory_iterator(
+ peciDir,
+ std::filesystem::directory_options::follow_directory_symlink);
+ p != std::filesystem::recursive_directory_iterator(); ++p)
{
std::string path = p->path().string();
std::cerr << path << "\n";
@@ -87,7 +89,7 @@
TEST_F(TestUtils, findFiles_non_exist)
{
- std::vector<fs::path> foundPaths;
+ std::vector<std::filesystem::path> foundPaths;
auto ret = findFiles("non-exist", "", foundPaths);
EXPECT_FALSE(ret);
@@ -96,7 +98,7 @@
TEST_F(TestUtils, findFiles_in_hwmon_no_match)
{
- std::vector<fs::path> foundPaths;
+ std::vector<std::filesystem::path> foundPaths;
auto ret = findFiles(hwmonDir, R"(in\d+_input)", foundPaths);
EXPECT_TRUE(ret);
@@ -105,7 +107,7 @@
TEST_F(TestUtils, findFiles_in_hwmon_match)
{
- std::vector<fs::path> foundPaths;
+ std::vector<std::filesystem::path> foundPaths;
auto ret = findFiles(hwmonDir, R"(temp\d+_input)", foundPaths);
EXPECT_TRUE(ret);
@@ -114,7 +116,7 @@
TEST_F(TestUtils, findFiles_in_peci_no_match)
{
- std::vector<fs::path> foundPaths;
+ std::vector<std::filesystem::path> foundPaths;
auto ret =
findFiles(peciDir, R"(peci-\d+/\d+-.+/peci-.+/hwmon/hwmon\d+/aaa$)",
foundPaths, 6);
@@ -125,7 +127,7 @@
TEST_F(TestUtils, findFiles_in_peci_match)
{
- std::vector<fs::path> foundPaths;
+ std::vector<std::filesystem::path> foundPaths;
auto ret =
findFiles(peciDir, R"(peci-\d+/\d+-.+/peci-.+/hwmon/hwmon\d+/name$)",
foundPaths, 6);
@@ -144,7 +146,7 @@
TEST_F(TestUtils, findFiles_hwmonPath_end_with_slash)
{
std::string p = hwmonDir.string() + "/";
- std::vector<fs::path> foundPaths;
+ std::vector<std::filesystem::path> foundPaths;
auto ret = findFiles(p, R"(temp\d+_input)", foundPaths);
EXPECT_TRUE(ret);
@@ -154,7 +156,7 @@
TEST_F(TestUtils, findFiles_peciPath_end_with_slash)
{
std::string p = peciDir.string() + "/";
- std::vector<fs::path> foundPaths;
+ std::vector<std::filesystem::path> foundPaths;
auto ret =
findFiles(p, R"(peci-\d+/\d+-.+/peci-.+/hwmon/hwmon\d+/temp\d+_input)",
foundPaths, 6);
@@ -165,7 +167,7 @@
TEST_F(TestUtils, findFiles_in_sub_peci_match)
{
- std::vector<fs::path> foundPaths;
+ std::vector<std::filesystem::path> foundPaths;
auto ret =
findFiles(peciDir / "peci-0", R"(\d+-.+/peci-.+/hwmon/hwmon\d+/name$)",
foundPaths, 5);