summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-07-21 10:26:58 +0200
committerTor Egge <Tor.Egge@online.no>2023-07-21 10:26:58 +0200
commita0a6e0137cc3741160a2d4d12905d65fac927cb0 (patch)
tree7dd49f685d04f92844cb65dae5cb9ce9bab32a25 /config
parent535a452f4a968a73a1f3c1e6a18a1edb2d4ff2c2 (diff)
Use std::filesystem::current_path
Diffstat (limited to 'config')
-rw-r--r--config/src/tests/misc/configsystem.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/config/src/tests/misc/configsystem.cpp b/config/src/tests/misc/configsystem.cpp
index db6764e6b17..c68c28b7c82 100644
--- a/config/src/tests/misc/configsystem.cpp
+++ b/config/src/tests/misc/configsystem.cpp
@@ -12,12 +12,10 @@ using namespace config;
namespace {
const char *VESPA_HOME="VESPA_HOME";
-char cwd[1_Ki];
}
TEST("require that bad home directory fails") {
- ASSERT_TRUE(nullptr != getcwd(cwd, sizeof(cwd)));
ASSERT_EQUAL(0, setenv(VESPA_HOME, "/nowhere/near/", 1));
vespa::Defaults::bootstrap("/nowhere/near/");
ConfigSystem configSystem;
@@ -25,27 +23,27 @@ TEST("require that bad home directory fails") {
}
TEST("require that incorrect pid file type fails") {
- ASSERT_TRUE(nullptr != getcwd(cwd, sizeof(cwd)));
+ std::string cwd = std::filesystem::current_path().string();
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);
+ ASSERT_EQUAL(0, setenv(VESPA_HOME, cwd.c_str(), 1));
+ vespa::Defaults::bootstrap(cwd.c_str());
ConfigSystem configSystem;
ASSERT_FALSE(configSystem.isUp());
std::filesystem::remove_all(std::filesystem::path("var"));
}
TEST("require that correct pid file succeeds") {
- ASSERT_TRUE(nullptr != getcwd(cwd, sizeof(cwd)));
+ std::string cwd = std::filesystem::current_path().string();
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());
- ASSERT_EQUAL(0, setenv(VESPA_HOME, cwd, 1));
- vespa::Defaults::bootstrap(cwd);
+ ASSERT_EQUAL(0, setenv(VESPA_HOME, cwd.c_str(), 1));
+ vespa::Defaults::bootstrap(cwd.c_str());
ConfigSystem configSystem;
ASSERT_TRUE(configSystem.isUp());
std::filesystem::remove_all(std::filesystem::path("var"));