diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-06-23 21:39:48 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-06-23 21:39:48 +0200 |
commit | 09d546dfdd152ce4e69971fc8ce422d998cb523a (patch) | |
tree | 18da6c3d44a2a056fcc41a213f47feec26f2e30b /config/src | |
parent | 316b44c13d886ef9ff50b040f4a01f38dfd3f94c (diff) |
Use std::filesystem to create and remove directories.
Diffstat (limited to 'config/src')
-rw-r--r-- | config/src/tests/misc/configsystem.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/config/src/tests/misc/configsystem.cpp b/config/src/tests/misc/configsystem.cpp index db3d0a80706..db6764e6b17 100644 --- a/config/src/tests/misc/configsystem.cpp +++ b/config/src/tests/misc/configsystem.cpp @@ -5,6 +5,7 @@ #include <vespa/defaults.h> #include <vespa/fastos/file.h> #include <unistd.h> +#include <filesystem> using namespace config; @@ -25,23 +26,20 @@ TEST("require that bad home directory fails") { TEST("require that incorrect pid file type fails") { ASSERT_TRUE(nullptr != getcwd(cwd, sizeof(cwd))); - FastOS_File::EmptyAndRemoveDirectory("var"); - FastOS_File::MakeDirIfNotPresentOrExit("var"); - FastOS_File::MakeDirIfNotPresentOrExit("var/run"); - FastOS_File::MakeDirIfNotPresentOrExit("var/run/configproxy.pid"); + std::filesystem::remove_all(std::filesystem::path("var")); + std::filesystem::create_directories(std::filesystem::path("var/run/configproxy.pid")); ASSERT_EQUAL(0, setenv(VESPA_HOME, cwd, 1)); vespa::Defaults::bootstrap(cwd); ConfigSystem configSystem; ASSERT_FALSE(configSystem.isUp()); - FastOS_File::EmptyAndRemoveDirectory("var"); + std::filesystem::remove_all(std::filesystem::path("var")); } TEST("require that correct pid file succeeds") { ASSERT_TRUE(nullptr != getcwd(cwd, sizeof(cwd))); - FastOS_File::EmptyAndRemoveDirectory("var"); - FastOS_File::MakeDirIfNotPresentOrExit("var"); - FastOS_File::MakeDirIfNotPresentOrExit("var/run"); + std::filesystem::remove_all(std::filesystem::path("var")); + std::filesystem::create_directories(std::filesystem::path("var/run")); FastOS_File pid_file("var/run/configproxy.pid"); pid_file.OpenWriteOnlyTruncate(); ASSERT_TRUE(pid_file.Close()); @@ -50,7 +48,7 @@ TEST("require that correct pid file succeeds") { vespa::Defaults::bootstrap(cwd); ConfigSystem configSystem; ASSERT_TRUE(configSystem.isUp()); - FastOS_File::EmptyAndRemoveDirectory("var"); + std::filesystem::remove_all(std::filesystem::path("var")); } TEST_MAIN() { TEST_RUN_ALL(); } |